shtan  2.0.0.0
shtan.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 SHTAN_H
35 #define SHTAN_H
36 
37 #include "drv_digital_out.h"
38 #include "drv_analog_in.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
41 
51 #define SHTAN_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
55  // End group macro
58 // --------------------------------------------------------------- PUBLIC TYPES
67 typedef enum
68 {
71 
73 
77 typedef enum
78 {
81 
83 
87 typedef struct
88 {
89  // Output pins
90 
91  digital_out_t rst;
92  digital_out_t cs;
93 
94  float vdd;
95 
96  // Modules
97 
98  analog_in_t adc;
99 
100 } shtan_t;
101 
105 typedef struct
106 {
107  // Communication gpio pins
108 
109  pin_name_t an;
110 
111  // Additional gpio pins
112 
113  pin_name_t rst;
114  pin_name_t cs;
115 
116  // Static variable
117 
118  analog_in_resolution_t resolution; // Resolution
119  float vref; // Reference voltage
120  float vdd; // Power supply voltage
121 
122 } shtan_cfg_t;
123  // End types group
125 
126 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
127 
133 #ifdef __cplusplus
134 extern "C"{
135 #endif
136 
146 
157 err_t shtan_init ( shtan_t *ctx, shtan_cfg_t *cfg );
158 
169 err_t shtan_read_adc ( shtan_t *ctx, uint16_t *data_out );
170 
181 err_t shtan_read_an_voltage ( shtan_t *ctx, float *data_out );
182 
195 err_t shtan_meas_temperature ( shtan_t *ctx, float *data_out, shtan_temp_mode_t sel );
196 
207 err_t shtan_meas_humidity ( shtan_t *ctx, float *data_out );
208 
220 
230 void shtan_reset ( shtan_t *ctx );
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 #endif // SHTAN_H
236  // End public_function group
239 
240 // ------------------------------------------------------------------------ END
shtan_cfg_t::vref
float vref
Definition: shtan.h:119
shtan_read_an_voltage
err_t shtan_read_an_voltage(shtan_t *ctx, float *data_out)
AN voltage read function.
shtan_t::vdd
float vdd
Definition: shtan.h:94
shtan_meas_humidity
err_t shtan_meas_humidity(shtan_t *ctx, float *data_out)
Humidity measure function.
shtan_reset
void shtan_reset(shtan_t *ctx)
Hardware reset function.
SHTAN_SET_ADC_MODE_HUM
@ SHTAN_SET_ADC_MODE_HUM
Definition: shtan.h:70
shtan_cfg_t::resolution
analog_in_resolution_t resolution
Definition: shtan.h:118
SHTAN_SET_TEMP_MODE_DEG_F
@ SHTAN_SET_TEMP_MODE_DEG_F
Definition: shtan.h:80
SHTAN_SET_ADC_MODE_TEMP
@ SHTAN_SET_ADC_MODE_TEMP
Definition: shtan.h:69
shtan_t::cs
digital_out_t cs
Definition: shtan.h:92
shtan_t::adc
analog_in_t adc
Definition: shtan.h:98
shtan_cfg_t::rst
pin_name_t rst
Definition: shtan.h:113
shtan_t::rst
digital_out_t rst
Definition: shtan.h:91
shtan_cfg_t::an
pin_name_t an
Definition: shtan.h:109
shtan_read_adc
err_t shtan_read_adc(shtan_t *ctx, uint16_t *data_out)
ADC read function.
shtan_set_mode
void shtan_set_mode(shtan_t *ctx, shtan_adc_mode_t sel)
Set ADC mode function.
shtan_cfg_t::vdd
float vdd
Definition: shtan.h:120
shtan_init
err_t shtan_init(shtan_t *ctx, shtan_cfg_t *cfg)
Initialization function.
shtan_t
Click ctx object definition.
Definition: shtan.h:88
shtan_temp_mode_t
shtan_temp_mode_t
Click temperature unit mode descriptors.
Definition: shtan.h:78
shtan_cfg_t::cs
pin_name_t cs
Definition: shtan.h:114
SHTAN_SET_TEMP_MODE_DEG_C
@ SHTAN_SET_TEMP_MODE_DEG_C
Definition: shtan.h:79
shtan_meas_temperature
err_t shtan_meas_temperature(shtan_t *ctx, float *data_out, shtan_temp_mode_t sel)
Temperature measure function.
shtan_cfg_setup
void shtan_cfg_setup(shtan_cfg_t *cfg)
Config Object Initialization function.
shtan_cfg_t
Click configuration structure definition.
Definition: shtan.h:106
shtan_adc_mode_t
shtan_adc_mode_t
Click adc mode descriptors.
Definition: shtan.h:68