leddriver10 2.0.0.0
leddriver10.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef LEDDRIVER10_H
29#define LEDDRIVER10_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_spi_master.h"
38#include "drv_pwm.h"
39
60#define LEDDRIVER10_ENABLE_ALL_CH 0xFFFF
61#define LEDDRIVER10_DISABLE_ALL_CH 0x0000
62#define LEDDRIVER10_ENABLE_CH_0 0x0001
63#define LEDDRIVER10_ENABLE_CH_1 0x0002
64#define LEDDRIVER10_ENABLE_CH_2 0x0004
65#define LEDDRIVER10_ENABLE_CH_3 0x0008
66#define LEDDRIVER10_ENABLE_CH_4 0x0010
67#define LEDDRIVER10_ENABLE_CH_5 0x0020
68#define LEDDRIVER10_ENABLE_CH_6 0x0040
69#define LEDDRIVER10_ENABLE_CH_7 0x0080
70#define LEDDRIVER10_ENABLE_CH_8 0x0100
71#define LEDDRIVER10_ENABLE_CH_9 0x0200
72#define LEDDRIVER10_ENABLE_CH_10 0x0400
73#define LEDDRIVER10_ENABLE_CH_11 0x0800
74#define LEDDRIVER10_ENABLE_CH_12 0x1000
75#define LEDDRIVER10_ENABLE_CH_13 0x2000
76#define LEDDRIVER10_ENABLE_CH_14 0x4000
77#define LEDDRIVER10_ENABLE_CH_15 0x8000
78
83#define LEDDRIVER10_DEF_FREQ 10000
84 // leddriver10_set
86
101#define LEDDRIVER10_MAP_MIKROBUS( cfg, mikrobus ) \
102 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
103 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
104 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
105 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
106 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
107 // leddriver10_map // leddriver10
110
115typedef struct
116{
117 // Modules
118 spi_master_t spi;
119 pwm_t pwm;
121 pin_name_t chip_select;
122 uint32_t pwm_freq;
125
130typedef struct
131{
132 // Communication gpio pins
133 pin_name_t miso;
134 pin_name_t mosi;
135 pin_name_t sck;
136 pin_name_t cs;
137 pin_name_t pwm;
139 // Static variable
140 uint32_t spi_speed;
141 spi_master_mode_t spi_mode;
142 spi_master_chip_select_polarity_t cs_polarity;
143 uint32_t dev_pwm_freq;
146
151typedef enum
152{
155
157
174
190
203err_t leddriver10_set_channels ( leddriver10_t *ctx, uint16_t ch_mask );
204
217err_t leddriver10_read_channels ( leddriver10_t *ctx, uint16_t *ch_mask );
218
231err_t leddriver10_set_duty_cycle ( leddriver10_t *ctx, float duty_cycle );
232
245
258
259#ifdef __cplusplus
260}
261#endif
262#endif // LEDDRIVER10_H
263 // leddriver10
265
266// ------------------------------------------------------------------------ END
err_t leddriver10_pwm_start(leddriver10_t *ctx)
LED Driver 10 start PWM module.
err_t leddriver10_set_channels(leddriver10_t *ctx, uint16_t ch_mask)
LED Driver 10 set channels function.
err_t leddriver10_init(leddriver10_t *ctx, leddriver10_cfg_t *cfg)
LED Driver 10 initialization function.
void leddriver10_cfg_setup(leddriver10_cfg_t *cfg)
LED Driver 10 configuration object setup function.
err_t leddriver10_pwm_stop(leddriver10_t *ctx)
LED Driver 10 stop PWM module.
err_t leddriver10_set_duty_cycle(leddriver10_t *ctx, float duty_cycle)
LED Driver 10 sets PWM duty cycle.
err_t leddriver10_read_channels(leddriver10_t *ctx, uint16_t *ch_mask)
LED Driver 10 read channels function.
leddriver10_return_value_t
LED Driver 10 Click return value data.
Definition: leddriver10.h:152
@ LEDDRIVER10_ERROR
Definition: leddriver10.h:154
@ LEDDRIVER10_OK
Definition: leddriver10.h:153
LED Driver 10 Click configuration object.
Definition: leddriver10.h:131
spi_master_chip_select_polarity_t cs_polarity
Definition: leddriver10.h:142
pin_name_t sck
Definition: leddriver10.h:135
spi_master_mode_t spi_mode
Definition: leddriver10.h:141
pin_name_t mosi
Definition: leddriver10.h:134
uint32_t spi_speed
Definition: leddriver10.h:140
uint32_t dev_pwm_freq
Definition: leddriver10.h:143
pin_name_t pwm
Definition: leddriver10.h:137
pin_name_t miso
Definition: leddriver10.h:133
pin_name_t cs
Definition: leddriver10.h:136
LED Driver 10 Click context object.
Definition: leddriver10.h:116
spi_master_t spi
Definition: leddriver10.h:118
uint32_t pwm_freq
Definition: leddriver10.h:122
pin_name_t chip_select
Definition: leddriver10.h:121
pwm_t pwm
Definition: leddriver10.h:119