Statistics
| Branch: | Tag: | Revision:

amiro-lld / include / TLC5947 / v1 / alld_TLC5947_v1.h @ 5d67f4db

History | View | Annotate | Download (5.192 KB)

1
/*
2
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  Thomas Schöpping et al.
4

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
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
GNU Lesser General Public License for more details.
14

15
You should have received a copy of the GNU Lesser General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18

    
19
/**
20
 * @file    alld_TLC5947_v1.h
21
 * @brief   LED Driver macros and structures.
22
 *
23
 * @addtogroup lld_leddriver
24
 * @{
25
 */
26

    
27
#ifndef AMIROLLD_TLC5947_V1_H
28
#define AMIROLLD_TLC5947_V1_H
29

    
30
#include <amiro-lld.h>
31

    
32
#if (defined(AMIROLLD_CFG_TLC5947) && (AMIROLLD_CFG_TLC5947 == 1)) || defined(__DOXYGEN__)
33

    
34
/******************************************************************************/
35
/* CONSTANTS                                                                  */
36
/******************************************************************************/
37

    
38
/**
39
 * @brief   Number of chained TLC5947 devices.
40
 */
41
#if !defined(TLC5947_LLD_CHAINED) || defined(__DOXYGEN__)
42
#define TLC5947_LLD_CHAINED                     1
43
#endif
44

    
45
/**
46
 * @brief   Active state of the BLANK signal.
47
 */
48
#define TLC5947_LLD_BLANK_ACTIVE_STATE          APAL_GPIO_ACTIVE_HIGH
49

    
50
/**
51
 * @brief   Signal edge of the XLAT signal, which causes the SPI registers to be latched to the output.
52
 */
53
#define TLC5947_LLD_XLAT_UPDATE_EDGE            APAL_GPIO_EDGE_RISING
54

    
55
/**
56
 * @brief   Number of PWM channels.
57
 */
58
#define TLC5947_LLD_NUM_CHANNELS                (TLC5947_LLD_CHAINED * 24)
59

    
60
/**
61
 * @brief   Resulotion of the PWM channels in bits.
62
 */
63
#define TLC5947_LLD_PWM_RESOLUTION_BITS         12
64

    
65
/**
66
 * @brief   Size of the TLC grayscale buffer in bytes.
67
 */
68
#define TLC5947_LLD_BUFFER_SIZE                 (TLC5947_LLD_NUM_CHANNELS * TLC5947_LLD_PWM_RESOLUTION_BITS / 8)
69

    
70
/******************************************************************************/
71
/* SETTINGS                                                                   */
72
/******************************************************************************/
73

    
74
/******************************************************************************/
75
/* CHECKS                                                                     */
76
/******************************************************************************/
77

    
78
/******************************************************************************/
79
/* DATA STRUCTURES AND TYPES                                                  */
80
/******************************************************************************/
81

    
82
/**
83
 * @brief The TLC5947Driver struct
84
 */
85
typedef struct {
86
  apalSPIDriver_t* spi_driver;    /**< @brief The SPI Driver.                           */
87
  const apalControlGpio_t* blank_gpio;  /**< @brief The identifier of the BLANK signal GPIO (may be @p NULL).  */
88
  const apalControlGpio_t* xlat_gpio;   /**< @brief The identifier of the XLAT signal GPIO (may be @p NULL).   */
89
} TLC5947Driver;
90

    
91
/**
92
 * @brief The blank state of the TLC5947 driver.
93
 */
94
typedef enum {
95
  TLC5947_LLD_BLANK_ENABLE = 0,   /**< 'blank on' state of the TLC5947 driver.  */
96
  TLC5947_LLD_BLANK_DISABLE = 1,  /**< 'blank off' state of the TLC5947 driver. */
97
} tlc5947_lld_blank_t;
98

    
99

    
100
/**
101
 * @brief TLC5947 buffer struct.
102
 */
103
typedef struct {
104
  uint8_t data[TLC5947_LLD_BUFFER_SIZE]; /**< The raw buffer data. */
105
} tlc5947_lld_buffer_t;
106

    
107
/******************************************************************************/
108
/* MACROS                                                                     */
109
/******************************************************************************/
110

    
111
/******************************************************************************/
112
/* EXTERN DECLARATIONS                                                        */
113
/******************************************************************************/
114

    
115
#ifdef __cplusplus
116
extern "C" {
117
#endif
118
  apalExitStatus_t tlc5947_lld_setBlank(const TLC5947Driver* const tlc5947, const tlc5947_lld_blank_t blank);
119
  apalExitStatus_t tlc5947_lld_getBlank(const TLC5947Driver* const tlc5947, tlc5947_lld_blank_t* const blank);
120
  apalExitStatus_t tlc5947_lld_update(const TLC5947Driver* const tlc5947);
121
  apalExitStatus_t tlc5947_lld_write(const TLC5947Driver* const tlc5947, const tlc5947_lld_buffer_t* const buffer);
122
  void tlc5947_lld_setBuffer(tlc5947_lld_buffer_t* const buffer, const uint8_t channel, const uint16_t value);
123
  uint16_t tlc5947_lld_getBuffer(const tlc5947_lld_buffer_t* const buffer, const uint8_t channel);
124
#ifdef __cplusplus
125
}
126
#endif
127

    
128
/******************************************************************************/
129
/* INLINE FUNCTIONS                                                           */
130
/******************************************************************************/
131

    
132
#endif /* defined(AMIROLLD_CFG_TLC5947) && (AMIROLLD_CFG_TLC5947 == 1) */
133

    
134
#endif /* AMIROLLD_TLC5947_V1_H */
135

    
136
/** @} */