mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
driver/at30tse75x: avoid direct use of xtimer_ticks
This commit is contained in:
parent
2f1258f60b
commit
4d552e7e4a
@ -22,7 +22,10 @@
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#define AT30TSE75X_BUS_FREE_TIME_TICKS (xtimer_ticks_from_usec(AT30TSE75X_BUS_FREE_TIME_US))
|
||||
#ifndef xtimer_spin_usec
|
||||
#define xtimer_spin_usec(X) xtimer_spin(xtimer_ticks_from_usec(X))
|
||||
#endif
|
||||
|
||||
static inline float temperature_to_float(uint16_t temp)
|
||||
{
|
||||
/* Integer part is 8-bit signed */
|
||||
@ -38,7 +41,7 @@ static inline float temperature_to_float(uint16_t temp)
|
||||
static int at30tse75x_get_register(const at30tse75x_t *dev, uint8_t reg, uint16_t* data)
|
||||
{
|
||||
i2c_acquire(dev->i2c);
|
||||
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
|
||||
xtimer_spin_usec(AT30TSE75X_BUS_FREE_TIME_US);
|
||||
if (i2c_read_regs(dev->i2c, dev->addr, reg, data, 2, 0) < 0) {
|
||||
DEBUG("[at30tse75x] Can't read register 0x%x\n", reg);
|
||||
i2c_release(dev->i2c);
|
||||
@ -52,7 +55,7 @@ static int at30tse75x_get_register(const at30tse75x_t *dev, uint8_t reg, uint16_
|
||||
static int at30tse75x_set_register(const at30tse75x_t *dev, uint8_t reg, uint16_t *data)
|
||||
{
|
||||
i2c_acquire(dev->i2c);
|
||||
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
|
||||
xtimer_spin_usec(AT30TSE75X_BUS_FREE_TIME_US);
|
||||
if (i2c_write_regs(dev->i2c, dev->addr, reg, data, 2, 0) < 0) {
|
||||
DEBUG("[at30tse75x] Can't write to register 0x%x\n", reg);
|
||||
i2c_release(dev->i2c);
|
||||
@ -66,7 +69,7 @@ static int at30tse75x_set_register(const at30tse75x_t *dev, uint8_t reg, uint16_
|
||||
static int at30tse75x_reset(const at30tse75x_t *dev)
|
||||
{
|
||||
i2c_acquire(dev->i2c);
|
||||
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
|
||||
xtimer_spin_usec(AT30TSE75X_BUS_FREE_TIME_US);
|
||||
if (i2c_write_byte(dev->i2c, 0x00, AT30TSE75X_CMD__GENERAL_CALL_RESET, 0) < 0) {
|
||||
i2c_release(dev->i2c);
|
||||
return -1;
|
||||
@ -80,7 +83,7 @@ static int at30tse75x_reset(const at30tse75x_t *dev)
|
||||
int at30tse75x_get_config(const at30tse75x_t *dev, uint8_t *data)
|
||||
{
|
||||
i2c_acquire(dev->i2c);
|
||||
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
|
||||
xtimer_spin_usec(AT30TSE75X_BUS_FREE_TIME_US);
|
||||
if (i2c_read_reg(dev->i2c, dev->addr, AT30TSE75X_REG__CONFIG, data, 0) < 0) {
|
||||
DEBUG("[at30tse75x] Can't read CONFIG register\n");
|
||||
i2c_release(dev->i2c);
|
||||
@ -94,7 +97,7 @@ int at30tse75x_get_config(const at30tse75x_t *dev, uint8_t *data)
|
||||
int at30tse75x_set_config(const at30tse75x_t *dev, uint8_t data)
|
||||
{
|
||||
i2c_acquire(dev->i2c);
|
||||
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
|
||||
xtimer_spin_usec(AT30TSE75X_BUS_FREE_TIME_US);
|
||||
if (i2c_write_reg(dev->i2c, dev->addr, AT30TSE75X_REG__CONFIG, data, 0) < 0) {
|
||||
DEBUG("[at30tse75x] Can't write to CONFIG register\n");
|
||||
i2c_release(dev->i2c);
|
||||
@ -211,7 +214,7 @@ int at30tse75x_set_limit_high(const at30tse75x_t *dev, int8_t t_high)
|
||||
int at30tse75x_save_config(const at30tse75x_t *dev)
|
||||
{
|
||||
i2c_acquire(dev->i2c);
|
||||
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
|
||||
xtimer_spin_usec(AT30TSE75X_BUS_FREE_TIME_US);
|
||||
if(i2c_write_byte(dev->i2c, dev->addr, AT30TSE75X_CMD__SAVE_TO_NVRAM, 0) < 0) {
|
||||
i2c_release(dev->i2c);
|
||||
return -1;
|
||||
@ -225,7 +228,7 @@ int at30tse75x_save_config(const at30tse75x_t *dev)
|
||||
int at30tse75x_restore_config(const at30tse75x_t *dev)
|
||||
{
|
||||
i2c_acquire(dev->i2c);
|
||||
xtimer_spin(AT30TSE75X_BUS_FREE_TIME_TICKS);
|
||||
xtimer_spin_usec(AT30TSE75X_BUS_FREE_TIME_US);
|
||||
if(i2c_write_byte(dev->i2c, dev->addr, AT30TSE75X_CMD__RESTORE_FROM_NVRAM, 0) < 0) {
|
||||
i2c_release(dev->i2c);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user