diff --git a/drivers/ccs811/Kconfig b/drivers/ccs811/Kconfig index 95c2eccbff..872c5f1f91 100644 --- a/drivers/ccs811/Kconfig +++ b/drivers/ccs811/Kconfig @@ -12,7 +12,9 @@ menuconfig MODULE_CCS811 depends on TEST_KCONFIG select MODULE_PERIPH_GPIO select MODULE_PERIPH_I2C - select MODULE_XTIMER + select MODULE_ZTIMER + select MODULE_ZTIMER_USEC + select MODULE_ZTIMER_PERIPH_TIMER config MODULE_CCS811_FULL bool "Full functionalities" diff --git a/drivers/ccs811/Makefile.dep b/drivers/ccs811/Makefile.dep index 659858548a..0fd0f94c86 100644 --- a/drivers/ccs811/Makefile.dep +++ b/drivers/ccs811/Makefile.dep @@ -1,6 +1,7 @@ FEATURES_REQUIRED += periph_gpio FEATURES_REQUIRED += periph_i2c -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_usec ifneq (,$(filter ccs811_full,$(USEMODULE))) FEATURES_REQUIRED += periph_gpio_irq diff --git a/drivers/ccs811/ccs811.c b/drivers/ccs811/ccs811.c index 453b12e418..f2248d2a1c 100644 --- a/drivers/ccs811/ccs811.c +++ b/drivers/ccs811/ccs811.c @@ -19,7 +19,7 @@ #include #include "log.h" -#include "xtimer.h" +#include "ztimer.h" #include "ccs811_regs.h" #include "ccs811.h" @@ -82,11 +82,11 @@ int ccs811_init(ccs811_t *dev, const ccs811_params_t *params) /* enable low active reset signal */ gpio_clear(dev->params.reset_pin); /* t_RESET (reset impuls) has to be at least 20 us, we wait 1 ms */ - xtimer_usleep(1000); + ztimer_sleep(ZTIMER_USEC, 1000); /* disable low active reset signal */ gpio_set(dev->params.reset_pin); /* t_START after reset is 1 ms, we wait 1 further ms */ - xtimer_usleep(1000); + ztimer_sleep(ZTIMER_USEC, 1000); } if (gpio_is_valid(dev->params.wake_pin) && @@ -112,7 +112,7 @@ int ccs811_init(ccs811_t *dev, const ccs811_params_t *params) uint8_t status; /* wait 100 ms after the reset */ - xtimer_usleep(100000); + ztimer_sleep(ZTIMER_USEC, 100000); /* get the status to check whether sensor is in bootloader mode */ if (_reg_read(dev, CCS811_REG_STATUS, &status, 1) != CCS811_OK) { @@ -139,7 +139,7 @@ int ccs811_init(ccs811_t *dev, const ccs811_params_t *params) } /* wait 100 ms after starting the app */ - xtimer_usleep(100000); + ztimer_sleep(ZTIMER_USEC, 100000); /* get the status to check whether sensor switched to application mode */ if (_reg_read(dev, CCS811_REG_STATUS, &status, 1) != CCS811_OK) { @@ -482,7 +482,7 @@ static int _reg_read(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t l /* wake the sensor with low active WAKE signal */ gpio_clear(dev->params.wake_pin); /* t_WAKE is 50 us */ - xtimer_usleep(50); + ztimer_sleep(ZTIMER_USEC, 50); } #endif @@ -494,7 +494,7 @@ static int _reg_read(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t l /* let the sensor enter to sleep mode */ gpio_set(dev->params.wake_pin); /* minimum t_DWAKE is 20 us */ - xtimer_usleep(20); + ztimer_sleep(ZTIMER_USEC, 20); } #endif @@ -540,7 +540,7 @@ static int _reg_write(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t /* wake the sensor with low active WAKE signal */ gpio_clear(dev->params.wake_pin); /* t_WAKE is 50 us */ - xtimer_usleep(50); + ztimer_sleep(ZTIMER_USEC, 50); } #endif @@ -557,7 +557,7 @@ static int _reg_write(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t /* let the sensor enter to sleep mode */ gpio_set(dev->params.wake_pin); /* minimum t_DWAKE is 20 us */ - xtimer_usleep(20); + ztimer_sleep(ZTIMER_USEC, 20); } #endif diff --git a/tests/driver_ccs811/Makefile b/tests/driver_ccs811/Makefile index 7b7b9b9802..b38053bdd0 100644 --- a/tests/driver_ccs811/Makefile +++ b/tests/driver_ccs811/Makefile @@ -2,4 +2,7 @@ include ../Makefile.tests_common USEMODULE += ccs811 +USEMODULE += ztimer +USEMODULE += ztimer_usec + include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_ccs811/app.config.test b/tests/driver_ccs811/app.config.test index 168cb3ae3b..b952fa3cc3 100644 --- a/tests/driver_ccs811/app.config.test +++ b/tests/driver_ccs811/app.config.test @@ -1,3 +1,5 @@ # this file enables modules defined in Kconfig. Do not use this file for # application configuration. This is only needed during migration. CONFIG_MODULE_CCS811=y +CONFIG_MODULE_ZTIMER=y +CONFIG_MODULE_ZTIMER_USEC=y diff --git a/tests/driver_ccs811/main.c b/tests/driver_ccs811/main.c index 2bdb75735b..8f0d6597ff 100644 --- a/tests/driver_ccs811/main.c +++ b/tests/driver_ccs811/main.c @@ -27,7 +27,7 @@ #include #include "thread.h" -#include "xtimer.h" +#include "ztimer.h" #include "ccs811.h" #include "ccs811_params.h" @@ -54,7 +54,7 @@ int main(void) /* wait and check for for new data every 10 ms */ while (ccs811_data_ready (&sensor) != CCS811_OK) { - xtimer_usleep(10000); + ztimer_sleep(ZTIMER_USEC, 10000); } /* read the data and print them on success */ diff --git a/tests/driver_ccs811_full/main.c b/tests/driver_ccs811_full/main.c index face4a4ee8..2f1bfe0082 100644 --- a/tests/driver_ccs811_full/main.c +++ b/tests/driver_ccs811_full/main.c @@ -35,7 +35,6 @@ #include #include "thread.h" -#include "xtimer.h" #include "ccs811.h" #include "ccs811_params.h"