|
struct can * | can_init (uint32_t index, uint32_t bitrate, struct gpio_pin *pin, bool pinHigh, bool(*callback)(struct can *can, can_error_t error, can_errorData_t data, void *userData), void *data) |
|
int32_t | can_deinit (struct can *can) |
|
int32_t | can_setCallback (struct can *can, int32_t filterID, bool(*callback)(struct can *can, struct can_msg *msg, void *data), void *data) |
|
int32_t | can_registerFilter (struct can *can, struct can_filter *filter) |
|
int32_t | can_deregisterFilter (struct can *can, int32_t filterID) |
|
int32_t | can_send (struct can *can, struct can_msg *msg, TickType_t waittime) |
|
int32_t | can_recv (struct can *can, int32_t filterID, struct can_msg *msg, TickType_t waittime) |
|
int32_t | can_sendISR (struct can *can, struct can_msg *msg) |
|
int32_t | can_recvISR (struct can *can, int32_t filterID, struct can_msg *msg) |
|
int32_t | can_up (struct can *can) |
|
int32_t | can_down (struct can *can) |
|
This is the CAN Subsystem for controlling CAN of a SOC.
◆ CAN_EFF_FLAG
#define CAN_EFF_FLAG BIT(31) /* EFF/SFF is set in the MSB */ |
◆ CAN_EFF_MASK
#define CAN_EFF_MASK 0x1FFFFFFFUL /* extended frame format (EFF) */ |
◆ CAN_ERR_ACK
#define CAN_ERR_ACK BIT64(3) |
received no ACK on transmission
◆ CAN_ERR_BUSERROR
#define CAN_ERR_BUSERROR BIT64(5) |
◆ CAN_ERR_BUSOFF
#define CAN_ERR_BUSOFF BIT64(4) |
◆ CAN_ERR_CRTL
#define CAN_ERR_CRTL BIT64(0) |
◆ CAN_ERR_CRTL_ACTIVE
recovered to error active state (one error counter is under a the protocol-defined level of 127)
◆ CAN_ERR_CRTL_RX_OVERFLOW
◆ CAN_ERR_CRTL_RX_PASSIVE
reached error passive status RX
◆ CAN_ERR_CRTL_RX_WARNING
reached warning level for RX errors
◆ CAN_ERR_CRTL_TX_OVERFLOW
◆ CAN_ERR_CRTL_TX_PASSIVE
reached error passive status TX (at least one error counter exceeds the protocol-defined level of 127)
◆ CAN_ERR_CRTL_TX_WARNING
◆ CAN_ERR_CRTL_UNSPEC
unspecified controller protocol
◆ CAN_ERR_CTRL_OFFSET
#define CAN_ERR_CTRL_OFFSET 0 |
◆ CAN_ERR_PROT
#define CAN_ERR_PROT BIT64(1) |
◆ CAN_ERR_PROT_ACTIVE
Active error announcement
◆ CAN_ERR_PROT_BIT
◆ CAN_ERR_PROT_BIT0
Unable to send dominant bit
◆ CAN_ERR_PROT_BIT1
Unable to send recessive bit
◆ CAN_ERR_PROT_FORM
◆ CAN_ERR_PROT_LOC_ACK
Error in CAN protocol at ACK slot
◆ CAN_ERR_PROT_LOC_ACK_DEL
Error in CAN protocol at ACK delimiter
◆ CAN_ERR_PROT_LOC_CRC_DEL
Error in CAN protocol at CRC delimiter
◆ CAN_ERR_PROT_LOC_CRC_SEQ
Error in CAN protocol at CRC sequence
◆ CAN_ERR_PROT_LOC_DATA
Error in CAN protocol at data section
◆ CAN_ERR_PROT_LOC_DLC
Error in CAN protocol at data length code
◆ CAN_ERR_PROT_LOC_EOF
Error in CAN protocol at end of frame
◆ CAN_ERR_PROT_LOC_ID04_00
Error in CAN protocol at ID bits 4-0
◆ CAN_ERR_PROT_LOC_ID12_05
Error in CAN protocol at ID bits 12-5
◆ CAN_ERR_PROT_LOC_ID17_13
Error in CAN protocol at ID bits 17-13
◆ CAN_ERR_PROT_LOC_ID20_18
Error in CAN protocol at ID bits 20 - 18 (SFF: 2 - 0)
◆ CAN_ERR_PROT_LOC_ID28_21
Error in CAN protocol at ID bits 28 - 21 (SFF: 10 - 3)
◆ CAN_ERR_PROT_LOC_IDE
Error in CAN protocol at Identifier extension
◆ CAN_ERR_PROT_LOC_INTERM
Error in CAN protocol at intermission
◆ CAN_ERR_PROT_LOC_OFFSET
#define CAN_ERR_PROT_LOC_OFFSET 24 |
◆ CAN_ERR_PROT_LOC_RES0
Error in CAN protocol at reserved bit 0
◆ CAN_ERR_PROT_LOC_RES1
Error in CAN protocol at reserved bit 1
◆ CAN_ERR_PROT_LOC_RTR
Error in CAN protocol at RTR
◆ CAN_ERR_PROT_LOC_SOF
Error in CAN protocol at Start of frame
◆ CAN_ERR_PROT_LOC_SRTR
Error in CAN protocol at Substitute RTR (SFF: RTR)
◆ CAN_ERR_PROT_LOC_UNSPEC
Unspecified error in CAN protocol (location)
◆ CAN_ERR_PROT_OFFSET
#define CAN_ERR_PROT_OFFSET 8 |
◆ CAN_ERR_PROT_OVERLOAD
◆ CAN_ERR_PROT_STUFF
◆ CAN_ERR_PROT_TX
Error occurred on transmission
◆ CAN_ERR_PROT_UNSPEC
Unspecified protocol violations
◆ CAN_ERR_RESTARTED
#define CAN_ERR_RESTARTED BIT64(6) |
◆ CAN_ERR_TRX
#define CAN_ERR_TRX BIT64(2) |
◆ CAN_ERR_TRX_CANH_NO_WIRE
◆ CAN_ERR_TRX_CANH_SHORT_TO_BAT
◆ CAN_ERR_TRX_CANH_SHORT_TO_GND
◆ CAN_ERR_TRX_CANH_SHORT_TO_VCC
◆ CAN_ERR_TRX_CANL_NO_WIRE
◆ CAN_ERR_TRX_CANL_SHORT_TO_BAT
◆ CAN_ERR_TRX_CANL_SHORT_TO_CANH
CAN Low is short to CAN High
◆ CAN_ERR_TRX_CANL_SHORT_TO_GND
◆ CAN_ERR_TRX_CANL_SHORT_TO_VCC
◆ CAN_ERR_TRX_OFFSET
#define CAN_ERR_TRX_OFFSET 48 |
◆ CAN_ERR_TRX_UNSPEC
Transiver Status Error is unspecified
◆ CAN_MAX_LENGTH
MAX CAN length 8 or 64 if CAN_FD
◆ CAN_RTR_FLAG
#define CAN_RTR_FLAG BIT(30) /* remote transmission request */ |
◆ CAN_SFF_MASK
#define CAN_SFF_MASK 0x000007FFUL /* standard frame format (SFF) */ |
◆ can_error_t
◆ can_errorData_t
◆ can_deinit()
int32_t can_deinit |
( |
struct can * |
can | ) |
|
Deinit CAN
- Parameters
-
- Returns
- -1 on error 0 on ok
◆ can_deregisterFilter()
int32_t can_deregisterFilter |
( |
struct can * |
can, |
|
|
int32_t |
filterID |
|
) |
| |
Deregister CAN Filter
- Parameters
-
can | CAN instance |
filterID | FilterID |
- Returns
- -1 on error 0 on ok
◆ can_down()
int32_t can_down |
( |
struct can * |
can | ) |
|
Stop CAN Net
- Parameters
-
- Returns
- -1 on error 0 on ok
◆ can_init()
struct can* can_init |
( |
uint32_t |
index, |
|
|
uint32_t |
bitrate, |
|
|
struct gpio_pin * |
pin, |
|
|
bool |
pinHigh, |
|
|
bool(*)(struct can *can, can_error_t error, can_errorData_t data, void *userData) |
callback, |
|
|
void * |
data |
|
) |
| |
init CAN instance
- Parameters
-
index | Index of CAN |
bitrate | bitrate |
pin | enable pin |
pinHigh | Enable Pin Driven High or low for enable |
callback | Callback if error is happened, ignored if defined NULL, The Hardware or the diver should restore the bus of Bus off automatically |
data | Callback User Data |
- Returns
- CAN Instance NULL on Error if only get instance on bits == 0
◆ can_recv()
int32_t can_recv |
( |
struct can * |
can, |
|
|
int32_t |
filterID, |
|
|
struct can_msg * |
msg, |
|
|
TickType_t |
waittime |
|
) |
| |
Receive CAN Message
- Parameters
-
can | CAN instance |
filterID | filterID |
msg | CAN Message |
waittime | max waittime in mutex or isr lock see xSemaphoreTake() |
- Returns
- -1 on error 0 on ok
◆ can_recvISR()
int32_t can_recvISR |
( |
struct can * |
can, |
|
|
int32_t |
filterID, |
|
|
struct can_msg * |
msg |
|
) |
| |
Receive CAN Message
- Parameters
-
can | CAN instance |
filterID | filterID |
msg | CAN Message |
- Returns
- -1 on error 0 on ok
◆ can_registerFilter()
int32_t can_registerFilter |
( |
struct can * |
can, |
|
|
struct can_filter * |
filter |
|
) |
| |
Register CAN Filter
- Warning
- If a id and a mask is overlapping with another filter only one filter get the messages
- Parameters
-
can | CAN instance |
filter | Filter |
- Returns
- -1 on error or filterID
◆ can_send()
int32_t can_send |
( |
struct can * |
can, |
|
|
struct can_msg * |
msg, |
|
|
TickType_t |
waittime |
|
) |
| |
Send CAN Message
- Parameters
-
can | CAN instance |
msg | CAN Message |
waittime | max waittime in mutex or isr lock see xSemaphoreTake() |
- Returns
- -1 on error 0 on ok
◆ can_sendISR()
int32_t can_sendISR |
( |
struct can * |
can, |
|
|
struct can_msg * |
msg |
|
) |
| |
Send CAN Message
- Parameters
-
can | CAN instance |
msg | CAN Message |
- Returns
- -1 on error 0 on ok
◆ can_setCallback()
int32_t can_setCallback |
( |
struct can * |
can, |
|
|
int32_t |
filterID, |
|
|
bool(*)(struct can *can, struct can_msg *msg, void *data) |
callback, |
|
|
void * |
data |
|
) |
| |
Set CAN Interrupt Callback for a filter
- Warning
- This Callback is may executed in the contex of CAN interrupt ISR!
- Parameters
-
can | CAN instance |
filterID | filterID |
callback | Callback |
data | Data parsed to Callback |
- Returns
- -1 on error 0 on ok
◆ can_up()
int32_t can_up |
( |
struct can * |
can | ) |
|
Start CAN Net
- Parameters
-
- Returns
- -1 on error 0 on ok