temphum10 2.0.0.0
temphum10.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef TEMPHUM10_H
36#define TEMPHUM10_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_i2c_master.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define TEMPHUM10_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
68 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
69
76#define TEMPHUM10_RETVAL uint8_t
77
78#define TEMPHUM10_OK 0x00
79#define TEMPHUM10_INIT_ERROR 0xFF
86#define TEMPHUM10_REG_DEVICE_RESET 0x00
87#define TEMPHUM10_REG_AVERAGE_MODE 0x01
88#define TEMPHUM10_REG_ERROR_FLAG 0x03
89#define TEMPHUM10_REG_HUMIDITY_LSB 0x04
90#define TEMPHUM10_REG_HUMIDITY_MSB 0x05
91#define TEMPHUM10_REG_TEMPERATURE_LSB 0x06
92#define TEMPHUM10_REG_TEMPERATURE_MSB 0x07
93#define TEMPHUM10_REG_CAPACITY_LSB 0x0A
94#define TEMPHUM10_REG_CAPACITY_MSB 0x0B
95#define TEMPHUM10_REG_CAPACITY_CTRL 0x2C
102#define TEMPHUM10_MODE_SLEEP 0x00
103#define TEMPHUM10_MODE_STANDBY 0x01
110#define TEMPHUM10_RST_NORMAL_OPERATION 0x00
111#define TEMPHUM10_RST_ACTIVE_RESET 0x01
118#define TEMPHUM10_AM_NO_AVERAGING_PROCESS 0x00
119#define TEMPHUM10_AM_TIMES_AVERAGE_MODE_2 0x08
120#define TEMPHUM10_AM_TIMES_AVERAGE_MODE_4 0x10
121#define TEMPHUM10_AM_TIMES_AVERAGE_MODE_8 0x20
122#define TEMPHUM10_AM_TEMP_AVERAGE_MODE_TIMES_8 0x00
123#define TEMPHUM10_AM_TEMP_AVERAGE_MODE_TIMES_16 0x04
124#define TEMPHUM10_AM_MANUAL_MODE_DETECTION_OP_STOP 0x00
125#define TEMPHUM10_AM_MANUAL_MODE_DETECTION_OP_START 0x01
132#define TEMPHUM10_ERR_NO_ERROR 0x00
133#define TEMPHUM10_ERR_ERROR_FLAG_RESET 0x01
140#define TEMPHUM10_CAP_OUTSIDE_CAPACITY_CUTTING 0x00
141#define TEMPHUM10_CAP_OUTSIDE_CAPACITY_CONNECTION 0x10
144 // End group macro
145// --------------------------------------------------------------- PUBLIC TYPES
154typedef struct
155{
156 // Output pins
157
158 digital_out_t cs;
159
160 // Modules
161
162 i2c_master_t i2c;
163
164 // ctx variable
165
167
169
173typedef struct
174{
175 // Communication gpio pins
176
177 pin_name_t scl;
178 pin_name_t sda;
179
180 // Additional gpio pins
181
182 pin_name_t cs;
183
184 // static variable
185
186 uint32_t i2c_speed;
187 uint8_t i2c_address;
188
190
191 // End types group
192// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
193
199#ifdef __cplusplus
200extern "C"{
201#endif
202
212
222
233void temphum10_generic_write ( temphum10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
234
245void temphum10_generic_read ( temphum10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
246
255
264
271void temphum10_set_device_mode ( temphum10_t *ctx, uint8_t mode );
272
279void temphum10_repeat_measurement ( temphum10_t *ctx, uint8_t average );
280
281#ifdef __cplusplus
282}
283#endif
284#endif // _TEMPHUM10_H_
285
286 // End public_function group
288
289// ------------------------------------------------------------------------- END
#define TEMPHUM10_RETVAL
Definition temphum10.h:76
TEMPHUM10_RETVAL temphum10_init(temphum10_t *ctx, temphum10_cfg_t *cfg)
Initialization function.
void temphum10_cfg_setup(temphum10_cfg_t *cfg)
Config Object Initialization function.
void temphum10_set_device_mode(temphum10_t *ctx, uint8_t mode)
Functions for sets Device mode.
float temphum10_get_humidity(temphum10_t *ctx)
Functions for read Relative Huminidy data.
void temphum10_generic_read(temphum10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void temphum10_repeat_measurement(temphum10_t *ctx, uint8_t average)
Functions for repeat measurement.
void temphum10_generic_write(temphum10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
float temphum10_get_temperature(temphum10_t *ctx)
Functions for read Temperature data.
Click configuration structure definition.
Definition temphum10.h:174
uint32_t i2c_speed
Definition temphum10.h:186
pin_name_t scl
Definition temphum10.h:177
pin_name_t sda
Definition temphum10.h:178
pin_name_t cs
Definition temphum10.h:182
uint8_t i2c_address
Definition temphum10.h:187
Click ctx object definition.
Definition temphum10.h:155
digital_out_t cs
Definition temphum10.h:158
i2c_master_t i2c
Definition temphum10.h:162
uint8_t slave_address
Definition temphum10.h:166