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 
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
58 
63 #define THERMO4_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
67 
73 #define THERMO4_RETVAL uint8_t
74 
75 #define THERMO4_OK 0x00
76 #define THERMO4_INIT_ERROR 0xFF
77  // End group macro
80 // --------------------------------------------------------------- PUBLIC TYPES
89 typedef struct
90 {
91 
92  // Input pins
93 
94  digital_in_t int_pin;
95 
96  // Modules
97 
98  i2c_master_t i2c;
99 
100  // ctx variable
101 
102  uint8_t slave_address;
103 
104 } thermo4_t;
105 
109 typedef struct
110 {
111  // Communication gpio pins
112 
113  pin_name_t scl;
114  pin_name_t sda;
115 
116  // Additional gpio pins
117 
118  pin_name_t int_pin;
119 
120  // static variable
121 
122  uint32_t i2c_speed;
123  uint8_t i2c_address;
124 
125 } thermo4_cfg_t;
126  // End types group
128 
129 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130 
136 #ifdef __cplusplus
137 extern "C"{
138 #endif
139 
149 
159 
168 
178 void thermo4_write_byte ( thermo4_t *ctx, uint8_t reg, uint8_t data_in );
179 
189 void thermo4_read_byte ( thermo4_t *ctx, uint8_t reg, uint8_t *data_out );
190 
200 void thermo4_write_data ( thermo4_t *ctx, uint8_t reg, uint16_t data_in );
201 
211 void thermo4_read_data ( thermo4_t *ctx, uint8_t reg, uint16_t *data_out );
212 
221 void thermo4_write_cfg ( thermo4_t *ctx, uint8_t wr_cfg );
222 
232 uint8_t thermo4_read_cfg ( thermo4_t *ctx );
233 
242 
251 
259 void thermo4_reset ( thermo4_t *ctx );
260 
271 
282 
293 
305 
316 
326 void thermo4_write_over_temp_shut_down ( thermo4_t *ctx, float input_val );
327 
336 void thermo4_write_temp_hyst( thermo4_t *ctx, float input_val );
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 #endif // _THERMO4_H_
342  // End public_function group
345 
346 // ------------------------------------------------------------------------- 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:122
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:90
thermo4_cfg_t
Click configuration structure definition.
Definition: thermo4.h:110
thermo4_cfg_t::sda
pin_name_t sda
Definition: thermo4.h:114
thermo4_t::i2c
i2c_master_t i2c
Definition: thermo4.h:98
THERMO4_RETVAL
#define THERMO4_RETVAL
Definition: thermo4.h:73
thermo4_cfg_t::scl
pin_name_t scl
Definition: thermo4.h:113
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:123
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:94
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:102
thermo4_cfg_t::int_pin
pin_name_t int_pin
Definition: thermo4.h:118
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.