diff --git a/cpu/stm32/Makefile.dep b/cpu/stm32/Makefile.dep index d45a978ad6..4d032b3645 100644 --- a/cpu/stm32/Makefile.dep +++ b/cpu/stm32/Makefile.dep @@ -79,7 +79,7 @@ ifneq (,$(filter periph_rtc_mem,$(USEMODULE))) endif ifneq (,$(filter periph_adc,$(FEATURES_USED))) - ifneq (,$(filter f3 l4 wl, $(CPU_FAM))) + ifneq (,$(filter f3 l4 wb wl, $(CPU_FAM))) USEMODULE += ztimer USEMODULE += ztimer_msec endif diff --git a/cpu/stm32/include/periph/wb/periph_cpu.h b/cpu/stm32/include/periph/wb/periph_cpu.h index f03075e936..ab9194e15d 100644 --- a/cpu/stm32/include/periph/wb/periph_cpu.h +++ b/cpu/stm32/include/periph/wb/periph_cpu.h @@ -24,6 +24,26 @@ extern "C" { #endif +/** + * @brief Available number of ADC devices + */ +#if defined(ADC3) +#define ADC_DEVS (3U) +#elif defined(ADC2) +#define ADC_DEVS (2U) +#elif defined(ADC1) +#define ADC_DEVS (1U) +#else +#error "Can't determine the number of ADC devices" +#endif + +#if defined(CPU_MODEL_STM32WB55RG) +/** + * @brief ADC voltage regulator start-up time [us] + */ +#define ADC_T_ADCVREG_STUP_US (20) +#endif + #ifndef DOXYGEN /** @@ -32,6 +52,21 @@ extern "C" { */ #define STM32_BOOTLOADER_ADDR (0x1FFF0000) +/** + * @brief Override ADC resolution values + * @{ + */ +#define HAVE_ADC_RES_T +typedef enum { + ADC_RES_6BIT = (ADC_CFGR_RES), /**< ADC resolution: 6 bit */ + ADC_RES_8BIT = (ADC_CFGR_RES_1), /**< ADC resolution: 8 bit */ + ADC_RES_10BIT = (ADC_CFGR_RES_0), /**< ADC resolution: 10 bit */ + ADC_RES_12BIT = (0x0), /**< ADC resolution: 12 bit */ + ADC_RES_14BIT = (0x1), /**< not applicable */ + ADC_RES_16BIT = (0x2) /**< not applicable */ +} adc_res_t; +/** @} */ + /** * @name Constants for internal VBAT ADC line * @{ diff --git a/cpu/stm32/periph/Makefile b/cpu/stm32/periph/Makefile index af3456fbe6..7c4b73deb7 100644 --- a/cpu/stm32/periph/Makefile +++ b/cpu/stm32/periph/Makefile @@ -17,6 +17,8 @@ ifneq (,$(filter periph_adc,$(USEMODULE))) 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 diff --git a/cpu/stm32/periph/adc_l4.c b/cpu/stm32/periph/adc_l4_wb.c similarity index 100% rename from cpu/stm32/periph/adc_l4.c rename to cpu/stm32/periph/adc_l4_wb.c