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 ) // End group macro
58// --------------------------------------------------------------- PUBLIC TYPES
67typedef enum
68{
71
73
77typedef enum
78{
81
83
87typedef 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
105typedef 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
123 // End types group
125
126// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
127
133#ifdef __cplusplus
134extern "C"{
135#endif
136
146
157err_t shtan_init ( shtan_t *ctx, shtan_cfg_t *cfg );
158
169err_t shtan_read_adc ( shtan_t *ctx, uint16_t *data_out );
170
181err_t shtan_read_an_voltage ( shtan_t *ctx, float *data_out );
182
195err_t shtan_meas_temperature ( shtan_t *ctx, float *data_out, shtan_temp_mode_t sel );
196
207err_t shtan_meas_humidity ( shtan_t *ctx, float *data_out );
208
220
230void shtan_reset ( shtan_t *ctx );
231
232#ifdef __cplusplus
233}
234#endif
235#endif // SHTAN_H
236 // End public_function group
239
240// ------------------------------------------------------------------------ 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:78
shtan_adc_mode_t
Click adc mode descriptors.
Definition: shtan.h:68
@ SHTAN_SET_TEMP_MODE_DEG_C
Definition: shtan.h:79
@ SHTAN_SET_TEMP_MODE_DEG_F
Definition: shtan.h:80
@ SHTAN_SET_ADC_MODE_HUM
Definition: shtan.h:70
@ SHTAN_SET_ADC_MODE_TEMP
Definition: shtan.h:69
Click configuration structure definition.
Definition: shtan.h:106
analog_in_resolution_t resolution
Definition: shtan.h:118
float vref
Definition: shtan.h:119
float vdd
Definition: shtan.h:120
pin_name_t rst
Definition: shtan.h:113
pin_name_t an
Definition: shtan.h:109
pin_name_t cs
Definition: shtan.h:114
Click ctx object definition.
Definition: shtan.h:88
digital_out_t cs
Definition: shtan.h:92
float vdd
Definition: shtan.h:94
digital_out_t rst
Definition: shtan.h:91
analog_in_t adc
Definition: shtan.h:98