cpu/stm32: added ADC for g0

This commit is contained in:
Dave VanKampen 2021-09-24 10:20:09 -04:00
parent c1e4a28c9b
commit 6414c64f89
2 changed files with 14 additions and 2 deletions

View File

@ -15,6 +15,8 @@ endif
ifneq (,$(filter periph_adc,$(USEMODULE))) ifneq (,$(filter periph_adc,$(USEMODULE)))
ifneq (,$(filter $(CPU_FAM),f4 f7)) ifneq (,$(filter $(CPU_FAM),f4 f7))
SRC += adc_f4_f7.c SRC += adc_f4_f7.c
else ifneq (,$(filter $(CPU_FAM),f0 g0))
SRC += adc_f0_g0.c
else else
SRC += adc_$(CPU_FAM).c SRC += adc_$(CPU_FAM).c
endif endif

View File

@ -24,21 +24,31 @@
#include "periph/adc.h" #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 mutex_t lock = MUTEX_INIT;
static inline void prep(void) static inline void prep(void)
{ {
mutex_lock(&lock); mutex_lock(&lock);
#ifdef RCC_APB2ENR_ADCEN
periph_clk_en(APB2, 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) static inline void done(void)
{ {
#ifdef RCC_APB2ENR_ADCEN
periph_clk_dis(APB2, 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); mutex_unlock(&lock);
} }