thermo16  2.0.0.0
thermo16.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 
34 #ifndef THERMO16_H
35 #define THERMO16_H
36 
37 #include "drv_analog_in.h"
38 
39 // -------------------------------------------------------------- PUBLIC MACROS
40 
50 #define THERMO16_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
52 
58 #define THERMO16_RETVAL uint8_t
59 
60 #define THERMO16_OK 0x00
61 #define THERMO16_INIT_ERROR 0xFF
62 
68 #define THERMO16_TEMP_IN_CELSIUS 0x00
69 #define THERMO16_TEMP_IN_KELVIN 0x01
70 #define THERMO16_TEMP_IN_FAHRENHEIT 0x02
71  // End group macro
74 // --------------------------------------------------------------- PUBLIC TYPES
83 typedef uint16_t thermo16_data_t;
84 
88 typedef struct
89 {
90  // Modules
91 
92  analog_in_t adc;
93  analog_in_resolution_t adc_res;
94 
95 } thermo16_t;
96 
100 typedef struct
101 {
102  // Communication gpio pins
103 
104  pin_name_t an_pin;
105 
106  // static variable
107 
108  analog_in_resolution_t resolution; // Resolution
109  float vref; // VRef
110 
112  // End types group
114 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
115 
121 #ifdef __cplusplus
122 extern "C"{
123 #endif
124 
133 void thermo16_cfg_setup ( thermo16_cfg_t *cfg );
134 
144 
154 
164 float thermo16_get_temperature ( thermo16_t *ctx, uint8_t temp_format );
165 
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 #endif // _THERMO16_H_
171  // End public_function group
174 
175 // ------------------------------------------------------------------------ END
THERMO16_RETVAL thermo16_init(thermo16_t *ctx, thermo16_cfg_t *cfg)
Initialization function.
analog_in_t adc
Definition: thermo16.h:92
float thermo16_get_temperature(thermo16_t *ctx, uint8_t temp_format)
Temperature function.
pin_name_t an_pin
Definition: thermo16.h:104
void thermo16_cfg_setup(thermo16_cfg_t *cfg)
Config Object Initialization function.
thermo16_data_t thermo16_generic_read(thermo16_t *ctx)
Generic read function.
float vref
Definition: thermo16.h:109
analog_in_resolution_t resolution
Definition: thermo16.h:108
analog_in_resolution_t adc_res
Definition: thermo16.h:93
Click ctx object definition.
Definition: thermo16.h:88
#define THERMO16_RETVAL
Definition: thermo16.h:58
Click configuration structure definition.
Definition: thermo16.h:100
uint16_t thermo16_data_t
Analog data type.
Definition: thermo16.h:83