PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

176 lines
6.2KB

  1. /* Copyright (c) 2009 by Alex Leone <acleone ~AT~ gmail.com>
  2. This file is part of the Arduino TLC5940 Library.
  3. The Arduino TLC5940 Library is free software: you can redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. The Arduino TLC5940 Library is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with The Arduino TLC5940 Library. If not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef TLC_CONFIG_H
  15. #define TLC_CONFIG_H
  16. #include <stdint.h>
  17. /** \file
  18. Configuration for the Arduino Tlc5940 library. After making changes to
  19. this file, delete Tlc5940.o in this folder so the changes are applied.
  20. A summary of all the options:
  21. - Number of TLCs daisy-chained: NUM_TLCS (default 1)
  22. - Enable/Disable VPRG functionality: VPRG_ENABLED (default 0)
  23. - Enable/Disable XERR functionality: XERR_ENABLED (default 0)
  24. - Should the library use bit-banging (any pins) or hardware SPI (faster):
  25. DATA_TRANSFER_MODE (default TLC_SPI)
  26. - Which pins to use for bit-banging: SIN_PIN, SIN_PORT, SIN_DDR and
  27. SCLK_PIN, SCLK_PORT, SCLK_DDR
  28. - The PWM period: TLC_PWM_PERIOD (be sure to change TLC_GSCLK_PERIOD
  29. accordingly!)
  30. How to change the pin mapping:
  31. - Arduino digital pin 0-7 = PORTD, PD0-7
  32. - Arduino digital pin 8-13 = PORTB, PB0-5
  33. - Arduino analog pin 0-5 = PORTC, PC0-5 */
  34. /** Bit-bang using any two i/o pins */
  35. #define TLC_BITBANG 1
  36. /** Use the much faster hardware SPI module */
  37. #define TLC_SPI 2
  38. /* ------------------------ START EDITING HERE ----------------------------- */
  39. /** Number of TLCs daisy-chained. To daisy-chain, attach the SOUT (TLC pin 17)
  40. of the first TLC to the SIN (TLC pin 26) of the next. The rest of the pins
  41. are attached normally.
  42. \note Each TLC needs it's own IREF resistor */
  43. #define NUM_TLCS 1
  44. /** Determines how data should be transfered to the TLCs. Bit-banging can use
  45. any two i/o pins, but the hardware SPI is faster.
  46. - Bit-Bang = TLC_BITBANG
  47. - Hardware SPI = TLC_SPI (default) */
  48. #define DATA_TRANSFER_MODE TLC_SPI
  49. /* This include is down here because the files it includes needs the data
  50. transfer mode */
  51. #include "pinouts/chip_includes.h"
  52. /* Set DATA_TRANSFER_MODE to TLC_BITBANG and change the pins below if you need
  53. to use different pins for sin and sclk. The defaults are defined in
  54. pinouts/ATmega_xx8.h for most Arduino's. */
  55. #if DATA_TRANSFER_MODE == TLC_BITBANG
  56. /** SIN (TLC pin 26) */
  57. #define SIN_PIN DEFAULT_BB_SIN_PIN
  58. #define SIN_PORT DEFAULT_BB_SIN_PORT
  59. #define SIN_DDR DEFAULT_BB_SIN_DDR
  60. /** SCLK (TLC pin 25) */
  61. #define SCLK_PIN DEFAULT_BB_SCLK_PIN
  62. #define SCLK_PORT DEFAULT_BB_SCLK_PORT
  63. #define SCLK_DDR DEFAULT_BB_SCLK_DDR
  64. #endif
  65. /** If more than 16 TLCs are daisy-chained, the channel type has to be uint16_t.
  66. Default is uint8_t, which supports up to 16 TLCs. */
  67. #define TLC_CHANNEL_TYPE uint8_t
  68. /** Determines how long each PWM period should be, in clocks.
  69. \f$\displaystyle f_{PWM} = \frac{f_{osc}}{2 * TLC\_PWM\_PERIOD} Hz \f$
  70. \f$\displaystyle TLC\_PWM\_PERIOD = \frac{f_{osc}}{2 * f_{PWM}} \f$
  71. This is related to TLC_GSCLK_PERIOD:
  72. \f$\displaystyle TLC\_PWM\_PERIOD =
  73. \frac{(TLC\_GSCLK\_PERIOD + 1) * 4096}{2} \f$
  74. \note The default of 8192 means the PWM frequency is 976.5625Hz */
  75. #define TLC_PWM_PERIOD 8192
  76. /** Determines how long each period GSCLK is.
  77. This is related to TLC_PWM_PERIOD:
  78. \f$\displaystyle TLC\_GSCLK\_PERIOD =
  79. \frac{2 * TLC\_PWM\_PERIOD}{4096} - 1 \f$
  80. \note Default is 3 */
  81. #define TLC_GSCLK_PERIOD 3
  82. /** Enables/disables VPRG (TLC pin 27) functionality. If you need to set dot
  83. correction data, this needs to be enabled.
  84. - 0 VPRG is not connected. <em>TLC pin 27 must be grounded!</em> (default)
  85. - 1 VPRG is connected
  86. \note VPRG to GND inputs grayscale data, VPRG to Vcc inputs dot-correction
  87. data */
  88. #define VPRG_ENABLED 0
  89. /** Enables/disables XERR (TLC pin 16) functionality to check for shorted/broken
  90. LEDs
  91. - 0 XERR is not connected (default)
  92. - 1 XERR is connected
  93. \note XERR is active low */
  94. #define XERR_ENABLED 0
  95. /* You can change the VPRG and XERR pins freely. The defaults are defined in
  96. the chip-specific pinouts: see pinouts/ATmega_xx8.h for most Arduino's. */
  97. #if VPRG_ENABLED
  98. /** VPRG (TLC pin 27) */
  99. #define VPRG_PIN DEFAULT_VPRG_PIN
  100. #define VPRG_PORT DEFAULT_VPRG_PORT
  101. #define VPRG_DDR DEFAULT_VPRG_DDR
  102. #endif
  103. #if XERR_ENABLED
  104. /** XERR (TLC pin 16) */
  105. #define XERR_PIN DEFAULT_XERR_PIN
  106. #define XERR_PORT DEFAULT_XERR_PORT
  107. #define XERR_DDR DEFAULT_XERR_DDR
  108. #define XERR_PINS DEFAULT_XERR_PINS
  109. #endif
  110. /* ------------------------- STOP EDITING HERE ----------------------------- */
  111. #if DATA_TRANSFER_MODE == TLC_SPI
  112. /** SIN (TLC pin 26) */
  113. #define SIN_PIN TLC_MOSI_PIN
  114. #define SIN_PORT TLC_MOSI_PORT
  115. #define SIN_DDR TLC_MOSI_DDR
  116. /** SCLK (TLC pin 25) */
  117. #define SCLK_PIN TLC_SCK_PIN
  118. #define SCLK_PORT TLC_SCK_PORT
  119. #define SCLK_DDR TLC_SCK_DDR
  120. #endif
  121. #if !(DATA_TRANSFER_MODE == TLC_BITBANG \
  122. || DATA_TRANSFER_MODE == TLC_SPI)
  123. #error "Invalid DATA_TRANSFER_MODE specified, see DATA_TRANSFER_MODE"
  124. #endif
  125. /* Various Macros */
  126. /** Arranges 2 grayscale values (0 - 4095) in the packed array format (3 bytes).
  127. This is for array initializers only: the output is three comma seperated
  128. 8-bit values. */
  129. //#define GS_DUO(a, b) ((a) >> 4), ((a) << 4) | ((b) >> 8), (b)
  130. #define GS_DUO(a, b) (uint8_t)((a) >> 4), (uint8_t)((a) << 4) | (uint8_t)((b) >> 8), (uint8_t)(b)
  131. #if VPRG_ENABLED
  132. /** Arranges 4 dot correction values (0 - 63) in the packed array format.
  133. \see setDCtoProgmemArray */
  134. #define DC_QUARTET(a, b, c, d) ((a) << 2) | ((b) >> 4), \
  135. ((b) << 4) | ((c) >> 2), \
  136. ((c) << 6) | (d)
  137. #endif
  138. #endif