microwave  2.0.0.0
microwave.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 
35 #ifndef _MICROWAVE_H_
36 #define _MICROWAVE_H_
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_analog_in.h"
49 
50 // -------------------------------------------------------------- PUBLIC MACROS
60 #define MICROWAVE_SAMPLES_COUNT_50 50
61 #define MICROWAVE_SAMPLES_COUNT_100 100
62 #define MICROWAVE_SAMPLES_COUNT_200 200
63 
69 #define MICROWAVE_THRESHOLD_10 10
70 #define MICROWAVE_THRESHOLD_25 25
71 #define MICROWAVE_THRESHOLD_50 50
72 #define MICROWAVE_THRESHOLD_100 100
73 #define MICROWAVE_THRESHOLD_200 200
74 #define MICROWAVE_THRESHOLD_500 500
75 
81 #define MICROWAVE_MAP_MIKROBUS( cfg, mikrobus ) \
82  cfg.out = MIKROBUS( mikrobus, MIKROBUS_AN )
83  // End macros group
86 // --------------------------------------------------------------- PUBLIC TYPES
95 typedef uint16_t microwave_data_t;
96 
100 typedef enum
101 {
104 
106 
110 typedef struct
111 {
112  analog_in_t adc;
113 
114 } microwave_t;
115 
119 typedef struct
120 {
121  // Analog gpio pin.
122  pin_name_t out;
123 
124  // Configuration variables.
125  analog_in_resolution_t resolution; // Resolution
126  float vref; // VRef
127 
129  // End types group
131 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
137 #ifdef __cplusplus
138 extern "C"{
139 #endif
140 
153 void
155 
169 
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 #endif // _MICROWAVE_H_
187  // End public_function group
190 
191 // ------------------------------------------------------------------------ END
microwave_data_t
uint16_t microwave_data_t
Analog data type.
Definition: microwave.h:95
MICROWAVE_ERR_INIT_ADC
@ MICROWAVE_ERR_INIT_ADC
Definition: microwave.h:103
microwave_cfg_t::vref
float vref
Definition: microwave.h:126
microwave_t::adc
analog_in_t adc
Definition: microwave.h:112
microwave_cfg_t::resolution
analog_in_resolution_t resolution
Definition: microwave.h:125
microwave_cfg_setup
void microwave_cfg_setup(microwave_cfg_t *cfg)
Configuration Object Setup function.
microwave_init
microwave_err_t microwave_init(microwave_t *ctx, microwave_cfg_t *cfg)
Click Initialization function.
microwave_cfg_t
Click configuration structure definition.
Definition: microwave.h:120
MICROWAVE_OK
@ MICROWAVE_OK
Definition: microwave.h:102
microwave_err_t
microwave_err_t
Click code error definition.
Definition: microwave.h:101
microwave_generic_read
microwave_data_t microwave_generic_read(microwave_t *ctx)
Generic ADC Read function.
microwave_t
Click context object definition.
Definition: microwave.h:111
microwave_cfg_t::out
pin_name_t out
Definition: microwave.h:122