tempiso  2.1.0.0
tempiso.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef TEMPISO_H
29 #define TEMPISO_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_analog_in.h"
52 
73 #define TEMPISO_NUM_CONVERSIONS 100
74 
79 #define TEMPISO_VREF_3V3 3.3
80 #define TEMPISO_VREF_5V 5.0
81 
86 #define TEMPISO_TIMEOUT_MS 2000
87 
92 #define TEMPISO_TEMP_SENS_V_PER_C 0.01f
93 #define TEMPISO_TEMP_ZERO_OFFSET_V 0.5f
94  // tempiso_set
96 
111 #define TEMPISO_MAP_MIKROBUS( cfg, mikrobus ) \
112  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN );
113  // tempiso_map // tempiso
116 
121 typedef struct
122 {
123  analog_in_t adc;
125 } tempiso_t;
126 
131 typedef struct
132 {
133  pin_name_t an;
135  analog_in_resolution_t resolution;
136  float vref;
138 } tempiso_cfg_t;
139 
144 typedef enum
145 {
147  TEMPISO_ERROR = -1
148 
150 
167 
181 err_t tempiso_init ( tempiso_t *ctx, tempiso_cfg_t *cfg );
182 
194 err_t tempiso_read_raw_adc ( tempiso_t *ctx, uint16_t *raw_adc );
195 
207 err_t tempiso_read_voltage ( tempiso_t *ctx, float *voltage );
208 
221 err_t tempiso_read_voltage_avg ( tempiso_t *ctx, uint16_t num_conv, float *voltage_avg );
222 
234 err_t tempiso_set_vref ( tempiso_t *ctx, float vref );
235 
248 err_t tempiso_read_temperature ( tempiso_t *ctx, float *data_out );
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 #endif // TEMPISO_H
254  // tempiso
256 
257 // ------------------------------------------------------------------------ END
TEMPISO_ERROR
@ TEMPISO_ERROR
Definition: tempiso.h:147
tempiso_read_raw_adc
err_t tempiso_read_raw_adc(tempiso_t *ctx, uint16_t *raw_adc)
Temp ISO read raw ADC value function.
tempiso_t::adc
analog_in_t adc
Definition: tempiso.h:123
tempiso_set_vref
err_t tempiso_set_vref(tempiso_t *ctx, float vref)
Temp ISO set vref function.
tempiso_read_temperature
err_t tempiso_read_temperature(tempiso_t *ctx, float *data_out)
Temp ISO read temperature function.
tempiso_cfg_t::resolution
analog_in_resolution_t resolution
Definition: tempiso.h:135
tempiso_t
Temp ISO Click context object.
Definition: tempiso.h:122
tempiso_read_voltage_avg
err_t tempiso_read_voltage_avg(tempiso_t *ctx, uint16_t num_conv, float *voltage_avg)
Temp ISO read average voltage level function.
tempiso_return_value_t
tempiso_return_value_t
Temp ISO Click return value data.
Definition: tempiso.h:145
tempiso_init
err_t tempiso_init(tempiso_t *ctx, tempiso_cfg_t *cfg)
Temp ISO initialization function.
tempiso_read_voltage
err_t tempiso_read_voltage(tempiso_t *ctx, float *voltage)
Temp ISO read voltage level function.
tempiso_cfg_t::an
pin_name_t an
Definition: tempiso.h:133
tempiso_cfg_t::vref
float vref
Definition: tempiso.h:136
tempiso_cfg_t
Temp ISO Click configuration object.
Definition: tempiso.h:132
TEMPISO_OK
@ TEMPISO_OK
Definition: tempiso.h:146
tempiso_cfg_setup
void tempiso_cfg_setup(tempiso_cfg_t *cfg)
Temp ISO configuration object setup function.