Skip to content
Snippets Groups Projects
Unverified Commit 6bc069e3 authored by MichelRottleuthner's avatar MichelRottleuthner Committed by GitHub
Browse files

Merge pull request #9386 from Hyungsin/forupstream_hdc1000

drivers/hdc1000: change renew_interval to a parameter
parents 91069e3c 88895bbe
No related branches found
No related tags found
No related merge requests found
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
#define ENABLE_DEBUG (0) #define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
#ifndef HDC1000_RENEW_INTERVAL
#define HDC1000_RENEW_INTERVAL (1000000ul)
#endif
static int16_t temp_cached, hum_cached; static int16_t temp_cached, hum_cached;
static uint32_t last_read_time; static uint32_t last_read_time;
...@@ -144,7 +140,7 @@ int hdc1000_read_cached(const hdc1000_t *dev, int16_t *temp, int16_t *hum) ...@@ -144,7 +140,7 @@ int hdc1000_read_cached(const hdc1000_t *dev, int16_t *temp, int16_t *hum)
uint32_t now = xtimer_now_usec(); uint32_t now = xtimer_now_usec();
/* check if readings are outdated */ /* check if readings are outdated */
if (now - last_read_time > HDC1000_RENEW_INTERVAL) { if (now - last_read_time > dev->p.renew_interval) {
/* update last_read_time */ /* update last_read_time */
if (hdc1000_read(dev, &temp_cached, &hum_cached) != HDC1000_OK) { if (hdc1000_read(dev, &temp_cached, &hum_cached) != HDC1000_OK) {
return HDC1000_BUSERR; return HDC1000_BUSERR;
......
...@@ -32,22 +32,26 @@ extern "C" { ...@@ -32,22 +32,26 @@ extern "C" {
* @{ * @{
*/ */
#ifndef HDC1000_PARAM_I2C #ifndef HDC1000_PARAM_I2C
#define HDC1000_PARAM_I2C I2C_DEV(0) #define HDC1000_PARAM_I2C I2C_DEV(0)
#endif #endif
#ifndef HDC1000_PARAM_ADDR #ifndef HDC1000_PARAM_ADDR
#define HDC1000_PARAM_ADDR (HDC1000_I2C_ADDRESS) #define HDC1000_PARAM_ADDR (HDC1000_I2C_ADDRESS)
#endif #endif
#ifndef HDC1000_PARAM_RES #ifndef HDC1000_PARAM_RES
#define HDC1000_PARAM_RES HDC1000_14BIT #define HDC1000_PARAM_RES HDC1000_14BIT
#endif
#ifndef HDC1000_PARAM_RENEW_INTERVAL
#define HDC1000_PARAM_RENEW_INTERVAL (1000000ul)
#endif #endif
#ifndef HDC1000_PARAMS #ifndef HDC1000_PARAMS
#define HDC1000_PARAMS { .i2c = HDC1000_PARAM_I2C, \ #define HDC1000_PARAMS { .i2c = HDC1000_PARAM_I2C, \
.addr = HDC1000_PARAM_ADDR, \ .addr = HDC1000_PARAM_ADDR, \
.res = HDC1000_PARAM_RES } .res = HDC1000_PARAM_RES, \
.renew_interval = HDC1000_PARAM_RENEW_INTERVAL }
#endif #endif
#ifndef HDC1000_SAUL_INFO #ifndef HDC1000_SAUL_INFO
#define HDC1000_SAUL_INFO { .name = "hdc1000" } #define HDC1000_SAUL_INFO { .name = "hdc1000" }
#endif #endif
/**@}*/ /**@}*/
......
...@@ -88,9 +88,10 @@ typedef enum { ...@@ -88,9 +88,10 @@ typedef enum {
* @brief Parameters needed for device initialization * @brief Parameters needed for device initialization
*/ */
typedef struct { typedef struct {
i2c_t i2c; /**< bus the device is connected to */ i2c_t i2c; /**< bus the device is connected to */
uint8_t addr; /**< address on that bus */ uint8_t addr; /**< address on that bus */
hdc1000_res_t res; /**< resolution used for sampling temp and hum */ hdc1000_res_t res; /**< resolution used for sampling temp and hum */
uint32_t renew_interval; /**< interval for cache renewal */
} hdc1000_params_t; } hdc1000_params_t;
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment