si70xx.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Bas Stottelaar <basstottelaar@gmail.com>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
35 #include "periph/i2c.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
44 #if MODULE_SI7050 || MODULE_SI7051 || MODULE_SI7053 || MODULE_SI7054 || \
45  MODULE_SI7055
46 /* Si705x sensors don't have a humidity sensor hardware, only temperature. */
47 #define SI70XX_HAS_HUMIDITY_SENSOR 0
48 #else
49 #define SI70XX_HAS_HUMIDITY_SENSOR 1
50 #endif
51 
55 enum {
59 };
60 
64 typedef struct {
66  uint8_t address;
68 
72 typedef struct {
74 } si70xx_t;
75 
87 int si70xx_init(si70xx_t *dev, const si70xx_params_t *params);
88 
89 #if SI70XX_HAS_HUMIDITY_SENSOR || DOXYGEN
99 #endif /* SI70XX_HAS_HUMIDITY_SENSOR || DOXYGEN */
100 
108 int16_t si70xx_get_temperature(const si70xx_t *dev);
109 
110 #if SI70XX_HAS_HUMIDITY_SENSOR || DOXYGEN
121 void si70xx_get_both(const si70xx_t *dev, uint16_t *humidity, int16_t *temperature);
122 #endif /* SI70XX_HAS_HUMIDITY_SENSOR || DOXYGEN */
123 
130 uint64_t si70xx_get_serial(const si70xx_t *dev);
131 
138 uint8_t si70xx_get_id(const si70xx_t *dev);
139 
146 uint8_t si70xx_get_revision(const si70xx_t *dev);
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:144
uint8_t si70xx_get_revision(const si70xx_t *dev)
Read the firmware revision of the sensor.
void si70xx_get_both(const si70xx_t *dev, uint16_t *humidity, int16_t *temperature)
Read the relative humidity and temperature from the sensor.
int16_t si70xx_get_temperature(const si70xx_t *dev)
Read the current temperature from the sensor.
int si70xx_init(si70xx_t *dev, const si70xx_params_t *params)
Initialize and reset the sensor.
uint8_t si70xx_get_id(const si70xx_t *dev)
Read the sensor id, to identifier the sensor variant.
uint16_t si70xx_get_relative_humidity(const si70xx_t *dev)
Read the relative humidity from the sensor.
uint64_t si70xx_get_serial(const si70xx_t *dev)
Read the sensor serial number.
@ SI70XX_ERR_NODEV
No valid device found on I2C bus.
Definition: si70xx.h:57
@ SI70XX_ERR_I2C
An error occurred when reading/writing on I2C bus.
Definition: si70xx.h:58
@ SI70XX_OK
All OK.
Definition: si70xx.h:56
Low-level I2C peripheral driver interface definition.
Device initialization parameters.
Definition: si70xx.h:64
i2c_t i2c_dev
I2C bus the sensor is connected to.
Definition: si70xx.h:65
uint8_t address
sensor address
Definition: si70xx.h:66
Si70xx device descriptor.
Definition: si70xx.h:72
si70xx_params_t params
Device parameters.
Definition: si70xx.h:73