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
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_digital_in.h"
53#include "drv_analog_in.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define POLLUTION_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67 cfg.ena = MIKROBUS( mikrobus, MIKROBUS_RST )
74#define POLLUTION_RETVAL uint8_t
75
76#define POLLUTION_OK 0x00
77#define POLLUTION_INIT_ERROR 0xFF
80 // End group macro
81
82// --------------------------------------------------------------- PUBLIC TYPES
91typedef uint16_t pollution_data_t;
92
96typedef struct
97{
98 // Output pins
99
100 digital_out_t ena;
101
102 // Modules
103
104 analog_in_t adc;
105
107
111typedef struct
112{
113 // Communication gpio pins
114
115 pin_name_t an_pin;
116
117 // Additional gpio pins
118
119 pin_name_t ena;
120
121 // Static variable
122
123 analog_in_resolution_t resolution; // Resolution
124 float vref; // VRef
125
127
128 // End types group
129// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
135#ifdef __cplusplus
136extern "C"{
137#endif
138
148
158
177
187
197
207
222
233
244
255
256#ifdef __cplusplus
257}
258#endif
259#endif // _POLLUTION_H_
260
261 // End public_function group
263
264// ------------------------------------------------------------------------ END
#define POLLUTION_RETVAL
Definition pollution.h:74
void pollution_disable(pollution_t *ctx)
Disable sensor function.
void pollution_reset(pollution_t *ctx)
Reset sensor function.
float pollution_get_resistance(pollution_t *ctx)
Get the resistance of the sensor function.
POLLUTION_RETVAL pollution_init(pollution_t *ctx, pollution_cfg_t *cfg)
Initialization function.
void pollution_cfg_setup(pollution_cfg_t *cfg)
Config Object Initialization function.
pollution_data_t pollution_generic_read(pollution_t *ctx)
Generic read function.
void pollution_enable(pollution_t *ctx)
Enable sensor function.
float pollution_get_corrected_resistance(pollution_t *ctx)
Get the corrected resistance of the sensor function.
void pollution_default_cfg(pollution_t *ctx)
Click Default Configuration function.
float pollution_measure_load_voltage(pollution_t *ctx)
Measure load voltage form ADC function.
uint16_t pollution_data_t
Analog data type.
Definition pollution.h:91
Click configuration structure definition.
Definition pollution.h:112
analog_in_resolution_t resolution
Definition pollution.h:123
float vref
Definition pollution.h:124
pin_name_t ena
Definition pollution.h:119
pin_name_t an_pin
Definition pollution.h:115
Click ctx object definition.
Definition pollution.h:97
digital_out_t ena
Definition pollution.h:100
analog_in_t adc
Definition pollution.h:104