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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_analog_in.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
43 
53 #define SLIDER2_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
55  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
56  cfg.rsl = MIKROBUS( mikrobus, MIKROBUS_PWM )
57 
63 #define SLIDER2_RETVAL uint8_t
64 
65 #define SLIDER2_OK 0x00
66 #define SLIDER2_INIT_ERROR 0xFF
67 
73 #define SLIDER2_DEVICE_ENABLE 1
74 #define SLIDER2_DEVICE_DISABLE 0
75 
81 #define SLIDER2_MAX_VOLTAGE_2_048V 1
82 #define SLIDER2_MAX_VOLTAGE_4_096V 0
83  // End group macro
86 // --------------------------------------------------------------- PUBLIC TYPES
95 typedef uint16_t slider2_data_t;
96 
100 typedef struct
101 {
102  // Output pins
103 
104  digital_out_t en;
105  digital_out_t rsl;
106 
107  // Modules
108 
109  analog_in_t adc;
110 
111 } slider2_t;
112 
116 typedef struct
117 {
118  // Communication gpio pins
119 
120  pin_name_t an_pin;
121 
122  // Additional gpio pins
123 
124  pin_name_t en;
125  pin_name_t rsl;
126 
127  // static variable
128 
129  analog_in_resolution_t resolution; // Resolution
130  float vref; // VRef
131 
132 } slider2_cfg_t;
133  // End types group
135 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
136 
142 #ifdef __cplusplus
143 extern "C"{
144 #endif
145 
155 
165 
174 
184 
193 void slider2_enable ( slider2_t *ctx, uint8_t state );
194 
203 void slider2_set_reference ( slider2_t *ctx, uint8_t ref );
204 
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 #endif // _SLIDER2_H_
210  // End public_function group
213 
214 // ------------------------------------------------------------------------ END
slider2_cfg_t::an_pin
pin_name_t an_pin
Definition: slider2.h:120
slider2_t::en
digital_out_t en
Definition: slider2.h:104
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:129
SLIDER2_RETVAL
#define SLIDER2_RETVAL
Definition: slider2.h:63
slider2_t::adc
analog_in_t adc
Definition: slider2.h:109
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:105
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:117
slider2_cfg_t::vref
float vref
Definition: slider2.h:130
slider2_data_t
uint16_t slider2_data_t
Analog data type.
Definition: slider2.h:95
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:125
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:124
slider2_t
Click ctx object definition.
Definition: slider2.h:101