Statistics
| Branch: | Tag: | Revision:

amiro-lld / include / alld_tlc5947.h @ 616f3584

History | View | Annotate | Download (3.055 KB)

1
/*
2
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2018  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
#ifndef _AMIROLLD_TLC5947_H_
20
#define _AMIROLLD_TLC5947_H_
21

    
22
#include <amiro-lld.h>
23

    
24
#if defined(AMIROLLD_CFG_USE_TLC5947) || defined(__DOXYGEN__)
25

    
26
/**
27
 * @brief   Active state of the BLANK signal.
28
 */
29
#define TLC5947_LLD_BLANK_ACTIVE_STATE          APAL_GPIO_ACTIVE_HIGH
30

    
31
/**
32
 * @brief   Active state of the XLAT signal.
33
 */
34
#define TLC5947_LLD_XLAT_ACTIVE_STATE           APAL_GPIO_ACTIVE_HIGH
35

    
36
/**
37
 * @brief   Number of PWM channels.
38
 */
39
#define TLC5947_LLD_NUM_CHANNELS                24
40

    
41
/**
42
 * @brief   Resulotion of the PWM channels in bits.
43
 */
44
#define TLC5947_LLD_PWM_RESOLUTION_BITS         12
45

    
46
/**
47
 * @brief   Size of the TLC grayscale buffer in bytes.
48
 */
49
#define TLC5947_LLD_BUFFER_SIZE                 (TLC5947_LLD_NUM_CHANNELS * TLC5947_LLD_PWM_RESOLUTION_BITS / 8)
50

    
51
/**
52
 * @brief The TLC5947Driver struct
53
 */
54
typedef struct {
55
  apalSPIDriver_t* spi_driver;        /**< @brief The SPI Driver.                           */
56
  apalControlGpio_t blank_gpio;       /**< @brief The identifier of the BLANK signal GPIO.  */
57
  apalControlGpio_t xlat_gpio;        /**< @brief The identifier of the XLAT signal GPIO.   */
58
} TLC5947Driver;
59

    
60
/**
61
 * @brief The blank state of the TLC5947 driver.
62
 */
63
typedef enum {
64
  TLC5947_LLD_BLANK_ENABLE = 0,   /**< 'blank on' state of the TLC5947 driver.  */
65
  TLC5947_LLD_BLANK_DISABLE = 1,  /**< 'blank off' state of the TLC5947 driver. */
66
} tlc5947_lld_blank_t;
67

    
68

    
69
/**
70
 * @brief TLC5947 buffer struct.
71
 */
72
typedef struct {
73
  uint8_t data[TLC5947_LLD_BUFFER_SIZE]; /**< The raw buffer data. */
74
} tlc5947_lld_buffer_t;
75

    
76
#ifdef __cplusplus
77
extern "C" {
78
#endif
79
  apalExitStatus_t tlc5947_lld_setBlank(const TLC5947Driver* const tlc5947, const tlc5947_lld_blank_t blank);
80
  apalExitStatus_t tlc5947_lld_getBlank(const TLC5947Driver* const tlc5947, tlc5947_lld_blank_t* const blank);
81
  apalExitStatus_t tlc5947_lld_update(const TLC5947Driver* const tlc5947);
82
  apalExitStatus_t tlc5947_lld_write(const TLC5947Driver* const tlc5947, const tlc5947_lld_buffer_t* const buffer);
83
  void tlc5947_lld_setBuffer(tlc5947_lld_buffer_t* const buffer, const uint8_t channel, const uint16_t value);
84
  uint16_t tlc5947_lld_getBuffer(const tlc5947_lld_buffer_t* const buffer, const uint8_t channel);
85
#ifdef __cplusplus
86
}
87
#endif
88

    
89
#endif /* defined(AMIROLLD_CFG_USE_TLC5947) */
90

    
91
#endif /* _AMIROLLD_TLC5947_H_ */