temphum5 2.0.0.0
temphum5.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 TEMPHUM5_H
36#define TEMPHUM5_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 TEMPHUM5_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.all = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
71 cfg.alh = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define TEMPHUM5_RETVAL uint8_t
79
80#define TEMPHUM5_OK 0x00
81#define TEMPHUM5_INIT_ERROR 0xFF
88#define TEMPHUM5_DEVICE_SLAVE_ADDRESS 0x27
95#define TEMPHUM5_TEMP_DATA_IN_CELSIUS 0x01
96#define TEMPHUM5_TEMP_DATA_IN_KELVIN 0x02
97#define TEMPHUM5_TEMP_DATA_IN_FAHRENHEIT 0x03
105#define TEMPHUM5_STATUS_NORMAL_OPERATION 0x00
106#define TEMPHUM5_STATUS_STALE_DATA 0x01
107#define TEMPHUM5_STATUS_COMMAND_MODE 0x02
114#define TEMPHUM5_ALARM_OUTPUT_HIGH 0x01
115#define TEMPHUM5_ALARM_OUTPUT_LOW 0x02
118 // End group macro
119// --------------------------------------------------------------- PUBLIC TYPES
128typedef struct
129{
130 // Input pins
131
132 digital_in_t all;
133 digital_in_t alh;
134
135 // Modules
136
137 i2c_master_t i2c;
138
139 // ctx variable
140
142
143 uint16_t temperature;
144 uint16_t humidity;
145
146} temphum5_t;
147
151typedef struct
152{
153 // Communication gpio pins
154
155 pin_name_t scl;
156 pin_name_t sda;
157
158 // Additional gpio pins
159
160 pin_name_t all;
161 pin_name_t alh;
162
163 // static variable
164
165 uint32_t i2c_speed;
166 uint8_t i2c_address;
167
169 uint16_t dev_humidity;
170
172
173 // End types group
174// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
175
181#ifdef __cplusplus
182extern "C"{
183#endif
184
194
203
214void temphum5_generic_write ( temphum5_t *ctx, uint8_t cmd );
215
227void temphum5_generic_read ( temphum5_t *ctx, uint8_t *data_out );
228
245
255float temphum5_get_temperature ( temphum5_t *ctx, uint8_t temp_in );
256
266
275uint8_t temphum5_get_alarm ( temphum5_t *ctx, uint8_t alarm );
276
277
278#ifdef __cplusplus
279}
280#endif
281#endif // _TEMPHUM5_H_
282
283 // End public_function group
285
286// ------------------------------------------------------------------------- END
#define TEMPHUM5_RETVAL
Definition temphum5.h:78
void temphum5_generic_write(temphum5_t *ctx, uint8_t cmd)
Generic write function.
float temphum5_get_temperature(temphum5_t *ctx, uint8_t temp_in)
Functions for read Temperature data.
uint8_t temphum5_get_alarm(temphum5_t *ctx, uint8_t alarm)
Functions for get output Alarm.
void temphum5_generic_read(temphum5_t *ctx, uint8_t *data_out)
Generic read function.
float temphum5_get_humidity(temphum5_t *ctx)
Functions for read Relative Huminidy data.
TEMPHUM5_RETVAL temphum5_init(temphum5_t *ctx, temphum5_cfg_t *cfg)
Initialization function.
uint8_t temphum5_start_measurement(temphum5_t *ctx)
Functions for start measurement.
void temphum5_cfg_setup(temphum5_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition temphum5.h:152
pin_name_t all
Definition temphum5.h:160
uint32_t i2c_speed
Definition temphum5.h:165
uint16_t dev_temperature
Definition temphum5.h:168
pin_name_t alh
Definition temphum5.h:161
uint16_t dev_humidity
Definition temphum5.h:169
pin_name_t scl
Definition temphum5.h:155
pin_name_t sda
Definition temphum5.h:156
uint8_t i2c_address
Definition temphum5.h:166
Click ctx object definition.
Definition temphum5.h:129
uint16_t humidity
Definition temphum5.h:144
digital_in_t all
Definition temphum5.h:132
uint16_t temperature
Definition temphum5.h:143
i2c_master_t i2c
Definition temphum5.h:137
digital_in_t alh
Definition temphum5.h:133
uint8_t slave_address
Definition temphum5.h:141