pot2  2.0.0.0
pot2.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 POT2_H
36 #define POT2_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
51 
61 #define POT2_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
63  // End group macro
66 // --------------------------------------------------------------- PUBLIC TYPES
75 typedef struct
76 {
77  // Modules
78 
79  analog_in_t adc;
80 
81 } pot2_t;
82 
86 typedef struct
87 {
88  // Communication gpio pins
89 
90  pin_name_t an_pin;
91 
92  // Static variable
93 
94  analog_in_resolution_t resolution;
95  float vref;
97 } pot2_cfg_t;
98  // End types group
100 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
101 
107 #ifdef __cplusplus
108 extern "C"{
109 #endif
110 
121 
135 err_t pot2_init ( pot2_t *ctx, pot2_cfg_t *cfg );
136 
147 err_t pot2_read_adc ( pot2_t *ctx, uint16_t *data_out );
148 
159 err_t pot2_read_pin_voltage ( pot2_t *ctx, float *data_out );
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 #endif // _POT2_H_
165  // End public_function group
168 
169 // ------------------------------------------------------------------------ END
pot2_cfg_setup
void pot2_cfg_setup(pot2_cfg_t *cfg)
Config Object Initialization function.
pot2_t::adc
analog_in_t adc
Definition: pot2.h:79
pot2_read_pin_voltage
err_t pot2_read_pin_voltage(pot2_t *ctx, float *data_out)
Generic read function.
pot2_cfg_t
Click configuration structure definition.
Definition: pot2.h:87
pot2_init
err_t pot2_init(pot2_t *ctx, pot2_cfg_t *cfg)
Initialization function.
pot2_cfg_t::resolution
analog_in_resolution_t resolution
Definition: pot2.h:94
pot2_t
Click ctx object definition.
Definition: pot2.h:76
pot2_cfg_t::vref
float vref
Definition: pot2.h:95
pot2_cfg_t::an_pin
pin_name_t an_pin
Definition: pot2.h:90
pot2_read_adc
err_t pot2_read_adc(pot2_t *ctx, uint16_t *data_out)
Generic read function.