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 )
71 // End group macro
72// --------------------------------------------------------------- PUBLIC TYPES
87
97
101typedef 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
119typedef 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
137
138 // End types group
139
140// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
141
147#ifdef __cplusplus
148extern "C"{
149#endif
150
160
171err_t shtan_init ( shtan_t *ctx, shtan_cfg_t *cfg );
172
183err_t shtan_read_adc ( shtan_t *ctx, uint16_t *data_out );
184
195err_t shtan_read_an_voltage ( shtan_t *ctx, float *data_out );
196
209err_t shtan_meas_temperature ( shtan_t *ctx, float *data_out, shtan_temp_mode_t sel );
210
221err_t shtan_meas_humidity ( shtan_t *ctx, float *data_out );
222
234
244void shtan_reset ( shtan_t *ctx );
245
246#ifdef __cplusplus
247}
248#endif
249#endif // SHTAN_H
250
251 // End public_function group
253
254// ------------------------------------------------------------------------ END
err_t shtan_init(shtan_t *ctx, shtan_cfg_t *cfg)
Initialization function.
err_t shtan_read_adc(shtan_t *ctx, uint16_t *data_out)
ADC read function.
void shtan_reset(shtan_t *ctx)
Hardware reset function.
void shtan_cfg_setup(shtan_cfg_t *cfg)
Config Object Initialization function.
void shtan_set_mode(shtan_t *ctx, shtan_adc_mode_t sel)
Set ADC mode function.
err_t shtan_read_an_voltage(shtan_t *ctx, float *data_out)
AN voltage read function.
err_t shtan_meas_temperature(shtan_t *ctx, float *data_out, shtan_temp_mode_t sel)
Temperature measure function.
err_t shtan_meas_humidity(shtan_t *ctx, float *data_out)
Humidity measure function.
shtan_temp_mode_t
Click temperature unit mode descriptors.
Definition shtan.h:92
shtan_adc_mode_t
Click adc mode descriptors.
Definition shtan.h:82
@ SHTAN_SET_TEMP_MODE_DEG_C
Definition shtan.h:93
@ SHTAN_SET_TEMP_MODE_DEG_F
Definition shtan.h:94
@ SHTAN_SET_ADC_MODE_HUM
Definition shtan.h:84
@ SHTAN_SET_ADC_MODE_TEMP
Definition shtan.h:83
Click configuration structure definition.
Definition shtan.h:120
analog_in_resolution_t resolution
Definition shtan.h:132
float vref
Definition shtan.h:133
float vdd
Definition shtan.h:134
pin_name_t rst
Definition shtan.h:127
pin_name_t an
Definition shtan.h:123
pin_name_t cs
Definition shtan.h:128
Click ctx object definition.
Definition shtan.h:102
digital_out_t cs
Definition shtan.h:106
float vdd
Definition shtan.h:108
digital_out_t rst
Definition shtan.h:105
analog_in_t adc
Definition shtan.h:112