diff options
-rw-r--r-- | os/hal/platforms/STM32/can_lld.c | 8 | ||||
-rw-r--r-- | testio/STM32/main.c | 10 |
2 files changed, 12 insertions, 6 deletions
diff --git a/os/hal/platforms/STM32/can_lld.c b/os/hal/platforms/STM32/can_lld.c index b9b088515..1115860eb 100644 --- a/os/hal/platforms/STM32/can_lld.c +++ b/os/hal/platforms/STM32/can_lld.c @@ -59,9 +59,11 @@ CH_IRQ_HANDLER(Vector8C) { /* No more events until a message is transmitted.*/
CAN1->TSR = CAN_TSR_RQCP0 | CAN_TSR_RQCP1 | CAN_TSR_RQCP2;
+ chSysLockFromIsr();
while (chSemGetCounterI(&CAND1.cd_txsem) < 0)
chSemSignalI(&CAND1.cd_txsem);
chEvtBroadcastI(&CAND1.cd_txempty_event);
+ chSysUnlockFromIsr();
CH_IRQ_EPILOGUE();
}
@@ -75,21 +77,23 @@ CH_IRQ_HANDLER(Vector90) { CH_IRQ_PROLOGUE();
rf0r = CAN1->RF0R;
- chSysLockFromIsr();
if ((rf0r & CAN_RF0R_FMP0) > 0) {
/* No more receive events until the queue 0 has been emptied.*/
CAN1->IER &= ~CAN_IER_FMPIE0;
+ chSysLockFromIsr();
while (chSemGetCounterI(&CAND1.cd_rxsem) < 0)
chSemSignalI(&CAND1.cd_rxsem);
chEvtBroadcastI(&CAND1.cd_rxfull_event);
+ chSysUnlockFromIsr();
}
if ((rf0r & CAN_RF0R_FOVR0) > 0) {
/* Overflow events handling.*/
CAN1->RF0R = CAN_RF0R_FOVR0;
canAddFlagsI(&CAND1, CAN_OVERFLOW_ERROR);
+ chSysLockFromIsr();
chEvtBroadcastI(&CAND1.cd_error_event);
+ chSysUnlockFromIsr();
}
- chSysUnlockFromIsr();
CH_IRQ_EPILOGUE();
}
diff --git a/testio/STM32/main.c b/testio/STM32/main.c index 4a774b246..d566c7546 100644 --- a/testio/STM32/main.c +++ b/testio/STM32/main.c @@ -56,6 +56,7 @@ static void adccallback(adcsample_t *buffer, size_t n) { ny += n;
}
}
+
static WORKING_AREA(adc_continuous_wa, 256);
static msg_t adc_continuous_thread(void *p){
@@ -91,6 +92,7 @@ static msg_t can_rx(void *p) { palTogglePad(IOPORT3, GPIOC_LED);
}
}
+ chEvtUnregister(&CAND1.cd_rxfull_event, &el);
return 0;
}
@@ -99,16 +101,16 @@ static msg_t can_tx(void * p) { CANTxFrame txmsg;
(void)p;
- txmsg.cf_IDE = CAN_IDE_STD;
+ txmsg.cf_IDE = CAN_IDE_EXT;
txmsg.cf_EID = 0x01234567;
txmsg.cf_RTR = CAN_RTR_DATA;
txmsg.cf_DLC = 8;
txmsg.cf_data32[0] = 0x55AA55AA;
- txmsg.cf_data32[0] = 0x00FF00FF;
+ txmsg.cf_data32[1] = 0x00FF00FF;
while (!chThdShouldTerminate()) {
- canTransmit(&CAND1, &txmsg, TIME_INFINITE);
- chThdSleepMilliseconds(50);
+ canTransmit(&CAND1, &txmsg, MS2ST(100));
+/* chThdSleepMilliseconds(5);*/
}
return 0;
}
|