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 )
73#define THERMO4_RETVAL uint8_t
74
75#define THERMO4_OK 0x00
76#define THERMO4_INIT_ERROR 0xFF
79 // End group macro
80// --------------------------------------------------------------- PUBLIC TYPES
89typedef 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
103
104} thermo4_t;
105
109typedef 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
126
127 // End types group
128
129// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130
136#ifdef __cplusplus
137extern "C"{
138#endif
139
149
159
168
178void thermo4_write_byte ( thermo4_t *ctx, uint8_t reg, uint8_t data_in );
179
189void thermo4_read_byte ( thermo4_t *ctx, uint8_t reg, uint8_t *data_out );
190
200void thermo4_write_data ( thermo4_t *ctx, uint8_t reg, uint16_t data_in );
201
211void thermo4_read_data ( thermo4_t *ctx, uint8_t reg, uint16_t *data_out );
212
221void thermo4_write_cfg ( thermo4_t *ctx, uint8_t wr_cfg );
222
233
242
251
260
271
282
293
305
316
326void thermo4_write_over_temp_shut_down ( thermo4_t *ctx, float input_val );
327
336void thermo4_write_temp_hyst( thermo4_t *ctx, float input_val );
337
338#ifdef __cplusplus
339}
340#endif
341#endif // _THERMO4_H_
342
343 // End public_function group
345
346// ------------------------------------------------------------------------- END
#define THERMO4_RETVAL
Definition thermo4.h:73
void thermo4_read_data(thermo4_t *ctx, uint8_t reg, uint16_t *data_out)
Data read function.
float thermo4_read_temperature_c(thermo4_t *ctx)
Read Temperature in Celsius function.
float thermo4_read_temperature_f(thermo4_t *ctx)
Read Temperature in Fahrenheit function.
void thermo4_write_cfg(thermo4_t *ctx, uint8_t wr_cfg)
Write configuration function.
void thermo4_power_up(thermo4_t *ctx)
Power up function.
void thermo4_read_byte(thermo4_t *ctx, uint8_t reg, uint8_t *data_out)
Byte read function.
void thermo4_write_data(thermo4_t *ctx, uint8_t reg, uint16_t data_in)
Data write function.
void thermo4_write_over_temp_shut_down(thermo4_t *ctx, float input_val)
Write overtemperature shutdown threshold function.
uint8_t thermo4_read_cfg(thermo4_t *ctx)
Read configuration function.
float thermo4_read_over_temp_shut_down(thermo4_t *ctx)
Read overtemperature shutdown threshold function.
void thermo4_default_cfg(thermo4_t *ctx)
Click Default Configuration function.
void thermo4_write_temp_hyst(thermo4_t *ctx, float input_val)
Write hysteresis function.
float thermo4_read_temp_hyst(thermo4_t *ctx)
Read hysteresis function.
void thermo4_shut_down(thermo4_t *ctx)
Read configuration function.
void thermo4_write_byte(thermo4_t *ctx, uint8_t reg, uint8_t data_in)
Byte write function.
void thermo4_reset(thermo4_t *ctx)
Reset function.
float thermo4_read_temperature_k(thermo4_t *ctx)
Read Temperature in Kelvin function.
void thermo4_cfg_setup(thermo4_cfg_t *cfg)
Config Object Initialization function.
THERMO4_RETVAL thermo4_init(thermo4_t *ctx, thermo4_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition thermo4.h:110
uint32_t i2c_speed
Definition thermo4.h:122
pin_name_t scl
Definition thermo4.h:113
pin_name_t int_pin
Definition thermo4.h:118
pin_name_t sda
Definition thermo4.h:114
uint8_t i2c_address
Definition thermo4.h:123
Click ctx object definition.
Definition thermo4.h:90
digital_in_t int_pin
Definition thermo4.h:94
i2c_master_t i2c
Definition thermo4.h:98
uint8_t slave_address
Definition thermo4.h:102