mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/bmp180: migrate to ztimer
This commit is contained in:
parent
1ef44844e0
commit
9029e1caf9
@ -10,4 +10,5 @@ config MODULE_BMP180
|
||||
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 "bmp180_internals.h"
|
||||
#include "bmp180_params.h"
|
||||
#include "periph/i2c.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
@ -65,7 +65,7 @@ int bmp180_init(bmp180_t *dev, const bmp180_params_t *params)
|
||||
}
|
||||
|
||||
/* adding delay before reading calibration values to avoid timing issues */
|
||||
xtimer_usleep(BMP180_ULTRALOWPOWER_DELAY);
|
||||
ztimer_sleep(ZTIMER_MSEC, BMP180_ULTRALOWPOWER_DELAY_MS);
|
||||
|
||||
uint8_t buffer[22] = {0};
|
||||
/* Read calibration values, using contiguous register addresses */
|
||||
@ -187,7 +187,7 @@ static int _read_ut(const bmp180_t *dev, int32_t *output)
|
||||
uint8_t ut[2] = {0};
|
||||
uint8_t control[2] = { BMP180_REGISTER_CONTROL, BMP180_TEMPERATURE_COMMAND };
|
||||
i2c_write_bytes(DEV_I2C, DEV_ADDR, control, 2, 0);
|
||||
xtimer_usleep(BMP180_ULTRALOWPOWER_DELAY);
|
||||
ztimer_sleep(ZTIMER_MSEC, BMP180_ULTRALOWPOWER_DELAY_MS);
|
||||
if (i2c_read_regs(DEV_I2C, DEV_ADDR, BMP180_REGISTER_DATA, ut, 2, 0) < 0) {
|
||||
DEBUG("[Error] Cannot read uncompensated temperature.\n");
|
||||
i2c_release(DEV_I2C);
|
||||
@ -209,19 +209,19 @@ static int _read_up(const bmp180_t *dev, int32_t *output)
|
||||
i2c_write_bytes(DEV_I2C, DEV_ADDR, control, 2, 0);
|
||||
switch (OVERSAMPLING) {
|
||||
case BMP180_ULTRALOWPOWER:
|
||||
xtimer_usleep(BMP180_ULTRALOWPOWER_DELAY);
|
||||
ztimer_sleep(ZTIMER_MSEC, BMP180_ULTRALOWPOWER_DELAY_MS);
|
||||
break;
|
||||
case BMP180_STANDARD:
|
||||
xtimer_usleep(BMP180_STANDARD_DELAY);
|
||||
ztimer_sleep(ZTIMER_MSEC, BMP180_STANDARD_DELAY_MS);
|
||||
break;
|
||||
case BMP180_HIGHRES:
|
||||
xtimer_usleep(BMP180_HIGHRES_DELAY);
|
||||
ztimer_sleep(ZTIMER_MSEC, BMP180_HIGHRES_DELAY_MS);
|
||||
break;
|
||||
case BMP180_ULTRAHIGHRES:
|
||||
xtimer_usleep(BMP180_ULTRAHIGHRES_DELAY);
|
||||
ztimer_sleep(ZTIMER_MSEC, BMP180_ULTRAHIGHRES_DELAY_MS);
|
||||
break;
|
||||
default:
|
||||
xtimer_usleep(BMP180_ULTRALOWPOWER_DELAY);
|
||||
ztimer_sleep(ZTIMER_MSEC, BMP180_ULTRALOWPOWER_DELAY_MS);
|
||||
break;
|
||||
}
|
||||
if (i2c_read_regs(DEV_I2C, DEV_ADDR, BMP180_REGISTER_DATA, up, 3, 0) < 0) {
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include "saul.h"
|
||||
#include "bmp180.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
static int read_temperature(const void *dev, phydat_t *res)
|
||||
{
|
||||
|
@ -47,10 +47,10 @@ extern "C" {
|
||||
* @name Oversampling modes delays (micros)
|
||||
* @{
|
||||
*/
|
||||
#define BMP180_ULTRALOWPOWER_DELAY (5000UL)
|
||||
#define BMP180_STANDARD_DELAY (8000UL)
|
||||
#define BMP180_HIGHRES_DELAY (14000UL)
|
||||
#define BMP180_ULTRAHIGHRES_DELAY (26000UL)
|
||||
#define BMP180_ULTRALOWPOWER_DELAY_MS (5UL) /**< Ultra low power delay (ms) */
|
||||
#define BMP180_STANDARD_DELAY_MS (8UL) /**< Standard resolution delay (ms) */
|
||||
#define BMP180_HIGHRES_DELAY_MS (14UL) /**< High resolution delay (ms) */
|
||||
#define BMP180_ULTRAHIGHRES_DELAY_MS (26UL) /**< Ultra high resolution delay (ms) */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user