thermo4  2.0.0.0
thermo4.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 THERMO4_H
36 #define THERMO4_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
54 
59 #define THERMO4_MAP_MIKROBUS( cfg, mikrobus ) \
60  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
61  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
62  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
63 
69 #define THERMO4_RETVAL uint8_t
70 
71 #define THERMO4_OK 0x00
72 #define THERMO4_INIT_ERROR 0xFF
73  // End group macro
76 // --------------------------------------------------------------- PUBLIC TYPES
85 typedef struct
86 {
87 
88  // Input pins
89 
90  digital_in_t int_pin;
91 
92  // Modules
93 
94  i2c_master_t i2c;
95 
96  // ctx variable
97 
98  uint8_t slave_address;
99 
100 } thermo4_t;
101 
105 typedef struct
106 {
107  // Communication gpio pins
108 
109  pin_name_t scl;
110  pin_name_t sda;
111 
112  // Additional gpio pins
113 
114  pin_name_t int_pin;
115 
116  // static variable
117 
118  uint32_t i2c_speed;
119  uint8_t i2c_address;
120 
121 } thermo4_cfg_t;
122  // End types group
124 
125 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
126 
132 #ifdef __cplusplus
133 extern "C"{
134 #endif
135 
145 
155 
164 
174 void thermo4_write_byte ( thermo4_t *ctx, uint8_t reg, uint8_t data_in );
175 
185 void thermo4_read_byte ( thermo4_t *ctx, uint8_t reg, uint8_t *data_out );
186 
196 void thermo4_write_data ( thermo4_t *ctx, uint8_t reg, uint16_t data_in );
197 
207 void thermo4_read_data ( thermo4_t *ctx, uint8_t reg, uint16_t *data_out );
208 
217 void thermo4_write_cfg ( thermo4_t *ctx, uint8_t wr_cfg );
218 
228 uint8_t thermo4_read_cfg ( thermo4_t *ctx );
229 
238 
247 
255 void thermo4_reset ( thermo4_t *ctx );
256 
267 
278 
289 
301 
312 
322 void thermo4_write_over_temp_shut_down ( thermo4_t *ctx, float input_val );
323 
332 void thermo4_write_temp_hyst( thermo4_t *ctx, float input_val );
333 
334 #ifdef __cplusplus
335 }
336 #endif
337 #endif // _THERMO4_H_
338  // End public_function group
341 
342 // ------------------------------------------------------------------------- END
thermo4_read_temperature_c
float thermo4_read_temperature_c(thermo4_t *ctx)
Read Temperature in Celsius function.
thermo4_power_up
void thermo4_power_up(thermo4_t *ctx)
Power up function.
thermo4_read_cfg
uint8_t thermo4_read_cfg(thermo4_t *ctx)
Read configuration function.
thermo4_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: thermo4.h:118
thermo4_read_byte
void thermo4_read_byte(thermo4_t *ctx, uint8_t reg, uint8_t *data_out)
Byte read function.
thermo4_write_data
void thermo4_write_data(thermo4_t *ctx, uint8_t reg, uint16_t data_in)
Data write function.
thermo4_reset
void thermo4_reset(thermo4_t *ctx)
Reset function.
thermo4_read_data
void thermo4_read_data(thermo4_t *ctx, uint8_t reg, uint16_t *data_out)
Data read function.
thermo4_read_over_temp_shut_down
float thermo4_read_over_temp_shut_down(thermo4_t *ctx)
Read overtemperature shutdown threshold function.
thermo4_cfg_setup
void thermo4_cfg_setup(thermo4_cfg_t *cfg)
Config Object Initialization function.
thermo4_t
Click ctx object definition.
Definition: thermo4.h:86
thermo4_cfg_t
Click configuration structure definition.
Definition: thermo4.h:106
thermo4_cfg_t::sda
pin_name_t sda
Definition: thermo4.h:110
thermo4_t::i2c
i2c_master_t i2c
Definition: thermo4.h:94
THERMO4_RETVAL
#define THERMO4_RETVAL
Definition: thermo4.h:69
thermo4_cfg_t::scl
pin_name_t scl
Definition: thermo4.h:109
thermo4_read_temperature_f
float thermo4_read_temperature_f(thermo4_t *ctx)
Read Temperature in Fahrenheit function.
thermo4_cfg_t::i2c_address
uint8_t i2c_address
Definition: thermo4.h:119
thermo4_read_temp_hyst
float thermo4_read_temp_hyst(thermo4_t *ctx)
Read hysteresis function.
thermo4_write_cfg
void thermo4_write_cfg(thermo4_t *ctx, uint8_t wr_cfg)
Write configuration function.
thermo4_read_temperature_k
float thermo4_read_temperature_k(thermo4_t *ctx)
Read Temperature in Kelvin function.
thermo4_t::int_pin
digital_in_t int_pin
Definition: thermo4.h:90
thermo4_write_byte
void thermo4_write_byte(thermo4_t *ctx, uint8_t reg, uint8_t data_in)
Byte write function.
thermo4_write_temp_hyst
void thermo4_write_temp_hyst(thermo4_t *ctx, float input_val)
Write hysteresis function.
thermo4_init
THERMO4_RETVAL thermo4_init(thermo4_t *ctx, thermo4_cfg_t *cfg)
Initialization function.
thermo4_t::slave_address
uint8_t slave_address
Definition: thermo4.h:98
thermo4_cfg_t::int_pin
pin_name_t int_pin
Definition: thermo4.h:114
thermo4_shut_down
void thermo4_shut_down(thermo4_t *ctx)
Read configuration function.
thermo4_default_cfg
void thermo4_default_cfg(thermo4_t *ctx)
Click Default Configuration function.
thermo4_write_over_temp_shut_down
void thermo4_write_over_temp_shut_down(thermo4_t *ctx, float input_val)
Write overtemperature shutdown threshold function.