slider 2.0.0.0
slider.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
33// ----------------------------------------------------------------------------
34
35#ifndef SLIDER_H
36#define SLIDER_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_spi_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
68#define SLIDER_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_AN ); \
74 cfg.csl = MIKROBUS( mikrobus, MIKROBUS_RST )
81#define SLIDER_RETVAL uint8_t
82
83#define SLIDER_OK 0x00
84#define SLIDER_INIT_ERROR 0xFF
87 // End group macro
88// --------------------------------------------------------------- PUBLIC TYPES
97typedef struct
98{
99 // Output pins
100
101 digital_out_t oe;
102 digital_out_t csl;
103 digital_in_t miso;
104 digital_out_t cs;
105
106 // Modules
107
108 spi_master_t spi;
109 pin_name_t chip_select;
110
111} slider_t;
112
116typedef struct
117{
118 // Communication gpio pins
119
120 pin_name_t miso;
121 pin_name_t mosi;
122 pin_name_t sck;
123 pin_name_t cs;
124
125 // Additional gpio pins
126
127 pin_name_t oe;
128 pin_name_t csl;
129
130 // static variable
131
132 uint32_t spi_speed;
133 uint8_t spi_mode;
134 spi_master_chip_select_polarity_t cs_polarity;
135
137
138 // End types group
139// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
140
145#ifdef __cplusplus
146extern "C"{
147#endif
148
158
167
176
189(
190 slider_t *ctx,
191 uint8_t *wr_buf,
192 uint16_t wr_len,
193 uint8_t *rd_buf,
194 uint16_t rd_len
195);
196
205uint32_t slider_read_adc ( slider_t *ctx );
206
217
227void slider_enable_led_output ( slider_t *ctx, uint8_t state );
228
238void slider_enable_output_laches ( slider_t *ctx, uint8_t state );
239
250
251
252#ifdef __cplusplus
253}
254#endif
255#endif // _SLIDER_H_
256
257 // End public_function group
259
260// ------------------------------------------------------------------------- END
#define SLIDER_RETVAL
Definition slider.h:81
void slider_enable_output_laches(slider_t *ctx, uint8_t state)
Output laches enable function.
uint32_t slider_write_output(slider_t *ctx)
Output write function.
void slider_enable_led_output(slider_t *ctx, uint8_t state)
Output enable function.
void slider_cfg_setup(slider_cfg_t *cfg)
Config Object Initialization function.
void slider_generic_transfer(slider_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void slider_default_cfg(slider_t *ctx)
Click Default Configuration function.
uint32_t slider_read_adc_and_ready(slider_t *ctx)
ADC and READY read function.
SLIDER_RETVAL slider_init(slider_t *ctx, slider_cfg_t *cfg)
Initialization function.
uint32_t slider_read_adc(slider_t *ctx)
ADC read function.
Click configuration structure definition.
Definition slider.h:117
uint8_t spi_mode
Definition slider.h:133
spi_master_chip_select_polarity_t cs_polarity
Definition slider.h:134
pin_name_t sck
Definition slider.h:122
pin_name_t oe
Definition slider.h:127
pin_name_t mosi
Definition slider.h:121
uint32_t spi_speed
Definition slider.h:132
pin_name_t miso
Definition slider.h:120
pin_name_t csl
Definition slider.h:128
pin_name_t cs
Definition slider.h:123
Click ctx object definition.
Definition slider.h:98
digital_out_t cs
Definition slider.h:104
spi_master_t spi
Definition slider.h:108
digital_in_t miso
Definition slider.h:103
digital_out_t oe
Definition slider.h:101
digital_out_t csl
Definition slider.h:102
pin_name_t chip_select
Definition slider.h:109