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 
38 #include "drv_digital_in.h"
39 #include "drv_i2c_master.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define FEVER_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
53  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );\
54  cfg.os = MIKROBUS( mikrobus, MIKROBUS_INT )
55 
61 #define FEVER_RETVAL uint8_t
62 
63 #define FEVER_OK 0x00
64 #define FEVER_INIT_ERROR 0xFF
65 
71 #define FEVER_TEMP 0x00
72 #define FEVER_CONFIG 0x01
73 #define FEVER_THYST 0x02
74 #define FEVER_TOS 0x03
75 
81 #define FEVER_SHUTDOWN 0x01
82 #define FEVER_POWERUP 0xFE
83 #define FEVER_INTERUPT_MODE 0x02
84 #define FEVER_COMPARATOR_MODE 0xFD
85 
91 #define FEVER_OS_ACTIVE_HIGH 0x04
92 #define FEVER_OS_ACTIVE_LOW 0xFB
93 
99 #define FEVER_FAULT_QUEUE_1 0xE7
100 #define FEVER_FAULT_QUEUE_2 0x08
101 #define FEVER_FAULT_QUEUE_4 0x10
102 #define FEVER_FAULT_QUEUE_6 0x18
103 
109 #define FEVER_EXTENDED_DATA_FORMAT 0x20
110 #define FEVER_NORMAL_DATA_FORMAT 0xDF
111 
117 #define FEVER_TIMEOUT_DISABLE 0x40
118 #define FEVER_TIMEOUT_ENABLE 0xBF
119 
125 #define FEVER_ONE_SHOT_MEASURE 0x80
126  // End group macro
129 // --------------------------------------------------------------- PUBLIC TYPES
138 typedef struct
139 {
140  // Input pins
141 
142  digital_in_t os;
143 
144  // Modules
145 
146  i2c_master_t i2c;
147 
148  // ctx variable
149 
150  uint8_t slave_address;
151 
152 } fever_t;
153 
157 typedef struct
158 {
159  // Communication gpio pins
160 
161  pin_name_t scl;
162  pin_name_t sda;
163 
164  // Additional gpio pins
165 
166  pin_name_t os;
167 
168  // static variable
169 
170  uint32_t i2c_speed;
171  uint8_t i2c_address;
172 
173 } fever_cfg_t;
174  // End types group
176 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
177 
183 #ifdef __cplusplus
184 extern "C"{
185 #endif
186 
196 
206 
215 
226 void fever_generic_write ( fever_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
227 
238 void fever_generic_read ( fever_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
239 
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 #endif // _FEVER_H_
253  // End public_function group
256 
257 // ------------------------------------------------------------------------- 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:170
FEVER_RETVAL
#define FEVER_RETVAL
Definition: fever.h:61
fever_cfg_setup
void fever_cfg_setup(fever_cfg_t *cfg)
Config Object Initialization function.
fever_t
Click ctx object definition.
Definition: fever.h:139
fever_cfg_t::os
pin_name_t os
Definition: fever.h:166
fever_cfg_t::sda
pin_name_t sda
Definition: fever.h:162
fever_t::slave_address
uint8_t slave_address
Definition: fever.h:150
fever_t::i2c
i2c_master_t i2c
Definition: fever.h:146
fever_cfg_t::i2c_address
uint8_t i2c_address
Definition: fever.h:171
fever_t::os
digital_in_t os
Definition: fever.h:142
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:158
fever_cfg_t::scl
pin_name_t scl
Definition: fever.h:161
fever_init
FEVER_RETVAL fever_init(fever_t *ctx, fever_cfg_t *cfg)
Initialization function.