thermo4  2.0.0.0
thermo4.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * 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  hal_i2c_address_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  hal_i2c_speed_t i2c_speed;
109  hal_i2c_address_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 
134 void thermo4_cfg_setup ( thermo4_cfg_t *cfg );
135 
144 
152 void thermo4_default_cfg ( thermo4_t *ctx );
153 
163 void thermo4_write_byte ( thermo4_t *ctx, uint8_t reg, uint8_t data_in );
164 
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 
198 void thermo4_read_data ( thermo4_t *ctx, uint8_t reg, uint16_t *data_out );
199 
209 void thermo4_write_cfg ( thermo4_t *ctx, uint8_t wr_cfg );
210 
220 uint8_t thermo4_read_cfg ( thermo4_t *ctx );
221 
230 void thermo4_shut_down ( thermo4_t *ctx );
231 
239 void thermo4_power_up ( thermo4_t *ctx );
240 
248 void thermo4_reset ( thermo4_t *ctx );
249 
260 
271 
282 
294 
304 float thermo4_read_temp_hyst ( thermo4_t *ctx );
305 
315 void thermo4_write_over_temp_shut_down ( thermo4_t *ctx, float input_val );
316 
325 void thermo4_write_temp_hyst( thermo4_t *ctx, float input_val );
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 #endif // _THERMO4_H_
331  // End public_function group
334 
335 // ------------------------------------------------------------------------- END
pin_name_t sda
Definition: thermo4.h:100
i2c_master_t i2c
Definition: thermo4.h:84
void thermo4_read_data(thermo4_t *ctx, uint8_t reg, uint16_t *data_out)
Data read function.
float thermo4_read_over_temp_shut_down(thermo4_t *ctx)
Read overtemperature shutdown threshold function.
#define THERMO4_RETVAL
Definition: thermo4.h:59
pin_name_t int_pin
Definition: thermo4.h:104
float thermo4_read_temperature_c(thermo4_t *ctx)
Read Temperature in Celsius function.
void thermo4_write_byte(thermo4_t *ctx, uint8_t reg, uint8_t data_in)
Byte write function.
Click ctx object definition.
Definition: thermo4.h:75
float thermo4_read_temperature_f(thermo4_t *ctx)
Read Temperature in Fahrenheit function.
uint8_t thermo4_read_cfg(thermo4_t *ctx)
Read configuration function.
void thermo4_reset(thermo4_t *ctx)
Reset function.
pin_name_t scl
Definition: thermo4.h:99
Click configuration structure definition.
Definition: thermo4.h:95
void thermo4_shut_down(thermo4_t *ctx)
Read configuration function.
void thermo4_default_cfg(thermo4_t *ctx)
Click Default Configuration function.
void thermo4_read_byte(thermo4_t *ctx, uint8_t reg, uint8_t *data_out)
Byte read function.
void thermo4_write_cfg(thermo4_t *ctx, uint8_t wr_cfg)
Write configuration function.
void thermo4_cfg_setup(thermo4_cfg_t *cfg)
Config Object Initialization function.
void thermo4_power_up(thermo4_t *ctx)
Power up function.
hal_i2c_speed_t i2c_speed
Definition: thermo4.h:108
float thermo4_read_temperature_k(thermo4_t *ctx)
Read Temperature in Kelvin function.
void thermo4_write_over_temp_shut_down(thermo4_t *ctx, float input_val)
Write overtemperature shutdown threshold function.
void thermo4_write_temp_hyst(thermo4_t *ctx, float input_val)
Write hysteresis function.
hal_i2c_address_t slave_address
Definition: thermo4.h:88
THERMO4_RETVAL thermo4_init(thermo4_t *ctx, thermo4_cfg_t *cfg)
Initialization function.
void thermo4_write_data(thermo4_t *ctx, uint8_t reg, uint16_t data_in)
Data write function.
hal_i2c_address_t i2c_address
Definition: thermo4.h:109
digital_in_t int_pin
Definition: thermo4.h:80
float thermo4_read_temp_hyst(thermo4_t *ctx)
Read hysteresis function.