temphum13 2.0.0.0
temphum13.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 TEMPHUM13_H
36#define TEMPHUM13_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define TEMPHUM13_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
61#define TEMPHUM13_RETVAL uint8_t
62
63#define TEMPHUM13_OK 0x00
64#define TEMPHUM13_INIT_ERROR 0xFF
71#define TEMPHUM13_DEVICE_ADDRESS 0x40
78#define TEMPHUM13_CMD_TRIG_TEMP_MEAS_HOLD 0xE3
79#define TEMPHUM13_CMD_TRIG_HUMI_MEAS_HOLD 0xE5
80#define TEMPHUM13_CMD_TRIG_TEMP_MEAS_NOHOLD 0xF3
81#define TEMPHUM13_CMD_TRIG_HUMI_MEAS_NOHOLD 0xF5
82#define TEMPHUM13_CMD_WRITE_USER_REG 0xE6
83#define TEMPHUM13_CMD_READ_USER_REG 0xE7
84#define TEMPHUM13_CMD_SOFT_RESET 0xFE
92#define TEMPHUM13_HEATER_ENABLE 0x01
93#define TEMPHUM13_HEATER_DISABLE 0x00
100#define TEMPHUM13_RESOLUTION_8 0x01
101#define TEMPHUM13_RESOLUTION_10 0x80
102#define TEMPHUM13_RESOLUTION_11 0x81
103#define TEMPHUM13_RESOLUTION_12 0x00
110#define TEMPHUM13_OTP_DISABLE 0x01
111#define TEMPHUM13_OTP_ENABLE 0x00 // End group macro
116// --------------------------------------------------------------- PUBLIC TYPES
125typedef struct
126{
127 // Modules
128
129 i2c_master_t i2c;
130
131 // ctx variable
132
134
136
140typedef struct
141{
142 // Communication gpio pins
143
144 pin_name_t scl;
145 pin_name_t sda;
146
147 // static variable
148
149 uint32_t i2c_speed;
150 uint8_t i2c_address;
151
153 // End types group // End variable group
156// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
157
163#ifdef __cplusplus
164extern "C"{
165#endif
166
176
186
196
207void temphum13_generic_write ( temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
208
219void temphum13_generic_read ( temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
220
231
242
253
262void temphum13_set_user_register ( temphum13_t *ctx, uint8_t register_content );
263
272
288uint8_t temphum13_enable_heater ( temphum13_t *ctx, uint8_t enable_heater );
289
306uint8_t temphum13_change_resolution ( temphum13_t *ctx, uint8_t meas_res );
307
323uint8_t temphum13_disable_otp_reload ( temphum13_t *ctx, uint8_t disable_otp_rel );
324
325#ifdef __cplusplus
326}
327#endif
328#endif // _TEMPHUM13_H_
329 // End public_function group
332
333// ------------------------------------------------------------------------- END
#define TEMPHUM13_RETVAL
Definition: temphum13.h:61
void temphum13_generic_read(temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t temphum13_change_resolution(temphum13_t *ctx, uint8_t meas_res)
Change measurement resolution.
float temphum13_get_temperature(temphum13_t *ctx)
Get temperature value.
void temphum13_set_user_register(temphum13_t *ctx, uint8_t register_content)
Set user register.
uint8_t temphum13_disable_otp_reload(temphum13_t *ctx, uint8_t disable_otp_rel)
Disable OTP.
void temphum13_default_cfg(temphum13_t *ctx)
Click Default Configuration function.
float temphum13_get_humidity(temphum13_t *ctx)
Get humidity value.
void temphum13_cfg_setup(temphum13_cfg_t *cfg)
Config Object Initialization function.
uint8_t temphum13_enable_heater(temphum13_t *ctx, uint8_t enable_heater)
Enable heater.
TEMPHUM13_RETVAL temphum13_init(temphum13_t *ctx, temphum13_cfg_t *cfg)
Initialization function.
void temphum13_soft_reset(temphum13_t *ctx)
Software reset.
void temphum13_generic_write(temphum13_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t temphum13_get_user_register(temphum13_t *ctx)
Get user register value.
Click configuration structure definition.
Definition: temphum13.h:141
uint32_t i2c_speed
Definition: temphum13.h:149
pin_name_t scl
Definition: temphum13.h:144
pin_name_t sda
Definition: temphum13.h:145
uint8_t i2c_address
Definition: temphum13.h:150
Click ctx object definition.
Definition: temphum13.h:126
i2c_master_t i2c
Definition: temphum13.h:129
uint8_t slave_address
Definition: temphum13.h:133