Go to the documentation of this file.
28 #if (HAL_USE_CAN == TRUE) || defined(__DOXYGEN__)
41 #define CAN_LIMIT_WARNING 1U
45 #define CAN_LIMIT_ERROR 2U
49 #define CAN_BUS_OFF_ERROR 4U
53 #define CAN_FRAMING_ERROR 8U
57 #define CAN_OVERFLOW_ERROR 16U
63 #define CAN_ANY_MAILBOX 0U
79 #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
80 #define CAN_USE_SLEEP_MODE TRUE
86 #if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
87 #define CAN_ENFORCE_USE_CALLBACKS FALSE
124 #define CAN_MAILBOX_TO_MASK(mbx) (1U << ((mbx) - 1U))
131 #define canTransmit(canp, mailbox, ctfp, timeout) \
132 canTransmitTimeout(canp, mailbox, ctfp, timeout)
139 #define canReceive(canp, mailbox, crfp, timeout) \
140 canReceiveTimeout(canp, mailbox, crfp, timeout)
147 #if (CAN_ENFORCE_USE_CALLBACKS == FALSE) || defined(__DOXYGEN__)
151 #define _can_tx_empty_isr(canp, flags) { \
152 osalSysLockFromISR(); \
153 osalThreadDequeueAllI(&(canp)->txqueue, MSG_OK); \
154 osalEventBroadcastFlagsI(&(canp)->txempty_event, flags); \
155 osalSysUnlockFromISR(); \
161 #define _can_rx_full_isr(canp, flags) { \
162 osalSysLockFromISR(); \
163 osalThreadDequeueAllI(&(canp)->rxqueue, MSG_OK); \
164 osalEventBroadcastFlagsI(&(canp)->rxfull_event, flags); \
165 osalSysUnlockFromISR(); \
171 #define _can_wakeup_isr(canp) { \
172 osalSysLockFromISR(); \
173 osalEventBroadcastFlagsI(&(canp)->wakeup_event, 0U); \
174 osalSysUnlockFromISR(); \
180 #define _can_error_isr(canp, flags) { \
181 osalSysLockFromISR(); \
182 osalEventBroadcastFlagsI(&(canp)->error_event, flags); \
183 osalSysUnlockFromISR(); \
186 #define _can_tx_empty_isr(canp, flags) { \
187 if ((canp)->txempty_cb != NULL) { \
188 (canp)->txempty_cb(canp, flags); \
190 osalSysLockFromISR(); \
191 osalThreadDequeueAllI(&(canp)->txqueue, MSG_OK); \
192 osalSysUnlockFromISR(); \
195 #define _can_rx_full_isr(canp, flags) { \
196 if ((canp)->rxfull_cb != NULL) { \
197 (canp)->rxfull_cb(canp, flags); \
199 osalSysLockFromISR(); \
200 osalThreadDequeueAllI(&(canp)->rxqueue, MSG_OK); \
201 osalSysUnlockFromISR(); \
204 #define _can_wakeup_isr(canp) { \
205 if ((canp)->wakeup_cb != NULL) { \
206 (canp)->wakeup_cb(canp, 0U); \
210 #define _can_error_isr(canp, flags) { \
211 if ((canp)->error_cb != NULL) { \
212 (canp)->error_cb(canp, flags); \
245 #if CAN_USE_SLEEP_MODE
canstate_t
Driver state machine possible states.
bool canTryReceiveI(CANDriver *canp, canmbx_t mailbox, CANRxFrame *crfp)
Can frame receive attempt.
msg_t canReceiveTimeout(CANDriver *canp, canmbx_t mailbox, CANRxFrame *crfp, sysinterval_t timeout)
Can frame receive.
void canInit(void)
CAN Driver initialization.
void canObjectInit(CANDriver *canp)
Initializes the standard part of a CANDriver structure.
void canWakeup(CANDriver *canp)
Enforces leaving the sleep mode.
Structure representing an CAN driver.
void canStop(CANDriver *canp)
Deactivates the CAN peripheral.
void canStart(CANDriver *canp, const CANConfig *config)
Configures and activates the CAN peripheral.
void canTryAbortX(CANDriver *canp, canmbx_t mailbox)
Tries to abort an ongoing transmission.
PLATFORM CAN subsystem low level driver header.
bool canTryTransmitI(CANDriver *canp, canmbx_t mailbox, const CANTxFrame *ctfp)
Can frame transmission attempt.
uint64_t sysinterval_t
Type of time interval.
Driver configuration structure.
void canSleep(CANDriver *canp)
Enters the sleep mode.
uint32_t canmbx_t
Type of a transmission mailbox index.
msg_t canTransmitTimeout(CANDriver *canp, canmbx_t mailbox, const CANTxFrame *ctfp, sysinterval_t timeout)
Can frame transmission.