From bb5aaa38ad2e7a0616f408a48bc2740ca6a42b57 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 1 Dec 2021 14:49:48 +0100 Subject: [PATCH 1/4] pkg/cryptoauthlib: migrate to ztimer --- pkg/cryptoauthlib/Makefile.dep | 3 ++- pkg/cryptoauthlib/contrib/atca.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/cryptoauthlib/Makefile.dep b/pkg/cryptoauthlib/Makefile.dep index cff48ab08a..4da9094721 100644 --- a/pkg/cryptoauthlib/Makefile.dep +++ b/pkg/cryptoauthlib/Makefile.dep @@ -1,4 +1,5 @@ -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_usec FEATURES_REQUIRED += periph_i2c FEATURES_OPTIONAL += periph_i2c_reconfigure DEFAULT_MODULE += auto_init_security diff --git a/pkg/cryptoauthlib/contrib/atca.c b/pkg/cryptoauthlib/contrib/atca.c index 0f9eb6486e..78aaa522cc 100644 --- a/pkg/cryptoauthlib/contrib/atca.c +++ b/pkg/cryptoauthlib/contrib/atca.c @@ -19,7 +19,8 @@ */ #include #include -#include "xtimer.h" +#include "timex.h" +#include "ztimer.h" #include "periph/i2c.h" #include "periph/gpio.h" @@ -29,17 +30,17 @@ /* Timer functions */ void atca_delay_us(uint32_t delay) { - xtimer_usleep(delay); + ztimer_sleep(ZTIMER_USEC, delay); } void atca_delay_10us(uint32_t delay) { - xtimer_usleep(delay * 10); + ztimer_sleep(ZTIMER_USEC, delay * 10); } void atca_delay_ms(uint32_t delay) { - xtimer_usleep(delay * 1000); + ztimer_sleep(ZTIMER_USEC, delay * US_PER_MS); } /* Hal I2C implementation */ From 25d1e2daa2dcf838999f5baa93459404bb0b3003 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 1 Dec 2021 14:59:38 +0100 Subject: [PATCH 2/4] pkg/driver_bme680: migrate to ztimer --- drivers/bme680/Kconfig | 3 ++- drivers/bme680/Makefile.dep | 3 ++- drivers/bme680/bme680_saul.c | 4 ++-- pkg/driver_bme680/Kconfig | 2 ++ pkg/driver_bme680/Makefile.dep | 2 ++ pkg/driver_bme680/contrib/bme680_hal.c | 4 ++-- tests/driver_bme680/Makefile | 3 ++- tests/driver_bme680/app.config.test | 3 ++- tests/driver_bme680/main.c | 13 +++++++------ 9 files changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/bme680/Kconfig b/drivers/bme680/Kconfig index a6d53458b3..623c1ee8bc 100644 --- a/drivers/bme680/Kconfig +++ b/drivers/bme680/Kconfig @@ -9,7 +9,8 @@ menuconfig MODULE_BME680 bool "BME680 Temperature/Humidity/Pressure/Gas sensor" depends on TEST_KCONFIG select PACKAGE_DRIVER_BME680 - select MODULE_XTIMER if MODULE_SAUL + select MODULE_ZTIMER if MODULE_SAUL + select MODULE_ZTIMER_MSEC if MODULE_SAUL if MODULE_BME680 diff --git a/drivers/bme680/Makefile.dep b/drivers/bme680/Makefile.dep index 651ee40a84..69968ce08a 100644 --- a/drivers/bme680/Makefile.dep +++ b/drivers/bme680/Makefile.dep @@ -1,7 +1,8 @@ USEPKG += driver_bme680 ifneq (,$(filter saul%,$(USEMODULE))) - USEMODULE += xtimer + USEMODULE += ztimer + USEMODULE += ztimer_msec endif ifneq (,$(filter bme680_i2c,$(USEMODULE))) diff --git a/drivers/bme680/bme680_saul.c b/drivers/bme680/bme680_saul.c index 31d77d05fc..fecb824e55 100644 --- a/drivers/bme680/bme680_saul.c +++ b/drivers/bme680/bme680_saul.c @@ -21,7 +21,7 @@ #include "saul.h" #include "bme680.h" #include "bme680_params.h" -#include "xtimer.h" +#include "ztimer.h" extern bme680_t bme680_devs_saul[BME680_NUMOF]; @@ -65,7 +65,7 @@ static int _read(int dev) if ((drt = bme680_get_duration(&bme680_devs_saul[dev])) < 0) { return BME680_INVALID; } - xtimer_msleep(drt); + ztimer_sleep(ZTIMER_MSEC, drt); bme680_field_data_t data; if ((res = bme680_get_data(&bme680_devs_saul[dev], &data)) != BME680_OK) { diff --git a/pkg/driver_bme680/Kconfig b/pkg/driver_bme680/Kconfig index d3e5d9b212..d155801192 100644 --- a/pkg/driver_bme680/Kconfig +++ b/pkg/driver_bme680/Kconfig @@ -9,6 +9,8 @@ config PACKAGE_DRIVER_BME680 bool "BME680 sensor driver package" depends on TEST_KCONFIG select MODULE_DRIVER_BME680_CONTRIB + select MODULE_ZTIMER + select MODULE_ZTIMER_MSEC config MODULE_DRIVER_BME680_CONTRIB bool diff --git a/pkg/driver_bme680/Makefile.dep b/pkg/driver_bme680/Makefile.dep index 0567ee2f56..a7661f3ade 100644 --- a/pkg/driver_bme680/Makefile.dep +++ b/pkg/driver_bme680/Makefile.dep @@ -1 +1,3 @@ +USEMODULE += ztimer +USEMODULE += ztimer_msec USEMODULE += driver_bme680_contrib diff --git a/pkg/driver_bme680/contrib/bme680_hal.c b/pkg/driver_bme680/contrib/bme680_hal.c index 26c16523ac..ec3f2a2436 100644 --- a/pkg/driver_bme680/contrib/bme680_hal.c +++ b/pkg/driver_bme680/contrib/bme680_hal.c @@ -33,7 +33,7 @@ #include "periph/spi.h" #endif -#include "xtimer.h" +#include "ztimer.h" #ifndef BME680_SPI_SPEED #define BME680_SPI_SPEED (SPI_CLK_1MHZ) @@ -45,7 +45,7 @@ void bme680_ms_sleep(uint32_t msleep) { - xtimer_msleep(msleep); + ztimer_sleep(ZTIMER_MSEC, msleep); } #ifdef MODULE_PERIPH_I2C diff --git a/tests/driver_bme680/Makefile b/tests/driver_bme680/Makefile index b0a7023834..2419840ecf 100644 --- a/tests/driver_bme680/Makefile +++ b/tests/driver_bme680/Makefile @@ -3,7 +3,8 @@ include ../Makefile.tests_common DRIVER ?= bme680_i2c USEMODULE += $(DRIVER) -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_msec ifeq ($(ENABLE_FP),1) USEMODULE += bme680_fp diff --git a/tests/driver_bme680/app.config.test b/tests/driver_bme680/app.config.test index 325e73a745..e183d82598 100644 --- a/tests/driver_bme680/app.config.test +++ b/tests/driver_bme680/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_BME680=y -CONFIG_MODULE_XTIMER=y +CONFIG_MODULE_ZTIMER=y +CONFIG_MODULE_ZTIMER_MSEC=y diff --git a/tests/driver_bme680/main.c b/tests/driver_bme680/main.c index a8cd454407..e7d8e5c155 100644 --- a/tests/driver_bme680/main.c +++ b/tests/driver_bme680/main.c @@ -25,15 +25,16 @@ #include "bme680.h" #include "bme680_params.h" #include "mutex.h" -#include "xtimer.h" +#include "timex.h" +#include "ztimer.h" -#define BME680_TEST_PERIOD_US (5 * US_PER_SEC) +#define BME680_TEST_PERIOD_MS (5 * MS_PER_SEC) /* 5s */ -xtimer_t timer; +ztimer_t timer; static void _timer_cb(void *arg) { - xtimer_set(&timer, BME680_TEST_PERIOD_US); + ztimer_set(ZTIMER_MSEC, &timer, BME680_TEST_PERIOD_MS); mutex_unlock(arg); } @@ -64,7 +65,7 @@ int main(void) timer.callback = _timer_cb; timer.arg = &timer_mtx; - xtimer_set(&timer, BME680_TEST_PERIOD_US); + ztimer_set(ZTIMER_MSEC, &timer, BME680_TEST_PERIOD_MS); while (1) { @@ -76,7 +77,7 @@ int main(void) /* get the duration for the measurement */ int duration = bme680_get_duration(&dev[i]); /* wait for the duration */ - xtimer_msleep(duration); + ztimer_sleep(ZTIMER_MSEC, duration); /* read the data */ int res = bme680_get_data(&dev[i], &data); From 4f3a61c7dc8ad6172267f03fb731d2bbefb174e2 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 1 Dec 2021 15:07:26 +0100 Subject: [PATCH 3/4] pkg/u8g2: migrate to ztimer --- pkg/u8g2/Kconfig | 3 ++- pkg/u8g2/Makefile.dep | 3 ++- pkg/u8g2/contrib/u8x8_riotos.c | 8 ++++---- tests/pkg_u8g2/Makefile | 3 ++- tests/pkg_u8g2/main.c | 5 +++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pkg/u8g2/Kconfig b/pkg/u8g2/Kconfig index 27cfebe8e5..80ab54d0a4 100644 --- a/pkg/u8g2/Kconfig +++ b/pkg/u8g2/Kconfig @@ -10,7 +10,8 @@ config PACKAGE_U8G2 depends on TEST_KCONFIG depends on HAS_PERIPH_GPIO select MODULE_PERIPH_GPIO - select MODULE_XTIMER + select MODULE_ZTIMER + select MODULE_ZTIMER_USEC select MODULE_U8G2_RIOT select MODULE_U8G2_CSRC diff --git a/pkg/u8g2/Makefile.dep b/pkg/u8g2/Makefile.dep index 24df6f6fda..afc477e960 100644 --- a/pkg/u8g2/Makefile.dep +++ b/pkg/u8g2/Makefile.dep @@ -1,4 +1,5 @@ -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_usec FEATURES_REQUIRED += periph_gpio diff --git a/pkg/u8g2/contrib/u8x8_riotos.c b/pkg/u8g2/contrib/u8x8_riotos.c index a45a479ae3..0730f9da01 100644 --- a/pkg/u8g2/contrib/u8x8_riotos.c +++ b/pkg/u8g2/contrib/u8x8_riotos.c @@ -24,7 +24,7 @@ #include "u8x8_riotos.h" -#include "xtimer.h" +#include "ztimer.h" #ifdef MODULE_PERIPH_SPI #include "periph/spi.h" @@ -97,14 +97,14 @@ uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, v _enable_pins(u8x8_riot_ptr); break; case U8X8_MSG_DELAY_MILLI: - xtimer_usleep(arg_int * 1000); + ztimer_sleep(ZTIMER_USEC, arg_int * 1000); break; case U8X8_MSG_DELAY_10MICRO: - xtimer_usleep(arg_int * 10); + ztimer_sleep(ZTIMER_USEC, arg_int * 10); break; case U8X8_MSG_DELAY_100NANO: /* not used in upstream so approximating to 1us should be fine */ - xtimer_usleep(1); + ztimer_sleep(ZTIMER_USEC, 1); break; case U8X8_MSG_GPIO_CS: if (u8x8_riot_ptr != NULL && gpio_is_valid(u8x8_riot_ptr->pin_cs)) { diff --git a/tests/pkg_u8g2/Makefile b/tests/pkg_u8g2/Makefile index baa1cfca57..c7148c9e64 100644 --- a/tests/pkg_u8g2/Makefile +++ b/tests/pkg_u8g2/Makefile @@ -1,6 +1,7 @@ include ../Makefile.tests_common -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_usec USEPKG += u8g2 diff --git a/tests/pkg_u8g2/main.c b/tests/pkg_u8g2/main.c index 2d797e7ccd..b58565c0e5 100644 --- a/tests/pkg_u8g2/main.c +++ b/tests/pkg_u8g2/main.c @@ -70,7 +70,8 @@ #include "periph/i2c.h" #endif -#include "xtimer.h" +#include "timex.h" +#include "ztimer.h" #include "u8g2.h" #include "u8x8_riotos.h" @@ -200,7 +201,7 @@ int main(void) screen = (screen + 1) % 3; /* sleep a little */ - xtimer_sleep(1); + ztimer_sleep(ZTIMER_USEC, US_PER_SEC); } return 0; From 24ff8f7ece2639470690bad5de0dbc0e66e4d2e7 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 1 Dec 2021 15:07:47 +0100 Subject: [PATCH 4/4] pkg/ucglib: migrate to ztimer --- pkg/ucglib/Kconfig | 3 ++- pkg/ucglib/Makefile.dep | 3 ++- pkg/ucglib/contrib/ucg_riotos.c | 4 ++-- tests/pkg_ucglib/main.c | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/ucglib/Kconfig b/pkg/ucglib/Kconfig index 168d425d24..5e40bcbe9b 100644 --- a/pkg/ucglib/Kconfig +++ b/pkg/ucglib/Kconfig @@ -10,7 +10,8 @@ config PACKAGE_UCGLIB depends on TEST_KCONFIG depends on HAS_PERIPH_GPIO select MODULE_PERIPH_GPIO - select MODULE_XTIMER + select MODULE_ZTIMER + select MODULE_ZTIMER_USEC select MODULE_UCGLIB_RIOT select MODULE_UCGLIB_CSRC diff --git a/pkg/ucglib/Makefile.dep b/pkg/ucglib/Makefile.dep index 29d5db25a0..cd5014c9e7 100644 --- a/pkg/ucglib/Makefile.dep +++ b/pkg/ucglib/Makefile.dep @@ -1,4 +1,5 @@ -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_usec FEATURES_REQUIRED += periph_gpio diff --git a/pkg/ucglib/contrib/ucg_riotos.c b/pkg/ucglib/contrib/ucg_riotos.c index b3f3f617fa..33449b648f 100644 --- a/pkg/ucglib/contrib/ucg_riotos.c +++ b/pkg/ucglib/contrib/ucg_riotos.c @@ -23,7 +23,7 @@ #include "ucg_riotos.h" -#include "xtimer.h" +#include "ztimer.h" #ifdef MODULE_PERIPH_SPI #include "periph/spi.h" @@ -98,7 +98,7 @@ int16_t ucg_com_hw_spi_riotos(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *da spi_release(dev); break; case UCG_COM_MSG_DELAY: - xtimer_usleep(arg); + ztimer_sleep(ZTIMER_USEC, arg); break; case UCG_COM_MSG_CHANGE_RESET_LINE: if (ucg_riot_ptr != NULL && gpio_is_valid(ucg_riot_ptr->pin_reset)) { diff --git a/tests/pkg_ucglib/main.c b/tests/pkg_ucglib/main.c index 10abb7e514..0eef82921a 100644 --- a/tests/pkg_ucglib/main.c +++ b/tests/pkg_ucglib/main.c @@ -54,7 +54,8 @@ #include "periph/spi.h" #endif -#include "xtimer.h" +#include "timex.h" +#include "ztimer.h" #include "ucg.h" #include "ucg_riotos.h" @@ -139,7 +140,7 @@ int main(void) screen = (screen + 1) % 3; /* sleep a little */ - xtimer_sleep(1); + ztimer_sleep(ZTIMER_USEC, US_PER_SEC); } return 0;