ledringr 2.0.0.0
ledringr.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 LEDRINGR_H
36#define LEDRINGR_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 LEDRINGR_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.mr = MIKROBUS( mikrobus, MIKROBUS_RST );
74
81#define LEDRINGR_RETVAL uint8_t
82
83#define LEDRINGR_OK 0x00
84#define LEDRINGR_INIT_ERROR 0xFF
88 // End group macro
89// --------------------------------------------------------------- PUBLIC TYPES
98typedef struct
99{
100 // Output pins
101
102 digital_out_t mr;
103 digital_out_t cs;
104
105 // Modules
106
107 spi_master_t spi;
108 pin_name_t chip_select;
109
110} ledringr_t;
111
115typedef struct
116{
117 // Communication gpio pins
118
119 pin_name_t miso;
120 pin_name_t mosi;
121 pin_name_t sck;
122 pin_name_t cs;
123
124 // Additional gpio pins
125
126 pin_name_t mr;
127
128 // static variable
129
130 uint32_t spi_speed;
131 uint8_t spi_mode;
132 spi_master_chip_select_polarity_t cs_polarity;
133
135
136 // End types group
137
138// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
139
144#ifdef __cplusplus
145extern "C"{
146#endif
147
157
166
179(
180 ledringr_t *ctx,
181 uint8_t *write_buf,
182 uint16_t wbuf_size,
183 uint8_t *read_buf,
184 uint16_t rbuf_size
185);
186
195void ledringr_write_data ( ledringr_t *ctx, uint32_t data_to_write );
196
205void ledringr_turn_on_led ( ledringr_t *ctx, uint8_t led_position );
206
215
224
225#ifdef __cplusplus
226}
227#endif
228#endif // _LEDRINGR_H_
229
230 // End public_function group
232
233// ------------------------------------------------------------------------- END
#define LEDRINGR_RETVAL
Definition ledringr.h:81
void ledringr_turn_on_led(ledringr_t *ctx, uint8_t led_position)
Turn On LED by position.
void ledringr_led_ring_set(ledringr_t *ctx)
Set led.
void ledringr_cfg_setup(ledringr_cfg_t *cfg)
Config Object Initialization function.
LEDRINGR_RETVAL ledringr_init(ledringr_t *ctx, ledringr_cfg_t *cfg)
Initialization function.
void ledringr_transfer_data(ledringr_t *ctx, uint8_t *write_buf, uint16_t wbuf_size, uint8_t *read_buf, uint16_t rbuf_size)
Transfer data function.
void ledringr_led_ring_reset(ledringr_t *ctx)
Set led.
void ledringr_write_data(ledringr_t *ctx, uint32_t data_to_write)
Generic write function.
Click configuration structure definition.
Definition ledringr.h:116
uint8_t spi_mode
Definition ledringr.h:131
spi_master_chip_select_polarity_t cs_polarity
Definition ledringr.h:132
pin_name_t mr
Definition ledringr.h:126
pin_name_t sck
Definition ledringr.h:121
pin_name_t mosi
Definition ledringr.h:120
uint32_t spi_speed
Definition ledringr.h:130
pin_name_t miso
Definition ledringr.h:119
pin_name_t cs
Definition ledringr.h:122
Click ctx object definition.
Definition ledringr.h:99
digital_out_t cs
Definition ledringr.h:103
spi_master_t spi
Definition ledringr.h:107
digital_out_t mr
Definition ledringr.h:102
pin_name_t chip_select
Definition ledringr.h:108