thermo16  2.0.0.0
thermo16.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 
34 #ifndef THERMO16_H
35 #define THERMO16_H
36 
37 #include "mikrosdk_version.h"
38 
39 #ifdef __GNUC__
40 #if mikroSDK_GET_VERSION < 20800ul
41 #include "rcu_delays.h"
42 #else
43 #include "delays.h"
44 #endif
45 #endif
46 
47 #include "drv_analog_in.h"
48 
49 // -------------------------------------------------------------- PUBLIC MACROS
50 
60 #define THERMO16_MAP_MIKROBUS( cfg, mikrobus ) \
61  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
62 
68 #define THERMO16_RETVAL uint8_t
69 
70 #define THERMO16_OK 0x00
71 #define THERMO16_INIT_ERROR 0xFF
72 
78 #define THERMO16_TEMP_IN_CELSIUS 0x00
79 #define THERMO16_TEMP_IN_KELVIN 0x01
80 #define THERMO16_TEMP_IN_FAHRENHEIT 0x02
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef uint16_t thermo16_data_t;
94 
98 typedef struct
99 {
100  // Modules
101 
102  analog_in_t adc;
103  analog_in_resolution_t adc_res;
104 
105 } thermo16_t;
106 
110 typedef struct
111 {
112  // Communication gpio pins
113 
114  pin_name_t an_pin;
115 
116  // static variable
117 
118  analog_in_resolution_t resolution; // Resolution
119  float vref; // VRef
120 
122  // End types group
124 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
125 
131 #ifdef __cplusplus
132 extern "C"{
133 #endif
134 
144 
154 
164 
174 float thermo16_get_temperature ( thermo16_t *ctx, uint8_t temp_format );
175 
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 #endif // _THERMO16_H_
181  // End public_function group
184 
185 // ------------------------------------------------------------------------ END
thermo16_t::adc_res
analog_in_resolution_t adc_res
Definition: thermo16.h:103
thermo16_cfg_t::vref
float vref
Definition: thermo16.h:119
thermo16_cfg_setup
void thermo16_cfg_setup(thermo16_cfg_t *cfg)
Config Object Initialization function.
THERMO16_RETVAL
#define THERMO16_RETVAL
Definition: thermo16.h:68
thermo16_t
Click ctx object definition.
Definition: thermo16.h:99
thermo16_cfg_t::resolution
analog_in_resolution_t resolution
Definition: thermo16.h:118
thermo16_generic_read
thermo16_data_t thermo16_generic_read(thermo16_t *ctx)
Generic read function.
thermo16_cfg_t
Click configuration structure definition.
Definition: thermo16.h:111
thermo16_get_temperature
float thermo16_get_temperature(thermo16_t *ctx, uint8_t temp_format)
Temperature function.
thermo16_cfg_t::an_pin
pin_name_t an_pin
Definition: thermo16.h:114
thermo16_data_t
uint16_t thermo16_data_t
Analog data type.
Definition: thermo16.h:93
thermo16_t::adc
analog_in_t adc
Definition: thermo16.h:102
thermo16_init
THERMO16_RETVAL thermo16_init(thermo16_t *ctx, thermo16_cfg_t *cfg)
Initialization function.