1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

drivers/ads101x: migrate to ztimer

This commit is contained in:
Alexandre Abadie 2021-11-02 11:21:23 +01:00
parent 1ef44844e0
commit 3fa2154d48
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
3 changed files with 8 additions and 6 deletions

View File

@ -14,7 +14,8 @@ config MODULE_ADS101X
select MODULE_PERIPH_GPIO select MODULE_PERIPH_GPIO
select MODULE_PERIPH_GPIO_IRQ select MODULE_PERIPH_GPIO_IRQ
select MODULE_PERIPH_I2C select MODULE_PERIPH_I2C
select MODULE_XTIMER select MODULE_ZTIMER
select MODULE_ZTIMER_MSEC
help help
This driver works with the ads1013, ads1014, ads1015, ads1113, ads1114 This driver works with the ads1013, ads1014, ads1015, ads1113, ads1114
and ads1115 models. and ads1115 models.

View File

@ -1,3 +1,4 @@
FEATURES_REQUIRED += periph_gpio_irq FEATURES_REQUIRED += periph_gpio_irq
FEATURES_REQUIRED += periph_i2c FEATURES_REQUIRED += periph_i2c
USEMODULE += xtimer USEMODULE += ztimer
USEMODULE += ztimer_msec

View File

@ -22,7 +22,7 @@
#include "assert.h" #include "assert.h"
#include "periph/i2c.h" #include "periph/i2c.h"
#include "periph/gpio.h" #include "periph/gpio.h"
#include "xtimer.h" #include "ztimer.h"
#include "ads101x.h" #include "ads101x.h"
#include "ads101x_params.h" #include "ads101x_params.h"
@ -31,8 +31,8 @@
#define ENABLE_DEBUG 0 #define ENABLE_DEBUG 0
#include "debug.h" #include "debug.h"
#ifndef ADS101X_READ_DELAY #ifndef ADS101X_READ_DELAY_MS
#define ADS101X_READ_DELAY (8 * US_PER_MS) /* Compatible with 128SPS */ #define ADS101X_READ_DELAY_MS 8 /* ompatible with 128SPS */
#endif #endif
#define DEV (dev->params.i2c) #define DEV (dev->params.i2c)
@ -138,7 +138,7 @@ int ads101x_read_raw(const ads101x_t *dev, int16_t *raw)
i2c_write_regs(DEV, ADDR, ADS101X_CONF_ADDR, &regs, 2, 0x0); i2c_write_regs(DEV, ADDR, ADS101X_CONF_ADDR, &regs, 2, 0x0);
/* Wait for the sample to be acquired */ /* Wait for the sample to be acquired */
xtimer_usleep(ADS101X_READ_DELAY); ztimer_sleep(ZTIMER_MSEC, ADS101X_READ_DELAY_MS);
/* Read the sample */ /* Read the sample */
if (i2c_read_regs(DEV, ADDR, ADS101X_CONV_RES_ADDR, &regs, 2, 0x0) < 0) { if (i2c_read_regs(DEV, ADDR, ADS101X_CONV_RES_ADDR, &regs, 2, 0x0) < 0) {