diff --git a/cpu/stm32/periph/Makefile b/cpu/stm32/periph/Makefile index 83c291a1b2..8db7e41985 100644 --- a/cpu/stm32/periph/Makefile +++ b/cpu/stm32/periph/Makefile @@ -15,6 +15,8 @@ endif ifneq (,$(filter periph_adc,$(USEMODULE))) ifneq (,$(filter $(CPU_FAM),f4 f7)) SRC += adc_f4_f7.c + else ifneq (,$(filter $(CPU_FAM),f0 g0)) + SRC += adc_f0_g0.c else SRC += adc_$(CPU_FAM).c endif diff --git a/cpu/stm32/periph/adc_f0.c b/cpu/stm32/periph/adc_f0_g0.c similarity index 84% rename from cpu/stm32/periph/adc_f0.c rename to cpu/stm32/periph/adc_f0_g0.c index 16e5f8d7bd..50f68fffd9 100644 --- a/cpu/stm32/periph/adc_f0.c +++ b/cpu/stm32/periph/adc_f0_g0.c @@ -24,21 +24,31 @@ #include "periph/adc.h" /** - * @brief Allocate locks for all three available ADC device + * @brief Allocate lock for the ADC device * - * All STM32F0 CPUs we support so far only come with a single ADC device. + * All STM32F0 & STM32G0 CPUs we support so far only come with a single ADC device. */ static mutex_t lock = MUTEX_INIT; static inline void prep(void) { mutex_lock(&lock); +#ifdef RCC_APB2ENR_ADCEN periph_clk_en(APB2, RCC_APB2ENR_ADCEN); +#endif +#ifdef RCC_APBENR2_ADCEN + periph_clk_en(APB12, RCC_APBENR2_ADCEN); +#endif } static inline void done(void) { +#ifdef RCC_APB2ENR_ADCEN periph_clk_dis(APB2, RCC_APB2ENR_ADCEN); +#endif +#ifdef RCC_APBENR2_ADCEN + periph_clk_dis(APB12, RCC_APBENR2_ADCEN); +#endif mutex_unlock(&lock); }