is31fl3741.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2018 Jack Humbert
  3. * Copyright 2018 Yiancar
  4. * Copyright 2020 MelGeek
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #pragma once
  20. #include <stdint.h>
  21. #include <stdbool.h>
  22. #include "progmem.h"
  23. #include "util.h"
  24. // ======== DEPRECATED DEFINES - DO NOT USE ========
  25. #ifdef DRIVER_ADDR_1
  26. # define IS31FL3741_I2C_ADDRESS_1 DRIVER_ADDR_1
  27. #endif
  28. #ifdef DRIVER_ADDR_2
  29. # define IS31FL3741_I2C_ADDRESS_2 DRIVER_ADDR_2
  30. #endif
  31. #ifdef DRIVER_ADDR_3
  32. # define IS31FL3741_I2C_ADDRESS_3 DRIVER_ADDR_3
  33. #endif
  34. #ifdef DRIVER_ADDR_4
  35. # define IS31FL3741_I2C_ADDRESS_4 DRIVER_ADDR_4
  36. #endif
  37. #ifdef ISSI_TIMEOUT
  38. # define IS31FL3741_I2C_TIMEOUT ISSI_TIMEOUT
  39. #endif
  40. #ifdef ISSI_PERSISTENCE
  41. # define IS31FL3741_I2C_PERSISTENCE ISSI_PERSISTENCE
  42. #endif
  43. #ifdef ISSI_CONFIGURATION
  44. # define IS31FL3741_CONFIGURATION ISSI_CONFIGURATION
  45. #endif
  46. #ifdef ISSI_SWPULLUP
  47. # define IS31FL3741_SW_PULLUP ISSI_SWPULLUP
  48. #endif
  49. #ifdef ISSI_CSPULLUP
  50. # define IS31FL3741_CS_PULLDOWN ISSI_CSPULLUP
  51. #endif
  52. #ifdef ISSI_GLOBALCURRENT
  53. # define IS31FL3741_GLOBAL_CURRENT ISSI_GLOBALCURRENT
  54. #endif
  55. #define is31_led is31fl3741_led_t
  56. #define g_is31_leds g_is31fl3741_leds
  57. #define PUR_0R IS31FL3741_PUR_0_OHM
  58. #define PUR_05KR IS31FL3741_PUR_0K5_OHM
  59. #define PUR_1KR IS31FL3741_PUR_1K_OHM
  60. #define PUR_2KR IS31FL3741_PUR_2K_OHM
  61. #define PUR_4KR IS31FL3741_PUR_4K_OHM
  62. #define PUR_8KR IS31FL3741_PUR_8K_OHM
  63. #define PUR_16KR IS31FL3741_PUR_16K_OHM
  64. #define PUR_32KR IS31FL3741_PUR_32K_OHM
  65. // ========
  66. #define IS31FL3741_REG_INTERRUPT_MASK 0xF0
  67. #define IS31FL3741_REG_INTERRUPT_STATUS 0xF1
  68. #define IS31FL3741_REG_ID 0xFC
  69. #define IS31FL3741_REG_COMMAND 0xFD
  70. #define IS31FL3741_COMMAND_PWM_0 0x00
  71. #define IS31FL3741_COMMAND_PWM_1 0x01
  72. #define IS31FL3741_COMMAND_SCALING_0 0x02
  73. #define IS31FL3741_COMMAND_SCALING_1 0x03
  74. #define IS31FL3741_COMMAND_FUNCTION 0x04
  75. #define IS31FL3741_FUNCTION_REG_CONFIGURATION 0x00
  76. #define IS31FL3741_FUNCTION_REG_GLOBAL_CURRENT 0x01
  77. #define IS31FL3741_FUNCTION_REG_PULLDOWNUP 0x02
  78. #define IS31FL3741_FUNCTION_REG_PWM_FREQUENCY 0x36
  79. #define IS31FL3741_FUNCTION_REG_RESET 0x3F
  80. #define IS31FL3741_REG_COMMAND_WRITE_LOCK 0xFE
  81. #define IS31FL3741_COMMAND_WRITE_LOCK_MAGIC 0xC5
  82. #define IS31FL3741_I2C_ADDRESS_GND 0x30
  83. #define IS31FL3741_I2C_ADDRESS_SCL 0x31
  84. #define IS31FL3741_I2C_ADDRESS_SDA 0x32
  85. #define IS31FL3741_I2C_ADDRESS_VCC 0x33
  86. #if defined(RGB_MATRIX_IS31FL3741)
  87. # define IS31FL3741_LED_COUNT RGB_MATRIX_LED_COUNT
  88. #endif
  89. #if defined(IS31FL3741_I2C_ADDRESS_4)
  90. # define IS31FL3741_DRIVER_COUNT 4
  91. #elif defined(IS31FL3741_I2C_ADDRESS_3)
  92. # define IS31FL3741_DRIVER_COUNT 3
  93. #elif defined(IS31FL3741_I2C_ADDRESS_2)
  94. # define IS31FL3741_DRIVER_COUNT 2
  95. #elif defined(IS31FL3741_I2C_ADDRESS_1)
  96. # define IS31FL3741_DRIVER_COUNT 1
  97. #endif
  98. typedef struct is31fl3741_led_t {
  99. uint8_t driver : 2;
  100. uint16_t r : 9;
  101. uint16_t g : 9;
  102. uint16_t b : 9;
  103. } PACKED is31fl3741_led_t;
  104. extern const is31fl3741_led_t PROGMEM g_is31fl3741_leds[IS31FL3741_LED_COUNT];
  105. void is31fl3741_init_drivers(void);
  106. void is31fl3741_init(uint8_t index);
  107. void is31fl3741_write_register(uint8_t index, uint8_t reg, uint8_t data);
  108. void is31fl3741_select_page(uint8_t index, uint8_t page);
  109. void is31fl3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
  110. void is31fl3741_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
  111. void is31fl3741_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
  112. // This should not be called from an interrupt
  113. // (eg. from a timer interrupt).
  114. // Call this while idle (in between matrix scans).
  115. // If the buffer is dirty, it will update the driver with the buffer.
  116. void is31fl3741_update_pwm_buffers(uint8_t index);
  117. void is31fl3741_update_led_control_registers(uint8_t index);
  118. void is31fl3741_set_scaling_registers(const is31fl3741_led_t *pled, uint8_t red, uint8_t green, uint8_t blue);
  119. void is31fl3741_set_pwm_buffer(const is31fl3741_led_t *pled, uint8_t red, uint8_t green, uint8_t blue);
  120. void is31fl3741_flush(void);
  121. #define IS31FL3741_PDR_0_OHM 0b000 // No pull-down resistor
  122. #define IS31FL3741_PDR_0K5_OHM 0b001 // 0.5 kOhm resistor
  123. #define IS31FL3741_PDR_1K_OHM 0b010 // 1 kOhm resistor
  124. #define IS31FL3741_PDR_2K_OHM 0b011 // 2 kOhm resistor
  125. #define IS31FL3741_PDR_4K_OHM 0b100 // 4 kOhm resistor
  126. #define IS31FL3741_PDR_8K_OHM 0b101 // 8 kOhm resistor
  127. #define IS31FL3741_PDR_16K_OHM 0b110 // 16 kOhm resistor
  128. #define IS31FL3741_PDR_32K_OHM 0b111 // 32 kOhm resistor
  129. #define IS31FL3741_PUR_0_OHM 0b000 // No pull-up resistor
  130. #define IS31FL3741_PUR_0K5_OHM 0b001 // 0.5 kOhm resistor
  131. #define IS31FL3741_PUR_1K_OHM 0b010 // 1 kOhm resistor
  132. #define IS31FL3741_PUR_2K_OHM 0b011 // 2 kOhm resistor
  133. #define IS31FL3741_PUR_4K_OHM 0b100 // 4 kOhm resistor
  134. #define IS31FL3741_PUR_8K_OHM 0b101 // 8 kOhm resistor
  135. #define IS31FL3741_PUR_16K_OHM 0b110 // 16 kOhm resistor
  136. #define IS31FL3741_PUR_32K_OHM 0b111 // 32 kOhm resistor
  137. #define IS31FL3741_PWM_FREQUENCY_29K_HZ 0b0000
  138. #define IS31FL3741_PWM_FREQUENCY_3K6_HZ 0b0011
  139. #define IS31FL3741_PWM_FREQUENCY_1K8_HZ 0b0111
  140. #define IS31FL3741_PWM_FREQUENCY_900_HZ 0b1011
  141. #define SW1_CS1 0x00
  142. #define SW1_CS2 0x01
  143. #define SW1_CS3 0x02
  144. #define SW1_CS4 0x03
  145. #define SW1_CS5 0x04
  146. #define SW1_CS6 0x05
  147. #define SW1_CS7 0x06
  148. #define SW1_CS8 0x07
  149. #define SW1_CS9 0x08
  150. #define SW1_CS10 0x09
  151. #define SW1_CS11 0x0A
  152. #define SW1_CS12 0x0B
  153. #define SW1_CS13 0x0C
  154. #define SW1_CS14 0x0D
  155. #define SW1_CS15 0x0E
  156. #define SW1_CS16 0x0F
  157. #define SW1_CS17 0x10
  158. #define SW1_CS18 0x11
  159. #define SW1_CS19 0x12
  160. #define SW1_CS20 0x13
  161. #define SW1_CS21 0x14
  162. #define SW1_CS22 0x15
  163. #define SW1_CS23 0x16
  164. #define SW1_CS24 0x17
  165. #define SW1_CS25 0x18
  166. #define SW1_CS26 0x19
  167. #define SW1_CS27 0x1A
  168. #define SW1_CS28 0x1B
  169. #define SW1_CS29 0x1C
  170. #define SW1_CS30 0x1D
  171. #define SW2_CS1 0x1E
  172. #define SW2_CS2 0x1F
  173. #define SW2_CS3 0x20
  174. #define SW2_CS4 0x21
  175. #define SW2_CS5 0x22
  176. #define SW2_CS6 0x23
  177. #define SW2_CS7 0x24
  178. #define SW2_CS8 0x25
  179. #define SW2_CS9 0x26
  180. #define SW2_CS10 0x27
  181. #define SW2_CS11 0x28
  182. #define SW2_CS12 0x29
  183. #define SW2_CS13 0x2A
  184. #define SW2_CS14 0x2B
  185. #define SW2_CS15 0x2C
  186. #define SW2_CS16 0x2D
  187. #define SW2_CS17 0x2E
  188. #define SW2_CS18 0x2F
  189. #define SW2_CS19 0x30
  190. #define SW2_CS20 0x31
  191. #define SW2_CS21 0x32
  192. #define SW2_CS22 0x33
  193. #define SW2_CS23 0x34
  194. #define SW2_CS24 0x35
  195. #define SW2_CS25 0x36
  196. #define SW2_CS26 0x37
  197. #define SW2_CS27 0x38
  198. #define SW2_CS28 0x39
  199. #define SW2_CS29 0x3A
  200. #define SW2_CS30 0x3B
  201. #define SW3_CS1 0x3C
  202. #define SW3_CS2 0x3D
  203. #define SW3_CS3 0x3E
  204. #define SW3_CS4 0x3F
  205. #define SW3_CS5 0x40
  206. #define SW3_CS6 0x41
  207. #define SW3_CS7 0x42
  208. #define SW3_CS8 0x43
  209. #define SW3_CS9 0x44
  210. #define SW3_CS10 0x45
  211. #define SW3_CS11 0x46
  212. #define SW3_CS12 0x47
  213. #define SW3_CS13 0x48
  214. #define SW3_CS14 0x49
  215. #define SW3_CS15 0x4A
  216. #define SW3_CS16 0x4B
  217. #define SW3_CS17 0x4C
  218. #define SW3_CS18 0x4D
  219. #define SW3_CS19 0x4E
  220. #define SW3_CS20 0x4F
  221. #define SW3_CS21 0x50
  222. #define SW3_CS22 0x51
  223. #define SW3_CS23 0x52
  224. #define SW3_CS24 0x53
  225. #define SW3_CS25 0x54
  226. #define SW3_CS26 0x55
  227. #define SW3_CS27 0x56
  228. #define SW3_CS28 0x57
  229. #define SW3_CS29 0x58
  230. #define SW3_CS30 0x59
  231. #define SW4_CS1 0x5A
  232. #define SW4_CS2 0x5B
  233. #define SW4_CS3 0x5C
  234. #define SW4_CS4 0x5D
  235. #define SW4_CS5 0x5E
  236. #define SW4_CS6 0x5F
  237. #define SW4_CS7 0x60
  238. #define SW4_CS8 0x61
  239. #define SW4_CS9 0x62
  240. #define SW4_CS10 0x63
  241. #define SW4_CS11 0x64
  242. #define SW4_CS12 0x65
  243. #define SW4_CS13 0x66
  244. #define SW4_CS14 0x67
  245. #define SW4_CS15 0x68
  246. #define SW4_CS16 0x69
  247. #define SW4_CS17 0x6A
  248. #define SW4_CS18 0x6B
  249. #define SW4_CS19 0x6C
  250. #define SW4_CS20 0x6D
  251. #define SW4_CS21 0x6E
  252. #define SW4_CS22 0x6F
  253. #define SW4_CS23 0x70
  254. #define SW4_CS24 0x71
  255. #define SW4_CS25 0x72
  256. #define SW4_CS26 0x73
  257. #define SW4_CS27 0x74
  258. #define SW4_CS28 0x75
  259. #define SW4_CS29 0x76
  260. #define SW4_CS30 0x77
  261. #define SW5_CS1 0x78
  262. #define SW5_CS2 0x79
  263. #define SW5_CS3 0x7A
  264. #define SW5_CS4 0x7B
  265. #define SW5_CS5 0x7C
  266. #define SW5_CS6 0x7D
  267. #define SW5_CS7 0x7E
  268. #define SW5_CS8 0x7F
  269. #define SW5_CS9 0x80
  270. #define SW5_CS10 0x81
  271. #define SW5_CS11 0x82
  272. #define SW5_CS12 0x83
  273. #define SW5_CS13 0x84
  274. #define SW5_CS14 0x85
  275. #define SW5_CS15 0x86
  276. #define SW5_CS16 0x87
  277. #define SW5_CS17 0x88
  278. #define SW5_CS18 0x89
  279. #define SW5_CS19 0x8A
  280. #define SW5_CS20 0x8B
  281. #define SW5_CS21 0x8C
  282. #define SW5_CS22 0x8D
  283. #define SW5_CS23 0x8E
  284. #define SW5_CS24 0x8F
  285. #define SW5_CS25 0x90
  286. #define SW5_CS26 0x91
  287. #define SW5_CS27 0x92
  288. #define SW5_CS28 0x93
  289. #define SW5_CS29 0x94
  290. #define SW5_CS30 0x95
  291. #define SW6_CS1 0x96
  292. #define SW6_CS2 0x97
  293. #define SW6_CS3 0x98
  294. #define SW6_CS4 0x99
  295. #define SW6_CS5 0x9A
  296. #define SW6_CS6 0x9B
  297. #define SW6_CS7 0x9C
  298. #define SW6_CS8 0x9D
  299. #define SW6_CS9 0x9E
  300. #define SW6_CS10 0x9F
  301. #define SW6_CS11 0xA0
  302. #define SW6_CS12 0xA1
  303. #define SW6_CS13 0xA2
  304. #define SW6_CS14 0xA3
  305. #define SW6_CS15 0xA4
  306. #define SW6_CS16 0xA5
  307. #define SW6_CS17 0xA6
  308. #define SW6_CS18 0xA7
  309. #define SW6_CS19 0xA8
  310. #define SW6_CS20 0xA9
  311. #define SW6_CS21 0xAA
  312. #define SW6_CS22 0xAB
  313. #define SW6_CS23 0xAC
  314. #define SW6_CS24 0xAD
  315. #define SW6_CS25 0xAE
  316. #define SW6_CS26 0xAF
  317. #define SW6_CS27 0xB0
  318. #define SW6_CS28 0xB1
  319. #define SW6_CS29 0xB2
  320. #define SW6_CS30 0xB3
  321. #define SW7_CS1 0x100
  322. #define SW7_CS2 0x101
  323. #define SW7_CS3 0x102
  324. #define SW7_CS4 0x103
  325. #define SW7_CS5 0x104
  326. #define SW7_CS6 0x105
  327. #define SW7_CS7 0x106
  328. #define SW7_CS8 0x107
  329. #define SW7_CS9 0x108
  330. #define SW7_CS10 0x109
  331. #define SW7_CS11 0x10A
  332. #define SW7_CS12 0x10B
  333. #define SW7_CS13 0x10C
  334. #define SW7_CS14 0x10D
  335. #define SW7_CS15 0x10E
  336. #define SW7_CS16 0x10F
  337. #define SW7_CS17 0x110
  338. #define SW7_CS18 0x111
  339. #define SW7_CS19 0x112
  340. #define SW7_CS20 0x113
  341. #define SW7_CS21 0x114
  342. #define SW7_CS22 0x115
  343. #define SW7_CS23 0x116
  344. #define SW7_CS24 0x117
  345. #define SW7_CS25 0x118
  346. #define SW7_CS26 0x119
  347. #define SW7_CS27 0x11A
  348. #define SW7_CS28 0x11B
  349. #define SW7_CS29 0x11C
  350. #define SW7_CS30 0x11D
  351. #define SW8_CS1 0x11E
  352. #define SW8_CS2 0x11F
  353. #define SW8_CS3 0x120
  354. #define SW8_CS4 0x121
  355. #define SW8_CS5 0x122
  356. #define SW8_CS6 0x123
  357. #define SW8_CS7 0x124
  358. #define SW8_CS8 0x125
  359. #define SW8_CS9 0x126
  360. #define SW8_CS10 0x127
  361. #define SW8_CS11 0x128
  362. #define SW8_CS12 0x129
  363. #define SW8_CS13 0x12A
  364. #define SW8_CS14 0x12B
  365. #define SW8_CS15 0x12C
  366. #define SW8_CS16 0x12D
  367. #define SW8_CS17 0x12E
  368. #define SW8_CS18 0x12F
  369. #define SW8_CS19 0x130
  370. #define SW8_CS20 0x131
  371. #define SW8_CS21 0x132
  372. #define SW8_CS22 0x133
  373. #define SW8_CS23 0x134
  374. #define SW8_CS24 0x135
  375. #define SW8_CS25 0x136
  376. #define SW8_CS26 0x137
  377. #define SW8_CS27 0x138
  378. #define SW8_CS28 0x139
  379. #define SW8_CS29 0x13A
  380. #define SW8_CS30 0x13B
  381. #define SW9_CS1 0x13C
  382. #define SW9_CS2 0x13D
  383. #define SW9_CS3 0x13E
  384. #define SW9_CS4 0x13F
  385. #define SW9_CS5 0x140
  386. #define SW9_CS6 0x141
  387. #define SW9_CS7 0x142
  388. #define SW9_CS8 0x143
  389. #define SW9_CS9 0x144
  390. #define SW9_CS10 0x145
  391. #define SW9_CS11 0x146
  392. #define SW9_CS12 0x147
  393. #define SW9_CS13 0x148
  394. #define SW9_CS14 0x149
  395. #define SW9_CS15 0x14A
  396. #define SW9_CS16 0x14B
  397. #define SW9_CS17 0x14C
  398. #define SW9_CS18 0x14D
  399. #define SW9_CS19 0x14E
  400. #define SW9_CS20 0x14F
  401. #define SW9_CS21 0x150
  402. #define SW9_CS22 0x151
  403. #define SW9_CS23 0x152
  404. #define SW9_CS24 0x153
  405. #define SW9_CS25 0x154
  406. #define SW9_CS26 0x155
  407. #define SW9_CS27 0x156
  408. #define SW9_CS28 0x157
  409. #define SW9_CS29 0x158
  410. #define SW9_CS30 0x159
  411. #define SW1_CS31 0x15A
  412. #define SW1_CS32 0x15B
  413. #define SW1_CS33 0x15C
  414. #define SW1_CS34 0x15D
  415. #define SW1_CS35 0x15E
  416. #define SW1_CS36 0x15F
  417. #define SW1_CS37 0x160
  418. #define SW1_CS38 0x161
  419. #define SW1_CS39 0x162
  420. #define SW2_CS31 0x163
  421. #define SW2_CS32 0x164
  422. #define SW2_CS33 0x165
  423. #define SW2_CS34 0x166
  424. #define SW2_CS35 0x167
  425. #define SW2_CS36 0x168
  426. #define SW2_CS37 0x169
  427. #define SW2_CS38 0x16A
  428. #define SW2_CS39 0x16B
  429. #define SW3_CS31 0x16C
  430. #define SW3_CS32 0x16D
  431. #define SW3_CS33 0x16E
  432. #define SW3_CS34 0x16F
  433. #define SW3_CS35 0x170
  434. #define SW3_CS36 0x171
  435. #define SW3_CS37 0x172
  436. #define SW3_CS38 0x173
  437. #define SW3_CS39 0x174
  438. #define SW4_CS31 0x175
  439. #define SW4_CS32 0x176
  440. #define SW4_CS33 0x177
  441. #define SW4_CS34 0x178
  442. #define SW4_CS35 0x179
  443. #define SW4_CS36 0x17A
  444. #define SW4_CS37 0x17B
  445. #define SW4_CS38 0x17C
  446. #define SW4_CS39 0x17D
  447. #define SW5_CS31 0x17E
  448. #define SW5_CS32 0x17F
  449. #define SW5_CS33 0x180
  450. #define SW5_CS34 0x181
  451. #define SW5_CS35 0x182
  452. #define SW5_CS36 0x183
  453. #define SW5_CS37 0x184
  454. #define SW5_CS38 0x185
  455. #define SW5_CS39 0x186
  456. #define SW6_CS31 0x187
  457. #define SW6_CS32 0x188
  458. #define SW6_CS33 0x189
  459. #define SW6_CS34 0x18A
  460. #define SW6_CS35 0x18B
  461. #define SW6_CS36 0x18C
  462. #define SW6_CS37 0x18D
  463. #define SW6_CS38 0x18E
  464. #define SW6_CS39 0x18F
  465. #define SW7_CS31 0x190
  466. #define SW7_CS32 0x191
  467. #define SW7_CS33 0x192
  468. #define SW7_CS34 0x193
  469. #define SW7_CS35 0x194
  470. #define SW7_CS36 0x195
  471. #define SW7_CS37 0x196
  472. #define SW7_CS38 0x197
  473. #define SW7_CS39 0x198
  474. #define SW8_CS31 0x199
  475. #define SW8_CS32 0x19A
  476. #define SW8_CS33 0x19B
  477. #define SW8_CS34 0x19C
  478. #define SW8_CS35 0x19D
  479. #define SW8_CS36 0x19E
  480. #define SW8_CS37 0x19F
  481. #define SW8_CS38 0x1A0
  482. #define SW8_CS39 0x1A1
  483. #define SW9_CS31 0x1A2
  484. #define SW9_CS32 0x1A3
  485. #define SW9_CS33 0x1A4
  486. #define SW9_CS34 0x1A5
  487. #define SW9_CS35 0x1A6
  488. #define SW9_CS36 0x1A7
  489. #define SW9_CS37 0x1A8
  490. #define SW9_CS38 0x1A9
  491. #define SW9_CS39 0x1AA
  492. // DEPRECATED - DO NOT USE
  493. #define CS1_SW1 SW1_CS1
  494. #define CS2_SW1 SW1_CS2
  495. #define CS3_SW1 SW1_CS3
  496. #define CS4_SW1 SW1_CS4
  497. #define CS5_SW1 SW1_CS5
  498. #define CS6_SW1 SW1_CS6
  499. #define CS7_SW1 SW1_CS7
  500. #define CS8_SW1 SW1_CS8
  501. #define CS9_SW1 SW1_CS9
  502. #define CS10_SW1 SW1_CS10
  503. #define CS11_SW1 SW1_CS11
  504. #define CS12_SW1 SW1_CS12
  505. #define CS13_SW1 SW1_CS13
  506. #define CS14_SW1 SW1_CS14
  507. #define CS15_SW1 SW1_CS15
  508. #define CS16_SW1 SW1_CS16
  509. #define CS17_SW1 SW1_CS17
  510. #define CS18_SW1 SW1_CS18
  511. #define CS19_SW1 SW1_CS19
  512. #define CS20_SW1 SW1_CS20
  513. #define CS21_SW1 SW1_CS21
  514. #define CS22_SW1 SW1_CS22
  515. #define CS23_SW1 SW1_CS23
  516. #define CS24_SW1 SW1_CS24
  517. #define CS25_SW1 SW1_CS25
  518. #define CS26_SW1 SW1_CS26
  519. #define CS27_SW1 SW1_CS27
  520. #define CS28_SW1 SW1_CS28
  521. #define CS29_SW1 SW1_CS29
  522. #define CS30_SW1 SW1_CS30
  523. #define CS1_SW2 SW2_CS1
  524. #define CS2_SW2 SW2_CS2
  525. #define CS3_SW2 SW2_CS3
  526. #define CS4_SW2 SW2_CS4
  527. #define CS5_SW2 SW2_CS5
  528. #define CS6_SW2 SW2_CS6
  529. #define CS7_SW2 SW2_CS7
  530. #define CS8_SW2 SW2_CS8
  531. #define CS9_SW2 SW2_CS9
  532. #define CS10_SW2 SW2_CS10
  533. #define CS11_SW2 SW2_CS11
  534. #define CS12_SW2 SW2_CS12
  535. #define CS13_SW2 SW2_CS13
  536. #define CS14_SW2 SW2_CS14
  537. #define CS15_SW2 SW2_CS15
  538. #define CS16_SW2 SW2_CS16
  539. #define CS17_SW2 SW2_CS17
  540. #define CS18_SW2 SW2_CS18
  541. #define CS19_SW2 SW2_CS19
  542. #define CS20_SW2 SW2_CS20
  543. #define CS21_SW2 SW2_CS21
  544. #define CS22_SW2 SW2_CS22
  545. #define CS23_SW2 SW2_CS23
  546. #define CS24_SW2 SW2_CS24
  547. #define CS25_SW2 SW2_CS25
  548. #define CS26_SW2 SW2_CS26
  549. #define CS27_SW2 SW2_CS27
  550. #define CS28_SW2 SW2_CS28
  551. #define CS29_SW2 SW2_CS29
  552. #define CS30_SW2 SW2_CS30
  553. #define CS1_SW3 SW3_CS1
  554. #define CS2_SW3 SW3_CS2
  555. #define CS3_SW3 SW3_CS3
  556. #define CS4_SW3 SW3_CS4
  557. #define CS5_SW3 SW3_CS5
  558. #define CS6_SW3 SW3_CS6
  559. #define CS7_SW3 SW3_CS7
  560. #define CS8_SW3 SW3_CS8
  561. #define CS9_SW3 SW3_CS9
  562. #define CS10_SW3 SW3_CS10
  563. #define CS11_SW3 SW3_CS11
  564. #define CS12_SW3 SW3_CS12
  565. #define CS13_SW3 SW3_CS13
  566. #define CS14_SW3 SW3_CS14
  567. #define CS15_SW3 SW3_CS15
  568. #define CS16_SW3 SW3_CS16
  569. #define CS17_SW3 SW3_CS17
  570. #define CS18_SW3 SW3_CS18
  571. #define CS19_SW3 SW3_CS19
  572. #define CS20_SW3 SW3_CS20
  573. #define CS21_SW3 SW3_CS21
  574. #define CS22_SW3 SW3_CS22
  575. #define CS23_SW3 SW3_CS23
  576. #define CS24_SW3 SW3_CS24
  577. #define CS25_SW3 SW3_CS25
  578. #define CS26_SW3 SW3_CS26
  579. #define CS27_SW3 SW3_CS27
  580. #define CS28_SW3 SW3_CS28
  581. #define CS29_SW3 SW3_CS29
  582. #define CS30_SW3 SW3_CS30
  583. #define CS1_SW4 SW4_CS1
  584. #define CS2_SW4 SW4_CS2
  585. #define CS3_SW4 SW4_CS3
  586. #define CS4_SW4 SW4_CS4
  587. #define CS5_SW4 SW4_CS5
  588. #define CS6_SW4 SW4_CS6
  589. #define CS7_SW4 SW4_CS7
  590. #define CS8_SW4 SW4_CS8
  591. #define CS9_SW4 SW4_CS9
  592. #define CS10_SW4 SW4_CS10
  593. #define CS11_SW4 SW4_CS11
  594. #define CS12_SW4 SW4_CS12
  595. #define CS13_SW4 SW4_CS13
  596. #define CS14_SW4 SW4_CS14
  597. #define CS15_SW4 SW4_CS15
  598. #define CS16_SW4 SW4_CS16
  599. #define CS17_SW4 SW4_CS17
  600. #define CS18_SW4 SW4_CS18
  601. #define CS19_SW4 SW4_CS19
  602. #define CS20_SW4 SW4_CS20
  603. #define CS21_SW4 SW4_CS21
  604. #define CS22_SW4 SW4_CS22
  605. #define CS23_SW4 SW4_CS23
  606. #define CS24_SW4 SW4_CS24
  607. #define CS25_SW4 SW4_CS25
  608. #define CS26_SW4 SW4_CS26
  609. #define CS27_SW4 SW4_CS27
  610. #define CS28_SW4 SW4_CS28
  611. #define CS29_SW4 SW4_CS29
  612. #define CS30_SW4 SW4_CS30
  613. #define CS1_SW5 SW5_CS1
  614. #define CS2_SW5 SW5_CS2
  615. #define CS3_SW5 SW5_CS3
  616. #define CS4_SW5 SW5_CS4
  617. #define CS5_SW5 SW5_CS5
  618. #define CS6_SW5 SW5_CS6
  619. #define CS7_SW5 SW5_CS7
  620. #define CS8_SW5 SW5_CS8
  621. #define CS9_SW5 SW5_CS9
  622. #define CS10_SW5 SW5_CS10
  623. #define CS11_SW5 SW5_CS11
  624. #define CS12_SW5 SW5_CS12
  625. #define CS13_SW5 SW5_CS13
  626. #define CS14_SW5 SW5_CS14
  627. #define CS15_SW5 SW5_CS15
  628. #define CS16_SW5 SW5_CS16
  629. #define CS17_SW5 SW5_CS17
  630. #define CS18_SW5 SW5_CS18
  631. #define CS19_SW5 SW5_CS19
  632. #define CS20_SW5 SW5_CS20
  633. #define CS21_SW5 SW5_CS21
  634. #define CS22_SW5 SW5_CS22
  635. #define CS23_SW5 SW5_CS23
  636. #define CS24_SW5 SW5_CS24
  637. #define CS25_SW5 SW5_CS25
  638. #define CS26_SW5 SW5_CS26
  639. #define CS27_SW5 SW5_CS27
  640. #define CS28_SW5 SW5_CS28
  641. #define CS29_SW5 SW5_CS29
  642. #define CS30_SW5 SW5_CS30
  643. #define CS1_SW6 SW6_CS1
  644. #define CS2_SW6 SW6_CS2
  645. #define CS3_SW6 SW6_CS3
  646. #define CS4_SW6 SW6_CS4
  647. #define CS5_SW6 SW6_CS5
  648. #define CS6_SW6 SW6_CS6
  649. #define CS7_SW6 SW6_CS7
  650. #define CS8_SW6 SW6_CS8
  651. #define CS9_SW6 SW6_CS9
  652. #define CS10_SW6 SW6_CS10
  653. #define CS11_SW6 SW6_CS11
  654. #define CS12_SW6 SW6_CS12
  655. #define CS13_SW6 SW6_CS13
  656. #define CS14_SW6 SW6_CS14
  657. #define CS15_SW6 SW6_CS15
  658. #define CS16_SW6 SW6_CS16
  659. #define CS17_SW6 SW6_CS17
  660. #define CS18_SW6 SW6_CS18
  661. #define CS19_SW6 SW6_CS19
  662. #define CS20_SW6 SW6_CS20
  663. #define CS21_SW6 SW6_CS21
  664. #define CS22_SW6 SW6_CS22
  665. #define CS23_SW6 SW6_CS23
  666. #define CS24_SW6 SW6_CS24
  667. #define CS25_SW6 SW6_CS25
  668. #define CS26_SW6 SW6_CS26
  669. #define CS27_SW6 SW6_CS27
  670. #define CS28_SW6 SW6_CS28
  671. #define CS29_SW6 SW6_CS29
  672. #define CS30_SW6 SW6_CS30
  673. #define CS1_SW7 SW7_CS1
  674. #define CS2_SW7 SW7_CS2
  675. #define CS3_SW7 SW7_CS3
  676. #define CS4_SW7 SW7_CS4
  677. #define CS5_SW7 SW7_CS5
  678. #define CS6_SW7 SW7_CS6
  679. #define CS7_SW7 SW7_CS7
  680. #define CS8_SW7 SW7_CS8
  681. #define CS9_SW7 SW7_CS9
  682. #define CS10_SW7 SW7_CS10
  683. #define CS11_SW7 SW7_CS11
  684. #define CS12_SW7 SW7_CS12
  685. #define CS13_SW7 SW7_CS13
  686. #define CS14_SW7 SW7_CS14
  687. #define CS15_SW7 SW7_CS15
  688. #define CS16_SW7 SW7_CS16
  689. #define CS17_SW7 SW7_CS17
  690. #define CS18_SW7 SW7_CS18
  691. #define CS19_SW7 SW7_CS19
  692. #define CS20_SW7 SW7_CS20
  693. #define CS21_SW7 SW7_CS21
  694. #define CS22_SW7 SW7_CS22
  695. #define CS23_SW7 SW7_CS23
  696. #define CS24_SW7 SW7_CS24
  697. #define CS25_SW7 SW7_CS25
  698. #define CS26_SW7 SW7_CS26
  699. #define CS27_SW7 SW7_CS27
  700. #define CS28_SW7 SW7_CS28
  701. #define CS29_SW7 SW7_CS29
  702. #define CS30_SW7 SW7_CS30
  703. #define CS1_SW8 SW8_CS1
  704. #define CS2_SW8 SW8_CS2
  705. #define CS3_SW8 SW8_CS3
  706. #define CS4_SW8 SW8_CS4
  707. #define CS5_SW8 SW8_CS5
  708. #define CS6_SW8 SW8_CS6
  709. #define CS7_SW8 SW8_CS7
  710. #define CS8_SW8 SW8_CS8
  711. #define CS9_SW8 SW8_CS9
  712. #define CS10_SW8 SW8_CS10
  713. #define CS11_SW8 SW8_CS11
  714. #define CS12_SW8 SW8_CS12
  715. #define CS13_SW8 SW8_CS13
  716. #define CS14_SW8 SW8_CS14
  717. #define CS15_SW8 SW8_CS15
  718. #define CS16_SW8 SW8_CS16
  719. #define CS17_SW8 SW8_CS17
  720. #define CS18_SW8 SW8_CS18
  721. #define CS19_SW8 SW8_CS19
  722. #define CS20_SW8 SW8_CS20
  723. #define CS21_SW8 SW8_CS21
  724. #define CS22_SW8 SW8_CS22
  725. #define CS23_SW8 SW8_CS23
  726. #define CS24_SW8 SW8_CS24
  727. #define CS25_SW8 SW8_CS25
  728. #define CS26_SW8 SW8_CS26
  729. #define CS27_SW8 SW8_CS27
  730. #define CS28_SW8 SW8_CS28
  731. #define CS29_SW8 SW8_CS29
  732. #define CS30_SW8 SW8_CS30
  733. #define CS1_SW9 SW9_CS1
  734. #define CS2_SW9 SW9_CS2
  735. #define CS3_SW9 SW9_CS3
  736. #define CS4_SW9 SW9_CS4
  737. #define CS5_SW9 SW9_CS5
  738. #define CS6_SW9 SW9_CS6
  739. #define CS7_SW9 SW9_CS7
  740. #define CS8_SW9 SW9_CS8
  741. #define CS9_SW9 SW9_CS9
  742. #define CS10_SW9 SW9_CS10
  743. #define CS11_SW9 SW9_CS11
  744. #define CS12_SW9 SW9_CS12
  745. #define CS13_SW9 SW9_CS13
  746. #define CS14_SW9 SW9_CS14
  747. #define CS15_SW9 SW9_CS15
  748. #define CS16_SW9 SW9_CS16
  749. #define CS17_SW9 SW9_CS17
  750. #define CS18_SW9 SW9_CS18
  751. #define CS19_SW9 SW9_CS19
  752. #define CS20_SW9 SW9_CS20
  753. #define CS21_SW9 SW9_CS21
  754. #define CS22_SW9 SW9_CS22
  755. #define CS23_SW9 SW9_CS23
  756. #define CS24_SW9 SW9_CS24
  757. #define CS25_SW9 SW9_CS25
  758. #define CS26_SW9 SW9_CS26
  759. #define CS27_SW9 SW9_CS27
  760. #define CS28_SW9 SW9_CS28
  761. #define CS29_SW9 SW9_CS29
  762. #define CS30_SW9 SW9_CS30
  763. #define CS31_SW1 SW1_CS31
  764. #define CS32_SW1 SW1_CS32
  765. #define CS33_SW1 SW1_CS33
  766. #define CS34_SW1 SW1_CS34
  767. #define CS35_SW1 SW1_CS35
  768. #define CS36_SW1 SW1_CS36
  769. #define CS37_SW1 SW1_CS37
  770. #define CS38_SW1 SW1_CS38
  771. #define CS39_SW1 SW1_CS39
  772. #define CS31_SW2 SW2_CS31
  773. #define CS32_SW2 SW2_CS32
  774. #define CS33_SW2 SW2_CS33
  775. #define CS34_SW2 SW2_CS34
  776. #define CS35_SW2 SW2_CS35
  777. #define CS36_SW2 SW2_CS36
  778. #define CS37_SW2 SW2_CS37
  779. #define CS38_SW2 SW2_CS38
  780. #define CS39_SW2 SW2_CS39
  781. #define CS31_SW3 SW3_CS31
  782. #define CS32_SW3 SW3_CS32
  783. #define CS33_SW3 SW3_CS33
  784. #define CS34_SW3 SW3_CS34
  785. #define CS35_SW3 SW3_CS35
  786. #define CS36_SW3 SW3_CS36
  787. #define CS37_SW3 SW3_CS37
  788. #define CS38_SW3 SW3_CS38
  789. #define CS39_SW3 SW3_CS39
  790. #define CS31_SW4 SW4_CS31
  791. #define CS32_SW4 SW4_CS32
  792. #define CS33_SW4 SW4_CS33
  793. #define CS34_SW4 SW4_CS34
  794. #define CS35_SW4 SW4_CS35
  795. #define CS36_SW4 SW4_CS36
  796. #define CS37_SW4 SW4_CS37
  797. #define CS38_SW4 SW4_CS38
  798. #define CS39_SW4 SW4_CS39
  799. #define CS31_SW5 SW5_CS31
  800. #define CS32_SW5 SW5_CS32
  801. #define CS33_SW5 SW5_CS33
  802. #define CS34_SW5 SW5_CS34
  803. #define CS35_SW5 SW5_CS35
  804. #define CS36_SW5 SW5_CS36
  805. #define CS37_SW5 SW5_CS37
  806. #define CS38_SW5 SW5_CS38
  807. #define CS39_SW5 SW5_CS39
  808. #define CS31_SW6 SW6_CS31
  809. #define CS32_SW6 SW6_CS32
  810. #define CS33_SW6 SW6_CS33
  811. #define CS34_SW6 SW6_CS34
  812. #define CS35_SW6 SW6_CS35
  813. #define CS36_SW6 SW6_CS36
  814. #define CS37_SW6 SW6_CS37
  815. #define CS38_SW6 SW6_CS38
  816. #define CS39_SW6 SW6_CS39
  817. #define CS31_SW7 SW7_CS31
  818. #define CS32_SW7 SW7_CS32
  819. #define CS33_SW7 SW7_CS33
  820. #define CS34_SW7 SW7_CS34
  821. #define CS35_SW7 SW7_CS35
  822. #define CS36_SW7 SW7_CS36
  823. #define CS37_SW7 SW7_CS37
  824. #define CS38_SW7 SW7_CS38
  825. #define CS39_SW7 SW7_CS39
  826. #define CS31_SW8 SW8_CS31
  827. #define CS32_SW8 SW8_CS32
  828. #define CS33_SW8 SW8_CS33
  829. #define CS34_SW8 SW8_CS34
  830. #define CS35_SW8 SW8_CS35
  831. #define CS36_SW8 SW8_CS36
  832. #define CS37_SW8 SW8_CS37
  833. #define CS38_SW8 SW8_CS38
  834. #define CS39_SW8 SW8_CS39
  835. #define CS31_SW9 SW9_CS31
  836. #define CS32_SW9 SW9_CS32
  837. #define CS33_SW9 SW9_CS33
  838. #define CS34_SW9 SW9_CS34
  839. #define CS35_SW9 SW9_CS35
  840. #define CS36_SW9 SW9_CS36
  841. #define CS37_SW9 SW9_CS37
  842. #define CS38_SW9 SW9_CS38
  843. #define CS39_SW9 SW9_CS39