Merge pull request #17315 from aabadie/pr/drivers/ztimer
drivers: migrate some drivers to ztimer
This commit is contained in:
commit
5c99f951cd
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
@ -10,4 +10,5 @@ config MODULE_LSM6DSL
|
||||
depends on HAS_PERIPH_I2C
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_PERIPH_I2C
|
||||
select MODULE_XTIMER
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
FEATURES_REQUIRED += periph_i2c
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
@ -22,8 +22,6 @@
|
||||
#ifndef LSM6DSL_INTERNAL_H
|
||||
#define LSM6DSL_INTERNAL_H
|
||||
|
||||
#include "xtimer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -159,9 +157,9 @@ extern "C" {
|
||||
#define LSM6DSL_TEMP_OFFSET (0x1900)
|
||||
|
||||
/**
|
||||
* @brief Reboot wait interval in us (15ms)
|
||||
* @brief Reboot wait interval in ms (15ms)
|
||||
*/
|
||||
#define LSM6DSL_BOOT_WAIT (15 * US_PER_MS)
|
||||
#define LSM6DSL_BOOT_WAIT_MS (15)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#include "lsm6dsl.h"
|
||||
#include "lsm6dsl_internal.h"
|
||||
@ -62,7 +62,7 @@ int lsm6dsl_init(lsm6dsl_t *dev, const lsm6dsl_params_t *params)
|
||||
/* Reboot */
|
||||
i2c_write_reg(BUS, ADDR, LSM6DSL_REG_CTRL3_C, LSM6DSL_CTRL3_C_BOOT, 0);
|
||||
|
||||
xtimer_usleep(LSM6DSL_BOOT_WAIT);
|
||||
ztimer_sleep(ZTIMER_MSEC, LSM6DSL_BOOT_WAIT_MS);
|
||||
|
||||
if (i2c_read_reg(BUS, ADDR, LSM6DSL_REG_WHO_AM_I, &tmp, 0) < 0) {
|
||||
i2c_release(BUS);
|
||||
|
||||
@ -31,6 +31,7 @@ config MODULE_SI114X
|
||||
bool
|
||||
depends on HAS_PERIPH_I2C
|
||||
select MODULE_PERIPH_I2C
|
||||
select MODULE_XTIMER
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
endif # TEST_KCONFIG
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
FEATURES_REQUIRED += periph_i2c
|
||||
|
||||
@ -161,8 +161,8 @@ extern "C" {
|
||||
#define SI1145_ID (0x45)
|
||||
#define SI1146_ID (0x46)
|
||||
#define SI1147_ID (0x47)
|
||||
#define SI114X_STARTUP_TIME (25000UL) /* 25ms */
|
||||
#define SI114X_WAIT_10MS (10000UL) /* 10ms */
|
||||
#define SI114X_STARTUP_TIME_MS (25UL) /**< startup time (25ms) */
|
||||
#define SI114X_WAIT_10MS (10UL) /* 10ms */
|
||||
#define SI114X_INIT_VALUE (0x17)
|
||||
#define SI114X_UCOEF0_DEFAULT (0x29)
|
||||
#define SI114X_UCOEF1_DEFAULT (0x89)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#include "periph/i2c.h"
|
||||
|
||||
@ -50,7 +50,7 @@ int8_t si114x_init(si114x_t *dev, const si114x_params_t *params)
|
||||
dev->params = *params;
|
||||
|
||||
/* wait before sensor is ready */
|
||||
xtimer_usleep(SI114X_STARTUP_TIME);
|
||||
ztimer_sleep(ZTIMER_MSEC, SI114X_STARTUP_TIME_MS);
|
||||
|
||||
/* acquire exclusive access */
|
||||
i2c_acquire(DEV_I2C);
|
||||
@ -178,12 +178,12 @@ void _reset(si114x_t *dev)
|
||||
/* perform RESET command */
|
||||
i2c_write_reg(DEV_I2C, SI114X_ADDR,
|
||||
SI114X_REG_COMMAND, SI114X_RESET, 0);
|
||||
xtimer_usleep(SI114X_WAIT_10MS);
|
||||
ztimer_sleep(ZTIMER_MSEC, SI114X_WAIT_10MS);
|
||||
|
||||
/* write HW_KEY for proper operation */
|
||||
i2c_write_reg(DEV_I2C, SI114X_ADDR,
|
||||
SI114X_REG_HW_KEY, SI114X_INIT_VALUE, 0);
|
||||
xtimer_usleep(SI114X_WAIT_10MS);
|
||||
ztimer_sleep(ZTIMER_MSEC, SI114X_WAIT_10MS);
|
||||
}
|
||||
|
||||
void _initialize(si114x_t *dev)
|
||||
|
||||
@ -9,9 +9,12 @@ config MODULE_STMPE811
|
||||
bool
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_I2C
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_XTIMER
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
depends on TEST_KCONFIG
|
||||
|
||||
choice
|
||||
|
||||
@ -8,4 +8,5 @@ ifneq (,$(filter stmpe811_i2c,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_i2c
|
||||
endif
|
||||
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
#if IS_USED(MODULE_STMPE811_SPI)
|
||||
#include "periph/spi.h"
|
||||
#else
|
||||
@ -135,13 +135,13 @@ static int _soft_reset(const stmpe811_t *dev)
|
||||
DEBUG("[stmpe811] soft reset: cannot write soft reset bit to SYS_CTRL1 register\n");
|
||||
return -EPROTO;
|
||||
}
|
||||
xtimer_msleep(10);
|
||||
ztimer_sleep(ZTIMER_MSEC, 10);
|
||||
|
||||
if (_write_reg(dev, STMPE811_SYS_CTRL1, 0) < 0) {
|
||||
DEBUG("[stmpe811] soft reset: cannot clear SYS_CTRL1 register\n");
|
||||
return -EPROTO;
|
||||
}
|
||||
xtimer_msleep(2);
|
||||
ztimer_sleep(ZTIMER_MSEC, 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -10,4 +10,5 @@ config MODULE_TSL2561
|
||||
depends on HAS_PERIPH_I2C
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_PERIPH_I2C
|
||||
select MODULE_XTIMER
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
FEATURES_REQUIRED += periph_i2c
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#include "tsl2561.h"
|
||||
#include "tsl2561_internals.h"
|
||||
#include "periph/i2c.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
@ -220,16 +220,16 @@ static void _read_data(const tsl2561_t *dev, uint16_t *full, uint16_t *ir)
|
||||
|
||||
/* Wait integration time in ms for ADC to complete */
|
||||
switch (DEV_INTEGRATION) {
|
||||
case TSL2561_INTEGRATIONTIME_13MS:
|
||||
xtimer_usleep(13700);
|
||||
case TSL2561_INTEGRATIONTIME_13MS: /* 13700us */
|
||||
ztimer_sleep(ZTIMER_MSEC, 14);
|
||||
break;
|
||||
|
||||
case TSL2561_INTEGRATIONTIME_101MS:
|
||||
xtimer_usleep(101000);
|
||||
ztimer_sleep(ZTIMER_MSEC, 101);
|
||||
break;
|
||||
|
||||
default: /* TSL2561_INTEGRATIONTIME_402MS */
|
||||
xtimer_usleep(402000);
|
||||
ztimer_sleep(ZTIMER_MSEC, 402);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -2,4 +2,7 @@ include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += ccs811
|
||||
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_usec
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
@ -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
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#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 */
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#include "ccs811.h"
|
||||
#include "ccs811_params.h"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += lsm6dsl
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
@ -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_LSM6DSL=y
|
||||
CONFIG_MODULE_XTIMER=y
|
||||
CONFIG_MODULE_ZTIMER=y
|
||||
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||
|
||||
@ -22,11 +22,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
#include "lsm6dsl.h"
|
||||
#include "lsm6dsl_params.h"
|
||||
|
||||
#define SLEEP_USEC (500UL * US_PER_MS)
|
||||
#define SLEEP_MSEC (500UL)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@ -55,7 +55,7 @@ int main(void)
|
||||
}
|
||||
puts("[SUCCESS]\n");
|
||||
|
||||
xtimer_sleep(1);
|
||||
ztimer_sleep(ZTIMER_MSEC, 1 * 1000);
|
||||
|
||||
puts("Powering up LSM6DSL sensor...");
|
||||
if (lsm6dsl_acc_power_up(&dev) != LSM6DSL_OK) {
|
||||
@ -95,7 +95,7 @@ int main(void)
|
||||
}
|
||||
|
||||
puts("");
|
||||
xtimer_usleep(SLEEP_USEC);
|
||||
ztimer_sleep(ZTIMER_MSEC, SLEEP_MSEC);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
# This test should also work with Si1146 and Si1147 variants.
|
||||
USEMODULE += si1145
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
# this file enables modules defined in Kconfig. Do not use this file for
|
||||
# application configuration. This is only needed during migration.
|
||||
|
||||
CONFIG_MODULE_ZTIMER=y
|
||||
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||
|
||||
# This test should also work with Si1146 and Si1147 variants.
|
||||
CONFIG_MODULE_SI1145=y
|
||||
|
||||
@ -25,7 +25,8 @@
|
||||
|
||||
#include "si114x.h"
|
||||
#include "si114x_params.h"
|
||||
#include "xtimer.h"
|
||||
#include "timex.h"
|
||||
#include "ztimer.h"
|
||||
#include "board.h"
|
||||
|
||||
static si114x_t dev;
|
||||
@ -63,7 +64,7 @@ int main(void)
|
||||
si114x_read_response(&dev));
|
||||
|
||||
/* 2 seconds delay between measures */
|
||||
xtimer_sleep(2);
|
||||
ztimer_sleep(ZTIMER_MSEC, 2 * MS_PER_SEC);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
3
tests/driver_stmpe811/Makefile.ci
Normal file
3
tests/driver_stmpe811/Makefile.ci
Normal file
@ -0,0 +1,3 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-l011k4 \
|
||||
#
|
||||
@ -1,6 +1,7 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += tsl2561
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
@ -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_TSL2561=y
|
||||
CONFIG_MODULE_XTIMER=y
|
||||
CONFIG_MODULE_ZTIMER=y
|
||||
CONFIG_MODULE_ZTIMER_MSEC=y
|
||||
|
||||
@ -21,14 +21,13 @@
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "timex.h"
|
||||
#include "ztimer.h"
|
||||
#include "board.h"
|
||||
|
||||
#include "tsl2561.h"
|
||||
#include "tsl2561_params.h"
|
||||
|
||||
#define SLEEP_1S (1 * 1000 * 1000u) /* 1 second delay between printf */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("TSL2561 test application\n");
|
||||
@ -58,7 +57,7 @@ int main(void)
|
||||
"\n+-------------------------------------+\n",
|
||||
(int)tsl2561_read_illuminance(&dev));
|
||||
|
||||
xtimer_usleep(SLEEP_1S);
|
||||
ztimer_sleep(ZTIMER_MSEC, MS_PER_SEC); /* 1s delay */
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user