diff --git a/drivers/led/issi/is31fl3733-mono.c b/drivers/led/issi/is31fl3733-mono.c index bd3d15c5166..b6e4a59b6be 100644 --- a/drivers/led/issi/is31fl3733-mono.c +++ b/drivers/led/issi/is31fl3733-mono.c @@ -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; } diff --git a/drivers/led/issi/is31fl3733-mono.h b/drivers/led/issi/is31fl3733-mono.h index 5a588834b8d..2fae1f1afe1 100644 --- a/drivers/led/issi/is31fl3733-mono.h +++ b/drivers/led/issi/is31fl3733-mono.h @@ -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); diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c index ad98bd3cec2..f16bb162a57 100644 --- a/drivers/led/issi/is31fl3733.c +++ b/drivers/led/issi/is31fl3733.c @@ -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; } diff --git a/drivers/led/issi/is31fl3733.h b/drivers/led/issi/is31fl3733.h index f273f1f0032..a1b44b57518 100644 --- a/drivers/led/issi/is31fl3733.h +++ b/drivers/led/issi/is31fl3733.h @@ -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); diff --git a/drivers/led/issi/is31fl3741-mono.c b/drivers/led/issi/is31fl3741-mono.c index 09838aa4557..9994ab3bfe8 100644 --- a/drivers/led/issi/is31fl3741-mono.c +++ b/drivers/led/issi/is31fl3741-mono.c @@ -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) { diff --git a/drivers/led/issi/is31fl3741-mono.h b/drivers/led/issi/is31fl3741-mono.h index ad416b62d5d..06c7da5afd8 100644 --- a/drivers/led/issi/is31fl3741-mono.h +++ b/drivers/led/issi/is31fl3741-mono.h @@ -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); diff --git a/drivers/led/issi/is31fl3741.c b/drivers/led/issi/is31fl3741.c index 9bc8c11e8c7..35cf85beeba 100644 --- a/drivers/led/issi/is31fl3741.c +++ b/drivers/led/issi/is31fl3741.c @@ -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) { diff --git a/drivers/led/issi/is31fl3741.h b/drivers/led/issi/is31fl3741.h index 5151d81c37b..92127a3c4ec 100644 --- a/drivers/led/issi/is31fl3741.h +++ b/drivers/led/issi/is31fl3741.h @@ -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); diff --git a/drivers/led/snled27351-mono.c b/drivers/led/snled27351-mono.c index 5d4b8e3a405..9bad5ccba47 100644 --- a/drivers/led/snled27351-mono.c +++ b/drivers/led/snled27351-mono.c @@ -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) { diff --git a/drivers/led/snled27351-mono.h b/drivers/led/snled27351-mono.h index df1cd21efbe..8188b075ff6 100644 --- a/drivers/led/snled27351-mono.h +++ b/drivers/led/snled27351-mono.h @@ -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); diff --git a/drivers/led/snled27351.c b/drivers/led/snled27351.c index e40d09e7597..9313a9b94d5 100644 --- a/drivers/led/snled27351.c +++ b/drivers/led/snled27351.c @@ -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) { diff --git a/drivers/led/snled27351.h b/drivers/led/snled27351.h index 184fdbc523c..5c50bf27f19 100644 --- a/drivers/led/snled27351.h +++ b/drivers/led/snled27351.h @@ -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); diff --git a/keyboards/input_club/k_type/is31fl3733-dual.c b/keyboards/input_club/k_type/is31fl3733-dual.c index 4b40175994b..b4528b5a6f1 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.c +++ b/keyboards/input_club/k_type/is31fl3733-dual.c @@ -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) { diff --git a/keyboards/input_club/k_type/is31fl3733-dual.h b/keyboards/input_club/k_type/is31fl3733-dual.h index 21dd7015253..9cdfb29f748 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.h +++ b/keyboards/input_club/k_type/is31fl3733-dual.h @@ -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);