mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/qn908x: migrate ADC periph to ztimer
This commit is contained in:
parent
2e0c02b25d
commit
7c34d69b84
@ -14,4 +14,9 @@ ifneq (,$(filter periph_uart periph_i2c periph_spi,$(USEMODULE)))
|
|||||||
USEMODULE += periph_flexcomm
|
USEMODULE += periph_flexcomm
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(filter periph_adc,$(USEMODULE)))
|
||||||
|
USEMODULE += ztimer
|
||||||
|
USEMODULE += ztimer_usec
|
||||||
|
endif
|
||||||
|
|
||||||
include $(RIOTCPU)/cortexm_common/Makefile.dep
|
include $(RIOTCPU)/cortexm_common/Makefile.dep
|
||||||
|
@ -17,3 +17,10 @@ config MODULE_PERIPH_GPIO_MUX
|
|||||||
depends on TEST_KCONFIG
|
depends on TEST_KCONFIG
|
||||||
help
|
help
|
||||||
Common Pin MUX functions for qn908x CPUs.
|
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
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "bitarithm.h"
|
#include "bitarithm.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "xtimer.h"
|
#include "ztimer.h"
|
||||||
|
|
||||||
#include "gpio_mux.h"
|
#include "gpio_mux.h"
|
||||||
#include "periph/adc.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
|
/* 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()
|
* 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. */
|
* 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. */
|
/* Enable the ADC clock so we can use the ADC. */
|
||||||
CLOCK_EnableClock(kCLOCK_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. */
|
ADC_CFG_SCAN_INTV(4); /* Switching ADC source every 32 clock cycles. */
|
||||||
|
|
||||||
/* Need to wait for one ADC cycle before it can be started. */
|
/* 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. */
|
/* Configure the destination of the ADC value read from the interrupt. */
|
||||||
volatile int32_t adc_data = 0;
|
volatile int32_t adc_data = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user