is31fl3742.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. // ADDR represents A1:A0 of the 7-bit address.
  29. // The result is: 0b01100(ADDR)
  30. #ifndef DRIVER_ADDR_1
  31. # define DRIVER_ADDR_1 0b0110000
  32. #endif
  33. // Command Registers
  34. #define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
  35. #define ISSI_COMMANDREGISTER 0xFD
  36. #define ISSI_IDREGISTER 0xFC
  37. #define ISSI_REGISTER_UNLOCK 0xC5
  38. // Response Registers
  39. #define ISSI_PAGE_PWM 0x00
  40. #define ISSI_PAGE_SCALING 0x02
  41. #define ISSI_PAGE_FUNCTION 0x04
  42. // Registers under Function Register
  43. #define ISSI_REG_CONFIGURATION 0x00
  44. #define ISSI_REG_GLOBALCURRENT 0x01
  45. #define ISSI_REG_PULLDOWNUP 0x02
  46. #define ISSI_REG_SSR 0x41
  47. #define ISSI_REG_RESET 0x3F
  48. #define ISSI_REG_PWM_SET 0x36
  49. // Set defaults for Function Registers
  50. #ifndef ISSI_CONFIGURATION
  51. # define ISSI_CONFIGURATION 0x31
  52. #endif
  53. #ifndef ISSI_GLOBALCURRENT
  54. # define ISSI_GLOBALCURRENT 0xFF
  55. #endif
  56. #ifndef ISSI_PULLDOWNUP
  57. # define ISSI_PULLDOWNUP 0x55
  58. #endif
  59. #ifndef ISSI_PWM_SET
  60. # define ISSI_PWM_SET 0x00
  61. #endif
  62. // Set defaults for Spread Spectrum Register
  63. #ifndef ISSI_SSR_1
  64. # define ISSI_SSR_1 0x00
  65. #endif
  66. #ifndef ISSI_SSR_2
  67. # define ISSI_SSR_2 0x00
  68. #endif
  69. #ifndef ISSI_SSR_3
  70. # define ISSI_SSR_3 0x00
  71. #endif
  72. #ifndef ISSI_SSR_4
  73. # define ISSI_SSR_4 0x00
  74. #endif
  75. // Set defaults for Scaling registers
  76. #ifndef ISSI_SCAL_RED
  77. # define ISSI_SCAL_RED 0xFF
  78. #endif
  79. #ifndef ISSI_SCAL_BLUE
  80. # define ISSI_SCAL_BLUE 0xFF
  81. #endif
  82. #ifndef ISSI_SCAL_GREEN
  83. # define ISSI_SCAL_GREEN 0xFF
  84. #endif
  85. #define ISSI_SCAL_RED_OFF 0x00
  86. #define ISSI_SCAL_GREEN_OFF 0x00
  87. #define ISSI_SCAL_BLUE_OFF 0x00
  88. #ifndef ISSI_SCAL_LED
  89. # define ISSI_SCAL_LED 0xFF
  90. #endif
  91. #define ISSI_SCAL_LED_OFF 0x00
  92. // Set buffer sizes
  93. #define ISSI_MAX_LEDS 180
  94. #define ISSI_SCALING_SIZE 180
  95. #define ISSI_PWM_TRF_SIZE 18
  96. #define ISSI_SCALING_TRF_SIZE 18
  97. // Location of 1st bit for PWM and Scaling registers
  98. #define ISSI_PWM_REG_1ST 0x00
  99. #define ISSI_SCL_REG_1ST 0x00
  100. // Map CS SW locations to order in PWM / Scaling buffers
  101. // This matches the ORDER in the Datasheet Register not the POSITION
  102. // It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
  103. #define CS1_SW1 0x00
  104. #define CS2_SW1 0x01
  105. #define CS3_SW1 0x02
  106. #define CS4_SW1 0x03
  107. #define CS5_SW1 0x04
  108. #define CS6_SW1 0x05
  109. #define CS7_SW1 0x06
  110. #define CS8_SW1 0x07
  111. #define CS9_SW1 0x08
  112. #define CS10_SW1 0x09
  113. #define CS11_SW1 0x0A
  114. #define CS12_SW1 0x0B
  115. #define CS13_SW1 0x0C
  116. #define CS14_SW1 0x0D
  117. #define CS15_SW1 0x0E
  118. #define CS16_SW1 0x0F
  119. #define CS17_SW1 0x10
  120. #define CS18_SW1 0x11
  121. #define CS19_SW1 0x12
  122. #define CS20_SW1 0x13
  123. #define CS21_SW1 0x14
  124. #define CS22_SW1 0x15
  125. #define CS23_SW1 0x16
  126. #define CS24_SW1 0x17
  127. #define CS25_SW1 0x18
  128. #define CS26_SW1 0x19
  129. #define CS27_SW1 0x1A
  130. #define CS28_SW1 0x1B
  131. #define CS29_SW1 0x1C
  132. #define CS30_SW1 0x1D
  133. #define CS1_SW2 0x1E
  134. #define CS2_SW2 0x1F
  135. #define CS3_SW2 0x20
  136. #define CS4_SW2 0x21
  137. #define CS5_SW2 0x22
  138. #define CS6_SW2 0x23
  139. #define CS7_SW2 0x24
  140. #define CS8_SW2 0x25
  141. #define CS9_SW2 0x26
  142. #define CS10_SW2 0x27
  143. #define CS11_SW2 0x28
  144. #define CS12_SW2 0x29
  145. #define CS13_SW2 0x2A
  146. #define CS14_SW2 0x2B
  147. #define CS15_SW2 0x2C
  148. #define CS16_SW2 0x2D
  149. #define CS17_SW2 0x2E
  150. #define CS18_SW2 0x2F
  151. #define CS19_SW2 0x30
  152. #define CS20_SW2 0x31
  153. #define CS21_SW2 0x32
  154. #define CS22_SW2 0x33
  155. #define CS23_SW2 0x34
  156. #define CS24_SW2 0x35
  157. #define CS25_SW2 0x36
  158. #define CS26_SW2 0x37
  159. #define CS27_SW2 0x38
  160. #define CS28_SW2 0x39
  161. #define CS29_SW2 0x3A
  162. #define CS30_SW2 0x3B
  163. #define CS1_SW3 0x3C
  164. #define CS2_SW3 0x3D
  165. #define CS3_SW3 0x3E
  166. #define CS4_SW3 0x3F
  167. #define CS5_SW3 0x40
  168. #define CS6_SW3 0x41
  169. #define CS7_SW3 0x42
  170. #define CS8_SW3 0x43
  171. #define CS9_SW3 0x44
  172. #define CS10_SW3 0x45
  173. #define CS11_SW3 0x46
  174. #define CS12_SW3 0x47
  175. #define CS13_SW3 0x48
  176. #define CS14_SW3 0x49
  177. #define CS15_SW3 0x4A
  178. #define CS16_SW3 0x4B
  179. #define CS17_SW3 0x4C
  180. #define CS18_SW3 0x4D
  181. #define CS19_SW3 0x4E
  182. #define CS20_SW3 0x4F
  183. #define CS21_SW3 0x50
  184. #define CS22_SW3 0x51
  185. #define CS23_SW3 0x52
  186. #define CS24_SW3 0x53
  187. #define CS25_SW3 0x54
  188. #define CS26_SW3 0x55
  189. #define CS27_SW3 0x56
  190. #define CS28_SW3 0x57
  191. #define CS29_SW3 0x58
  192. #define CS30_SW3 0x59
  193. #define CS1_SW4 0x5A
  194. #define CS2_SW4 0x5B
  195. #define CS3_SW4 0x5C
  196. #define CS4_SW4 0x5D
  197. #define CS5_SW4 0x5E
  198. #define CS6_SW4 0x5F
  199. #define CS7_SW4 0x60
  200. #define CS8_SW4 0x61
  201. #define CS9_SW4 0x62
  202. #define CS10_SW4 0x63
  203. #define CS11_SW4 0x64
  204. #define CS12_SW4 0x65
  205. #define CS13_SW4 0x66
  206. #define CS14_SW4 0x67
  207. #define CS15_SW4 0x68
  208. #define CS16_SW4 0x69
  209. #define CS17_SW4 0x6A
  210. #define CS18_SW4 0x6B
  211. #define CS19_SW4 0x6C
  212. #define CS20_SW4 0x6D
  213. #define CS21_SW4 0x6E
  214. #define CS22_SW4 0x6F
  215. #define CS23_SW4 0x70
  216. #define CS24_SW4 0x71
  217. #define CS25_SW4 0x72
  218. #define CS26_SW4 0x73
  219. #define CS27_SW4 0x74
  220. #define CS28_SW4 0x75
  221. #define CS29_SW4 0x76
  222. #define CS30_SW4 0x77
  223. #define CS1_SW5 0x78
  224. #define CS2_SW5 0x79
  225. #define CS3_SW5 0x7A
  226. #define CS4_SW5 0x7B
  227. #define CS5_SW5 0x7C
  228. #define CS6_SW5 0x7D
  229. #define CS7_SW5 0x7E
  230. #define CS8_SW5 0x7F
  231. #define CS9_SW5 0x80
  232. #define CS10_SW5 0x81
  233. #define CS11_SW5 0x82
  234. #define CS12_SW5 0x83
  235. #define CS13_SW5 0x84
  236. #define CS14_SW5 0x85
  237. #define CS15_SW5 0x86
  238. #define CS16_SW5 0x87
  239. #define CS17_SW5 0x88
  240. #define CS18_SW5 0x89
  241. #define CS19_SW5 0x8A
  242. #define CS20_SW5 0x8B
  243. #define CS21_SW5 0x8C
  244. #define CS22_SW5 0x8D
  245. #define CS23_SW5 0x8E
  246. #define CS24_SW5 0x8F
  247. #define CS25_SW5 0x90
  248. #define CS26_SW5 0x91
  249. #define CS27_SW5 0x92
  250. #define CS28_SW5 0x93
  251. #define CS29_SW5 0x94
  252. #define CS30_SW5 0x95
  253. #define CS1_SW6 0x96
  254. #define CS2_SW6 0x97
  255. #define CS3_SW6 0x98
  256. #define CS4_SW6 0x99
  257. #define CS5_SW6 0x9A
  258. #define CS6_SW6 0x9B
  259. #define CS7_SW6 0x9C
  260. #define CS8_SW6 0x9D
  261. #define CS9_SW6 0x9E
  262. #define CS10_SW6 0x9F
  263. #define CS11_SW6 0xA0
  264. #define CS12_SW6 0xA1
  265. #define CS13_SW6 0xA2
  266. #define CS14_SW6 0xA3
  267. #define CS15_SW6 0xA4
  268. #define CS16_SW6 0xA5
  269. #define CS17_SW6 0xA6
  270. #define CS18_SW6 0xA7
  271. #define CS19_SW6 0xA8
  272. #define CS20_SW6 0xA9
  273. #define CS21_SW6 0xAA
  274. #define CS22_SW6 0xAB
  275. #define CS23_SW6 0xAC
  276. #define CS24_SW6 0xAD
  277. #define CS25_SW6 0xAE
  278. #define CS26_SW6 0xAF
  279. #define CS27_SW6 0xB0
  280. #define CS28_SW6 0xB1
  281. #define CS29_SW6 0xB2
  282. #define CS30_SW6 0xB3