led_controller.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. Copyright 2016 flabbergast <s3+flabbergast@sdfeu.org>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. 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 this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _LED_CONTROLLER_H_
  15. #define _LED_CONTROLLER_H_
  16. /* =========================
  17. * communication functions
  18. * ========================= */
  19. msg_t is31_write_data(uint8_t page, uint8_t *buffer, uint8_t size);
  20. msg_t is31_write_register(uint8_t page, uint8_t reg, uint8_t data);
  21. msg_t is31_read_register(uint8_t page, uint8_t reg, uint8_t *result);
  22. /* =============================
  23. * IS31 chip related definitions
  24. * ============================= */
  25. #define IS31_ADDR_DEFAULT 0x74
  26. #define IS31_REG_CONFIG 0x00
  27. // bits in reg
  28. #define IS31_REG_CONFIG_PICTUREMODE 0x00
  29. #define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
  30. #define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
  31. // D2:D0 bits are starting frame for autoplay mode
  32. #define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode
  33. #define IS31_REG_AUTOPLAYCTRL1 0x02
  34. // D6:D4 number of loops (000=infty)
  35. // D2:D0 number of frames to be used
  36. #define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms)
  37. #define IS31_REG_DISPLAYOPT 0x05
  38. #define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames
  39. #define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8
  40. // D2:D0 bits blink period time (*0.27s)
  41. #define IS31_REG_AUDIOSYNC 0x06
  42. #define IS31_REG_AUDIOSYNC_ENABLE 0x1
  43. #define IS31_REG_FRAMESTATE 0x07
  44. #define IS31_REG_BREATHCTRL1 0x08
  45. // D6:D4 fade out time (26ms*2^i)
  46. // D2:D0 fade in time (26ms*2^i)
  47. #define IS31_REG_BREATHCTRL2 0x09
  48. #define IS31_REG_BREATHCTRL2_ENABLE 0x10
  49. // D2:D0 extinguish time (3.5ms*2^i)
  50. #define IS31_REG_SHUTDOWN 0x0A
  51. #define IS31_REG_SHUTDOWN_ON 0x1
  52. #define IS31_REG_AGCCTRL 0x0B
  53. #define IS31_REG_ADCRATE 0x0C
  54. #define IS31_COMMANDREGISTER 0xFD
  55. #define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine'
  56. #define IS31_TIMEOUT 10000 // needs to be long enough to write a whole page
  57. /* ==============================
  58. * LED Thread related definitions
  59. * ============================== */
  60. extern mailbox_t led_mailbox;
  61. // constants for signaling the LED controller thread
  62. #define LED_MSG_CAPS_ON 1
  63. #define LED_MSG_CAPS_OFF 2
  64. #define LED_MSG_SLEEP_LED_ON 3
  65. #define LED_MSG_SLEEP_LED_OFF 4
  66. #define LED_MSG_ALL_TOGGLE 5
  67. #define LED_MSG_GAME_TOGGLE 6
  68. #endif /* _LED_CONTROLLER_H_ */