Add skeleton for HTU21DF driver
This commit is contained in:
64
include/mgos_htu21df.h
Normal file
64
include/mgos_htu21df.h
Normal file
@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include "mgos.h"
|
||||
#include "mgos_i2c.h"
|
||||
|
||||
#define MGOS_HTU21DF_READ_DELAY (2)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct mgos_htu21df;
|
||||
|
||||
/*
|
||||
* Initialize a HTU21DF on the I2C bus `i2c` at address specified in `i2caddr`
|
||||
* parameter (default HTU21DF is on address 0x40). The sensor will be polled for
|
||||
* validity, upon success a new `struct mgos_htu21df` is allocated and
|
||||
* returned. If the device could not be found, NULL is returned.
|
||||
*/
|
||||
struct mgos_htu21df *mgos_htu21df_create(struct mgos_i2c *i2c, uint8_t i2caddr);
|
||||
|
||||
/*
|
||||
* Destroy the data structure associated with a HTU21DF device. The reference
|
||||
* to the pointer of the `struct mgos_htu21df` has to be provided, and upon
|
||||
* successful destruction, its associated memory will be freed and the pointer
|
||||
* set to NULL.
|
||||
*/
|
||||
void mgos_htu21df_destroy(struct mgos_htu21df **sensor);
|
||||
|
||||
/*
|
||||
* The sensor will be polled for its temperature and humidity data. If the poll
|
||||
* has occured in the last `MGOS_HTU21DF_READ_DELAY` seconds, the cached data is
|
||||
* used (so as not to repeatedly poll the bus upon subsequent calls).
|
||||
*/
|
||||
bool mgos_htu21df_read(struct mgos_htu21df *sensor);
|
||||
|
||||
/*
|
||||
* The sensor will be polled for its temperature and humidity data. If the poll
|
||||
* has occured in the last `MGOS_HTU21DF_READ_DELAY` seconds, the cached data is
|
||||
* used (so as not to repeatedly poll the bus upon subsequent calls).
|
||||
*
|
||||
* The return value is the temperature of the sensor in Celsius, or NAN if no
|
||||
* data was found.
|
||||
*/
|
||||
float mgos_htu21df_getTemperature(struct mgos_htu21df *sensor);
|
||||
|
||||
/*
|
||||
* The sensor will be polled for its temperature and humidity data. If the poll
|
||||
* has occured in the last `MGOS_HTU21DF_READ_DELAY` seconds, the cached data is
|
||||
* used (so as not to repeatedly poll the bus upon subsequent calls).
|
||||
*
|
||||
* The return value is the humidity of the sensor in percent relative humidity,
|
||||
* or NAN if no data was found.
|
||||
*/
|
||||
float mgos_htu21df_getHumidity(struct mgos_htu21df *sensor);
|
||||
|
||||
/*
|
||||
* Initialization function for MGOS -- currently a noop.
|
||||
*/
|
||||
bool mgos_htu21df_i2c_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user