You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

327 lines
7.4 KiB

  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: 0b010(ADDR2)(ADDR1)
  31. #ifndef DRIVER_ADDR_1
  32. # define DRIVER_ADDR_1 0b0100000
  33. #endif
  34. // Set defaults for Spread Spectrum Register
  35. #ifndef ISSI_SSR_1
  36. # ifndef DRIVER_ADDR_2
  37. # define ISSI_SSR_1 0x00
  38. # else
  39. # define ISSI_SSR_1 0xC0
  40. # endif
  41. #endif
  42. #ifndef ISSI_SSR_2
  43. # define ISSI_SSR_2 0x80
  44. #endif
  45. #ifndef ISSI_SSR_3
  46. # define ISSI_SSR_3 0x80
  47. #endif
  48. #ifndef ISSI_SSR_4
  49. # define ISSI_SSR_4 0x80
  50. #endif
  51. // Command Registers
  52. #define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
  53. #define ISSI_COMMANDREGISTER 0xFD
  54. #define ISSI_IDREGISTER 0xFC
  55. #define ISSI_REGISTER_UNLOCK 0xC5
  56. // Response Registers
  57. #define ISSI_PAGE_PWM 0x00
  58. #define ISSI_PAGE_SCALING 0x01
  59. #define ISSI_PAGE_FUNCTION 0x02
  60. // Registers under Function Register
  61. #define ISSI_REG_CONFIGURATION 0x00
  62. #define ISSI_REG_GLOBALCURRENT 0x01
  63. #define ISSI_REG_PULLDOWNUP 0x02
  64. #define ISSI_REG_TEMP 0x24
  65. #define ISSI_REG_SSR 0x25
  66. #define ISSI_REG_RESET 0x2F
  67. // Set defaults for Function Registers
  68. #ifndef ISSI_CONFIGURATION
  69. # define ISSI_CONFIGURATION 0x01
  70. #endif
  71. #ifndef ISSI_GLOBALCURRENT
  72. # define ISSI_GLOBALCURRENT 0xFF
  73. #endif
  74. #ifndef ISSI_PULLDOWNUP
  75. # define ISSI_PULLDOWNUP 0x33
  76. #endif
  77. #ifndef ISSI_TEMP
  78. # define ISSI_TEMP 0x00
  79. #endif
  80. // Set defaults for Scaling registers
  81. #ifndef ISSI_SCAL_RED
  82. # define ISSI_SCAL_RED 0xFF
  83. #endif
  84. #ifndef ISSI_SCAL_BLUE
  85. # define ISSI_SCAL_BLUE 0xFF
  86. #endif
  87. #ifndef ISSI_SCAL_GREEN
  88. # define ISSI_SCAL_GREEN 0xFF
  89. #endif
  90. #define ISSI_SCAL_RED_OFF 0x00
  91. #define ISSI_SCAL_GREEN_OFF 0x00
  92. #define ISSI_SCAL_BLUE_OFF 0x00
  93. #ifndef ISSI_SCAL_LED
  94. # define ISSI_SCAL_LED 0xFF
  95. #endif
  96. #define ISSI_SCAL_LED_OFF 0x00
  97. // Set buffer sizes
  98. #define ISSI_MAX_LEDS 198
  99. #define ISSI_SCALING_SIZE 198
  100. #define ISSI_PWM_TRF_SIZE 18
  101. #define ISSI_SCALING_TRF_SIZE 18
  102. // Location of 1st bit for PWM and Scaling registers
  103. #define ISSI_PWM_REG_1ST 0x01
  104. #define ISSI_SCL_REG_1ST 0x01
  105. // Map CS SW locations to order in PWM / Scaling buffers
  106. // This matches the ORDER in the Datasheet Register not the POSITION
  107. // It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
  108. #define CS1_SW1 0x00
  109. #define CS2_SW1 0x01
  110. #define CS3_SW1 0x02
  111. #define CS4_SW1 0x03
  112. #define CS5_SW1 0x04
  113. #define CS6_SW1 0x05
  114. #define CS7_SW1 0x06
  115. #define CS8_SW1 0x07
  116. #define CS9_SW1 0x08
  117. #define CS10_SW1 0x09
  118. #define CS11_SW1 0x0A
  119. #define CS12_SW1 0x0B
  120. #define CS13_SW1 0x0C
  121. #define CS14_SW1 0x0D
  122. #define CS15_SW1 0x0E
  123. #define CS16_SW1 0x0F
  124. #define CS17_SW1 0x10
  125. #define CS18_SW1 0x11
  126. #define CS1_SW2 0x12
  127. #define CS2_SW2 0x13
  128. #define CS3_SW2 0x14
  129. #define CS4_SW2 0x15
  130. #define CS5_SW2 0x16
  131. #define CS6_SW2 0x17
  132. #define CS7_SW2 0x18
  133. #define CS8_SW2 0x19
  134. #define CS9_SW2 0x1A
  135. #define CS10_SW2 0x1B
  136. #define CS11_SW2 0x1C
  137. #define CS12_SW2 0x1D
  138. #define CS13_SW2 0x1E
  139. #define CS14_SW2 0x1F
  140. #define CS15_SW2 0x20
  141. #define CS16_SW2 0x21
  142. #define CS17_SW2 0x22
  143. #define CS18_SW2 0x23
  144. #define CS1_SW3 0x24
  145. #define CS2_SW3 0x25
  146. #define CS3_SW3 0x26
  147. #define CS4_SW3 0x27
  148. #define CS5_SW3 0x28
  149. #define CS6_SW3 0x29
  150. #define CS7_SW3 0x2A
  151. #define CS8_SW3 0x2B
  152. #define CS9_SW3 0x2C
  153. #define CS10_SW3 0x2D
  154. #define CS11_SW3 0x2E
  155. #define CS12_SW3 0x2F
  156. #define CS13_SW3 0x30
  157. #define CS14_SW3 0x31
  158. #define CS15_SW3 0x32
  159. #define CS16_SW3 0x33
  160. #define CS17_SW3 0x34
  161. #define CS18_SW3 0x35
  162. #define CS1_SW4 0x36
  163. #define CS2_SW4 0x37
  164. #define CS3_SW4 0x38
  165. #define CS4_SW4 0x39
  166. #define CS5_SW4 0x3A
  167. #define CS6_SW4 0x3B
  168. #define CS7_SW4 0x3C
  169. #define CS8_SW4 0x3D
  170. #define CS9_SW4 0x3E
  171. #define CS10_SW4 0x3F
  172. #define CS11_SW4 0x40
  173. #define CS12_SW4 0x41
  174. #define CS13_SW4 0x42
  175. #define CS14_SW4 0x43
  176. #define CS15_SW4 0x44
  177. #define CS16_SW4 0x45
  178. #define CS17_SW4 0x46
  179. #define CS18_SW4 0x47
  180. #define CS1_SW5 0x48
  181. #define CS2_SW5 0x49
  182. #define CS3_SW5 0x4A
  183. #define CS4_SW5 0x4B
  184. #define CS5_SW5 0x4C
  185. #define CS6_SW5 0x4D
  186. #define CS7_SW5 0x4E
  187. #define CS8_SW5 0x4F
  188. #define CS9_SW5 0x50
  189. #define CS10_SW5 0x51
  190. #define CS11_SW5 0x52
  191. #define CS12_SW5 0x53
  192. #define CS13_SW5 0x54
  193. #define CS14_SW5 0x55
  194. #define CS15_SW5 0x56
  195. #define CS16_SW5 0x57
  196. #define CS17_SW5 0x58
  197. #define CS18_SW5 0x59
  198. #define CS1_SW6 0x5A
  199. #define CS2_SW6 0x5B
  200. #define CS3_SW6 0x5C
  201. #define CS4_SW6 0x5D
  202. #define CS5_SW6 0x5E
  203. #define CS6_SW6 0x5F
  204. #define CS7_SW6 0x60
  205. #define CS8_SW6 0x61
  206. #define CS9_SW6 0x62
  207. #define CS10_SW6 0x63
  208. #define CS11_SW6 0x64
  209. #define CS12_SW6 0x65
  210. #define CS13_SW6 0x66
  211. #define CS14_SW6 0x67
  212. #define CS15_SW6 0x68
  213. #define CS16_SW6 0x69
  214. #define CS17_SW6 0x6A
  215. #define CS18_SW6 0x6B
  216. #define CS1_SW7 0x6C
  217. #define CS2_SW7 0x6D
  218. #define CS3_SW7 0x6E
  219. #define CS4_SW7 0x6F
  220. #define CS5_SW7 0x70
  221. #define CS6_SW7 0x71
  222. #define CS7_SW7 0x72
  223. #define CS8_SW7 0x73
  224. #define CS9_SW7 0x74
  225. #define CS10_SW7 0x75
  226. #define CS11_SW7 0x76
  227. #define CS12_SW7 0x77
  228. #define CS13_SW7 0x78
  229. #define CS14_SW7 0x79
  230. #define CS15_SW7 0x7A
  231. #define CS16_SW7 0x7B
  232. #define CS17_SW7 0x7C
  233. #define CS18_SW7 0x7D
  234. #define CS1_SW8 0x7E
  235. #define CS2_SW8 0x7F
  236. #define CS3_SW8 0x80
  237. #define CS4_SW8 0x81
  238. #define CS5_SW8 0x82
  239. #define CS6_SW8 0x83
  240. #define CS7_SW8 0x84
  241. #define CS8_SW8 0x85
  242. #define CS9_SW8 0x86
  243. #define CS10_SW8 0x87
  244. #define CS11_SW8 0x88
  245. #define CS12_SW8 0x89
  246. #define CS13_SW8 0x8A
  247. #define CS14_SW8 0x8B
  248. #define CS15_SW8 0x8C
  249. #define CS16_SW8 0x8D
  250. #define CS17_SW8 0x8E
  251. #define CS18_SW8 0x8F
  252. #define CS1_SW9 0x90
  253. #define CS2_SW9 0x91
  254. #define CS3_SW9 0x92
  255. #define CS4_SW9 0x93
  256. #define CS5_SW9 0x94
  257. #define CS6_SW9 0x95
  258. #define CS7_SW9 0x96
  259. #define CS8_SW9 0x97
  260. #define CS9_SW9 0x98
  261. #define CS10_SW9 0x99
  262. #define CS11_SW9 0x9A
  263. #define CS12_SW9 0x9B
  264. #define CS13_SW9 0x9C
  265. #define CS14_SW9 0x9D
  266. #define CS15_SW9 0x9E
  267. #define CS16_SW9 0x9F
  268. #define CS17_SW9 0xA0
  269. #define CS18_SW9 0xA1
  270. #define CS1_SW10 0xA2
  271. #define CS2_SW10 0xA3
  272. #define CS3_SW10 0xA4
  273. #define CS4_SW10 0xA5
  274. #define CS5_SW10 0xA6
  275. #define CS6_SW10 0xA7
  276. #define CS7_SW10 0xA8
  277. #define CS8_SW10 0xA9
  278. #define CS9_SW10 0xAA
  279. #define CS10_SW10 0xAB
  280. #define CS11_SW10 0xAC
  281. #define CS12_SW10 0xAD
  282. #define CS13_SW10 0xAE
  283. #define CS14_SW10 0xAF
  284. #define CS15_SW10 0xB0
  285. #define CS16_SW10 0xB1
  286. #define CS17_SW10 0xB2
  287. #define CS18_SW10 0xB3
  288. #define CS1_SW11 0xB4
  289. #define CS2_SW11 0xB5
  290. #define CS3_SW11 0xB6
  291. #define CS4_SW11 0xB7
  292. #define CS5_SW11 0xB8
  293. #define CS6_SW11 0xB9
  294. #define CS7_SW11 0xBA
  295. #define CS8_SW11 0xBB
  296. #define CS9_SW11 0xBC
  297. #define CS10_SW11 0xBD
  298. #define CS11_SW11 0xBE
  299. #define CS12_SW11 0xBF
  300. #define CS13_SW11 0xC0
  301. #define CS14_SW11 0xC1
  302. #define CS15_SW11 0xC2
  303. #define CS16_SW11 0xC3
  304. #define CS17_SW11 0xC4
  305. #define CS18_SW11 0xC5