amiro-lld / drivers / TLC5947 / v1 / alld_TLC5947.h @ ed9a1bf5
History | View | Annotate | Download (5.019 KB)
1 | d6728c5b | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | f69ec051 | Thomas Schöpping | Copyright (C) 2016..2020 Thomas Schöpping et al.
|
4 | d6728c5b | Thomas Schöpping | |
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | f0ca400f | Thomas Schöpping | it under the terms of the GNU Lesser General Public License as published by
|
7 | d6728c5b | Thomas Schöpping | the Free Software Foundation, either version 3 of the License, or
|
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | f0ca400f | Thomas Schöpping | GNU Lesser General Public License for more details.
|
14 | d6728c5b | Thomas Schöpping | |
15 | f0ca400f | Thomas Schöpping | You should have received a copy of the GNU Lesser General Public License
|
16 | d6728c5b | Thomas Schöpping | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 | */
|
||
18 | |||
19 | 5e2f673b | Marc Rothmann | /**
|
20 | 9466e34d | Thomas Schöpping | * @file alld_TLC5947.h
|
21 | 5e2f673b | Marc Rothmann | * @brief LED Driver macros and structures.
|
22 | *
|
||
23 | * @addtogroup lld_leddriver
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 9466e34d | Thomas Schöpping | #ifndef AMIROLLD_TLC5947_H
|
28 | #define AMIROLLD_TLC5947_H
|
||
29 | d6728c5b | Thomas Schöpping | |
30 | #include <amiro-lld.h> |
||
31 | |||
32 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
33 | /* CONSTANTS */
|
||
34 | /******************************************************************************/
|
||
35 | |||
36 | d6728c5b | Thomas Schöpping | /**
|
37 | 5d0950c9 | Thomas Schöpping | * @brief Number of chained TLC5947 devices.
|
38 | */
|
||
39 | #if !defined(TLC5947_LLD_CHAINED) || defined(__DOXYGEN__)
|
||
40 | #define TLC5947_LLD_CHAINED 1 |
||
41 | #endif
|
||
42 | |||
43 | /**
|
||
44 | d6728c5b | Thomas Schöpping | * @brief Active state of the BLANK signal.
|
45 | */
|
||
46 | #define TLC5947_LLD_BLANK_ACTIVE_STATE APAL_GPIO_ACTIVE_HIGH
|
||
47 | |||
48 | /**
|
||
49 | bbeeceaf | Thomas Schöpping | * @brief Signal edge of the XLAT signal, which causes the SPI registers to be latched to the output.
|
50 | d6728c5b | Thomas Schöpping | */
|
51 | bbeeceaf | Thomas Schöpping | #define TLC5947_LLD_XLAT_UPDATE_EDGE APAL_GPIO_EDGE_RISING
|
52 | d6728c5b | Thomas Schöpping | |
53 | /**
|
||
54 | * @brief Number of PWM channels.
|
||
55 | */
|
||
56 | 5d0950c9 | Thomas Schöpping | #define TLC5947_LLD_NUM_CHANNELS (TLC5947_LLD_CHAINED * 24) |
57 | d6728c5b | Thomas Schöpping | |
58 | /**
|
||
59 | * @brief Resulotion of the PWM channels in bits.
|
||
60 | */
|
||
61 | #define TLC5947_LLD_PWM_RESOLUTION_BITS 12 |
||
62 | |||
63 | /**
|
||
64 | * @brief Size of the TLC grayscale buffer in bytes.
|
||
65 | */
|
||
66 | #define TLC5947_LLD_BUFFER_SIZE (TLC5947_LLD_NUM_CHANNELS * TLC5947_LLD_PWM_RESOLUTION_BITS / 8) |
||
67 | |||
68 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
69 | /* SETTINGS */
|
||
70 | /******************************************************************************/
|
||
71 | |||
72 | /******************************************************************************/
|
||
73 | /* CHECKS */
|
||
74 | /******************************************************************************/
|
||
75 | |||
76 | /******************************************************************************/
|
||
77 | /* DATA STRUCTURES AND TYPES */
|
||
78 | /******************************************************************************/
|
||
79 | |||
80 | d6728c5b | Thomas Schöpping | /**
|
81 | * @brief The TLC5947Driver struct
|
||
82 | */
|
||
83 | typedef struct { |
||
84 | cf1f756b | Thomas Schöpping | apalSPIDriver_t* spi_driver; /**< @brief The SPI Driver. */
|
85 | bbeeceaf | Thomas Schöpping | const apalControlGpio_t* blank_gpio; /**< @brief The identifier of the BLANK signal GPIO (may be @p NULL). */ |
86 | const apalControlGpio_t* xlat_gpio; /**< @brief The identifier of the XLAT signal GPIO (may be @p NULL). */ |
||
87 | d6728c5b | Thomas Schöpping | } TLC5947Driver; |
88 | |||
89 | /**
|
||
90 | * @brief The blank state of the TLC5947 driver.
|
||
91 | */
|
||
92 | typedef enum { |
||
93 | TLC5947_LLD_BLANK_ENABLE = 0, /**< 'blank on' state of the TLC5947 driver. */ |
||
94 | TLC5947_LLD_BLANK_DISABLE = 1, /**< 'blank off' state of the TLC5947 driver. */ |
||
95 | } tlc5947_lld_blank_t; |
||
96 | |||
97 | |||
98 | /**
|
||
99 | * @brief TLC5947 buffer struct.
|
||
100 | */
|
||
101 | typedef struct { |
||
102 | uint8_t data[TLC5947_LLD_BUFFER_SIZE]; /**< The raw buffer data. */
|
||
103 | } tlc5947_lld_buffer_t; |
||
104 | |||
105 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
106 | /* MACROS */
|
||
107 | /******************************************************************************/
|
||
108 | |||
109 | /******************************************************************************/
|
||
110 | /* EXTERN DECLARATIONS */
|
||
111 | /******************************************************************************/
|
||
112 | |||
113 | d6728c5b | Thomas Schöpping | #ifdef __cplusplus
|
114 | extern "C" { |
||
115 | #endif
|
||
116 | apalExitStatus_t tlc5947_lld_setBlank(const TLC5947Driver* const tlc5947, const tlc5947_lld_blank_t blank); |
||
117 | apalExitStatus_t tlc5947_lld_getBlank(const TLC5947Driver* const tlc5947, tlc5947_lld_blank_t* const blank); |
||
118 | apalExitStatus_t tlc5947_lld_update(const TLC5947Driver* const tlc5947); |
||
119 | apalExitStatus_t tlc5947_lld_write(const TLC5947Driver* const tlc5947, const tlc5947_lld_buffer_t* const buffer); |
||
120 | void tlc5947_lld_setBuffer(tlc5947_lld_buffer_t* const buffer, const uint8_t channel, const uint16_t value); |
||
121 | uint16_t tlc5947_lld_getBuffer(const tlc5947_lld_buffer_t* const buffer, const uint8_t channel); |
||
122 | #ifdef __cplusplus
|
||
123 | } |
||
124 | #endif
|
||
125 | |||
126 | ef078306 | Thomas Schöpping | /******************************************************************************/
|
127 | /* INLINE FUNCTIONS */
|
||
128 | /******************************************************************************/
|
||
129 | |||
130 | 9466e34d | Thomas Schöpping | #endif /* AMIROLLD_TLC5947_H */ |
131 | 5e2f673b | Marc Rothmann | |
132 | /** @} */
|