drivers/ccs811: migrate to ztimer
This commit is contained in:
parent
1acdec389e
commit
2a1be13f17
@ -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
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user