pot  2.0.0.0
pot.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 
34 #ifndef POT_H
35 #define POT_H
36 
37 #include "drv_digital_out.h"
38 #include "drv_digital_in.h"
39 #include "drv_analog_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define POT_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 } pot_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; // Resolution
85  float vref; // VRef
86 
87 } pot_cfg_t;
88  // End types group
90 
91 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
92 
98 #ifdef __cplusplus
99 extern "C"{
100 #endif
101 
110 void pot_cfg_setup ( pot_cfg_t *cfg );
111 
122 err_t pot_init ( pot_t *ctx, pot_cfg_t *cfg );
123 
132 uint16_t pot_generic_read ( pot_t *ctx );
133 
142 float pot_read_voltage ( pot_t *ctx );
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 #endif // _POT_H_
148  // End public_function group
151 
152 // ------------------------------------------------------------------------ END
pot_cfg_setup
void pot_cfg_setup(pot_cfg_t *cfg)
Config Object Initialization function.
pot_read_voltage
float pot_read_voltage(pot_t *ctx)
Generic read voltage function.
pot_cfg_t
Click configuration structure definition.
Definition: pot.h:76
pot_cfg_t::resolution
analog_in_resolution_t resolution
Definition: pot.h:84
pot_t::adc
analog_in_t adc
Definition: pot.h:69
pot_init
err_t pot_init(pot_t *ctx, pot_cfg_t *cfg)
Initialization function.
pot_cfg_t::an_pin
pin_name_t an_pin
Definition: pot.h:80
pot_t
Click ctx object definition.
Definition: pot.h:65
pot_generic_read
uint16_t pot_generic_read(pot_t *ctx)
Generic read function.
pot_cfg_t::vref
float vref
Definition: pot.h:85