slider2  2.0.0.0
slider2.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 SLIDER2_H
36 #define SLIDER2_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_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_analog_in.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
53 
63 #define SLIDER2_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
65  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
66  cfg.rsl = MIKROBUS( mikrobus, MIKROBUS_PWM )
67 
73 #define SLIDER2_RETVAL uint8_t
74 
75 #define SLIDER2_OK 0x00
76 #define SLIDER2_INIT_ERROR 0xFF
77 
83 #define SLIDER2_DEVICE_ENABLE 1
84 #define SLIDER2_DEVICE_DISABLE 0
85 
91 #define SLIDER2_MAX_VOLTAGE_2_048V 1
92 #define SLIDER2_MAX_VOLTAGE_4_096V 0
93  // End group macro
96 // --------------------------------------------------------------- PUBLIC TYPES
105 typedef uint16_t slider2_data_t;
106 
110 typedef struct
111 {
112  // Output pins
113 
114  digital_out_t en;
115  digital_out_t rsl;
116 
117  // Modules
118 
119  analog_in_t adc;
120 
121 } slider2_t;
122 
126 typedef struct
127 {
128  // Communication gpio pins
129 
130  pin_name_t an_pin;
131 
132  // Additional gpio pins
133 
134  pin_name_t en;
135  pin_name_t rsl;
136 
137  // static variable
138 
139  analog_in_resolution_t resolution; // Resolution
140  float vref; // VRef
141 
142 } slider2_cfg_t;
143  // End types group
145 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
146 
152 #ifdef __cplusplus
153 extern "C"{
154 #endif
155 
165 
175 
184 
194 
203 void slider2_enable ( slider2_t *ctx, uint8_t state );
204 
213 void slider2_set_reference ( slider2_t *ctx, uint8_t ref );
214 
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 #endif // _SLIDER2_H_
220  // End public_function group
223 
224 // ------------------------------------------------------------------------ END
slider2_cfg_t::an_pin
pin_name_t an_pin
Definition: slider2.h:130
slider2_t::en
digital_out_t en
Definition: slider2.h:114
slider2_cfg_setup
void slider2_cfg_setup(slider2_cfg_t *cfg)
Config Object Initialization function.
slider2_cfg_t::resolution
analog_in_resolution_t resolution
Definition: slider2.h:139
SLIDER2_RETVAL
#define SLIDER2_RETVAL
Definition: slider2.h:73
slider2_t::adc
analog_in_t adc
Definition: slider2.h:119
slider2_set_reference
void slider2_set_reference(slider2_t *ctx, uint8_t ref)
Setting reference function.
slider2_t::rsl
digital_out_t rsl
Definition: slider2.h:115
slider2_init
SLIDER2_RETVAL slider2_init(slider2_t *ctx, slider2_cfg_t *cfg)
Initialization function.
slider2_cfg_t
Click configuration structure definition.
Definition: slider2.h:127
slider2_cfg_t::vref
float vref
Definition: slider2.h:140
slider2_data_t
uint16_t slider2_data_t
Analog data type.
Definition: slider2.h:105
slider2_enable
void slider2_enable(slider2_t *ctx, uint8_t state)
Setting state function.
slider2_cfg_t::rsl
pin_name_t rsl
Definition: slider2.h:135
slider2_default_cfg
void slider2_default_cfg(slider2_t *ctx)
Click Default Configuration function.
slider2_generic_read
slider2_data_t slider2_generic_read(slider2_t *ctx)
Generic read function.
slider2_cfg_t::en
pin_name_t en
Definition: slider2.h:134
slider2_t
Click ctx object definition.
Definition: slider2.h:111