aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/platforms/STM32/can_lld.c10
-rw-r--r--os/hal/platforms/STM32/can_lld.h4
2 files changed, 14 insertions, 0 deletions
diff --git a/os/hal/platforms/STM32/can_lld.c b/os/hal/platforms/STM32/can_lld.c
index 2f4f760f0..30e9dd7cf 100644
--- a/os/hal/platforms/STM32/can_lld.c
+++ b/os/hal/platforms/STM32/can_lld.c
@@ -411,6 +411,10 @@ void can_lld_start(CANDriver *canp) {
#endif
#if STM32_CAN_USE_CAN2
if (&CAND2 == canp) {
+
+ chDbgAssert(CAND1.state != CAN_STOP,
+ "can_lld_start(), #1", "CAN1 must be started");
+
nvicEnableVector(STM32_CAN2_TX_NUMBER,
CORTEX_PRIORITY_MASK(STM32_CAN_CAN2_IRQ_PRIORITY));
nvicEnableVector(STM32_CAN2_RX0_NUMBER,
@@ -453,6 +457,12 @@ void can_lld_stop(CANDriver *canp) {
if (canp->state == CAN_READY) {
#if STM32_CAN_USE_CAN1
if (&CAND1 == canp) {
+
+#if STM32_CAN_USE_CAN2
+ chDbgAssert(CAND2.state == CAN_STOP,
+ "can_lld_stop(), #1", "CAN2 must be stopped");
+#endif
+
CAN1->MCR = 0x00010002; /* Register reset value. */
CAN1->IER = 0x00000000; /* All sources disabled. */
nvicDisableVector(STM32_CAN1_TX_NUMBER);
diff --git a/os/hal/platforms/STM32/can_lld.h b/os/hal/platforms/STM32/can_lld.h
index 44906b7ed..c339c01e7 100644
--- a/os/hal/platforms/STM32/can_lld.h
+++ b/os/hal/platforms/STM32/can_lld.h
@@ -128,6 +128,10 @@
#error "CAN driver activated but no CAN peripheral assigned"
#endif
+#if !STM32_CAN_USE_CAN1 && STM32_CAN_USE_CAN2
+#error "CAN2 requires CAN1, it cannot operate independently"
+#endif
+
#if CAN_USE_SLEEP_MODE && !CAN_SUPPORTS_SLEEP
#error "CAN sleep mode not supported in this architecture"
#endif