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 
41 #ifdef PREINIT_SUPPORTED
42 #include "preinit.h"
43 #endif
44 
45 #ifdef MikroCCoreVersion
46  #if MikroCCoreVersion >= 1
47  #include "delays.h"
48  #endif
49 #endif
50 
51 #include "drv_digital_out.h"
52 #include "drv_analog_in.h"
53 
54 // -------------------------------------------------------------- PUBLIC MACROS
55 
65 #define SHTAN_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
69  // End group macro
72 // --------------------------------------------------------------- PUBLIC TYPES
81 typedef enum
82 {
85 
87 
91 typedef enum
92 {
95 
97 
101 typedef struct
102 {
103  // Output pins
104 
105  digital_out_t rst;
106  digital_out_t cs;
107 
108  float vdd;
109 
110  // Modules
111 
112  analog_in_t adc;
113 
114 } shtan_t;
115 
119 typedef struct
120 {
121  // Communication gpio pins
122 
123  pin_name_t an;
124 
125  // Additional gpio pins
126 
127  pin_name_t rst;
128  pin_name_t cs;
129 
130  // Static variable
131 
132  analog_in_resolution_t resolution; // Resolution
133  float vref; // Reference voltage
134  float vdd; // Power supply voltage
135 
136 } shtan_cfg_t;
137  // End types group
139 
140 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
141 
147 #ifdef __cplusplus
148 extern "C"{
149 #endif
150 
160 
171 err_t shtan_init ( shtan_t *ctx, shtan_cfg_t *cfg );
172 
183 err_t shtan_read_adc ( shtan_t *ctx, uint16_t *data_out );
184 
195 err_t shtan_read_an_voltage ( shtan_t *ctx, float *data_out );
196 
209 err_t shtan_meas_temperature ( shtan_t *ctx, float *data_out, shtan_temp_mode_t sel );
210 
221 err_t shtan_meas_humidity ( shtan_t *ctx, float *data_out );
222 
234 
244 void shtan_reset ( shtan_t *ctx );
245 
246 #ifdef __cplusplus
247 }
248 #endif
249 #endif // SHTAN_H
250  // End public_function group
253 
254 // ------------------------------------------------------------------------ END
shtan_cfg_t::vref
float vref
Definition: shtan.h:133
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:108
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:84
shtan_cfg_t::resolution
analog_in_resolution_t resolution
Definition: shtan.h:132
SHTAN_SET_TEMP_MODE_DEG_F
@ SHTAN_SET_TEMP_MODE_DEG_F
Definition: shtan.h:94
SHTAN_SET_ADC_MODE_TEMP
@ SHTAN_SET_ADC_MODE_TEMP
Definition: shtan.h:83
shtan_t::cs
digital_out_t cs
Definition: shtan.h:106
shtan_t::adc
analog_in_t adc
Definition: shtan.h:112
shtan_cfg_t::rst
pin_name_t rst
Definition: shtan.h:127
shtan_t::rst
digital_out_t rst
Definition: shtan.h:105
shtan_cfg_t::an
pin_name_t an
Definition: shtan.h:123
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:134
shtan_init
err_t shtan_init(shtan_t *ctx, shtan_cfg_t *cfg)
Initialization function.
shtan_t
Click ctx object definition.
Definition: shtan.h:102
shtan_temp_mode_t
shtan_temp_mode_t
Click temperature unit mode descriptors.
Definition: shtan.h:92
shtan_cfg_t::cs
pin_name_t cs
Definition: shtan.h:128
SHTAN_SET_TEMP_MODE_DEG_C
@ SHTAN_SET_TEMP_MODE_DEG_C
Definition: shtan.h:93
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:120
shtan_adc_mode_t
shtan_adc_mode_t
Click adc mode descriptors.
Definition: shtan.h:82