pollution  2.0.0.0
pollution.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 POLLUTION_H
35 #define POLLUTION_H
36 
37 #include "drv_digital_out.h"
38 #include "drv_digital_in.h"
39 #include "drv_analog_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define POLLUTION_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.ena = MIKROBUS( mikrobus, MIKROBUS_RST )
54 
60 #define POLLUTION_RETVAL uint8_t
61 
62 #define POLLUTION_OK 0x00
63 #define POLLUTION_INIT_ERROR 0xFF
64  // End group macro
67 
68 // --------------------------------------------------------------- PUBLIC TYPES
77 typedef uint16_t pollution_data_t;
78 
82 typedef struct
83 {
84  // Output pins
85 
86  digital_out_t ena;
87 
88  // Modules
89 
90  analog_in_t adc;
91 
92 } pollution_t;
93 
97 typedef struct
98 {
99  // Communication gpio pins
100 
101  pin_name_t an_pin;
102 
103  // Additional gpio pins
104 
105  pin_name_t ena;
106 
107  // Static variable
108 
109  analog_in_resolution_t resolution; // Resolution
110  float vref; // VRef
111 
113  // End types group
115 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
121 #ifdef __cplusplus
122 extern "C"{
123 #endif
124 
134 
144 
162 void pollution_default_cfg ( pollution_t *ctx );
163 
173 
182 void pollution_enable ( pollution_t *ctx );
183 
192 void pollution_disable ( pollution_t *ctx );
193 
207 void pollution_reset ( pollution_t *ctx );
208 
219 
230 
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 #endif // _POLLUTION_H_
246  // End public_function group
249 
250 // ------------------------------------------------------------------------ END
void pollution_cfg_setup(pollution_cfg_t *cfg)
Config Object Initialization function.
void pollution_enable(pollution_t *ctx)
Enable sensor function.
pin_name_t an_pin
Definition: pollution.h:101
analog_in_t adc
Definition: pollution.h:90
#define POLLUTION_RETVAL
Definition: pollution.h:60
POLLUTION_RETVAL pollution_init(pollution_t *ctx, pollution_cfg_t *cfg)
Initialization function.
pin_name_t ena
Definition: pollution.h:105
float pollution_get_corrected_resistance(pollution_t *ctx)
Get the corrected resistance of the sensor function.
Click ctx object definition.
Definition: pollution.h:82
Click configuration structure definition.
Definition: pollution.h:97
void pollution_reset(pollution_t *ctx)
Reset sensor function.
float pollution_get_resistance(pollution_t *ctx)
Get the resistance of the sensor function.
void pollution_disable(pollution_t *ctx)
Disable sensor function.
float vref
Definition: pollution.h:110
digital_out_t ena
Definition: pollution.h:86
float pollution_measure_load_voltage(pollution_t *ctx)
Measure load voltage form ADC function.
void pollution_default_cfg(pollution_t *ctx)
Click Default Configuration function.
pollution_data_t pollution_generic_read(pollution_t *ctx)
Generic read function.
analog_in_resolution_t resolution
Definition: pollution.h:109
uint16_t pollution_data_t
Analog data type.
Definition: pollution.h:77