thermostat5 2.1.0.0
Loading...
Searching...
No Matches
thermostat5.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef THERMOSTAT5_H
29#define THERMOSTAT5_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
52#include "drv_i2c_master.h"
53
74#define THERMOSTAT5_ROOM_TEMP_IN_K 293.15f
75#define THERMOSTAT5_THERMISOR_BETA 3435.0f
76#define THERMOSTAT5_INVERTED_VALUE 1.0f
77#define THERMOSTAT5_TEMP_K_TO_C 273.15f
78
83#define THERMOSTAT5_RELAY_OFF 0
84#define THERMOSTAT5_RELAY_ON 1
85
90#define THERMOSTAT5_ADC_RESOLUTION 0x0FFFu
91#define THERMOSTAT5_VREF_3V3 3.3
92#define THERMOSTAT5_VREF_5V 5.0
93
99#define THERMOSTAT5_SET_DEV_ADDR 0x4D
100
101 // thermostat5_set
102
117#define THERMOSTAT5_MAP_MIKROBUS( cfg, mikrobus ) \
118 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
119 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
120 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
121 cfg.on = MIKROBUS( mikrobus, MIKROBUS_PWM )
122
123 // thermostat5_map
124 // thermostat5
125
136
141typedef struct
142{
143 digital_out_t on;
145 analog_in_t adc;
146 i2c_master_t i2c;
149 float vref;
153
158typedef struct
159{
160 pin_name_t an;
161 pin_name_t scl;
162 pin_name_t sda;
163 pin_name_t on;
165 analog_in_resolution_t resolution;
166 float vref;
168 uint32_t i2c_speed;
169 uint8_t i2c_address;
174
185
202
218
233
245err_t thermostat5_read_raw_adc ( thermostat5_t *ctx, uint16_t *raw_adc );
246
258err_t thermostat5_read_voltage ( thermostat5_t *ctx, float *voltage );
259
271err_t thermostat5_set_vref ( thermostat5_t *ctx, float vref );
272
284err_t thermostat5_get_temperature ( thermostat5_t *ctx, float *temperature );
285
297void thermostat5_set_relay ( thermostat5_t *ctx, uint8_t state );
298
299#ifdef __cplusplus
300}
301#endif
302#endif // THERMOSTAT5_H
303
304 // thermostat5
305
306// ------------------------------------------------------------------------ END
err_t thermostat5_set_vref(thermostat5_t *ctx, float vref)
Thermostat 5 set vref function.
void thermostat5_set_relay(thermostat5_t *ctx, uint8_t state)
Thermostat 5 set relay function.
void thermostat5_drv_interface_sel(thermostat5_cfg_t *cfg, thermostat5_drv_t drv_sel)
Thermostat 5 driver interface setup function.
err_t thermostat5_read_raw_adc(thermostat5_t *ctx, uint16_t *raw_adc)
Thermostat 5 read raw ADC value function.
err_t thermostat5_init(thermostat5_t *ctx, thermostat5_cfg_t *cfg)
Thermostat 5 initialization function.
err_t thermostat5_get_temperature(thermostat5_t *ctx, float *temperature)
Thermostat 5 get temperature function.
err_t thermostat5_read_voltage(thermostat5_t *ctx, float *voltage)
Thermostat 5 read voltage level function.
void thermostat5_cfg_setup(thermostat5_cfg_t *cfg)
Thermostat 5 configuration object setup function.
Thermostat 5 Click configuration object.
Definition thermostat5.h:159
analog_in_resolution_t resolution
Definition thermostat5.h:165
float vref
Definition thermostat5.h:166
uint32_t i2c_speed
Definition thermostat5.h:168
thermostat5_drv_t drv_sel
Definition thermostat5.h:171
pin_name_t on
Definition thermostat5.h:163
pin_name_t scl
Definition thermostat5.h:161
pin_name_t sda
Definition thermostat5.h:162
pin_name_t an
Definition thermostat5.h:160
uint8_t i2c_address
Definition thermostat5.h:169
Thermostat 5 Click context object.
Definition thermostat5.h:142
float vref
Definition thermostat5.h:149
thermostat5_drv_t drv_sel
Definition thermostat5.h:150
digital_out_t on
Definition thermostat5.h:143
i2c_master_t i2c
Definition thermostat5.h:146
uint8_t slave_address
Definition thermostat5.h:148
analog_in_t adc
Definition thermostat5.h:145
thermostat5_drv_t
Thermostat 5 Click driver selector.
Definition thermostat5.h:131
@ THERMOSTAT5_DRV_SEL_I2C
Definition thermostat5.h:133
@ THERMOSTAT5_DRV_SEL_ADC
Definition thermostat5.h:132
thermostat5_return_value_t
Thermostat 5 Click return value data.
Definition thermostat5.h:180
@ THERMOSTAT5_OK
Definition thermostat5.h:181
@ THERMOSTAT5_ERROR
Definition thermostat5.h:182