logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

is31fl3737-mono.h (7234B)


  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2018 Jack Humbert
  3. * Copyright 2018 Yiancar
  4. * Copyright 2021 Doni Crosby
  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. #define IS31FL3737_REG_INTERRUPT_MASK 0xF0
  25. #define IS31FL3737_REG_INTERRUPT_STATUS 0xF1
  26. #define IS31FL3737_REG_COMMAND 0xFD
  27. #define IS31FL3737_COMMAND_LED_CONTROL 0x00
  28. #define IS31FL3737_COMMAND_PWM 0x01
  29. #define IS31FL3737_COMMAND_AUTO_BREATH 0x02
  30. #define IS31FL3737_COMMAND_FUNCTION 0x03
  31. #define IS31FL3737_FUNCTION_REG_CONFIGURATION 0x00
  32. #define IS31FL3737_FUNCTION_REG_GLOBAL_CURRENT 0x01
  33. #define IS31FL3737_FUNCTION_REG_SW_PULLUP 0x0F
  34. #define IS31FL3737_FUNCTION_REG_CS_PULLDOWN 0x10
  35. #define IS31FL3737_FUNCTION_REG_RESET 0x11
  36. #define IS31FL3737_REG_COMMAND_WRITE_LOCK 0xFE
  37. #define IS31FL3737_COMMAND_WRITE_LOCK_MAGIC 0xC5
  38. #define IS31FL3737_I2C_ADDRESS_GND 0x50
  39. #define IS31FL3737_I2C_ADDRESS_SCL 0x55
  40. #define IS31FL3737_I2C_ADDRESS_SDA 0x5A
  41. #define IS31FL3737_I2C_ADDRESS_VCC 0x5F
  42. #if defined(LED_MATRIX_IS31FL3737)
  43. # define IS31FL3737_LED_COUNT LED_MATRIX_LED_COUNT
  44. #endif
  45. #if defined(IS31FL3737_I2C_ADDRESS_4)
  46. # define IS31FL3737_DRIVER_COUNT 4
  47. #elif defined(IS31FL3737_I2C_ADDRESS_3)
  48. # define IS31FL3737_DRIVER_COUNT 3
  49. #elif defined(IS31FL3737_I2C_ADDRESS_2)
  50. # define IS31FL3737_DRIVER_COUNT 2
  51. #elif defined(IS31FL3737_I2C_ADDRESS_1)
  52. # define IS31FL3737_DRIVER_COUNT 1
  53. #endif
  54. typedef struct is31fl3737_led_t {
  55. uint8_t driver : 2;
  56. uint8_t v;
  57. } PACKED is31fl3737_led_t;
  58. extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[IS31FL3737_LED_COUNT];
  59. void is31fl3737_init_drivers(void);
  60. void is31fl3737_init(uint8_t index);
  61. void is31fl3737_write_register(uint8_t index, uint8_t reg, uint8_t data);
  62. void is31fl3737_select_page(uint8_t index, uint8_t page);
  63. void is31fl3737_set_value(int index, uint8_t value);
  64. void is31fl3737_set_value_all(uint8_t value);
  65. void is31fl3737_set_led_control_register(uint8_t index, bool value);
  66. // This should not be called from an interrupt
  67. // (eg. from a timer interrupt).
  68. // Call this while idle (in between matrix scans).
  69. // If the buffer is dirty, it will update the driver with the buffer.
  70. void is31fl3737_update_pwm_buffers(uint8_t index);
  71. void is31fl3737_update_led_control_registers(uint8_t index);
  72. void is31fl3737_flush(void);
  73. #define IS31FL3737_PDR_0_OHM 0b000 // No pull-down resistor
  74. #define IS31FL3737_PDR_0K5_OHM 0b001 // 0.5 kOhm resistor
  75. #define IS31FL3737_PDR_1K_OHM 0b010 // 1 kOhm resistor
  76. #define IS31FL3737_PDR_2K_OHM 0b011 // 2 kOhm resistor
  77. #define IS31FL3737_PDR_4K_OHM 0b100 // 4 kOhm resistor
  78. #define IS31FL3737_PDR_8K_OHM 0b101 // 8 kOhm resistor
  79. #define IS31FL3737_PDR_16K_OHM 0b110 // 16 kOhm resistor
  80. #define IS31FL3737_PDR_32K_OHM 0b111 // 32 kOhm resistor
  81. #define IS31FL3737_PUR_0_OHM 0b000 // No pull-up resistor
  82. #define IS31FL3737_PUR_0K5_OHM 0b001 // 0.5 kOhm resistor
  83. #define IS31FL3737_PUR_1K_OHM 0b010 // 1 kOhm resistor
  84. #define IS31FL3737_PUR_2K_OHM 0b011 // 2 kOhm resistor
  85. #define IS31FL3737_PUR_4K_OHM 0b100 // 4 kOhm resistor
  86. #define IS31FL3737_PUR_8K_OHM 0b101 // 8 kOhm resistor
  87. #define IS31FL3737_PUR_16K_OHM 0b110 // 16 kOhm resistor
  88. #define IS31FL3737_PUR_32K_OHM 0b111 // 32 kOhm resistor
  89. #define IS31FL3737_PWM_FREQUENCY_8K4_HZ 0b000
  90. #define IS31FL3737_PWM_FREQUENCY_4K2_HZ 0b001
  91. #define IS31FL3737_PWM_FREQUENCY_26K7_HZ 0b010
  92. #define IS31FL3737_PWM_FREQUENCY_2K1_HZ 0b011
  93. #define IS31FL3737_PWM_FREQUENCY_1K05_HZ 0b100
  94. #define SW1_CS1 0x00
  95. #define SW1_CS2 0x01
  96. #define SW1_CS3 0x02
  97. #define SW1_CS4 0x03
  98. #define SW1_CS5 0x04
  99. #define SW1_CS6 0x05
  100. #define SW1_CS7 0x08
  101. #define SW1_CS8 0x09
  102. #define SW1_CS9 0x0A
  103. #define SW1_CS10 0x0B
  104. #define SW1_CS11 0x0C
  105. #define SW1_CS12 0x0D
  106. #define SW2_CS1 0x10
  107. #define SW2_CS2 0x11
  108. #define SW2_CS3 0x12
  109. #define SW2_CS4 0x13
  110. #define SW2_CS5 0x14
  111. #define SW2_CS6 0x15
  112. #define SW2_CS7 0x18
  113. #define SW2_CS8 0x19
  114. #define SW2_CS9 0x1A
  115. #define SW2_CS10 0x1B
  116. #define SW2_CS11 0x1C
  117. #define SW2_CS12 0x1D
  118. #define SW3_CS1 0x20
  119. #define SW3_CS2 0x21
  120. #define SW3_CS3 0x22
  121. #define SW3_CS4 0x23
  122. #define SW3_CS5 0x24
  123. #define SW3_CS6 0x25
  124. #define SW3_CS7 0x28
  125. #define SW3_CS8 0x29
  126. #define SW3_CS9 0x2A
  127. #define SW3_CS10 0x2B
  128. #define SW3_CS11 0x2C
  129. #define SW3_CS12 0x2D
  130. #define SW4_CS1 0x30
  131. #define SW4_CS2 0x31
  132. #define SW4_CS3 0x32
  133. #define SW4_CS4 0x33
  134. #define SW4_CS5 0x34
  135. #define SW4_CS6 0x35
  136. #define SW4_CS7 0x38
  137. #define SW4_CS8 0x39
  138. #define SW4_CS9 0x3A
  139. #define SW4_CS10 0x3B
  140. #define SW4_CS11 0x3C
  141. #define SW4_CS12 0x3D
  142. #define SW5_CS1 0x40
  143. #define SW5_CS2 0x41
  144. #define SW5_CS3 0x42
  145. #define SW5_CS4 0x43
  146. #define SW5_CS5 0x44
  147. #define SW5_CS6 0x45
  148. #define SW5_CS7 0x48
  149. #define SW5_CS8 0x49
  150. #define SW5_CS9 0x4A
  151. #define SW5_CS10 0x4B
  152. #define SW5_CS11 0x4C
  153. #define SW5_CS12 0x4D
  154. #define SW6_CS1 0x50
  155. #define SW6_CS2 0x51
  156. #define SW6_CS3 0x52
  157. #define SW6_CS4 0x53
  158. #define SW6_CS5 0x54
  159. #define SW6_CS6 0x55
  160. #define SW6_CS7 0x58
  161. #define SW6_CS8 0x59
  162. #define SW6_CS9 0x5A
  163. #define SW6_CS10 0x5B
  164. #define SW6_CS11 0x5C
  165. #define SW6_CS12 0x5D
  166. #define SW7_CS1 0x60
  167. #define SW7_CS2 0x61
  168. #define SW7_CS3 0x62
  169. #define SW7_CS4 0x63
  170. #define SW7_CS5 0x64
  171. #define SW7_CS6 0x65
  172. #define SW7_CS7 0x68
  173. #define SW7_CS8 0x69
  174. #define SW7_CS9 0x6A
  175. #define SW7_CS10 0x6B
  176. #define SW7_CS11 0x6C
  177. #define SW7_CS12 0x6D
  178. #define SW8_CS1 0x70
  179. #define SW8_CS2 0x71
  180. #define SW8_CS3 0x72
  181. #define SW8_CS4 0x73
  182. #define SW8_CS5 0x74
  183. #define SW8_CS6 0x75
  184. #define SW8_CS7 0x78
  185. #define SW8_CS8 0x79
  186. #define SW8_CS9 0x7A
  187. #define SW8_CS10 0x7B
  188. #define SW8_CS11 0x7C
  189. #define SW8_CS12 0x7D
  190. #define SW9_CS1 0x80
  191. #define SW9_CS2 0x81
  192. #define SW9_CS3 0x82
  193. #define SW9_CS4 0x83
  194. #define SW9_CS5 0x84
  195. #define SW9_CS6 0x85
  196. #define SW9_CS7 0x88
  197. #define SW9_CS8 0x89
  198. #define SW9_CS9 0x8A
  199. #define SW9_CS10 0x8B
  200. #define SW9_CS11 0x8C
  201. #define SW9_CS12 0x8D
  202. #define SW10_CS1 0x90
  203. #define SW10_CS2 0x91
  204. #define SW10_CS3 0x92
  205. #define SW10_CS4 0x93
  206. #define SW10_CS5 0x94
  207. #define SW10_CS6 0x95
  208. #define SW10_CS7 0x98
  209. #define SW10_CS8 0x99
  210. #define SW10_CS9 0x9A
  211. #define SW10_CS10 0x9B
  212. #define SW10_CS11 0x9C
  213. #define SW10_CS12 0x9D
  214. #define SW11_CS1 0xA0
  215. #define SW11_CS2 0xA1
  216. #define SW11_CS3 0xA2
  217. #define SW11_CS4 0xA3
  218. #define SW11_CS5 0xA4
  219. #define SW11_CS6 0xA5
  220. #define SW11_CS7 0xA8
  221. #define SW11_CS8 0xA9
  222. #define SW11_CS9 0xAA
  223. #define SW11_CS10 0xAB
  224. #define SW11_CS11 0xAC
  225. #define SW11_CS12 0xAD
  226. #define SW12_CS1 0xB0
  227. #define SW12_CS2 0xB1
  228. #define SW12_CS3 0xB2
  229. #define SW12_CS4 0xB3
  230. #define SW12_CS5 0xB4
  231. #define SW12_CS6 0xB5
  232. #define SW12_CS7 0xB8
  233. #define SW12_CS8 0xB9
  234. #define SW12_CS9 0xBA
  235. #define SW12_CS10 0xBB
  236. #define SW12_CS11 0xBC
  237. #define SW12_CS12 0xBD