is31fl3743a.md (12761B)
1 # IS31FL3743A Driver {#is31fl3743a-driver} 2 3 I²C 18x11 LED matrix driver by Lumissil. Supports a maximum of four drivers, each controlling up to 198 single-color LEDs, or 66 RGB LEDs. 4 5 [IS31FL3743A Datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3743A_DS.pdf) 6 7 ## Usage {#usage} 8 9 The IS31FL3743A driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/rgb_matrix) feature with the `is31fl3743a` driver set, and you would use those APIs instead. 10 11 However, if you need to use the driver standalone, add this to your `rules.mk`: 12 13 ```make 14 COMMON_VPATH += $(DRIVER_PATH)/led/issi 15 SRC += is31fl3743a-mono.c # For single-color 16 SRC += is31fl3743a.c # For RGB 17 I2C_DRIVER_REQUIRED = yes 18 ``` 19 20 ## Basic Configuration {#basic-configuration} 21 22 Add the following to your `config.h`: 23 24 |Define |Default |Description | 25 |-----------------------------|-------------------------------|----------------------------------------------------| 26 |`IS31FL3743A_SDB_PIN` |*Not defined* |The GPIO pin connected to the drivers' shutdown pins| 27 |`IS31FL3743A_I2C_TIMEOUT` |`100` |The I²C timeout in milliseconds | 28 |`IS31FL3743A_I2C_PERSISTENCE`|`0` |The number of times to retry I²C transmissions | 29 |`IS31FL3743A_I2C_ADDRESS_1` |*Not defined* |The I²C address of driver 0 | 30 |`IS31FL3743A_I2C_ADDRESS_2` |*Not defined* |The I²C address of driver 1 | 31 |`IS31FL3743A_I2C_ADDRESS_3` |*Not defined* |The I²C address of driver 2 | 32 |`IS31FL3743A_I2C_ADDRESS_4` |*Not defined* |The I²C address of driver 3 | 33 |`IS31FL3743A_SYNC_1` |`IS31FL3743A_SYNC_NONE` |The sync configuration for driver 0 | 34 |`IS31FL3743A_SYNC_2` |`IS31FL3743A_SYNC_NONE` |The sync configuration for driver 1 | 35 |`IS31FL3743A_SYNC_3` |`IS31FL3743A_SYNC_NONE` |The sync configuration for driver 2 | 36 |`IS31FL3743A_SYNC_4` |`IS31FL3743A_SYNC_NONE` |The sync configuration for driver 3 | 37 |`IS31FL3743A_CONFIGURATION` |`0x01` |The value of the configuration register | 38 |`IS31FL3743A_SW_PULLDOWN` |`IS31FL3743A_PDR_2K_OHM_SW_OFF`|The `SWx` pulldown resistor value | 39 |`IS31FL3743A_CS_PULLUP` |`IS31FL3743A_PUR_2K_OHM_CS_OFF`|The `CSx` pullup resistor value | 40 |`IS31FL3743A_GLOBAL_CURRENT` |`0xFF` |The global current control value | 41 42 ### I²C Addressing {#i2c-addressing} 43 44 The IS31FL3743A has 16 possible 7-bit I²C addresses, depending on how the `ADDR1` and `ADDR2` pins are connected. 45 46 To configure this, set the `IS31FL3743A_I2C_ADDRESS_n` defines to one of the following in your `config.h`, where *n* denotes the driver index: 47 48 |Define |Value | 49 |---------------------------------|------| 50 |`IS31FL3743A_I2C_ADDRESS_GND_GND`|`0x20`| 51 |`IS31FL3743A_I2C_ADDRESS_GND_SCL`|`0x21`| 52 |`IS31FL3743A_I2C_ADDRESS_GND_SDA`|`0x22`| 53 |`IS31FL3743A_I2C_ADDRESS_GND_VCC`|`0x23`| 54 |`IS31FL3743A_I2C_ADDRESS_SCL_GND`|`0x24`| 55 |`IS31FL3743A_I2C_ADDRESS_SCL_SCL`|`0x25`| 56 |`IS31FL3743A_I2C_ADDRESS_SCL_SDA`|`0x26`| 57 |`IS31FL3743A_I2C_ADDRESS_SCL_VCC`|`0x27`| 58 |`IS31FL3743A_I2C_ADDRESS_SDA_GND`|`0x28`| 59 |`IS31FL3743A_I2C_ADDRESS_SDA_SCL`|`0x29`| 60 |`IS31FL3743A_I2C_ADDRESS_SDA_SDA`|`0x2A`| 61 |`IS31FL3743A_I2C_ADDRESS_SDA_VCC`|`0x2B`| 62 |`IS31FL3743A_I2C_ADDRESS_VCC_GND`|`0x2C`| 63 |`IS31FL3743A_I2C_ADDRESS_VCC_SCL`|`0x2D`| 64 |`IS31FL3743A_I2C_ADDRESS_VCC_SDA`|`0x2E`| 65 |`IS31FL3743A_I2C_ADDRESS_VCC_VCC`|`0x2F`| 66 67 ### Multi-Driver Synchronization {#multi-driver-synchronization} 68 69 Multiple IS31FL3743A drivers can be synchronized by connecting the `SYNC` pins together. One driver must be designated as the "master", and the others configured as "slave". 70 71 To do this, set the `IS31FL3743A_SYNC_n` defines accordingly in your `config.h`, where *n* denotes the driver index: 72 73 |Define |Value | 74 |-------------------------|---------------------------| 75 |`IS31FL3743A_SYNC_NONE` |No synchronization | 76 |`IS31FL3743A_SYNC_MASTER`|Driver configured as master| 77 |`IS31FL3743A_SYNC_SLAVE` |Driver configured as slave | 78 79 ### De-Ghosting {#de-ghosting} 80 81 These settings control the pulldown and pullup resistor values on the `SWy` and `CSx` pins respectively, for the purposes of eliminating ghosting. Refer to the datasheet (p. 23) for more information on how and why this occurs. 82 83 To adjust the resistor values, add the following to your `config.h`: 84 85 ```c 86 #define IS31FL3743A_SW_PULLDOWN IS31FL3743A_PDR_2K_OHM_SW_OFF 87 #define IS31FL3743A_CS_PULLUP IS31FL3743A_PUR_2K_OHM_CS_OFF 88 ``` 89 90 Valid values for `IS31FL3743A_SW_PULLDOWN` are: 91 92 |Define |Resistance | 93 |--------------------------------|------------------------------| 94 |`IS31FL3743A_PDR_0_OHM` |None (default) | 95 |`IS31FL3743A_PDR_0K5_OHM_SW_OFF`|0.5 kΩ in SWx off time | 96 |`IS31FL3743A_PDR_1K_OHM_SW_OFF` |1 kΩ in SWx off time | 97 |`IS31FL3743A_PDR_2K_OHM_SW_OFF` |2 kΩ in SWx off time (default)| 98 |`IS31FL3743A_PDR_1K_OHM` |1 kΩ | 99 |`IS31FL3743A_PDR_2K_OHM` |2 kΩ | 100 |`IS31FL3743A_PDR_4K_OHM` |4 kΩ | 101 |`IS31FL3743A_PDR_8K_OHM` |8 kΩ | 102 103 Valid values for `IS31FL3743A_CS_PULLUP` are: 104 105 |Define |Resistance | 106 |--------------------------------|------------------------------| 107 |`IS31FL3743A_PUR_0_OHM` |None (default) | 108 |`IS31FL3743A_PUR_0K5_OHM_CS_OFF`|0.5 kΩ in CSy off time | 109 |`IS31FL3743A_PUR_1K_OHM_CS_OFF` |1 kΩ in CSy off time | 110 |`IS31FL3743A_PUR_2K_OHM_CS_OFF` |2 kΩ in CSy off time (default)| 111 |`IS31FL3743A_PUR_1K_OHM` |1 kΩ | 112 |`IS31FL3743A_PUR_2K_OHM` |2 kΩ | 113 |`IS31FL3743A_PUR_4K_OHM` |4 kΩ | 114 |`IS31FL3743A_PUR_8K_OHM` |8 kΩ | 115 116 ### Global Current Control {#global-current-control} 117 118 This setting controls the current sunk by the `CSy` pins, from 0 to 255. By default, the value is the maximum (255), but if you need to lower it, add the following to your `config.h`: 119 120 ```c 121 #define IS31FL3743A_GLOBAL_CURRENT 0xFF 122 ``` 123 124 ## ARM/ChibiOS Configuration {#arm-configuration} 125 126 Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level. 127 128 ## LED Mapping {#led-mapping} 129 130 In order to use this driver, each output must be mapped to an LED index, by adding the following to your `<keyboard>.c`: 131 132 ```c 133 const is31fl3743a_led_t PROGMEM g_is31fl3743a_leds[IS31FL3743A_LED_COUNT] = { 134 /* Driver 135 * | R G B */ 136 {0, SW1_CS1, SW1_CS2, SW1_CS3}, 137 // etc... 138 }; 139 ``` 140 141 In this example, the red, green and blue channels for the first LED index on driver 0 all have their anodes connected to the `SW1` pin, and their cathodes on the `CS1`, `CS2` and `CS3` pins respectively. 142 143 For the single-color driver, the principle is the same, but there is only one channel: 144 145 ```c 146 const is31fl3743a_led_t PROGMEM g_is31fl3743a_leds[IS31FL3743A_LED_COUNT] = { 147 /* Driver 148 * | V */ 149 {0, SW1_CS1}, 150 // etc... 151 }; 152 ``` 153 154 These values correspond to the register indices as shown in the datasheet on page 12, figure 8. 155 156 ## API {#api} 157 158 ### `struct is31fl3743a_led_t` {#api-is31fl3743a-led-t} 159 160 Contains the PWM register addresses for a single RGB LED. 161 162 #### Members {#api-is31fl3743a-led-t-members} 163 164 - `uint8_t driver` 165 The driver index of the LED, from 0 to 3. 166 - `uint8_t r` 167 The output PWM register address for the LED's red channel (RGB driver only). 168 - `uint8_t g` 169 The output PWM register address for the LED's green channel (RGB driver only). 170 - `uint8_t b` 171 The output PWM register address for the LED's blue channel (RGB driver only). 172 - `uint8_t v` 173 The output PWM register address for the LED (single-color driver only). 174 175 --- 176 177 ### `void is31fl3743a_init(uint8_t index)` {#api-is31fl3743a-init} 178 179 Initialize the LED driver. This function should be called first. 180 181 #### Arguments {#api-is31fl3743a-init-arguments} 182 183 - `uint8_t index` 184 The driver index. 185 186 --- 187 188 ### `void is31fl3743a_write_register(uint8_t index, uint8_t reg, uint8_t data)` {#api-is31fl3743a-write-register} 189 190 Set the value of the given register. 191 192 #### Arguments {#api-is31fl3743a-write-register-arguments} 193 194 - `uint8_t index` 195 The driver index. 196 - `uint8_t reg` 197 The register address. 198 - `uint8_t data` 199 The value to set. 200 201 --- 202 203 ### `void is31fl3743a_select_page(uint8_t index, uint8_t page)` {#api-is31fl3743a-select-page} 204 205 Change the current page for configuring the LED driver. 206 207 #### Arguments {#api-is31fl3743a-select-page-arguments} 208 209 - `uint8_t index` 210 The driver index. 211 - `uint8_t page` 212 The page number to select. 213 214 --- 215 216 ### `void is31fl3743a_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3743a-set-color} 217 218 Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3743a_update_pwm_buffers()` after you are finished. 219 220 #### Arguments {#api-is31fl3743a-set-color-arguments} 221 222 - `int index` 223 The LED index (ie. the index into the `g_is31fl3743a_leds` array). 224 - `uint8_t red` 225 The red value to set. 226 - `uint8_t green` 227 The green value to set. 228 - `uint8_t blue` 229 The blue value to set. 230 231 --- 232 233 ### `void is31fl3743a_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3743a-set-color-all} 234 235 Set the color of all LEDs (RGB driver only). 236 237 #### Arguments {#api-is31fl3743a-set-color-all-arguments} 238 239 - `uint8_t red` 240 The red value to set. 241 - `uint8_t green` 242 The green value to set. 243 - `uint8_t blue` 244 The blue value to set. 245 246 --- 247 248 ### `void is31fl3743a_set_value(int index, uint8_t value)` {#api-is31fl3743a-set-value} 249 250 Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3743a_update_pwm_buffers()` after you are finished. 251 252 #### Arguments {#api-is31fl3743a-set-value-arguments} 253 254 - `int index` 255 The LED index (ie. the index into the `g_is31fl3743a_leds` array). 256 - `uint8_t value` 257 The brightness value to set. 258 259 --- 260 261 ### `void is31fl3743a_set_value_all(uint8_t value)` {#api-is31fl3743a-set-value-all} 262 263 Set the brightness of all LEDs (single-color driver only). 264 265 #### Arguments {#api-is31fl3743a-set-value-all-arguments} 266 267 - `uint8_t value` 268 The brightness value to set. 269 270 --- 271 272 ### `void is31fl3743a_set_scaling_register(uint8_t index, uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3743a-set-scaling-register-rgb} 273 274 Configure the scaling registers for a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3743a_update_scaling_registers()` after you are finished. 275 276 #### Arguments {#api-is31fl3743a-set-scaling-register-rgb-arguments} 277 278 - `uint8_t index` 279 The LED index (ie. the index into the `g_is31fl3743a_leds` array). 280 - `uint8_t red` 281 The scaling value for the red channel. 282 - `uint8_t green` 283 The scaling value for the green channel. 284 - `uint8_t blue` 285 The scaling value for the blue channel. 286 287 --- 288 289 ### `void is31fl3743a_set_scaling_register(uint8_t index, uint8_t value)` {#api-is31fl3743a-set-scaling-register-mono} 290 291 Configure the scaling register for a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3743a_update_scaling_registers()` after you are finished. 292 293 #### Arguments {#api-is31fl3743a-set-scaling-register-mono-arguments} 294 295 - `uint8_t index` 296 The LED index (ie. the index into the `g_is31fl3743a_leds` array). 297 - `uint8_t value` 298 The scaling value for the LED. 299 300 --- 301 302 ### `void is31fl3743a_update_pwm_buffers(uint8_t index)` {#api-is31fl3743a-update-pwm-buffers} 303 304 Flush the PWM values to the LED driver. 305 306 #### Arguments {#api-is31fl3743a-update-pwm-buffers-arguments} 307 308 - `uint8_t index` 309 The driver index. 310 311 --- 312 313 ### `void is31fl3743a_update_scaling_registers(uint8_t index)` {#api-is31fl3743a-update-scaling-registers} 314 315 Flush the scaling register values to the LED driver. 316 317 #### Arguments {#api-is31fl3743a-update-scaling-registers-arguments} 318 319 - `uint8_t index` 320 The driver index.