PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Tlc5940.h 2.9KB

il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 TLC5940_H
  15. #define TLC5940_H
  16. /** \file
  17. Tlc5940 library header file. */
  18. #include <Arduino.h>
  19. #include "tlc_config.h"
  20. #if defined(__AVR__)
  21. #ifdef TLC_ATMEGA_8_H
  22. /** Enables the Timer1 Overflow interrupt, which will fire after an XLAT
  23. pulse */
  24. #define set_XLAT_interrupt() TIFR |= _BV(TOV1); TIMSK = _BV(TOIE1)
  25. /** Disables any Timer1 interrupts */
  26. #define clear_XLAT_interrupt() TIMSK = 0
  27. #else
  28. /** Enables the Timer1 Overflow interrupt, which will fire after an XLAT
  29. pulse */
  30. #define set_XLAT_interrupt() TIFR1 |= _BV(TOV1); TIMSK1 = _BV(TOIE1)
  31. /** Disables any Timer1 interrupts */
  32. #define clear_XLAT_interrupt() TIMSK1 = 0
  33. #endif
  34. /** Enables the output of XLAT pulses */
  35. #define enable_XLAT_pulses() TCCR1A = _BV(COM1A1) | _BV(COM1B1)
  36. /** Disables the output of XLAT pulses */
  37. #define disable_XLAT_pulses() TCCR1A = _BV(COM1B1)
  38. #elif defined(__arm__) && defined(TEENSYDUINO)
  39. #define set_XLAT_interrupt() FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_CPWMS | FTM_SC_TOIE | (FTM1_SC & FTM_SC_PS(7))
  40. #define clear_XLAT_interrupt() FTM1_SC = FTM_SC_CLKS(1) | FTM_SC_CPWMS | (FTM1_SC & FTM_SC_PS(7))
  41. #define enable_XLAT_pulses() CORE_PIN3_CONFIG = PORT_PCR_MUX(3)|PORT_PCR_DSE|PORT_PCR_SRE
  42. #define disable_XLAT_pulses() CORE_PIN3_CONFIG = PORT_PCR_MUX(1)|PORT_PCR_DSE|PORT_PCR_SRE
  43. #endif
  44. extern volatile uint8_t tlc_needXLAT;
  45. extern volatile void (*tlc_onUpdateFinished)(void);
  46. extern uint8_t tlc_GSData[NUM_TLCS * 24];
  47. /** The main Tlc5940 class for the entire library. An instance of this class
  48. will be preinstantiated as Tlc. */
  49. class Tlc5940
  50. {
  51. public:
  52. void init(uint16_t initialValue = 0);
  53. void clear(void);
  54. uint8_t update(void);
  55. void set(TLC_CHANNEL_TYPE channel, uint16_t value);
  56. uint16_t get(TLC_CHANNEL_TYPE channel);
  57. void setAll(uint16_t value);
  58. #if VPRG_ENABLED
  59. void setAllDC(uint8_t value);
  60. #endif
  61. #if XERR_ENABLED
  62. uint8_t readXERR(void);
  63. #endif
  64. };
  65. void tlc_shift8_init(void);
  66. void tlc_shift8(uint8_t byte);
  67. #if VPRG_ENABLED
  68. void tlc_dcModeStart(void);
  69. void tlc_dcModeStop(void);
  70. #endif
  71. // for the preinstantiated Tlc variable.
  72. extern Tlc5940 Tlc;
  73. #endif