shtcx.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017, RWTH Aachen. All rights reserved.
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 
26 #include <stdint.h>
27 #include "saul.h"
28 
29 #include "periph/i2c.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
39 #ifndef SHTCX_I2C_ADDRESS
40 #define SHTCX_I2C_ADDRESS (0x70)
41 #endif
42 
47 typedef struct {
49  uint8_t i2c_addr;
57 typedef struct {
59 } shtcx_t;
62 enum {
67 };
68 
79 int8_t shtcx_init(shtcx_t* const dev, const shtcx_params_t* params);
80 
93 int8_t shtcx_read(const shtcx_t *dev, uint16_t *rel_humidity, int16_t *temperature);
94 
107 int8_t shtcx_id(const shtcx_t *dev, uint16_t *id);
108 
119 int8_t shtcx_reset(const shtcx_t *dev);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:144
int8_t shtcx_init(shtcx_t *const dev, const shtcx_params_t *params)
Initializes the sensor and I2C.
int8_t shtcx_reset(const shtcx_t *dev)
Resets sensor.
int8_t shtcx_id(const shtcx_t *dev, uint16_t *id)
Reads the ID and saves it in the device descriptor.
int8_t shtcx_read(const shtcx_t *dev, uint16_t *rel_humidity, int16_t *temperature)
Reads all register values from the device.
@ SHTCX_ERROR_BUS
I2C bus error.
Definition: shtcx.h:64
@ SHTCX_ERROR_CRC
CRC error.
Definition: shtcx.h:65
@ SHTCX_OK
Success, no error.
Definition: shtcx.h:63
@ SHTCX_ERROR
General error.
Definition: shtcx.h:66
Low-level I2C peripheral driver interface definition.
settings struct with all relevant parameters
Definition: shtcx.h:47
i2c_t i2c_dev
I2C bus descriptor.
Definition: shtcx.h:48
uint8_t i2c_addr
I2C address of the sensor.
Definition: shtcx.h:49
device descriptor for the SHTCX
Definition: shtcx.h:57
shtcx_params_t params
Parameters struct with all settings set.
Definition: shtcx.h:58
Functionality for reading [S]ensor [A]ctuator [U]ber [L]ayer sensors as SenML.