1
0
Fork 0
forked from forks/qmk_firmware

LED drivers: change write_pwm_buffer() return type to void (#22869)

This commit is contained in:
Ryan 2024-01-10 12:48:19 +11:00 committed by GitHub
parent 8de8af6632
commit 7a3183b8c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 43 additions and 112 deletions

View file

@ -95,9 +95,8 @@ void is31fl3733_select_page(uint8_t addr, uint8_t page) {
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, page);
}
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
void is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assumes page 1 is already selected.
// If any of the transactions fails function returns false.
// Transmit PWM registers in 12 transfers of 16 bytes.
// i2c_transfer_buffer[] is 20 bytes
@ -111,17 +110,12 @@ bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if IS31FL3733_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT);
#endif
}
return true;
}
void is31fl3733_init_drivers(void) {
@ -232,11 +226,7 @@ void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required[index]) {
is31fl3733_select_page(addr, IS31FL3733_COMMAND_PWM);
// If any of the transactions fail we risk writing dirty page 0,
// refresh page 0 just in case.
if (!is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
g_led_control_registers_update_required[index] = true;
}
is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index]);
g_pwm_buffer_update_required[index] = false;
}

View file

@ -118,7 +118,7 @@ void is31fl3733_init_drivers(void);
void is31fl3733_init(uint8_t addr, uint8_t sync);
void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3733_select_page(uint8_t addr, uint8_t page);
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3733_set_value(int index, uint8_t value);
void is31fl3733_set_value_all(uint8_t value);

View file

@ -94,9 +94,8 @@ void is31fl3733_select_page(uint8_t addr, uint8_t page) {
is31fl3733_write_register(addr, IS31FL3733_REG_COMMAND, page);
}
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
void is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assumes page 1 is already selected.
// If any of the transactions fails function returns false.
// Transmit PWM registers in 12 transfers of 16 bytes.
// i2c_transfer_buffer[] is 20 bytes
@ -110,17 +109,12 @@ bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if IS31FL3733_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT);
#endif
}
return true;
}
void is31fl3733_init_drivers(void) {
@ -247,11 +241,7 @@ void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required[index]) {
is31fl3733_select_page(addr, IS31FL3733_COMMAND_PWM);
// If any of the transactions fail we risk writing dirty page 0,
// refresh page 0 just in case.
if (!is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
g_led_control_registers_update_required[index] = true;
}
is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index]);
g_pwm_buffer_update_required[index] = false;
}

View file

@ -143,7 +143,7 @@ void is31fl3733_init_drivers(void);
void is31fl3733_init(uint8_t addr, uint8_t sync);
void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3733_select_page(uint8_t addr, uint8_t page);
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
void is31fl3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue);

View file

@ -85,7 +85,7 @@ void is31fl3741_select_page(uint8_t addr, uint8_t page) {
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, page);
}
bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
void is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assume page 0 is already selected
for (int i = 0; i < 342; i += 18) {
@ -98,14 +98,10 @@ bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT);
#endif
}
@ -115,17 +111,11 @@ bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT);
#endif
return true;
}
void is31fl3741_init_drivers(void) {

View file

@ -105,7 +105,7 @@ void is31fl3741_init_drivers(void);
void is31fl3741_init(uint8_t addr);
void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3741_select_page(uint8_t addr, uint8_t page);
bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3741_set_value(int index, uint8_t value);
void is31fl3741_set_value_all(uint8_t value);

View file

@ -85,7 +85,7 @@ void is31fl3741_select_page(uint8_t addr, uint8_t page) {
is31fl3741_write_register(addr, IS31FL3741_REG_COMMAND, page);
}
bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
void is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assume page 0 is already selected
for (int i = 0; i < 342; i += 18) {
@ -98,14 +98,10 @@ bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT);
#endif
}
@ -115,17 +111,11 @@ bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT);
#endif
return true;
}
void is31fl3741_init_drivers(void) {

View file

@ -122,7 +122,7 @@ void is31fl3741_init_drivers(void);
void is31fl3741_init(uint8_t addr);
void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3741_select_page(uint8_t addr, uint8_t page);
bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void is31fl3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
void is31fl3741_set_color_all(uint8_t red, uint8_t green, uint8_t blue);

View file

@ -68,9 +68,8 @@ void snled27351_select_page(uint8_t addr, uint8_t page) {
snled27351_write_register(addr, SNLED27351_REG_COMMAND, page);
}
bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
void snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assumes PG1 is already selected.
// If any of the transactions fails function returns false.
// Transmit PWM registers in 12 transfers of 16 bytes.
// i2c_transfer_buffer[] is 20 bytes
@ -86,17 +85,12 @@ bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if SNLED27351_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < SNLED27351_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT);
#endif
}
return true;
}
void snled27351_init_drivers(void) {
@ -216,14 +210,10 @@ void snled27351_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required[index]) {
snled27351_select_page(addr, SNLED27351_COMMAND_PWM);
// If any of the transactions fail we risk writing dirty PG0,
// refresh page 0 just in case.
if (!snled27351_write_pwm_buffer(addr, g_pwm_buffer[index])) {
g_pwm_buffer_update_required[index] = true;
}
}
snled27351_write_pwm_buffer(addr, g_pwm_buffer[index]);
g_pwm_buffer_update_required[index] = false;
g_pwm_buffer_update_required[index] = false;
}
}
void snled27351_update_led_control_registers(uint8_t addr, uint8_t index) {

View file

@ -157,7 +157,7 @@ void snled27351_init_drivers(void);
void snled27351_init(uint8_t addr);
void snled27351_select_page(uint8_t addr, uint8_t page);
void snled27351_write_register(uint8_t addr, uint8_t reg, uint8_t data);
bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void snled27351_set_value(int index, uint8_t value);
void snled27351_set_value_all(uint8_t value);

View file

@ -68,9 +68,8 @@ void snled27351_select_page(uint8_t addr, uint8_t page) {
snled27351_write_register(addr, SNLED27351_REG_COMMAND, page);
}
bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
void snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// Assumes PG1 is already selected.
// If any of the transactions fails function returns false.
// Transmit PWM registers in 3 transfers of 64 bytes.
// Iterate over the pwm_buffer contents at 64 byte intervals.
@ -85,17 +84,12 @@ bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
#if SNLED27351_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < SNLED27351_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT);
#endif
}
return true;
}
void snled27351_init_drivers(void) {
@ -231,14 +225,10 @@ void snled27351_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required[index]) {
snled27351_select_page(addr, SNLED27351_COMMAND_PWM);
// If any of the transactions fail we risk writing dirty PG0,
// refresh page 0 just in case.
if (!snled27351_write_pwm_buffer(addr, g_pwm_buffer[index])) {
g_pwm_buffer_update_required[index] = true;
}
}
snled27351_write_pwm_buffer(addr, g_pwm_buffer[index]);
g_pwm_buffer_update_required[index] = false;
g_pwm_buffer_update_required[index] = false;
}
}
void snled27351_update_led_control_registers(uint8_t addr, uint8_t index) {

View file

@ -171,7 +171,7 @@ void snled27351_init_drivers(void);
void snled27351_init(uint8_t addr);
void snled27351_select_page(uint8_t addr, uint8_t page);
void snled27351_write_register(uint8_t addr, uint8_t reg, uint8_t data);
bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
void snled27351_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
void snled27351_set_color_all(uint8_t red, uint8_t green, uint8_t blue);

View file

@ -92,9 +92,8 @@ void is31fl3733_select_page(uint8_t index, uint8_t addr, uint8_t page) {
is31fl3733_write_register(index, addr, IS31FL3733_REG_COMMAND, page);
}
bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffer) {
void is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffer) {
// Assumes page 1 is already selected.
// If any of the transactions fails function returns false.
// Transmit PWM registers in 12 transfers of 16 bytes.
// i2c_transfer_buffer[] is 20 bytes
@ -110,17 +109,12 @@ bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffe
#if IS31FL3733_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(index, addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT);
#endif
}
return true;
}
void is31fl3733_init_drivers(void) {
@ -236,13 +230,10 @@ void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required[index]) {
is31fl3733_select_page(index, addr, IS31FL3733_COMMAND_PWM);
// If any of the transactions fail we risk writing dirty page 0,
// refresh page 0 just in case.
if (!is31fl3733_write_pwm_buffer(index, addr, g_pwm_buffer[index])) {
g_led_control_registers_update_required[index] = true;
}
is31fl3733_write_pwm_buffer(index, addr, g_pwm_buffer[index]);
g_pwm_buffer_update_required[index] = false;
}
g_pwm_buffer_update_required[index] = false;
}
void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) {

View file

@ -86,7 +86,7 @@ void is31fl3733_init_drivers(void);
void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync);
void is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3733_select_page(uint8_t index, uint8_t addr, uint8_t page);
bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffer);
void is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffer);
void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
void is31fl3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue);