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
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
52#include "drv_pwm.h"
53
74#define LEDDRIVER10_ENABLE_ALL_CH 0xFFFF
75#define LEDDRIVER10_DISABLE_ALL_CH 0x0000
76#define LEDDRIVER10_ENABLE_CH_0 0x0001
77#define LEDDRIVER10_ENABLE_CH_1 0x0002
78#define LEDDRIVER10_ENABLE_CH_2 0x0004
79#define LEDDRIVER10_ENABLE_CH_3 0x0008
80#define LEDDRIVER10_ENABLE_CH_4 0x0010
81#define LEDDRIVER10_ENABLE_CH_5 0x0020
82#define LEDDRIVER10_ENABLE_CH_6 0x0040
83#define LEDDRIVER10_ENABLE_CH_7 0x0080
84#define LEDDRIVER10_ENABLE_CH_8 0x0100
85#define LEDDRIVER10_ENABLE_CH_9 0x0200
86#define LEDDRIVER10_ENABLE_CH_10 0x0400
87#define LEDDRIVER10_ENABLE_CH_11 0x0800
88#define LEDDRIVER10_ENABLE_CH_12 0x1000
89#define LEDDRIVER10_ENABLE_CH_13 0x2000
90#define LEDDRIVER10_ENABLE_CH_14 0x4000
91#define LEDDRIVER10_ENABLE_CH_15 0x8000
92
97#define LEDDRIVER10_DEF_FREQ 10000
98
99 // leddriver10_set
100
115#define LEDDRIVER10_MAP_MIKROBUS( cfg, mikrobus ) \
116 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
117 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
118 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
119 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
120 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
121
122 // leddriver10_map
123 // leddriver10
124
129typedef struct
130{
131 // Modules
132 spi_master_t spi;
133 pwm_t pwm;
135 pin_name_t chip_select;
136 uint32_t pwm_freq;
139
144typedef struct
145{
146 // Communication gpio pins
147 pin_name_t miso;
148 pin_name_t mosi;
149 pin_name_t sck;
150 pin_name_t cs;
151 pin_name_t pwm;
153 // Static variable
154 uint32_t spi_speed;
155 spi_master_mode_t spi_mode;
156 spi_master_chip_select_polarity_t cs_polarity;
157 uint32_t dev_pwm_freq;
160
171
188
204
217err_t leddriver10_set_channels ( leddriver10_t *ctx, uint16_t ch_mask );
218
231err_t leddriver10_read_channels ( leddriver10_t *ctx, uint16_t *ch_mask );
232
245err_t leddriver10_set_duty_cycle ( leddriver10_t *ctx, float duty_cycle );
246
259
272
273#ifdef __cplusplus
274}
275#endif
276#endif // LEDDRIVER10_H
277
278 // leddriver10
279
280// ------------------------------------------------------------------------ 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:166
@ LEDDRIVER10_ERROR
Definition leddriver10.h:168
@ LEDDRIVER10_OK
Definition leddriver10.h:167
LED Driver 10 Click configuration object.
Definition leddriver10.h:145
spi_master_chip_select_polarity_t cs_polarity
Definition leddriver10.h:156
pin_name_t sck
Definition leddriver10.h:149
spi_master_mode_t spi_mode
Definition leddriver10.h:155
pin_name_t mosi
Definition leddriver10.h:148
uint32_t spi_speed
Definition leddriver10.h:154
uint32_t dev_pwm_freq
Definition leddriver10.h:157
pin_name_t pwm
Definition leddriver10.h:151
pin_name_t miso
Definition leddriver10.h:147
pin_name_t cs
Definition leddriver10.h:150
LED Driver 10 Click context object.
Definition leddriver10.h:130
spi_master_t spi
Definition leddriver10.h:132
uint32_t pwm_freq
Definition leddriver10.h:136
pin_name_t chip_select
Definition leddriver10.h:135
pwm_t pwm
Definition leddriver10.h:133