So what's the deciding factor? Should this be in 'stm32' directory
because most peripherals have compatibility? Or a different directory
because RCC is different?

The deciding factor should be maintainability.

I have not heard any reason why the support should not go under stm32/.  Mu only concern is for the long lists of MCU dependencies that you see in the the code like:

   stm32_adc.c:244:#if defined(CONFIG_STM32_STM32F10XX)
   stm32_adc.c:264:#elif defined(CONFIG_STM32_STM32F30XX) ||
   defined(CONFIG_STM32_STM32F33XX)
   stm32_adc.c:288:#elif defined(CONFIG_STM32_STM32F20XX) ||
   defined(CONFIG_STM32_STM32F37XX) || \
   stm32_adc.c:289:    defined(CONFIG_STM32_STM32F4XXX)
   stm32_adc.c:290:#  if defined(CONFIG_STM32_STM32F37XX)
   stm32_adc.c:314:#elif defined(CONFIG_STM32_STM32L15XX)
   stm32_adc.c:361:#if defined(CONFIG_STM32_STM32F10XX)
   stm32_adc.c:363:#elif defined(CONFIG_STM32_STM32F20XX) ||
   defined(CONFIG_STM32_STM32F30XX) || \
   stm32_adc.c:364:      defined(CONFIG_STM32_STM32F33XX) ||
   defined(CONFIG_STM32_STM32F4XXX)
   stm32_adc.c:366:#elif defined(CONFIG_STM32_STM32L15XX)

One thing you can do to keep prevent the runaway dependencies on specific chips is to parameterized the features.  For example, if STM32abc, STM32def, and STM32ghi and have FEATURE_X, then instead of conditioning the implementation of FEATURE_X on all of those MCUs, you could minimize the chaos by defining a single CONFIG_STM32_FEATURE_X  Then conditioning the implementation of FEATURE_X on only that one parameter.

Also, use separater files when the logic is vastly different. Look, for example, at how many stm32*_rcc.c files there are in stm32/.  The correct one is selected in the Make.defs.

Greg

PS:  I see that you are a VP now!




Reply via email to