Skip to content

Commit

Permalink
Make SPI Mode configurable and change default mode to 3 (qmk#17263)
Browse files Browse the repository at this point in the history
  • Loading branch information
trwnh authored and zykrah committed Jul 2, 2022
1 parent 2e6b334 commit 4e27673
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ You can use up to 2 AW20216 IC's. Do not specify `DRIVER_<N>_xxx` defines for IC
| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
| `AW_SCALING_MAX` | (Optional) LED current scaling value (0-255, higher values mean LED is brighter at full PWM) | 150 |
| `AW_GLOBAL_CURRENT_MAX` | (Optional) Driver global current limit (0-255, higher values means the driver may consume more power) | 150 |
| `AW_SPI_MODE` | (Optional) Mode for SPI communication (0-3, defines polarity and phase of the clock) | 3 |
| `AW_SPI_DIVISOR` | (Optional) Clock divisor for SPI communication (powers of 2, smaller numbers means faster communication, should not be less than 4) | 4 |
Here is an example using 2 drivers.
Expand Down
6 changes: 5 additions & 1 deletion drivers/led/aw20216.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
# define AW_GLOBAL_CURRENT_MAX 150
#endif

#ifndef AW_SPI_MODE
# define AW_SPI_MODE 3
#endif

#ifndef AW_SPI_DIVISOR
# define AW_SPI_DIVISOR 4
#endif
Expand All @@ -63,7 +67,7 @@ bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
bool AW20216_write(pin_t cs_pin, uint8_t page, uint8_t reg, uint8_t* data, uint8_t len) {
static uint8_t s_spi_transfer_buffer[2] = {0};

if (!spi_start(cs_pin, false, 3, AW_SPI_DIVISOR)) {
if (!spi_start(cs_pin, false, AW_SPI_MODE, AW_SPI_DIVISOR)) {
spi_stop();
return false;
}
Expand Down

0 comments on commit 4e27673

Please sign in to comment.