thermostat4 2.0.0.0
thermostat4.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 THERMOSTAT4_H
29#define THERMOSTAT4_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_spi_master.h"
52
73#define THERMOSTAT4_RELAY_ON 0x01
74#define THERMOSTAT4_RELAY_OFF 0x00
75
76#define THERMOSTAT4_RESET_ON 0x01
77#define THERMOSTAT4_RESET_OFF 0x00
78
79#define THERMOSTAT4_WARM_ALERT 0x00
80#define THERMOSTAT4_HOT_ALERT 0x00
81
90#define THERMOSTAT4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
91#define THERMOSTAT4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
92
93 // thermostat4_set
94
109#define THERMOSTAT4_MAP_MIKROBUS( cfg, mikrobus ) \
110 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
111 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
112 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
113 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
114 cfg.oa = MIKROBUS( mikrobus, MIKROBUS_AN ); \
115 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
116 cfg.rly = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
117 cfg.ob = MIKROBUS( mikrobus, MIKROBUS_INT )
118
119 // thermostat4_map
120 // thermostat4
121
126typedef struct
127{
128 // Output pins
129 digital_out_t rst;
130 digital_out_t rly;
131 digital_out_t cs;
133 // Input pins
134 digital_in_t oa;
135 digital_in_t ob;
137 // Modules
138 spi_master_t spi;
140 pin_name_t chip_select;
143
148typedef struct
149{
150 // Communication gpio pins
151 pin_name_t miso;
152 pin_name_t mosi;
153 pin_name_t sck;
154 pin_name_t cs;
156 // Additional gpio pins
157 pin_name_t oa;
158 pin_name_t rst;
159 pin_name_t rly;
160 pin_name_t ob;
162 // static variable
163 uint32_t spi_speed;
164 spi_master_mode_t spi_mode;
165 spi_master_chip_select_polarity_t cs_polarity;
168
179
196
210
219void thermostat4_relay_ctrl ( thermostat4_t *ctx, uint8_t state );
220
229void thermostat4_rst_pin_ctrl ( thermostat4_t *ctx, uint8_t state );
230
239
248
257void thermostat4_set_warm_hysteresis ( thermostat4_t *ctx, uint8_t hyst_data );
258
267
268#ifdef __cplusplus
269}
270#endif
271#endif // _THERMOSTAT4_H_
272
273 // thermostat 4
274// ------------------------------------------------------------------------- END
err_t thermostat4_init(thermostat4_t *ctx, thermostat4_cfg_t *cfg)
Thermostat 4 initialization function.
void thermostat4_new_cfg_upload(thermostat4_t *ctx)
Reset module and upload new configuration on the Warm channel.
uint8_t thermostat4_warm_alert_state(thermostat4_t *ctx)
Warm temperature alert.
uint8_t thermostat4_hot_alert_state(thermostat4_t *ctx)
Hot temperature alert.
void thermostat4_rst_pin_ctrl(thermostat4_t *ctx, uint8_t state)
Sets reset pin state.
void thermostat4_cfg_setup(thermostat4_cfg_t *cfg)
Thermostat 4 configuration object setup function.
void thermostat4_relay_ctrl(thermostat4_t *ctx, uint8_t state)
Relay Control.
void thermostat4_set_warm_hysteresis(thermostat4_t *ctx, uint8_t hyst_data)
Hysteresis on the Warm channel.
Thermostat 4 Click configuration object.
Definition thermostat4.h:149
pin_name_t rly
Definition thermostat4.h:159
spi_master_chip_select_polarity_t cs_polarity
Definition thermostat4.h:165
pin_name_t sck
Definition thermostat4.h:153
spi_master_mode_t spi_mode
Definition thermostat4.h:164
pin_name_t ob
Definition thermostat4.h:160
pin_name_t mosi
Definition thermostat4.h:152
uint32_t spi_speed
Definition thermostat4.h:163
pin_name_t oa
Definition thermostat4.h:157
pin_name_t miso
Definition thermostat4.h:151
pin_name_t rst
Definition thermostat4.h:158
pin_name_t cs
Definition thermostat4.h:154
Thermostat 4 Click context object.
Definition thermostat4.h:127
digital_out_t cs
Definition thermostat4.h:131
spi_master_t spi
Definition thermostat4.h:138
digital_out_t rly
Definition thermostat4.h:130
digital_in_t oa
Definition thermostat4.h:134
digital_out_t rst
Definition thermostat4.h:129
pin_name_t chip_select
Definition thermostat4.h:140
digital_in_t ob
Definition thermostat4.h:135
thermostat4_return_value_t
Thermostat 4 Click return value data.
Definition thermostat4.h:174
@ THERMOSTAT4_ERROR
Definition thermostat4.h:176
@ THERMOSTAT4_OK
Definition thermostat4.h:175