1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #17309 from aabadie/pr/pkg/ztimer

pkg: migrate some packages to ztimer
This commit is contained in:
Francisco 2021-12-07 09:13:39 +01:00 committed by GitHub
commit de7df7201a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 52 additions and 34 deletions

View File

@ -9,7 +9,8 @@ menuconfig MODULE_BME680
bool "BME680 Temperature/Humidity/Pressure/Gas sensor" bool "BME680 Temperature/Humidity/Pressure/Gas sensor"
depends on TEST_KCONFIG depends on TEST_KCONFIG
select PACKAGE_DRIVER_BME680 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 if MODULE_BME680

View File

@ -1,7 +1,8 @@
USEPKG += driver_bme680 USEPKG += driver_bme680
ifneq (,$(filter saul%,$(USEMODULE))) ifneq (,$(filter saul%,$(USEMODULE)))
USEMODULE += xtimer USEMODULE += ztimer
USEMODULE += ztimer_msec
endif endif
ifneq (,$(filter bme680_i2c,$(USEMODULE))) ifneq (,$(filter bme680_i2c,$(USEMODULE)))

View File

@ -21,7 +21,7 @@
#include "saul.h" #include "saul.h"
#include "bme680.h" #include "bme680.h"
#include "bme680_params.h" #include "bme680_params.h"
#include "xtimer.h" #include "ztimer.h"
extern bme680_t bme680_devs_saul[BME680_NUMOF]; 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) { if ((drt = bme680_get_duration(&bme680_devs_saul[dev])) < 0) {
return BME680_INVALID; return BME680_INVALID;
} }
xtimer_msleep(drt); ztimer_sleep(ZTIMER_MSEC, drt);
bme680_field_data_t data; bme680_field_data_t data;
if ((res = bme680_get_data(&bme680_devs_saul[dev], &data)) != BME680_OK) { if ((res = bme680_get_data(&bme680_devs_saul[dev], &data)) != BME680_OK) {

View File

@ -1,4 +1,5 @@
USEMODULE += xtimer USEMODULE += ztimer
USEMODULE += ztimer_usec
FEATURES_REQUIRED += periph_i2c FEATURES_REQUIRED += periph_i2c
FEATURES_OPTIONAL += periph_i2c_reconfigure FEATURES_OPTIONAL += periph_i2c_reconfigure
DEFAULT_MODULE += auto_init_security DEFAULT_MODULE += auto_init_security

View File

@ -19,7 +19,8 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include "xtimer.h" #include "timex.h"
#include "ztimer.h"
#include "periph/i2c.h" #include "periph/i2c.h"
#include "periph/gpio.h" #include "periph/gpio.h"
@ -29,17 +30,17 @@
/* Timer functions */ /* Timer functions */
void atca_delay_us(uint32_t delay) void atca_delay_us(uint32_t delay)
{ {
xtimer_usleep(delay); ztimer_sleep(ZTIMER_USEC, delay);
} }
void atca_delay_10us(uint32_t 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) void atca_delay_ms(uint32_t delay)
{ {
xtimer_usleep(delay * 1000); ztimer_sleep(ZTIMER_USEC, delay * US_PER_MS);
} }
/* Hal I2C implementation */ /* Hal I2C implementation */

View File

@ -9,6 +9,8 @@ config PACKAGE_DRIVER_BME680
bool "BME680 sensor driver package" bool "BME680 sensor driver package"
depends on TEST_KCONFIG depends on TEST_KCONFIG
select MODULE_DRIVER_BME680_CONTRIB select MODULE_DRIVER_BME680_CONTRIB
select MODULE_ZTIMER
select MODULE_ZTIMER_MSEC
config MODULE_DRIVER_BME680_CONTRIB config MODULE_DRIVER_BME680_CONTRIB
bool bool

View File

@ -1 +1,3 @@
USEMODULE += ztimer
USEMODULE += ztimer_msec
USEMODULE += driver_bme680_contrib USEMODULE += driver_bme680_contrib

View File

@ -33,7 +33,7 @@
#include "periph/spi.h" #include "periph/spi.h"
#endif #endif
#include "xtimer.h" #include "ztimer.h"
#ifndef BME680_SPI_SPEED #ifndef BME680_SPI_SPEED
#define BME680_SPI_SPEED (SPI_CLK_1MHZ) #define BME680_SPI_SPEED (SPI_CLK_1MHZ)
@ -45,7 +45,7 @@
void bme680_ms_sleep(uint32_t msleep) void bme680_ms_sleep(uint32_t msleep)
{ {
xtimer_msleep(msleep); ztimer_sleep(ZTIMER_MSEC, msleep);
} }
#ifdef MODULE_PERIPH_I2C #ifdef MODULE_PERIPH_I2C

View File

@ -10,7 +10,8 @@ config PACKAGE_U8G2
depends on TEST_KCONFIG depends on TEST_KCONFIG
depends on HAS_PERIPH_GPIO depends on HAS_PERIPH_GPIO
select MODULE_PERIPH_GPIO select MODULE_PERIPH_GPIO
select MODULE_XTIMER select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_U8G2_RIOT select MODULE_U8G2_RIOT
select MODULE_U8G2_CSRC select MODULE_U8G2_CSRC

View File

@ -1,4 +1,5 @@
USEMODULE += xtimer USEMODULE += ztimer
USEMODULE += ztimer_usec
FEATURES_REQUIRED += periph_gpio FEATURES_REQUIRED += periph_gpio

View File

@ -24,7 +24,7 @@
#include "u8x8_riotos.h" #include "u8x8_riotos.h"
#include "xtimer.h" #include "ztimer.h"
#ifdef MODULE_PERIPH_SPI #ifdef MODULE_PERIPH_SPI
#include "periph/spi.h" #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); _enable_pins(u8x8_riot_ptr);
break; break;
case U8X8_MSG_DELAY_MILLI: case U8X8_MSG_DELAY_MILLI:
xtimer_usleep(arg_int * 1000); ztimer_sleep(ZTIMER_USEC, arg_int * 1000);
break; break;
case U8X8_MSG_DELAY_10MICRO: case U8X8_MSG_DELAY_10MICRO:
xtimer_usleep(arg_int * 10); ztimer_sleep(ZTIMER_USEC, arg_int * 10);
break; break;
case U8X8_MSG_DELAY_100NANO: case U8X8_MSG_DELAY_100NANO:
/* not used in upstream so approximating to 1us should be fine */ /* not used in upstream so approximating to 1us should be fine */
xtimer_usleep(1); ztimer_sleep(ZTIMER_USEC, 1);
break; break;
case U8X8_MSG_GPIO_CS: case U8X8_MSG_GPIO_CS:
if (u8x8_riot_ptr != NULL && gpio_is_valid(u8x8_riot_ptr->pin_cs)) { if (u8x8_riot_ptr != NULL && gpio_is_valid(u8x8_riot_ptr->pin_cs)) {

View File

@ -10,7 +10,8 @@ config PACKAGE_UCGLIB
depends on TEST_KCONFIG depends on TEST_KCONFIG
depends on HAS_PERIPH_GPIO depends on HAS_PERIPH_GPIO
select MODULE_PERIPH_GPIO select MODULE_PERIPH_GPIO
select MODULE_XTIMER select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_UCGLIB_RIOT select MODULE_UCGLIB_RIOT
select MODULE_UCGLIB_CSRC select MODULE_UCGLIB_CSRC

View File

@ -1,4 +1,5 @@
USEMODULE += xtimer USEMODULE += ztimer
USEMODULE += ztimer_usec
FEATURES_REQUIRED += periph_gpio FEATURES_REQUIRED += periph_gpio

View File

@ -23,7 +23,7 @@
#include "ucg_riotos.h" #include "ucg_riotos.h"
#include "xtimer.h" #include "ztimer.h"
#ifdef MODULE_PERIPH_SPI #ifdef MODULE_PERIPH_SPI
#include "periph/spi.h" #include "periph/spi.h"
@ -101,7 +101,7 @@ int16_t ucg_com_hw_spi_riotos(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *da
spi_release(dev); spi_release(dev);
break; break;
case UCG_COM_MSG_DELAY: case UCG_COM_MSG_DELAY:
xtimer_usleep(arg); ztimer_sleep(ZTIMER_USEC, arg);
break; break;
case UCG_COM_MSG_CHANGE_RESET_LINE: case UCG_COM_MSG_CHANGE_RESET_LINE:
if (ucg_riot_ptr != NULL && gpio_is_valid(ucg_riot_ptr->pin_reset)) { if (ucg_riot_ptr != NULL && gpio_is_valid(ucg_riot_ptr->pin_reset)) {

View File

@ -3,7 +3,8 @@ include ../Makefile.tests_common
DRIVER ?= bme680_i2c DRIVER ?= bme680_i2c
USEMODULE += $(DRIVER) USEMODULE += $(DRIVER)
USEMODULE += xtimer USEMODULE += ztimer
USEMODULE += ztimer_msec
ifeq ($(ENABLE_FP),1) ifeq ($(ENABLE_FP),1)
USEMODULE += bme680_fp USEMODULE += bme680_fp

View File

@ -1,4 +1,5 @@
# this file enables modules defined in Kconfig. Do not use this file for # this file enables modules defined in Kconfig. Do not use this file for
# application configuration. This is only needed during migration. # application configuration. This is only needed during migration.
CONFIG_MODULE_BME680=y CONFIG_MODULE_BME680=y
CONFIG_MODULE_XTIMER=y CONFIG_MODULE_ZTIMER=y
CONFIG_MODULE_ZTIMER_MSEC=y

View File

@ -25,15 +25,16 @@
#include "bme680.h" #include "bme680.h"
#include "bme680_params.h" #include "bme680_params.h"
#include "mutex.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) 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); mutex_unlock(arg);
} }
@ -64,7 +65,7 @@ int main(void)
timer.callback = _timer_cb; timer.callback = _timer_cb;
timer.arg = &timer_mtx; timer.arg = &timer_mtx;
xtimer_set(&timer, BME680_TEST_PERIOD_US); ztimer_set(ZTIMER_MSEC, &timer, BME680_TEST_PERIOD_MS);
while (1) while (1)
{ {
@ -76,7 +77,7 @@ int main(void)
/* get the duration for the measurement */ /* get the duration for the measurement */
int duration = bme680_get_duration(&dev[i]); int duration = bme680_get_duration(&dev[i]);
/* wait for the duration */ /* wait for the duration */
xtimer_msleep(duration); ztimer_sleep(ZTIMER_MSEC, duration);
/* read the data */ /* read the data */
int res = bme680_get_data(&dev[i], &data); int res = bme680_get_data(&dev[i], &data);

View File

@ -1,6 +1,7 @@
include ../Makefile.tests_common include ../Makefile.tests_common
USEMODULE += xtimer USEMODULE += ztimer
USEMODULE += ztimer_usec
USEPKG += u8g2 USEPKG += u8g2

View File

@ -70,7 +70,8 @@
#include "periph/i2c.h" #include "periph/i2c.h"
#endif #endif
#include "xtimer.h" #include "timex.h"
#include "ztimer.h"
#include "u8g2.h" #include "u8g2.h"
#include "u8x8_riotos.h" #include "u8x8_riotos.h"
@ -200,7 +201,7 @@ int main(void)
screen = (screen + 1) % 3; screen = (screen + 1) % 3;
/* sleep a little */ /* sleep a little */
xtimer_sleep(1); ztimer_sleep(ZTIMER_USEC, US_PER_SEC);
} }
return 0; return 0;

View File

@ -54,7 +54,8 @@
#include "periph/spi.h" #include "periph/spi.h"
#endif #endif
#include "xtimer.h" #include "timex.h"
#include "ztimer.h"
#include "ucg.h" #include "ucg.h"
#include "ucg_riotos.h" #include "ucg_riotos.h"
@ -139,7 +140,7 @@ int main(void)
screen = (screen + 1) % 3; screen = (screen + 1) % 3;
/* sleep a little */ /* sleep a little */
xtimer_sleep(1); ztimer_sleep(ZTIMER_USEC, US_PER_SEC);
} }
return 0; return 0;