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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
44 
49 #define THERMO4_MAP_MIKROBUS( cfg, mikrobus ) \
50  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
51  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
52  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
53 
59 #define THERMO4_RETVAL uint8_t
60 
61 #define THERMO4_OK 0x00
62 #define THERMO4_INIT_ERROR 0xFF
63  // End group macro
66 // --------------------------------------------------------------- PUBLIC TYPES
75 typedef struct
76 {
77 
78  // Input pins
79 
80  digital_in_t int_pin;
81 
82  // Modules
83 
84  i2c_master_t i2c;
85 
86  // ctx variable
87 
88  uint8_t slave_address;
89 
90 } thermo4_t;
91 
95 typedef struct
96 {
97  // Communication gpio pins
98 
99  pin_name_t scl;
100  pin_name_t sda;
101 
102  // Additional gpio pins
103 
104  pin_name_t int_pin;
105 
106  // static variable
107 
108  uint32_t i2c_speed;
109  uint8_t i2c_address;
110 
111 } thermo4_cfg_t;
112  // End types group
114 
115 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
116 
122 #ifdef __cplusplus
123 extern "C"{
124 #endif
125 
135 
145 
154 
164 void thermo4_write_byte ( thermo4_t *ctx, uint8_t reg, uint8_t data_in );
165 
175 void thermo4_read_byte ( thermo4_t *ctx, uint8_t reg, uint8_t *data_out );
176 
186 void thermo4_write_data ( thermo4_t *ctx, uint8_t reg, uint16_t data_in );
187 
197 void thermo4_read_data ( thermo4_t *ctx, uint8_t reg, uint16_t *data_out );
198 
207 void thermo4_write_cfg ( thermo4_t *ctx, uint8_t wr_cfg );
208 
218 uint8_t thermo4_read_cfg ( thermo4_t *ctx );
219 
228 
237 
245 void thermo4_reset ( thermo4_t *ctx );
246 
257 
268 
279 
291 
302 
312 void thermo4_write_over_temp_shut_down ( thermo4_t *ctx, float input_val );
313 
322 void thermo4_write_temp_hyst( thermo4_t *ctx, float input_val );
323 
324 #ifdef __cplusplus
325 }
326 #endif
327 #endif // _THERMO4_H_
328  // End public_function group
331 
332 // ------------------------------------------------------------------------- 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:108
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:76
thermo4_cfg_t
Click configuration structure definition.
Definition: thermo4.h:96
thermo4_cfg_t::sda
pin_name_t sda
Definition: thermo4.h:100
thermo4_t::i2c
i2c_master_t i2c
Definition: thermo4.h:84
THERMO4_RETVAL
#define THERMO4_RETVAL
Definition: thermo4.h:59
thermo4_cfg_t::scl
pin_name_t scl
Definition: thermo4.h:99
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:109
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:80
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:88
thermo4_cfg_t::int_pin
pin_name_t int_pin
Definition: thermo4.h:104
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.