Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow settable SPI divisor for AW20216 driver, set default to 4 #13309

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,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_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/awinic/aw20216.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@
# define DRIVER_1_EN C13
#endif

#ifndef AW_SPI_DIVISOR
# define AW_SPI_DIVISOR 4
#endif

uint8_t g_spi_transfer_buffer[20] = {0};
aw_led g_pwm_buffer[DRIVER_LED_TOTAL];
bool g_pwm_buffer_update_required[DRIVER_LED_TOTAL];

bool AW20216_write_register(pin_t slave_pin, uint8_t page, uint8_t reg, uint8_t data) {
// Do we need to call spi_stop() if this fails?
if (!spi_start(slave_pin, false, 0, 16)) {
if (!spi_start(slave_pin, false, 0, AW_SPI_DIVISOR)) {
return false;
}

Expand Down