mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/si114x: migrate to ztimer
This commit is contained in:
parent
0076eb83fc
commit
aa65feab25
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user