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 "drv_analog_in.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
41 
51 #define POT2_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
53  // End group macro
56 // --------------------------------------------------------------- PUBLIC TYPES
65 typedef struct
66 {
67  // Modules
68 
69  analog_in_t adc;
70 
71 } pot2_t;
72 
76 typedef struct
77 {
78  // Communication gpio pins
79 
80  pin_name_t an_pin;
81 
82  // Static variable
83 
84  analog_in_resolution_t resolution;
85  float vref;
87 } pot2_cfg_t;
88  // End types group
90 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
91 
97 #ifdef __cplusplus
98 extern "C"{
99 #endif
100 
110 void pot2_cfg_setup ( pot2_cfg_t *cfg );
111 
125 err_t pot2_init ( pot2_t *ctx, pot2_cfg_t *cfg );
126 
137 err_t pot2_read_adc ( pot2_t *ctx, uint16_t *data_out );
138 
149 err_t pot2_read_pin_voltage ( pot2_t *ctx, float *data_out );
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 #endif // _POT2_H_
155  // End public_function group
158 
159 // ------------------------------------------------------------------------ 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:69
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:76
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:84
pot2_t
Click ctx object definition.
Definition: pot2.h:65
pot2_cfg_t::vref
float vref
Definition: pot2.h:85
pot2_cfg_t::an_pin
pin_name_t an_pin
Definition: pot2.h:80
pot2_read_adc
err_t pot2_read_adc(pot2_t *ctx, uint16_t *data_out)
Generic read function.