mic  2.0.0.0
mic.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 MIC_H
36 #define MIC_H
37 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 #include "drv_analog_in.h"
55 
56 // -------------------------------------------------------------- PUBLIC MACROS
57 
67 #define MIC_MAP_MIKROBUS( cfg, mikrobus ) \
68  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
69 
75 #define MIC_RETVAL uint8_t
76 
77 #define MIC_OK 0x00
78 #define MIC_INIT_ERROR 0xFF
79  // End group macro
82 // --------------------------------------------------------------- PUBLIC TYPES
91 typedef uint16_t mic_data_t;
92 
96 typedef struct
97 {
98  // Modules
99 
100  analog_in_t adc;
101 
102 } mic_t;
103 
107 typedef struct
108 {
109  // Communication gpio pins
110 
111  pin_name_t an_pin;
112 
113  // static variable
114 
115  analog_in_resolution_t resolution; // Resolution
116  float vref; // VRef
117 
118 } mic_cfg_t;
119  // End types group
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
140 void mic_cfg_setup ( mic_cfg_t *cfg );
141 
151 
159 void mic_default_cfg ( mic_t *ctx );
160 
170 
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 #endif // _MIC_H_
176  // End public_function group
179 
180 // ------------------------------------------------------------------------ END
mic_cfg_t::vref
float vref
Definition: mic.h:116
mic_cfg_setup
void mic_cfg_setup(mic_cfg_t *cfg)
Config Object Initialization function.
mic_cfg_t::an_pin
pin_name_t an_pin
Definition: mic.h:111
mic_generic_read
mic_data_t mic_generic_read(mic_t *ctx)
Generic read function.
mic_cfg_t::resolution
analog_in_resolution_t resolution
Definition: mic.h:115
mic_t
Click ctx object definition.
Definition: mic.h:97
mic_cfg_t
Click configuration structure definition.
Definition: mic.h:108
mic_init
MIC_RETVAL mic_init(mic_t *ctx, mic_cfg_t *cfg)
Initialization function.
MIC_RETVAL
#define MIC_RETVAL
Definition: mic.h:75
mic_default_cfg
void mic_default_cfg(mic_t *ctx)
Click Default Configuration function.
mic_data_t
uint16_t mic_data_t
Analog data type.
Definition: mic.h:91
mic_t::adc
analog_in_t adc
Definition: mic.h:100