| Description | The CAN_send function transmits msg using the CAN controller specified by ctrl. If the CAN controller hardware is ready (no other transmissions are in progress), the CAN_send function sends the msg to the CAN controller for transmission. If the CAN controller is busy, the msg is put into a FIFO (that is managed using an RTX mailbox). Messages stored in the the FIFO are sent in order. The timeout specifies how long to wait for the FIFO (mailbox slot) to become available. | timeout | Description |
|---|
| 0 | Return immediately. | | 0x0001-0xFFFE | Wait the specified number of RTX Kernel ticks. | | 0xFFFF | Wait infinitely. |
If a message is not stored in the FIFO by the specified time, an error is returned. The CAN_send function executes quickly since all data transfers use software buffers. Only in situations where the FIFO is full is the CAN_send function delayed. The CAN_send function is part of RL-CAN. The prototype is defined in RTX_CAN.h. |
| Example |
#include <rtx_can.h>
__task void task_send_CAN (void) {
unsined int i = 0;
CAN_msg msg_buf = {
33, // ID
{ 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 }, // Data
1, // Length
1, // Channel
STANDARD_FORMAT, // Format
DATA_FRAME // Type
};
while (1) {
// Put data (i) into the transmit buffer
// Send CAN message on controller 2
msg_buf.data[0] = ++i;
CAN_send (2, &msg_buf, 0x0F00);
// Wait 100ms
os_dly_wait (10);
}
}
|