From e1310e3378187e9e5cd0e18f16760abc687ff594 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 10 Dec 2021 14:23:19 +0100 Subject: [PATCH] drivers/sps30: fix unused include, migrate to ztimer --- drivers/sps30/sps30.c | 1 - tests/driver_sps30/Makefile | 3 ++- tests/driver_sps30/app.config.test | 3 ++- tests/driver_sps30/main.c | 27 ++++++++++++++------------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/sps30/sps30.c b/drivers/sps30/sps30.c index c3d6d1b704..a3813b1603 100644 --- a/drivers/sps30/sps30.c +++ b/drivers/sps30/sps30.c @@ -21,7 +21,6 @@ #include "checksum/crc8.h" #include "sps30.h" -#include "xtimer.h" #include "byteorder.h" #include "kernel_defines.h" diff --git a/tests/driver_sps30/Makefile b/tests/driver_sps30/Makefile index a177f7c7f9..1430b29e14 100644 --- a/tests/driver_sps30/Makefile +++ b/tests/driver_sps30/Makefile @@ -1,7 +1,8 @@ include ../Makefile.tests_common USEMODULE += sps30 -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_msec CFLAGS+=-DPARAM_SPS30_I2C=I2C_DEV\(0\) CFLAGS+=-DI2C0_SPEED=I2C_SPEED_NORMAL diff --git a/tests/driver_sps30/app.config.test b/tests/driver_sps30/app.config.test index 12b3994de7..3e63f25ebd 100644 --- a/tests/driver_sps30/app.config.test +++ b/tests/driver_sps30/app.config.test @@ -1,4 +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_SPS30=y -CONFIG_MODULE_XTIMER=y +CONFIG_MODULE_ZTIMER=y +CONFIG_MODULE_ZTIMER_MSEC=y diff --git a/tests/driver_sps30/main.c b/tests/driver_sps30/main.c index f4a08fb0a5..4fed512d59 100644 --- a/tests/driver_sps30/main.c +++ b/tests/driver_sps30/main.c @@ -18,15 +18,16 @@ #include #include -#include "xtimer.h" +#include "timex.h" +#include "ztimer.h" #include "sps30.h" #include "sps30_params.h" -#define TEST_START_DELAY_S (2U) -#define SENSOR_RESET_DELAY_S (10U) -#define SENSOR_STARTUP_DELAY_S (10U) -#define SENSOR_SLEEP_WAKE_DELAY_S (5U) -#define POLL_FOR_READY_S (1U) +#define TEST_START_DELAY_MS (2 * MS_PER_SEC) +#define SENSOR_RESET_DELAY_MS (10 * MS_PER_SEC) +#define SENSOR_STARTUP_DELAY_MS (10 * MS_PER_SEC) +#define SENSOR_SLEEP_WAKE_DELAY_MS (5 * MS_PER_SEC) +#define POLL_FOR_READY_MS (1 * MS_PER_SEC) #define NUM_OF_MEASUREMENTS (10U) #define TYPE_MC_STR "MC PM" @@ -62,7 +63,7 @@ int main(void) bool error = false; unsigned cnt = NUM_OF_MEASUREMENTS; - xtimer_sleep(TEST_START_DELAY_S); + ztimer_sleep(ZTIMER_MSEC, TEST_START_DELAY_MS); puts("SPS30 test application\n"); @@ -87,7 +88,7 @@ int main(void) error |= _print_error("start_fan_clean", ec); /* wait long enough for the fan clean to be done and the fan to settle */ - xtimer_sleep(2 * SPS30_FAN_CLEAN_S); + ztimer_sleep(ZTIMER_MSEC, 2 * SPS30_FAN_CLEAN_S); /* read the currently set value from the sensor */ ec = sps30_read_ac_interval(&dev, &ci); @@ -101,23 +102,23 @@ int main(void) ec = sps30_reset(&dev); error |= _print_error("reset", ec); - xtimer_sleep(SENSOR_RESET_DELAY_S); + ztimer_sleep(ZTIMER_MSEC, SENSOR_RESET_DELAY_MS); /* Put the sensor in sleep */ ec = sps30_sleep(&dev); error |= _print_error("sleep", ec); - xtimer_sleep(SENSOR_SLEEP_WAKE_DELAY_S); + ztimer_sleep(ZTIMER_MSEC, SENSOR_SLEEP_WAKE_DELAY_MS); /* Wake-up the sensor */ ec = sps30_wakeup(&dev); error |= _print_error("wake-up", ec); - xtimer_sleep(SENSOR_SLEEP_WAKE_DELAY_S); + ztimer_sleep(ZTIMER_MSEC, SENSOR_SLEEP_WAKE_DELAY_MS); /* start the sensor again again... */ ec = sps30_start_measurement(&dev); error |= _print_error("start_measurement", ec); - xtimer_sleep(SENSOR_STARTUP_DELAY_S); + ztimer_sleep(ZTIMER_MSEC, SENSOR_STARTUP_DELAY_MS); ec = sps30_read_ac_interval(&dev, &ci); error |= _print_error("read_ac_interval", ec); @@ -141,7 +142,7 @@ int main(void) cnt--; /* if errors happen, stop after NUM_OF_MEASUREMENTS */ } /* try again after some time */ - xtimer_sleep(POLL_FOR_READY_S); + ztimer_sleep(ZTIMER_MSEC, POLL_FOR_READY_MS); continue; }