airquality  2.0.0.0
airquality.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 AIRQUALITY_H
29 #define AIRQUALITY_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_analog_in.h"
36 
67 #define AIRQUALITY_MAP_MIKROBUS( cfg, mikrobus ) \
68  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
69 
70  // airquality_map // airquality
72 
77 typedef struct {
78 
79  analog_in_t adc;
81 } airquality_t;
82 
87 typedef struct {
88 
89  // Communication gpio pins
90 
91  pin_name_t an;
93  // static variable
94 
95  analog_in_resolution_t resolution;
96  float vref;
99 
104 typedef enum {
106  AIRQUALITY_ERROR = -1
107 
109 
126 
141 err_t airquality_init ( airquality_t *ctx, airquality_cfg_t *cfg );
142 
155 err_t airquality_read_an_pin_value ( airquality_t *ctx, uint16_t *data_out );
156 
171 err_t airquality_read_an_pin_voltage ( airquality_t *ctx, float *data_out );
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 #endif // AIRQUALITY_H
177  // airquality
179 
180 // ------------------------------------------------------------------------ END
airquality_init
err_t airquality_init(airquality_t *ctx, airquality_cfg_t *cfg)
Air quality initialization function.
airquality_cfg_setup
void airquality_cfg_setup(airquality_cfg_t *cfg)
Air quality configuration object setup function.
AIRQUALITY_ERROR
Definition: airquality.h:105
airquality_t
Air quality Click context object.
Definition: airquality.h:76
airquality_read_an_pin_voltage
err_t airquality_read_an_pin_voltage(airquality_t *ctx, float *data_out)
Air quality read AN pin voltage level function.
airquality_read_an_pin_value
err_t airquality_read_an_pin_value(airquality_t *ctx, uint16_t *data_out)
Air quality read AN pin value function.
airquality_cfg_t
Air quality Click configuration object.
Definition: airquality.h:86
airquality_return_value_t
airquality_return_value_t
Air quality Click return value data.
Definition: airquality.h:103
AIRQUALITY_OK
Definition: airquality.h:104