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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define LEDRINGR_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  cfg.mr = MIKROBUS( mikrobus, MIKROBUS_RST );
60 
67 #define LEDRINGR_RETVAL uint8_t
68 
69 #define LEDRINGR_OK 0x00
70 #define LEDRINGR_INIT_ERROR 0xFF
71  // End group macro
75 // --------------------------------------------------------------- PUBLIC TYPES
84 typedef struct
85 {
86  // Output pins
87 
88  digital_out_t mr;
89  digital_out_t cs;
90 
91  // Modules
92 
93  spi_master_t spi;
94  pin_name_t chip_select;
95 
96 } ledringr_t;
97 
101 typedef struct
102 {
103  // Communication gpio pins
104 
105  pin_name_t miso;
106  pin_name_t mosi;
107  pin_name_t sck;
108  pin_name_t cs;
109 
110  // Additional gpio pins
111 
112  pin_name_t mr;
113 
114  // static variable
115 
116  uint32_t spi_speed;
117  uint8_t spi_mode;
118  spi_master_chip_select_polarity_t cs_polarity;
119 
121  // End types group
123 
124 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
125 
130 #ifdef __cplusplus
131 extern "C"{
132 #endif
133 
143 
152 
165 (
166  ledringr_t *ctx,
167  uint8_t *write_buf,
168  uint16_t wbuf_size,
169  uint8_t *read_buf,
170  uint16_t rbuf_size
171 );
172 
181 void ledringr_write_data ( ledringr_t *ctx, uint32_t data_to_write );
182 
191 void ledringr_turn_on_led ( ledringr_t *ctx, uint8_t led_position );
192 
201 
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // _LEDRINGR_H_
215  // End public_function group
218 
219 // ------------------------------------------------------------------------- END
ledringr_cfg_t::cs
pin_name_t cs
Definition: ledringr.h:108
ledringr_t::mr
digital_out_t mr
Definition: ledringr.h:88
ledringr_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: ledringr.h:118
ledringr_cfg_t::spi_speed
uint32_t spi_speed
Definition: ledringr.h:116
ledringr_transfer_data
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.
ledringr_cfg_t
Click configuration structure definition.
Definition: ledringr.h:102
ledringr_turn_on_led
void ledringr_turn_on_led(ledringr_t *ctx, uint8_t led_position)
Turn On LED by position.
ledringr_cfg_t::mosi
pin_name_t mosi
Definition: ledringr.h:106
ledringr_cfg_t::mr
pin_name_t mr
Definition: ledringr.h:112
ledringr_cfg_t::sck
pin_name_t sck
Definition: ledringr.h:107
ledringr_init
LEDRINGR_RETVAL ledringr_init(ledringr_t *ctx, ledringr_cfg_t *cfg)
Initialization function.
ledringr_cfg_t::spi_mode
uint8_t spi_mode
Definition: ledringr.h:117
ledringr_led_ring_reset
void ledringr_led_ring_reset(ledringr_t *ctx)
Set led.
ledringr_cfg_t::miso
pin_name_t miso
Definition: ledringr.h:105
ledringr_t::spi
spi_master_t spi
Definition: ledringr.h:93
ledringr_t::chip_select
pin_name_t chip_select
Definition: ledringr.h:94
ledringr_t::cs
digital_out_t cs
Definition: ledringr.h:89
ledringr_t
Click ctx object definition.
Definition: ledringr.h:85
ledringr_cfg_setup
void ledringr_cfg_setup(ledringr_cfg_t *cfg)
Config Object Initialization function.
ledringr_write_data
void ledringr_write_data(ledringr_t *ctx, uint32_t data_to_write)
Generic write function.
LEDRINGR_RETVAL
#define LEDRINGR_RETVAL
Definition: ledringr.h:67
ledringr_led_ring_set
void ledringr_led_ring_set(ledringr_t *ctx)
Set led.