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 
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_analog_in.h"
53 
54 // -------------------------------------------------------------- PUBLIC MACROS
55 
65 #define POT2_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
67  // End group macro
70 // --------------------------------------------------------------- PUBLIC TYPES
79 typedef struct
80 {
81  // Modules
82 
83  analog_in_t adc;
84 
85 } pot2_t;
86 
90 typedef struct
91 {
92  // Communication gpio pins
93 
94  pin_name_t an_pin;
95 
96  // Static variable
97 
98  analog_in_resolution_t resolution;
99  float vref;
101 } pot2_cfg_t;
102  // End types group
104 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
105 
111 #ifdef __cplusplus
112 extern "C"{
113 #endif
114 
125 
139 err_t pot2_init ( pot2_t *ctx, pot2_cfg_t *cfg );
140 
151 err_t pot2_read_adc ( pot2_t *ctx, uint16_t *data_out );
152 
163 err_t pot2_read_pin_voltage ( pot2_t *ctx, float *data_out );
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 #endif // _POT2_H_
169  // End public_function group
172 
173 // ------------------------------------------------------------------------ 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:83
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:91
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:98
pot2_t
Click ctx object definition.
Definition: pot2.h:80
pot2_cfg_t::vref
float vref
Definition: pot2.h:99
pot2_cfg_t::an_pin
pin_name_t an_pin
Definition: pot2.h:94
pot2_read_adc
err_t pot2_read_adc(pot2_t *ctx, uint16_t *data_out)
Generic read function.