Page 1 of 1

CAN RX mailbox support on STM32

Posted: Wed Jul 29, 2015 4:12 am
by trainman419
Trying to read from CAN RX mailbox 1 (the second mailbox) results in an OS exception (I think; I'm new to Chibi and the board I'm using it on doesn't have a lot of IO to tell me what's wrong).

I'm using ChibiOS 3.0.0b5

I'm using an STM32F405, for which CAN_RX_MAILBOXES is defined to be 2

Reading through can_lld_receive for the STM32 (os/hal/ports/STM32/LLD/can_lld.c), it looks like I should be passing a mailbox ID of `2` in order to read mailbox 1 (0 is ANY, 1 is mailbox 0, and 2 is mailbox 1 on this chip).

In canReceive (os/hal/src/can.c), there is an assertion: `mailbox < (canmbx_t)CAN_RX_MAILBOXES` ; obviously this fails if I pass `2` as the desired mailbox.

I've updated the assertion on my copy of ChibiOS to be `mailbox <= (canmbx_t)CAN_RX_MAILBOXES`, and it works. (I'm also using the CAN filters to assign messages to mailbox 0 or 1 depending on their ID).

Re: CAN RX mailbox support on STM32

Posted: Wed Jul 29, 2015 7:42 am
by Giovanni
Hi,

Thanks for finding. I will commit the change.

Giovanni