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
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_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_analog_in.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
57
67#define SLIDER2_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
69 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
70 cfg.rsl = MIKROBUS( mikrobus, MIKROBUS_PWM )
77#define SLIDER2_RETVAL uint8_t
78
79#define SLIDER2_OK 0x00
80#define SLIDER2_INIT_ERROR 0xFF
87#define SLIDER2_DEVICE_ENABLE 1
88#define SLIDER2_DEVICE_DISABLE 0
95#define SLIDER2_MAX_VOLTAGE_2_048V 1
96#define SLIDER2_MAX_VOLTAGE_4_096V 0
99 // End group macro
100// --------------------------------------------------------------- PUBLIC TYPES
109typedef uint16_t slider2_data_t;
110
114typedef struct
115{
116 // Output pins
117
118 digital_out_t en;
119 digital_out_t rsl;
120
121 // Modules
122
123 analog_in_t adc;
124
125} slider2_t;
126
130typedef struct
131{
132 // Communication gpio pins
133
134 pin_name_t an_pin;
135
136 // Additional gpio pins
137
138 pin_name_t en;
139 pin_name_t rsl;
140
141 // static variable
142
143 analog_in_resolution_t resolution; // Resolution
144 float vref; // VRef
145
147
148 // End types group
149// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
150
156#ifdef __cplusplus
157extern "C"{
158#endif
159
169
179
188
198
207void slider2_enable ( slider2_t *ctx, uint8_t state );
208
217void slider2_set_reference ( slider2_t *ctx, uint8_t ref );
218
219
220#ifdef __cplusplus
221}
222#endif
223#endif // _SLIDER2_H_
224
225 // End public_function group
227
228// ------------------------------------------------------------------------ END
#define SLIDER2_RETVAL
Definition slider2.h:77
void slider2_enable(slider2_t *ctx, uint8_t state)
Setting state function.
void slider2_cfg_setup(slider2_cfg_t *cfg)
Config Object Initialization function.
void slider2_default_cfg(slider2_t *ctx)
Click Default Configuration function.
SLIDER2_RETVAL slider2_init(slider2_t *ctx, slider2_cfg_t *cfg)
Initialization function.
slider2_data_t slider2_generic_read(slider2_t *ctx)
Generic read function.
void slider2_set_reference(slider2_t *ctx, uint8_t ref)
Setting reference function.
uint16_t slider2_data_t
Analog data type.
Definition slider2.h:109
Click configuration structure definition.
Definition slider2.h:131
analog_in_resolution_t resolution
Definition slider2.h:143
float vref
Definition slider2.h:144
pin_name_t an_pin
Definition slider2.h:134
pin_name_t en
Definition slider2.h:138
pin_name_t rsl
Definition slider2.h:139
Click ctx object definition.
Definition slider2.h:115
digital_out_t en
Definition slider2.h:118
digital_out_t rsl
Definition slider2.h:119
analog_in_t adc
Definition slider2.h:123