temphum6 2.0.0.0
temphum6.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 TEMPHUM6_H
36#define TEMPHUM6_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_digital_in.h"
54#include "drv_i2c_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define TEMPHUM6_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl= MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda= MIKROBUS( mikrobus, MIKROBUS_SDA )
76#define TEMPHUM6_RETVAL uint8_t
77
78#define TEMPHUM6_OK 0x00
79#define TEMPHUM6_INIT_ERROR 0xFF
86#define TEMPHUM6_PART_ID 0x0210
87#define TEMPHUM6_DEVICE_SLAVE_ADDRESS 0x43
94#define TEMPHUM6_REG_PART_ID 0x00
95#define TEMPHUM6_REG_UNIQUE_IDENTIFIER 0x04
96#define TEMPHUM6_REG_SYSTEM_CONTROL 0x10
97#define TEMPHUM6_REG_SYSTEM_STATUS 0x11
98#define TEMPHUM6_REG_SENS_RUN 0x21
99#define TEMPHUM6_REG_SENS_START 0x22
100#define TEMPHUM6_REG_SENS_STOP 0x23
101#define TEMPHUM6_REG_SENS_STATUS 0x24
102#define TEMPHUM6_REG_TEMPERATURE 0x30
103#define TEMPHUM6_REG_RELATIVE_HUMIDITY 0x33
110#define TEMPHUM6_STATUS_I2C_ERROR 4
111#define TEMPHUM6_STATUS_CRC_ERROR 3
112#define TEMPHUM6_STATUS_INVALID 2
113#define TEMPHUM6_STATUS_OK 1
120#define TEMPHUM6_TEMP_IN_FAHRENHEIT 2
121#define TEMPHUM6_TEMP_IN_KELVIN 1
122#define TEMPHUM6_TEMP_IN_CELSIUS 0
129#define TEMPHUM6_LOW_POWER_DISABLE 0x00
130#define TEMPHUM6_LOW_POWER_ENABLE 0x01
137#define TEMPHUM6_SYSTEM_IS_IN_STANDBY_OR_BOOTING_STATE 0
138#define TEMPHUM6_SYSTEM_IS_IN_ACTIVE_STATE 1
145#define TEMPHUM6_HUM_RUN_SINGLE_SHOT_MODE 0x00
146#define TEMPHUM6_TEMP_RUN_SINGLE_SHOT_MODE 0x00
147#define TEMPHUM6_HUM_RUN_CONTINUOUS_MODE 0x02
148#define TEMPHUM6_TEMP_RUN_CONTINUOUS_MODE 0x01
155#define TEMPHUM6_HUM_START_MEASUREMENT 0x02
156#define TEMPHUM6_TEMP_START_MEASUREMENT 0x01
157#define TEMPHUM6_DISABLE_MEASUREMENT 0x00
164#define TEMPHUM6_HUM_STOP_CONTINUOUS_MEASUREMENT 0x02
165#define TEMPHUM6_TEMP_STOP_CONTINUOUS_MEASUREMENT 0x01
166#define TEMPHUM6_DISABLE_CONTINUOUS_MEASUREMENT 0x00
171 // End group macro
172// --------------------------------------------------------------- PUBLIC TYPES
181typedef struct
182{
183 // Modules
184
185 i2c_master_t i2c;
186
187 // ctx variable
188
190
191} temphum6_t;
192
196typedef struct
197{
198 // Communication gpio pins
199
200 pin_name_t scl;
201 pin_name_t sda;
202
203 // static variable
204
205 uint32_t i2c_speed;
206 uint8_t i2c_address;
207
209
210 // End types group
211// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
212
218#ifdef __cplusplus
219extern "C"{
220#endif
221
231
241
252void temphum6_generic_write ( temphum6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
253
264void temphum6_generic_read ( temphum6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
265
274
285
298
309float temphum6_read_temperature ( temphum6_t *ctx, uint8_t temp_in );
310
321
322#ifdef __cplusplus
323}
324#endif
325#endif // _TEMPHUM6_H_
326
327 // End public_function group
329
330// ------------------------------------------------------------------------- END
#define TEMPHUM6_RETVAL
Definition temphum6.h:76
void temphum6_generic_write(temphum6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
TEMPHUM6_RETVAL temphum6_init(temphum6_t *ctx, temphum6_cfg_t *cfg)
Initialization function.
uint16_t temphum6_get_part_id(temphum6_t *ctx)
Functions for get device PART ID.
float temphum6_read_temperature(temphum6_t *ctx, uint8_t temp_in)
Functions for read Temperature data.
void temphum6_generic_read(temphum6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void temphum6_reset(temphum6_t *ctx)
Functions for reset device.
void temphum6_cfg_setup(temphum6_cfg_t *cfg)
Config Object Initialization function.
float temphum6_read_relative_huminidy(temphum6_t *ctx)
Functions for read Relative Huminidy data.
void temphum6_run(temphum6_t *ctx)
Functions for RUN measurement.
Click configuration structure definition.
Definition temphum6.h:197
uint32_t i2c_speed
Definition temphum6.h:205
pin_name_t scl
Definition temphum6.h:200
pin_name_t sda
Definition temphum6.h:201
uint8_t i2c_address
Definition temphum6.h:206
Click ctx object definition.
Definition temphum6.h:182
i2c_master_t i2c
Definition temphum6.h:185
uint8_t slave_address
Definition temphum6.h:189