aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/STM32
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/platforms/STM32')
-rw-r--r--os/hal/platforms/STM32/can_lld.c13
-rw-r--r--os/hal/platforms/STM32/can_lld.h9
2 files changed, 7 insertions, 15 deletions
diff --git a/os/hal/platforms/STM32/can_lld.c b/os/hal/platforms/STM32/can_lld.c
index dd0cacd11..32d273c6f 100644
--- a/os/hal/platforms/STM32/can_lld.c
+++ b/os/hal/platforms/STM32/can_lld.c
@@ -95,9 +95,8 @@ CH_IRQ_HANDLER(STM32_CAN1_RX0_HANDLER) {
if ((rf0r & CAN_RF0R_FOVR0) > 0) {
/* Overflow events handling.*/
CAN1->RF0R = CAN_RF0R_FOVR0;
- canAddFlagsI(&CAND1, CAN_OVERFLOW_ERROR);
chSysLockFromIsr();
- chEvtBroadcastI(&CAND1.error_event);
+ chEvtBroadcastFlagsI(&CAND1.error_event, CAN_OVERFLOW_ERROR);
chSysUnlockFromIsr();
}
@@ -138,16 +137,18 @@ CH_IRQ_HANDLER(STM32_CAN1_SCE_HANDLER) {
}
/* Error event.*/
if (msr & CAN_MSR_ERRI) {
- canstatus_t flags;
+ flagsmask_t flags;
uint32_t esr = CAN1->ESR;
CAN1->ESR &= ~CAN_ESR_LEC;
- flags = (canstatus_t)(esr & 7);
+ flags = (flagsmask_t)(esr & 7);
if ((esr & CAN_ESR_LEC) > 0)
flags |= CAN_FRAMING_ERROR;
+
chSysLockFromIsr();
- canAddFlagsI(&CAND1, flags | (canstatus_t)(flags < 16));
- chEvtBroadcastI(&CAND1.error_event);
+ /* The content of the ESR register is copied unchanged in the upper
+ half word of the listener flags mask.*/
+ chEvtBroadcastFlagsI(&CAND1.error_event, flags | (flagsmask_t)(esr < 16));
chSysUnlockFromIsr();
}
diff --git a/os/hal/platforms/STM32/can_lld.h b/os/hal/platforms/STM32/can_lld.h
index 6cb882df2..003a6743f 100644
--- a/os/hal/platforms/STM32/can_lld.h
+++ b/os/hal/platforms/STM32/can_lld.h
@@ -112,11 +112,6 @@
/*===========================================================================*/
/**
- * @brief CAN status flags.
- */
-typedef uint32_t canstatus_t;
-
-/**
* @brief CAN transmission frame.
* @note Accessing the frame data as word16 or word32 is not portable because
* machine data endianness, it can be still useful for a quick filling.
@@ -273,10 +268,6 @@ typedef struct {
* @brief A CAN bus error happened.
*/
EventSource error_event;
- /**
- * @brief Error flags set when an error event is broadcasted.
- */
- canstatus_t status;
#if CAN_USE_SLEEP_MODE || defined (__DOXYGEN__)
/**
* @brief Entering sleep state event.