diff options
author | Gigahawk <jasperchan515@gmail.com> | 2021-06-23 02:57:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 19:57:46 +1000 |
commit | 1ea01765e19bf84b9a09954443b7d64be2bec0c7 (patch) | |
tree | bc83579ed761f4c5a94ca918128b6d87097e855f | |
parent | 531f34d2a08312824e7906cfda24bb9127878ad8 (diff) | |
download | qmk_firmware-1ea01765e19bf84b9a09954443b7d64be2bec0c7.tar.gz qmk_firmware-1ea01765e19bf84b9a09954443b7d64be2bec0c7.zip |
Allow settable SPI divisor for AW20216 driver, set default to 4 (#13309)
-rw-r--r-- | docs/feature_rgb_matrix.md | 1 | ||||
-rw-r--r-- | drivers/awinic/aw20216.c | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 25ba3ffe3..925c9de6e 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md | |||
@@ -250,6 +250,7 @@ You can use up to 2 AW20216 IC's. Do not specify `DRIVER_<N>_xxx` defines for IC | |||
250 | | `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | | | 250 | | `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | | |
251 | | `AW_SCALING_MAX` | (Optional) LED current scaling value (0-255, higher values mean LED is brighter at full PWM) | 150 | | 251 | | `AW_SCALING_MAX` | (Optional) LED current scaling value (0-255, higher values mean LED is brighter at full PWM) | 150 | |
252 | | `AW_GLOBAL_CURRENT_MAX` | (Optional) Driver global current limit (0-255, higher values means the driver may consume more power) | 150 | | 252 | | `AW_GLOBAL_CURRENT_MAX` | (Optional) Driver global current limit (0-255, higher values means the driver may consume more power) | 150 | |
253 | | `AW_SPI_DIVISOR` | (Optional) Clock divisor for SPI communication (powers of 2, smaller numbers means faster communication, should not be less than 4) | 4 | | ||
253 | 254 | ||
254 | Here is an example using 2 drivers. | 255 | Here is an example using 2 drivers. |
255 | 256 | ||
diff --git a/drivers/awinic/aw20216.c b/drivers/awinic/aw20216.c index 236c42a3c..269bb3a59 100644 --- a/drivers/awinic/aw20216.c +++ b/drivers/awinic/aw20216.c | |||
@@ -59,13 +59,17 @@ | |||
59 | # define DRIVER_1_EN C13 | 59 | # define DRIVER_1_EN C13 |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #ifndef AW_SPI_DIVISOR | ||
63 | # define AW_SPI_DIVISOR 4 | ||
64 | #endif | ||
65 | |||
62 | uint8_t g_spi_transfer_buffer[20] = {0}; | 66 | uint8_t g_spi_transfer_buffer[20] = {0}; |
63 | aw_led g_pwm_buffer[DRIVER_LED_TOTAL]; | 67 | aw_led g_pwm_buffer[DRIVER_LED_TOTAL]; |
64 | bool g_pwm_buffer_update_required[DRIVER_LED_TOTAL]; | 68 | bool g_pwm_buffer_update_required[DRIVER_LED_TOTAL]; |
65 | 69 | ||
66 | bool AW20216_write_register(pin_t slave_pin, uint8_t page, uint8_t reg, uint8_t data) { | 70 | bool AW20216_write_register(pin_t slave_pin, uint8_t page, uint8_t reg, uint8_t data) { |
67 | // Do we need to call spi_stop() if this fails? | 71 | // Do we need to call spi_stop() if this fails? |
68 | if (!spi_start(slave_pin, false, 0, 16)) { | 72 | if (!spi_start(slave_pin, false, 0, AW_SPI_DIVISOR)) { |
69 | return false; | 73 | return false; |
70 | } | 74 | } |
71 | 75 | ||