is31fl3746.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2018 Jack Humbert
  3. * Copyright 2018 Yiancar
  4. * Copyright 2020 MelGeek
  5. * Copyright 2021 MasterSpoon
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #pragma once
  21. // This is a 7-bit address, that gets left-shifted and bit 0
  22. // set to 0 for write, 1 for read (as per I2C protocol)
  23. // The address will vary depending on your wiring:
  24. // 00 <-> GND
  25. // 01 <-> SCL
  26. // 10 <-> SDA
  27. // 11 <-> VCC
  28. // ADDR1 represents A1:A0 of the 7-bit address.
  29. // ADDR2 represents A3:A2 of the 7-bit address.
  30. // The result is: 0b110(ADDR2)(ADDR1)
  31. #ifndef DRIVER_ADDR_1
  32. # define DRIVER_ADDR_1 0b1100000
  33. #endif
  34. // Set defaults for Spread Spectrum Register
  35. #ifndef ISSI_SSR_1
  36. # define ISSI_SSR_1 0x00
  37. #endif
  38. #ifndef ISSI_SSR_2
  39. # define ISSI_SSR_2 0x00
  40. #endif
  41. #ifndef ISSI_SSR_3
  42. # define ISSI_SSR_3 0x00
  43. #endif
  44. #ifndef ISSI_SSR_4
  45. # define ISSI_SSR_4 0x00
  46. #endif
  47. // Command Registers
  48. #define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
  49. #define ISSI_COMMANDREGISTER 0xFD
  50. #define ISSI_IDREGISTER 0xFC
  51. #define ISSI_REGISTER_UNLOCK 0xC5
  52. // Response Registers
  53. #define ISSI_PAGE_PWM 0x00
  54. #define ISSI_PAGE_SCALING 0x01
  55. #define ISSI_PAGE_FUNCTION 0x01
  56. // Registers under Function Register
  57. #define ISSI_REG_CONFIGURATION 0x50
  58. #define ISSI_REG_GLOBALCURRENT 0x51
  59. #define ISSI_REG_PULLDOWNUP 0x52
  60. #define ISSI_REG_TEMP 0x5F
  61. #define ISSI_REG_SSR 0x60
  62. #define ISSI_REG_RESET 0x8F
  63. #define ISSI_REG_PWM_ENABLE 0xE0
  64. #define ISSI_REG_PWM_SET 0xE2
  65. // Set defaults for Function Registers
  66. #ifndef ISSI_CONFIGURATION
  67. # define ISSI_CONFIGURATION 0x01
  68. #endif
  69. #ifndef ISSI_GLOBALCURRENT
  70. # define ISSI_GLOBALCURRENT 0xFF
  71. #endif
  72. #ifndef ISSI_PULLDOWNUP
  73. # define ISSI_PULLDOWNUP 0x33
  74. #endif
  75. #ifndef ISSI_TEMP
  76. # define ISSI_TEMP 0x00
  77. #endif
  78. #ifndef ISSI_PWM_ENABLE
  79. # define ISSI_PWM_ENABLE 0x00
  80. #endif
  81. #ifndef ISSI_PWM_SET
  82. # define ISSI_PWM_SET 0x00
  83. #endif
  84. // Set defaults for Scaling registers
  85. #ifndef ISSI_SCAL_RED
  86. # define ISSI_SCAL_RED 0xFF
  87. #endif
  88. #ifndef ISSI_SCAL_BLUE
  89. # define ISSI_SCAL_BLUE 0xFF
  90. #endif
  91. #ifndef ISSI_SCAL_GREEN
  92. # define ISSI_SCAL_GREEN 0xFF
  93. #endif
  94. #define ISSI_SCAL_RED_OFF 0x00
  95. #define ISSI_SCAL_GREEN_OFF 0x00
  96. #define ISSI_SCAL_BLUE_OFF 0x00
  97. #ifndef ISSI_SCAL_LED
  98. # define ISSI_SCAL_LED 0xFF
  99. #endif
  100. #define ISSI_SCAL_LED_OFF 0x00
  101. // Set buffer sizes
  102. #define ISSI_MAX_LEDS 72
  103. #define ISSI_SCALING_SIZE 72
  104. #define ISSI_PWM_TRF_SIZE 18
  105. #define ISSI_SCALING_TRF_SIZE 18
  106. // Location of 1st bit for PWM and Scaling registers
  107. #define ISSI_PWM_REG_1ST 0x01
  108. #define ISSI_SCL_REG_1ST 0x01
  109. // Map CS SW locations to order in PWM / Scaling buffers
  110. // This matches the ORDER in the Datasheet Register not the POSITION
  111. // It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
  112. #define CS1_SW1 0x00
  113. #define CS2_SW1 0x01
  114. #define CS3_SW1 0x02
  115. #define CS4_SW1 0x03
  116. #define CS5_SW1 0x04
  117. #define CS6_SW1 0x05
  118. #define CS7_SW1 0x06
  119. #define CS8_SW1 0x07
  120. #define CS9_SW1 0x08
  121. #define CS10_SW1 0x09
  122. #define CS11_SW1 0x0A
  123. #define CS12_SW1 0x0B
  124. #define CS13_SW1 0x0C
  125. #define CS14_SW1 0x0D
  126. #define CS15_SW1 0x0E
  127. #define CS16_SW1 0x0F
  128. #define CS17_SW1 0x10
  129. #define CS18_SW1 0x11
  130. #define CS1_SW2 0x12
  131. #define CS2_SW2 0x13
  132. #define CS3_SW2 0x14
  133. #define CS4_SW2 0x15
  134. #define CS5_SW2 0x16
  135. #define CS6_SW2 0x17
  136. #define CS7_SW2 0x18
  137. #define CS8_SW2 0x19
  138. #define CS9_SW2 0x1A
  139. #define CS10_SW2 0x1B
  140. #define CS11_SW2 0x1C
  141. #define CS12_SW2 0x1D
  142. #define CS13_SW2 0x1E
  143. #define CS14_SW2 0x1F
  144. #define CS15_SW2 0x20
  145. #define CS16_SW2 0x21
  146. #define CS17_SW2 0x22
  147. #define CS18_SW2 0x23
  148. #define CS1_SW3 0x24
  149. #define CS2_SW3 0x25
  150. #define CS3_SW3 0x26
  151. #define CS4_SW3 0x27
  152. #define CS5_SW3 0x28
  153. #define CS6_SW3 0x29
  154. #define CS7_SW3 0x2A
  155. #define CS8_SW3 0x2B
  156. #define CS9_SW3 0x2C
  157. #define CS10_SW3 0x2D
  158. #define CS11_SW3 0x2E
  159. #define CS12_SW3 0x2F
  160. #define CS13_SW3 0x30
  161. #define CS14_SW3 0x31
  162. #define CS15_SW3 0x32
  163. #define CS16_SW3 0x33
  164. #define CS17_SW3 0x34
  165. #define CS18_SW3 0x35
  166. #define CS1_SW4 0x36
  167. #define CS2_SW4 0x37
  168. #define CS3_SW4 0x38
  169. #define CS4_SW4 0x39
  170. #define CS5_SW4 0x3A
  171. #define CS6_SW4 0x3B
  172. #define CS7_SW4 0x3C
  173. #define CS8_SW4 0x3D
  174. #define CS9_SW4 0x3E
  175. #define CS10_SW4 0x3F
  176. #define CS11_SW4 0x40
  177. #define CS12_SW4 0x41
  178. #define CS13_SW4 0x42
  179. #define CS14_SW4 0x43
  180. #define CS15_SW4 0x44
  181. #define CS16_SW4 0x45
  182. #define CS17_SW4 0x46
  183. #define CS18_SW4 0x47