diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-02-22 14:45:58 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-02-22 14:45:58 +0000 |
commit | 04385d42d46173127ac7c5274cbd15d5d255c460 (patch) | |
tree | 3ee6d3d57897cd1b47f14244d2f5554b76a036dd /os | |
parent | 48506ff3481afe8e2490e78a451852bc4bbb1c0b (diff) | |
download | ChibiOS-04385d42d46173127ac7c5274cbd15d5d255c460.tar.gz ChibiOS-04385d42d46173127ac7c5274cbd15d5d255c460.tar.bz2 ChibiOS-04385d42d46173127ac7c5274cbd15d5d255c460.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5300 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/platforms/STM32/can_lld.c | 26 | ||||
-rw-r--r-- | os/hal/platforms/STM32/can_lld.h | 2 |
2 files changed, 22 insertions, 6 deletions
diff --git a/os/hal/platforms/STM32/can_lld.c b/os/hal/platforms/STM32/can_lld.c index 785ca3482..7a6185c1f 100644 --- a/os/hal/platforms/STM32/can_lld.c +++ b/os/hal/platforms/STM32/can_lld.c @@ -510,12 +510,16 @@ void can_lld_transmit(CANDriver *canp, switch (mailbox) {
case CAN_ANY_TX_MAILBOX:
tmbp = &canp->can->sTxMailBox[(canp->can->TSR & CAN_TSR_CODE) >> 24];
+ break;
case 1:
tmbp = &canp->can->sTxMailBox[0];
+ break;
case 2:
tmbp = &canp->can->sTxMailBox[1];
+ break;
case 3:
tmbp = &canp->can->sTxMailBox[2];
+ break;
default:
return;
}
@@ -546,8 +550,14 @@ void can_lld_transmit(CANDriver *canp, */
bool_t can_lld_is_rx_nonempty(CANDriver *canp, canmbx_t mailbox) {
- return mailbox == 0 ? (canp->can->RF0R & CAN_RF0R_FMP0) > 0 :
- (canp->can->RF1R & CAN_RF1R_FMP1) > 0;
+ switch (mailbox) {
+ case 1:
+ return (canp->can->RF0R & CAN_RF0R_FMP0) > 0;
+ case 2:
+ return (canp->can->RF1R & CAN_RF1R_FMP1) > 0;
+ default:
+ return FALSE;
+ }
}
/**
@@ -564,7 +574,8 @@ void can_lld_receive(CANDriver *canp, CANRxFrame *crfp) {
uint32_t rir, rdtr;
- if (mailbox == 0) {
+ switch (mailbox) {
+ case 1:
/* Fetches the message.*/
rir = canp->can->sFIFOMailBox[0].RIR;
rdtr = canp->can->sFIFOMailBox[0].RDTR;
@@ -578,8 +589,8 @@ void can_lld_receive(CANDriver *canp, events again.*/
if ((canp->can->RF0R & CAN_RF0R_FMP0) == 0)
canp->can->IER |= CAN_IER_FMPIE0;
- }
- else {
+ break;
+ case 2:
/* Fetches the message.*/
rir = canp->can->sFIFOMailBox[1].RIR;
rdtr = canp->can->sFIFOMailBox[1].RDTR;
@@ -593,7 +604,12 @@ void can_lld_receive(CANDriver *canp, events again.*/
if ((canp->can->RF1R & CAN_RF1R_FMP1) == 0)
canp->can->IER |= CAN_IER_FMPIE1;
+ break;
+ default:
+ return;
}
+
+ /* Decodes the various fields in the RX frame.*/
crfp->RTR = (rir & CAN_RI0R_RTR) >> 1;
crfp->IDE = (rir & CAN_RI0R_IDE) >> 2;
if (crfp->IDE)
diff --git a/os/hal/platforms/STM32/can_lld.h b/os/hal/platforms/STM32/can_lld.h index a15226f4a..11ef5dcc9 100644 --- a/os/hal/platforms/STM32/can_lld.h +++ b/os/hal/platforms/STM32/can_lld.h @@ -58,7 +58,7 @@ /**
* @brief This implementation supports two receive mailboxes.
*/
-#define CAN_RX_MAILBOXES 3
+#define CAN_RX_MAILBOXES 2
/**
* @name CAN registers helper macros
|