amiro-lld / include / alld_tlc5947.h @ ef078306
History | View | Annotate | Download (4.845 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.h
|
| 21 |
* @brief LED Driver macros and structures.
|
| 22 |
*
|
| 23 |
* @addtogroup lld_leddriver
|
| 24 |
* @{
|
| 25 |
*/
|
| 26 |
|
| 27 |
#ifndef AMIROLLD_TLC5947_H
|
| 28 |
#define AMIROLLD_TLC5947_H
|
| 29 |
|
| 30 |
#include <amiro-lld.h> |
| 31 |
|
| 32 |
#if defined(AMIROLLD_CFG_USE_TLC5947) || defined(__DOXYGEN__)
|
| 33 |
|
| 34 |
/******************************************************************************/
|
| 35 |
/* CONSTANTS */
|
| 36 |
/******************************************************************************/
|
| 37 |
|
| 38 |
/**
|
| 39 |
* @brief Active state of the BLANK signal.
|
| 40 |
*/
|
| 41 |
#define TLC5947_LLD_BLANK_ACTIVE_STATE APAL_GPIO_ACTIVE_HIGH
|
| 42 |
|
| 43 |
/**
|
| 44 |
* @brief Active state of the XLAT signal.
|
| 45 |
*/
|
| 46 |
#define TLC5947_LLD_XLAT_ACTIVE_STATE APAL_GPIO_ACTIVE_HIGH
|
| 47 |
|
| 48 |
/**
|
| 49 |
* @brief Number of PWM channels.
|
| 50 |
*/
|
| 51 |
#define TLC5947_LLD_NUM_CHANNELS 24 |
| 52 |
|
| 53 |
/**
|
| 54 |
* @brief Resulotion of the PWM channels in bits.
|
| 55 |
*/
|
| 56 |
#define TLC5947_LLD_PWM_RESOLUTION_BITS 12 |
| 57 |
|
| 58 |
/**
|
| 59 |
* @brief Size of the TLC grayscale buffer in bytes.
|
| 60 |
*/
|
| 61 |
#define TLC5947_LLD_BUFFER_SIZE (TLC5947_LLD_NUM_CHANNELS * TLC5947_LLD_PWM_RESOLUTION_BITS / 8) |
| 62 |
|
| 63 |
/******************************************************************************/
|
| 64 |
/* SETTINGS */
|
| 65 |
/******************************************************************************/
|
| 66 |
|
| 67 |
/******************************************************************************/
|
| 68 |
/* CHECKS */
|
| 69 |
/******************************************************************************/
|
| 70 |
|
| 71 |
/******************************************************************************/
|
| 72 |
/* DATA STRUCTURES AND TYPES */
|
| 73 |
/******************************************************************************/
|
| 74 |
|
| 75 |
/**
|
| 76 |
* @brief The TLC5947Driver struct
|
| 77 |
*/
|
| 78 |
typedef struct { |
| 79 |
apalSPIDriver_t* spi_driver; /**< @brief The SPI Driver. */
|
| 80 |
const apalControlGpio_t* blank_gpio; /**< @brief The identifier of the BLANK signal GPIO. */ |
| 81 |
const apalControlGpio_t* xlat_gpio; /**< @brief The identifier of the XLAT signal GPIO. */ |
| 82 |
} TLC5947Driver; |
| 83 |
|
| 84 |
/**
|
| 85 |
* @brief The blank state of the TLC5947 driver.
|
| 86 |
*/
|
| 87 |
typedef enum { |
| 88 |
TLC5947_LLD_BLANK_ENABLE = 0, /**< 'blank on' state of the TLC5947 driver. */ |
| 89 |
TLC5947_LLD_BLANK_DISABLE = 1, /**< 'blank off' state of the TLC5947 driver. */ |
| 90 |
} tlc5947_lld_blank_t; |
| 91 |
|
| 92 |
|
| 93 |
/**
|
| 94 |
* @brief TLC5947 buffer struct.
|
| 95 |
*/
|
| 96 |
typedef struct { |
| 97 |
uint8_t data[TLC5947_LLD_BUFFER_SIZE]; /**< The raw buffer data. */
|
| 98 |
} tlc5947_lld_buffer_t; |
| 99 |
|
| 100 |
/******************************************************************************/
|
| 101 |
/* MACROS */
|
| 102 |
/******************************************************************************/
|
| 103 |
|
| 104 |
/******************************************************************************/
|
| 105 |
/* EXTERN DECLARATIONS */
|
| 106 |
/******************************************************************************/
|
| 107 |
|
| 108 |
#ifdef __cplusplus
|
| 109 |
extern "C" { |
| 110 |
#endif
|
| 111 |
apalExitStatus_t tlc5947_lld_setBlank(const TLC5947Driver* const tlc5947, const tlc5947_lld_blank_t blank); |
| 112 |
apalExitStatus_t tlc5947_lld_getBlank(const TLC5947Driver* const tlc5947, tlc5947_lld_blank_t* const blank); |
| 113 |
apalExitStatus_t tlc5947_lld_update(const TLC5947Driver* const tlc5947); |
| 114 |
apalExitStatus_t tlc5947_lld_write(const TLC5947Driver* const tlc5947, const tlc5947_lld_buffer_t* const buffer); |
| 115 |
void tlc5947_lld_setBuffer(tlc5947_lld_buffer_t* const buffer, const uint8_t channel, const uint16_t value); |
| 116 |
uint16_t tlc5947_lld_getBuffer(const tlc5947_lld_buffer_t* const buffer, const uint8_t channel); |
| 117 |
#ifdef __cplusplus
|
| 118 |
} |
| 119 |
#endif
|
| 120 |
|
| 121 |
/******************************************************************************/
|
| 122 |
/* INLINE FUNCTIONS */
|
| 123 |
/******************************************************************************/
|
| 124 |
|
| 125 |
#endif /* defined(AMIROLLD_CFG_USE_TLC5947) */ |
| 126 |
|
| 127 |
#endif /* AMIROLLD_TLC5947_H */ |
| 128 |
|
| 129 |
/** @} */
|