From 1bb0e9b9709f4cea76be12f4990c7ee1db47a6e1 Mon Sep 17 00:00:00 2001 From: Thomas Daede Date: Sun, 28 Oct 2012 02:50:46 -0500 Subject: [PATCH 1/3] Add CAN support for F2 and F4 series. All stm32 series currently released share the same bxCAN hardware, so share can.c among all the families. --- lib/stm32/{f1 => }/can.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) rename lib/stm32/{f1 => }/can.c (97%) diff --git a/lib/stm32/f1/can.c b/lib/stm32/can.c similarity index 97% rename from lib/stm32/f1/can.c rename to lib/stm32/can.c index fc7e0e75..0e61ecae 100644 --- a/lib/stm32/f1/can.c +++ b/lib/stm32/can.c @@ -18,7 +18,16 @@ */ #include -#include + +#if defined(STM32F1) +# include +#elif defined(STM32F2) +# include +#elif defined(STM32F4) +# include +#else +# error "stm32 family not defined." +#endif void can_reset(u32 canport) { From f385341495edafceca39a087dcae0eeb833fd14d Mon Sep 17 00:00:00 2001 From: Thomas Daede Date: Sun, 28 Oct 2012 02:53:53 -0500 Subject: [PATCH 2/3] Release the correct fifo in can_receive() --- lib/stm32/can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stm32/can.c b/lib/stm32/can.c index 0e61ecae..73036f4c 100644 --- a/lib/stm32/can.c +++ b/lib/stm32/can.c @@ -308,5 +308,5 @@ void can_receive(u32 canport, u8 fifo, bool release, u32 *id, bool *ext, /* Release the FIFO. */ if (release) - can_fifo_release(CAN1, 0); + can_fifo_release(canport, fifo); } From 0fd7cc3559eb3c180de97898edbfd77f827a83b1 Mon Sep 17 00:00:00 2001 From: Thomas Daede Date: Sun, 28 Oct 2012 02:56:22 -0500 Subject: [PATCH 3/3] Fix CAN standard ID mask to be 11 bits. --- include/libopencm3/stm32/can.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libopencm3/stm32/can.h b/include/libopencm3/stm32/can.h index d6636d5f..cdb5df19 100644 --- a/include/libopencm3/stm32/can.h +++ b/include/libopencm3/stm32/can.h @@ -458,7 +458,7 @@ /* --- CAN_TIxR values ------------------------------------------------------ */ /* STID[10:0]: Standard identifier */ -#define CAN_TIxR_STID_MASK (0x3FF << 21) +#define CAN_TIxR_STID_MASK (0x7FF << 21) #define CAN_TIxR_STID_SHIFT 21 /* EXID[15:0]: Extended identifier */