diff --git a/cpu/qn908x/Makefile.dep b/cpu/qn908x/Makefile.dep index b6aac56fc9..6902e4f8c0 100644 --- a/cpu/qn908x/Makefile.dep +++ b/cpu/qn908x/Makefile.dep @@ -14,4 +14,9 @@ ifneq (,$(filter periph_uart periph_i2c periph_spi,$(USEMODULE))) USEMODULE += periph_flexcomm endif +ifneq (,$(filter periph_adc,$(USEMODULE))) + USEMODULE += ztimer + USEMODULE += ztimer_usec +endif + include $(RIOTCPU)/cortexm_common/Makefile.dep diff --git a/cpu/qn908x/periph/Kconfig b/cpu/qn908x/periph/Kconfig index 50ab202853..a6cde85790 100644 --- a/cpu/qn908x/periph/Kconfig +++ b/cpu/qn908x/periph/Kconfig @@ -17,3 +17,10 @@ config MODULE_PERIPH_GPIO_MUX depends on TEST_KCONFIG help Common Pin MUX functions for qn908x CPUs. + +config MODULE_PERIPH_ADC + bool "ADC peripheral driver" + depends on HAS_PERIPH_ADC + select MODULE_ZTIMER + select MODULE_ZTIMER_USEC + select MODULE_ZTIMER_PERIPH_TIMER diff --git a/cpu/qn908x/periph/adc.c b/cpu/qn908x/periph/adc.c index d8de1c886d..55b0011707 100644 --- a/cpu/qn908x/periph/adc.c +++ b/cpu/qn908x/periph/adc.c @@ -41,7 +41,7 @@ #include "bitarithm.h" #include "cpu.h" #include "mutex.h" -#include "xtimer.h" +#include "ztimer.h" #include "gpio_mux.h" #include "periph/adc.h" @@ -142,7 +142,7 @@ int adc_init(adc_t line) /* Need to wait 100 us before the ADC can be used for sampling. We could * in theory avoid this wait since it is only needed before adc_sample() * is called but it is short enough that it is safer to include it. */ - xtimer_usleep(100u); + ztimer_sleep(ZTIMER_USEC, 100u); /* Enable the ADC clock so we can use the ADC. */ CLOCK_EnableClock(kCLOCK_Adc); @@ -278,7 +278,7 @@ int32_t adc_sample(adc_t line, adc_res_t res) { ADC_CFG_SCAN_INTV(4); /* Switching ADC source every 32 clock cycles. */ /* Need to wait for one ADC cycle before it can be started. */ - xtimer_usleep(adc_clock_cycle_us[QN908X_ADC_CLOCK]); + ztimer_sleep(ZTIMER_USEC, adc_clock_cycle_us[QN908X_ADC_CLOCK]); /* Configure the destination of the ADC value read from the interrupt. */ volatile int32_t adc_data = 0;