1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 05:53:49 +01:00
RIOT/cpu/stm32/periph/Makefile
Gilles DOFFE 5d48376a21 cpu/stm32: add FDCAN support to STM32G4 family
Until now, STM32 MCUs classic CAN support is coded in can.c file.
However CAN FD in STM32G4 family is designed in a very different way:
* CAN FD channels are independant
* CAN FD channel configuration is done in a dedicated RAM block called
  message RAM, with one message RAM per channel
* Each message RAM is divided this way:
  - 11-bit filter (28 elements / 28 words)
  - 29-bit filter (8 elements / 16 words)
  - Rx FIFO 0 (3 elements / 54 words)
  - Rx FIFO 1 (3 elements / 54 words)
  - Tx event FIFO (3 elements / 6 words)
  - Tx buffers (3 elements / 54 words)

Due to these design differences with other STM32 MCUs, the choice is
made to split the driver in two files:
* classiccan.c for STM32 MCUs that support classical CAN. This file
  has just been renamed (previously can.c) to avoid build conflicts
  but does not introduce changes
* fdcan.c for STM32 MCUs that support CAN FD

Message RAM definitions is not provided in CMSIS headers of the STM32G4
family, they are defined in fdcandev_stm32.h. Those definitions could be
extracted to a new file for each STM32 families as some differences
exist with other STM32 families that support CAN FD (for instance
STM32H7). This could be done in a futher commit, according to new
families requirements.

CAN hardware parameters stay similar and are kept in can_params.h.

There are 36 filters per channel:
* 28 first filters are standard ID (11 bit) filters
* 8 last filters are extended ID (29 bit) filters

On each Tx frame sent, the STM32G4 can store Tx events in a dedicated
FIFO. This feature is not yet implemented and Tx event FIFO is disabled
by default.
Automatic retransmission on arbitration loss is enabled by default by
the STM32G4.

About Rx, if no filter is configured, all frames are accepted by
default.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2025-01-29 20:51:23 +01:00

81 lines
1.9 KiB
Makefile

MODULE = periph
# Select the specific implementation for `periph_i2c`
ifneq (,$(filter periph_i2c,$(USEMODULE)))
ifneq (,$(filter $(CPU_FAM),f0 f3 f7 g0 g4 l0 l4 l5 u5 wb wl c0))
SRC += i2c_1.c
else ifneq (,$(filter $(CPU_FAM),f1 f2 f4 l1))
SRC += i2c_2.c
else
$(error STM32 series I2C implementation not found.)
endif
endif
# Select the specific implementation for `periph_adc`
ifneq (,$(filter periph_adc,$(USEMODULE)))
ifneq (,$(filter $(CPU_FAM),f4 f7))
SRC += adc_f4_f7.c
else ifneq (,$(filter $(CPU_FAM),f0 g0 c0))
SRC += adc_f0_g0_c0.c
else ifneq (,$(filter $(CPU_FAM),l4 wb))
SRC += adc_l4_wb.c
else
SRC += adc_$(CPU_FAM).c
endif
endif
# Select the correct implementation for `periph_gpio`
ifneq (,$(filter periph_gpio,$(USEMODULE)))
ifeq (f1,$(CPU_FAM))
SRC += gpio_f1.c
else
SRC += gpio_all.c
endif
endif
# Select the correct implementation for `periph_rtc`
ifneq (,$(filter periph_rtc,$(USEMODULE)))
ifeq (f1,$(CPU_FAM))
SRC += rtc_f1.c
else
SRC += rtc_all.c
endif
endif
# Select the correct implementation for `periph_rtt`
ifneq (,$(filter periph_rtt,$(USEMODULE)))
ifeq (f1,$(CPU_FAM))
SRC += rtt_f1.c
else
SRC += rtt_all.c
endif
endif
# Select the correct implementation for `periph_usbdev`
ifneq (,$(filter periph_usbdev,$(USEMODULE)))
ifeq (,$(filter usbdev_synopsys_dwc2,$(USEMODULE)))
SRC += usbdev_fs.c
endif
endif
# flashpage and eeprom periph implementations share flash lock/unlock functions
# defined in flash_common.c
ifneq (,$(filter periph_flashpage periph_eeprom,$(USEMODULE)))
SRC += flash_common.c
endif
ifneq (,$(filter periph_wdt,$(USEMODULE)))
$(warning Attention! WDT is clocked by CLOCK_LSI, it needs manual measuring\
since values can deviate up to 50% from reference)
endif
ifneq (,$(filter periph_can,$(FEATURES_USED)))
ifneq (,$(filter g4,$(CPU_FAM)))
SRC += fdcan.c
else
SRC += classiccan.c
endif
endif
include $(RIOTMAKE)/periph.mk