From 6414c64f89d287258a8703d3e9cb73b10d6d11ad Mon Sep 17 00:00:00 2001 From: Dave VanKampen Date: Fri, 24 Sep 2021 10:20:09 -0400 Subject: [PATCH] cpu/stm32: added ADC for g0 --- cpu/stm32/periph/Makefile | 2 ++ cpu/stm32/periph/{adc_f0.c => adc_f0_g0.c} | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) rename cpu/stm32/periph/{adc_f0.c => adc_f0_g0.c} (84%) 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); }