fever  2.0.0.0
fever.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 FEVER_H
36 #define FEVER_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_in.h"
53 #include "drv_i2c_master.h"
54 
55 // -------------------------------------------------------------- PUBLIC MACROS
65 #define FEVER_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );\
68  cfg.os = MIKROBUS( mikrobus, MIKROBUS_INT )
69 
75 #define FEVER_RETVAL uint8_t
76 
77 #define FEVER_OK 0x00
78 #define FEVER_INIT_ERROR 0xFF
79 
85 #define FEVER_TEMP 0x00
86 #define FEVER_CONFIG 0x01
87 #define FEVER_THYST 0x02
88 #define FEVER_TOS 0x03
89 
95 #define FEVER_SHUTDOWN 0x01
96 #define FEVER_POWERUP 0xFE
97 #define FEVER_INTERUPT_MODE 0x02
98 #define FEVER_COMPARATOR_MODE 0xFD
99 
105 #define FEVER_OS_ACTIVE_HIGH 0x04
106 #define FEVER_OS_ACTIVE_LOW 0xFB
107 
113 #define FEVER_FAULT_QUEUE_1 0xE7
114 #define FEVER_FAULT_QUEUE_2 0x08
115 #define FEVER_FAULT_QUEUE_4 0x10
116 #define FEVER_FAULT_QUEUE_6 0x18
117 
123 #define FEVER_EXTENDED_DATA_FORMAT 0x20
124 #define FEVER_NORMAL_DATA_FORMAT 0xDF
125 
131 #define FEVER_TIMEOUT_DISABLE 0x40
132 #define FEVER_TIMEOUT_ENABLE 0xBF
133 
139 #define FEVER_ONE_SHOT_MEASURE 0x80
140  // End group macro
143 // --------------------------------------------------------------- PUBLIC TYPES
152 typedef struct
153 {
154  // Input pins
155 
156  digital_in_t os;
157 
158  // Modules
159 
160  i2c_master_t i2c;
161 
162  // ctx variable
163 
164  uint8_t slave_address;
165 
166 } fever_t;
167 
171 typedef struct
172 {
173  // Communication gpio pins
174 
175  pin_name_t scl;
176  pin_name_t sda;
177 
178  // Additional gpio pins
179 
180  pin_name_t os;
181 
182  // static variable
183 
184  uint32_t i2c_speed;
185  uint8_t i2c_address;
186 
187 } fever_cfg_t;
188  // End types group
190 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
191 
197 #ifdef __cplusplus
198 extern "C"{
199 #endif
200 
210 
220 
229 
240 void fever_generic_write ( fever_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
241 
252 void fever_generic_read ( fever_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
253 
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 #endif // _FEVER_H_
267  // End public_function group
270 
271 // ------------------------------------------------------------------------- END
fever_generic_write
void fever_generic_write(fever_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
fever_get_temperature
float fever_get_temperature(fever_t *ctx)
Get temperature.
fever_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: fever.h:184
FEVER_RETVAL
#define FEVER_RETVAL
Definition: fever.h:75
fever_cfg_setup
void fever_cfg_setup(fever_cfg_t *cfg)
Config Object Initialization function.
fever_t
Click ctx object definition.
Definition: fever.h:153
fever_cfg_t::os
pin_name_t os
Definition: fever.h:180
fever_cfg_t::sda
pin_name_t sda
Definition: fever.h:176
fever_t::slave_address
uint8_t slave_address
Definition: fever.h:164
fever_t::i2c
i2c_master_t i2c
Definition: fever.h:160
fever_cfg_t::i2c_address
uint8_t i2c_address
Definition: fever.h:185
fever_t::os
digital_in_t os
Definition: fever.h:156
fever_default_cfg
void fever_default_cfg(fever_t *ctx)
Click Default Configuration function.
fever_generic_read
void fever_generic_read(fever_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
fever_cfg_t
Click configuration structure definition.
Definition: fever.h:172
fever_cfg_t::scl
pin_name_t scl
Definition: fever.h:175
fever_init
FEVER_RETVAL fever_init(fever_t *ctx, fever_cfg_t *cfg)
Initialization function.