From a38cd1477e658c96c2f74fad14810f3d149aa3e2 Mon Sep 17 00:00:00 2001 From: madokapeng Date: Fri, 5 Mar 2021 23:22:44 -0500 Subject: [PATCH] boards/nucleo-f722ze: Add periph_can support cpu/stm32: Add CAN support for f722ze board f722ze board has ONLY 1 CAN interface, fix compiling error which treats f722xx has more than 1 CAN. --- boards/nucleo-f722ze/Kconfig | 1 + boards/nucleo-f722ze/Makefile.features | 1 + cpu/stm32/include/can_params.h | 2 ++ cpu/stm32/include/candev_stm32.h | 3 +-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/boards/nucleo-f722ze/Kconfig b/boards/nucleo-f722ze/Kconfig index 8e5fcd5f5e..a6d9b19328 100644 --- a/boards/nucleo-f722ze/Kconfig +++ b/boards/nucleo-f722ze/Kconfig @@ -21,6 +21,7 @@ config BOARD_NUCLEO_F722ZE select HAS_PERIPH_TIMER select HAS_PERIPH_UART select HAS_PERIPH_USBDEV + select HAS_PERIPH_CAN # Put other features for this board (in alphabetical order) select HAS_RIOTBOOT diff --git a/boards/nucleo-f722ze/Makefile.features b/boards/nucleo-f722ze/Makefile.features index 346aa6ff29..87f80e5c15 100644 --- a/boards/nucleo-f722ze/Makefile.features +++ b/boards/nucleo-f722ze/Makefile.features @@ -8,6 +8,7 @@ FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev +FEATURES_PROVIDED += periph_can # Put other features for this board (in alphabetical order) FEATURES_PROVIDED += riotboot diff --git a/cpu/stm32/include/can_params.h b/cpu/stm32/include/can_params.h index b6294e599a..d1c0e26912 100644 --- a/cpu/stm32/include/can_params.h +++ b/cpu/stm32/include/can_params.h @@ -43,11 +43,13 @@ static const can_conf_t candev_conf[] = { .rcc_mask = RCC_APB1ENR1_CAN1EN, #else .rcc_mask = RCC_APB1ENR_CAN1EN, +#if CANDEV_STM32_CHAN_NUMOF > 1 .can_master = CAN1, .master_rcc_mask = RCC_APB1ENR_CAN1EN, .first_filter = 0, .nb_filters = 14, #endif +#endif #if defined(CPU_FAM_STM32F1) .rx_pin = GPIO_PIN(PORT_A, 11), .tx_pin = GPIO_PIN(PORT_A, 12), diff --git a/cpu/stm32/include/candev_stm32.h b/cpu/stm32/include/candev_stm32.h index 9a8925d380..c87467ea9a 100644 --- a/cpu/stm32/include/candev_stm32.h +++ b/cpu/stm32/include/candev_stm32.h @@ -42,7 +42,7 @@ extern "C" { #elif defined(CPU_FAM_STM32F1) || defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) #define CANDEV_STM32_CHAN_NUMOF 2 #elif defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F3) || \ - defined(CPU_FAM_STM32L4) || DOXYGEN + defined(CPU_FAM_STM32L4) || defined(CPU_LINE_STM32F722xx) || DOXYGEN /** Number of channels in the device (up to 3) */ #define CANDEV_STM32_CHAN_NUMOF 1 #else @@ -137,7 +137,6 @@ typedef struct { /** The number of receive FIFO */ #define CAN_STM32_RX_MAILBOXES 2 - #ifndef CAN_STM32_RX_MAIL_FIFO /** This is the maximum number of frame the driver can receive simultaneously */ #define CAN_STM32_RX_MAIL_FIFO 12