From b6fbed3dc345c722b6d667bc3421d3c82e09896b Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 6 Dec 2023 14:52:18 +1100 Subject: [PATCH] LED drivers: change "TWI" to "I2C" (#22617) --- drivers/led/issi/is31fl3218-simple.c | 19 +++++++------ drivers/led/issi/is31fl3218.c | 19 +++++++------ drivers/led/issi/is31fl3731-simple.c | 21 +++++++-------- drivers/led/issi/is31fl3731.c | 21 +++++++-------- drivers/led/issi/is31fl3733-simple.c | 21 +++++++-------- drivers/led/issi/is31fl3733.c | 21 +++++++-------- drivers/led/issi/is31fl3736-simple.c | 21 +++++++-------- drivers/led/issi/is31fl3736.c | 21 +++++++-------- drivers/led/issi/is31fl3737-simple.c | 21 +++++++-------- drivers/led/issi/is31fl3737.c | 21 +++++++-------- drivers/led/issi/is31fl3741-simple.c | 27 +++++++++---------- drivers/led/issi/is31fl3741.c | 27 +++++++++---------- drivers/led/issi/is31flcommon.c | 19 +++++++------ drivers/led/snled27351-simple.c | 21 +++++++-------- drivers/led/snled27351.c | 19 +++++++------ keyboards/input_club/k_type/is31fl3733-dual.c | 21 +++++++-------- 16 files changed, 162 insertions(+), 178 deletions(-) diff --git a/drivers/led/issi/is31fl3218-simple.c b/drivers/led/issi/is31fl3218-simple.c index ce28c51d18..e58b7d8bc0 100644 --- a/drivers/led/issi/is31fl3218-simple.c +++ b/drivers/led/issi/is31fl3218-simple.c @@ -28,8 +28,7 @@ # define IS31FL3218_I2C_PERSISTENCE 0 #endif -// Reusable buffer for transfers -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining. uint8_t g_pwm_buffer[IS31FL3218_PWM_REGISTER_COUNT]; @@ -39,27 +38,27 @@ uint8_t g_led_control_registers[IS31FL3218_LED_CONTROL_REGISTER_COUNT] = {0}; bool g_led_control_registers_update_required = false; void is31fl3218_write_register(uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3218_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) { - if (i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT); + i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT); #endif } void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) { - g_twi_transfer_buffer[0] = IS31FL3218_REG_PWM; - memcpy(g_twi_transfer_buffer + 1, pwm_buffer, 18); + i2c_transfer_buffer[0] = IS31FL3218_REG_PWM; + memcpy(i2c_transfer_buffer + 1, pwm_buffer, 18); #if IS31FL3218_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) { - i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); + i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); } #else - i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); + i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); #endif } diff --git a/drivers/led/issi/is31fl3218.c b/drivers/led/issi/is31fl3218.c index 39db09d518..9bfdc9c44d 100644 --- a/drivers/led/issi/is31fl3218.c +++ b/drivers/led/issi/is31fl3218.c @@ -28,8 +28,7 @@ # define IS31FL3218_I2C_PERSISTENCE 0 #endif -// Reusable buffer for transfers -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining. uint8_t g_pwm_buffer[IS31FL3218_PWM_REGISTER_COUNT]; @@ -39,27 +38,27 @@ uint8_t g_led_control_registers[IS31FL3218_LED_CONTROL_REGISTER_COUNT] = {0}; bool g_led_control_registers_update_required = false; void is31fl3218_write_register(uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3218_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) { - if (i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT); + i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT); #endif } void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) { - g_twi_transfer_buffer[0] = IS31FL3218_REG_PWM; - memcpy(g_twi_transfer_buffer + 1, pwm_buffer, 18); + i2c_transfer_buffer[0] = IS31FL3218_REG_PWM; + memcpy(i2c_transfer_buffer + 1, pwm_buffer, 18); #if IS31FL3218_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) { - i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); + i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); } #else - i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); + i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, i2c_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); #endif } diff --git a/drivers/led/issi/is31fl3731-simple.c b/drivers/led/issi/is31fl3731-simple.c index 563d377633..14743717d4 100644 --- a/drivers/led/issi/is31fl3731-simple.c +++ b/drivers/led/issi/is31fl3731-simple.c @@ -33,8 +33,7 @@ # define IS31FL3731_I2C_PERSISTENCE 0 #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3731 PWM registers 0x24-0xB3. // Storing them like this is optimal for I2C transfers to the registers. @@ -48,17 +47,17 @@ uint8_t g_led_control_registers[IS31FL3731_DRIVER_COUNT][IS31FL3731_LED_CONTROL_ bool g_led_control_registers_update_required[IS31FL3731_DRIVER_COUNT] = {false}; void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3731_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) { break; } } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT); #endif } @@ -70,23 +69,23 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { // assumes page 0 is already selected // transmit PWM registers in 9 transfers of 16 bytes - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // iterate over the pwm_buffer contents at 16 byte intervals for (int i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) { // set the first register, e.g. 0x24, 0x34, 0x44, etc. - g_twi_transfer_buffer[0] = 0x24 + i; + i2c_transfer_buffer[0] = 0x24 + i; // copy the data from i to i+15 // device will auto-increment register for data after the first byte // thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3731_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT); #endif } } diff --git a/drivers/led/issi/is31fl3731.c b/drivers/led/issi/is31fl3731.c index 19176458b7..9a7d0b5eca 100644 --- a/drivers/led/issi/is31fl3731.c +++ b/drivers/led/issi/is31fl3731.c @@ -32,8 +32,7 @@ # define IS31FL3731_I2C_PERSISTENCE 0 #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3731 PWM registers 0x24-0xB3. // Storing them like this is optimal for I2C transfers to the registers. @@ -47,15 +46,15 @@ uint8_t g_led_control_registers[IS31FL3731_DRIVER_COUNT][IS31FL3731_LED_CONTROL_ bool g_led_control_registers_update_required[IS31FL3731_DRIVER_COUNT] = {false}; void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3731_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT); #endif } @@ -67,23 +66,23 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { // assumes page 0 is already selected // transmit PWM registers in 9 transfers of 16 bytes - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // iterate over the pwm_buffer contents at 16 byte intervals for (int i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) { // set the first register, e.g. 0x24, 0x34, 0x44, etc. - g_twi_transfer_buffer[0] = 0x24 + i; + i2c_transfer_buffer[0] = 0x24 + i; // copy the data from i to i+15 // device will auto-increment register for data after the first byte // thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3731_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3731_I2C_TIMEOUT); #endif } } diff --git a/drivers/led/issi/is31fl3733-simple.c b/drivers/led/issi/is31fl3733-simple.c index 8bdea3827f..805905ebc2 100644 --- a/drivers/led/issi/is31fl3733-simple.c +++ b/drivers/led/issi/is31fl3733-simple.c @@ -63,8 +63,7 @@ # define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3733 PWM registers. // The control buffers match the page 0 LED On/Off registers. @@ -80,17 +79,17 @@ bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) { // If the transaction fails function returns false. - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } #endif @@ -106,24 +105,24 @@ bool 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. - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // Iterate over the pwm_buffer contents at 16 byte intervals. for (int i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // Copy the data from i to i+15. // Device will auto-increment register for data after the first byte // Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer. - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } #endif diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c index 0f263d949d..f7162a0ce5 100644 --- a/drivers/led/issi/is31fl3733.c +++ b/drivers/led/issi/is31fl3733.c @@ -62,8 +62,7 @@ # define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3733 PWM registers. // The control buffers match the page 0 LED On/Off registers. @@ -79,17 +78,17 @@ bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) { // If the transaction fails function returns false. - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } #endif @@ -105,24 +104,24 @@ bool 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. - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // Iterate over the pwm_buffer contents at 16 byte intervals. for (int i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // Copy the data from i to i+15. // Device will auto-increment register for data after the first byte // Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer. - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } #endif diff --git a/drivers/led/issi/is31fl3736-simple.c b/drivers/led/issi/is31fl3736-simple.c index 20f8dfd92c..ac5e0fb453 100644 --- a/drivers/led/issi/is31fl3736-simple.c +++ b/drivers/led/issi/is31fl3736-simple.c @@ -47,8 +47,7 @@ # define IS31FL3736_GLOBAL_CURRENT 0xFF #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3736 PWM registers. // The control buffers match the page 0 LED On/Off registers. @@ -63,15 +62,15 @@ uint8_t g_led_control_registers[IS31FL3736_DRIVER_COUNT][IS31FL3736_LED_CONTROL_ bool g_led_control_registers_update_required[IS31FL3736_DRIVER_COUNT] = {false}; void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3736_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT); #endif } @@ -84,22 +83,22 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { // assumes page 1 is already selected // transmit PWM registers in 12 transfers of 16 bytes - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // iterate over the pwm_buffer contents at 16 byte intervals for (int i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // copy the data from i to i+15 // device will auto-increment register for data after the first byte // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3736_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT); #endif } } diff --git a/drivers/led/issi/is31fl3736.c b/drivers/led/issi/is31fl3736.c index 530d92cf31..384b815850 100644 --- a/drivers/led/issi/is31fl3736.c +++ b/drivers/led/issi/is31fl3736.c @@ -47,8 +47,7 @@ # define IS31FL3736_GLOBAL_CURRENT 0xFF #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3736 PWM registers. // The control buffers match the page 0 LED On/Off registers. @@ -63,15 +62,15 @@ uint8_t g_led_control_registers[IS31FL3736_DRIVER_COUNT][IS31FL3736_LED_CONTROL_ bool g_led_control_registers_update_required[IS31FL3736_DRIVER_COUNT] = {false}; void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3736_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3736_I2C_TIMEOUT); #endif } @@ -84,22 +83,22 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { // assumes page 1 is already selected // transmit PWM registers in 12 transfers of 16 bytes - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // iterate over the pwm_buffer contents at 16 byte intervals for (int i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // copy the data from i to i+15 // device will auto-increment register for data after the first byte // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3736_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3736_I2C_TIMEOUT); #endif } } diff --git a/drivers/led/issi/is31fl3737-simple.c b/drivers/led/issi/is31fl3737-simple.c index 930a6c9a90..967a102b48 100644 --- a/drivers/led/issi/is31fl3737-simple.c +++ b/drivers/led/issi/is31fl3737-simple.c @@ -49,8 +49,7 @@ # define IS31FL3737_GLOBAL_CURRENT 0xFF #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3737 PWM registers. // The control buffers match the page 0 LED On/Off registers. @@ -66,15 +65,15 @@ uint8_t g_led_control_registers[IS31FL3737_DRIVER_COUNT][IS31FL3737_LED_CONTROL_ bool g_led_control_registers_update_required[IS31FL3737_DRIVER_COUNT] = {false}; void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3737_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT); #endif } @@ -87,22 +86,22 @@ void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { // assumes page 1 is already selected // transmit PWM registers in 12 transfers of 16 bytes - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // iterate over the pwm_buffer contents at 16 byte intervals for (int i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // copy the data from i to i+15 // device will auto-increment register for data after the first byte // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3737_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT); #endif } } diff --git a/drivers/led/issi/is31fl3737.c b/drivers/led/issi/is31fl3737.c index fd727e60d3..76d17c2b84 100644 --- a/drivers/led/issi/is31fl3737.c +++ b/drivers/led/issi/is31fl3737.c @@ -49,8 +49,7 @@ # define IS31FL3737_GLOBAL_CURRENT 0xFF #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3737 PWM registers. // The control buffers match the page 0 LED On/Off registers. @@ -66,15 +65,15 @@ uint8_t g_led_control_registers[IS31FL3737_DRIVER_COUNT][IS31FL3737_LED_CONTROL_ bool g_led_control_registers_update_required[IS31FL3737_DRIVER_COUNT] = {false}; void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3737_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3737_I2C_TIMEOUT); #endif } @@ -87,22 +86,22 @@ void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { // assumes page 1 is already selected // transmit PWM registers in 12 transfers of 16 bytes - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // iterate over the pwm_buffer contents at 16 byte intervals for (int i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // copy the data from i to i+15 // device will auto-increment register for data after the first byte // thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 16); + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 16); #if IS31FL3737_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 17, IS31FL3737_I2C_TIMEOUT); #endif } } diff --git a/drivers/led/issi/is31fl3741-simple.c b/drivers/led/issi/is31fl3741-simple.c index 6bce71d5f7..db245af4da 100644 --- a/drivers/led/issi/is31fl3741-simple.c +++ b/drivers/led/issi/is31fl3741-simple.c @@ -52,8 +52,7 @@ # define IS31FL3741_GLOBAL_CURRENT 0xFF #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20] = {0xFF}; +uint8_t i2c_transfer_buffer[20] = {0xFF}; // These buffers match the IS31FL3741 and IS31FL3741A PWM registers. // The scaling buffers match the page 2 and 3 LED On/Off registers. @@ -68,15 +67,15 @@ bool g_scaling_registers_update_required[IS31FL3741_DRIVER_COUNT] = {false}; uint8_t g_scaling_registers[IS31FL3741_DRIVER_COUNT][IS31FL3741_PWM_REGISTER_COUNT]; void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3741_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT); #endif } @@ -93,34 +92,34 @@ bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { is31fl3741_select_page(addr, IS31FL3741_COMMAND_PWM_1); } - g_twi_transfer_buffer[0] = i % 180; - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 18); + i2c_transfer_buffer[0] = i % 180; + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 18); #if IS31FL3741_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } #endif } // transfer the left cause the total number is 351 - g_twi_transfer_buffer[0] = 162; - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + 342, 9); + i2c_transfer_buffer[0] = 162; + memcpy(i2c_transfer_buffer + 1, pwm_buffer + 342, 9); #if IS31FL3741_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } #endif diff --git a/drivers/led/issi/is31fl3741.c b/drivers/led/issi/is31fl3741.c index 3ee75572fa..0575f31254 100644 --- a/drivers/led/issi/is31fl3741.c +++ b/drivers/led/issi/is31fl3741.c @@ -52,8 +52,7 @@ # define IS31FL3741_GLOBAL_CURRENT 0xFF #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20] = {0xFF}; +uint8_t i2c_transfer_buffer[20] = {0xFF}; // These buffers match the IS31FL3741 and IS31FL3741A PWM registers. // The scaling buffers match the page 2 and 3 LED On/Off registers. @@ -68,15 +67,15 @@ bool g_scaling_registers_update_required[IS31FL3741_DRIVER_COUNT] = {false}; uint8_t g_scaling_registers[IS31FL3741_DRIVER_COUNT][IS31FL3741_PWM_REGISTER_COUNT]; void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) { - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3741_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3741_I2C_TIMEOUT); #endif } @@ -93,34 +92,34 @@ bool is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { is31fl3741_select_page(addr, IS31FL3741_COMMAND_PWM_1); } - g_twi_transfer_buffer[0] = i % 180; - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, 18); + i2c_transfer_buffer[0] = i % 180; + memcpy(i2c_transfer_buffer + 1, pwm_buffer + i, 18); #if IS31FL3741_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 19, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } #endif } // transfer the left cause the total number is 351 - g_twi_transfer_buffer[0] = 162; - memcpy(g_twi_transfer_buffer + 1, pwm_buffer + 342, 9); + i2c_transfer_buffer[0] = 162; + memcpy(i2c_transfer_buffer + 1, pwm_buffer + 342, 9); #if IS31FL3741_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 10, IS31FL3741_I2C_TIMEOUT) != 0) { return false; } #endif diff --git a/drivers/led/issi/is31flcommon.c b/drivers/led/issi/is31flcommon.c index d6b9bce93d..048db286b6 100644 --- a/drivers/led/issi/is31flcommon.c +++ b/drivers/led/issi/is31flcommon.c @@ -31,8 +31,7 @@ # define ISSI_PERSISTENCE 0 #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the PWM & scaling registers. // Storing them like this is optimal for I2C transfers to the registers. @@ -45,15 +44,15 @@ bool g_scaling_buffer_update_required[DRIVER_COUNT] = {false}; // For writing of single register entry void IS31FL_write_single_register(uint8_t addr, uint8_t reg, uint8_t data) { // Set register address and register data ready to write - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if ISSI_PERSISTENCE > 0 for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break; + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break; } #else - i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT); + i2c_transmit(addr << 1, i2c_transfer_buffer, 2, ISSI_TIMEOUT); #endif } @@ -64,18 +63,18 @@ bool IS31FL_write_multi_registers(uint8_t addr, uint8_t *source_buffer, uint8_t // Split the buffer into chunks to transfer for (int i = 0; i < buffer_size; i += transfer_size) { // Set the first entry of transfer buffer to the first register we want to write - g_twi_transfer_buffer[0] = i + start_reg_addr; + i2c_transfer_buffer[0] = i + start_reg_addr; // Copy the section of our source buffer into the transfer buffer after first register address - memcpy(g_twi_transfer_buffer + 1, source_buffer + i, transfer_size); + memcpy(i2c_transfer_buffer + 1, source_buffer + i, transfer_size); #if ISSI_PERSISTENCE > 0 for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, transfer_size + 1, ISSI_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, transfer_size + 1, ISSI_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, transfer_size + 1, ISSI_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, transfer_size + 1, ISSI_TIMEOUT) != 0) { return false; } #endif diff --git a/drivers/led/snled27351-simple.c b/drivers/led/snled27351-simple.c index 3906b0eb4b..7b7a82f90f 100644 --- a/drivers/led/snled27351-simple.c +++ b/drivers/led/snled27351-simple.c @@ -37,8 +37,7 @@ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the SNLED27351 PWM registers. // The control buffers match the PG0 LED On/Off registers. @@ -54,17 +53,17 @@ bool g_led_control_registers_update_required[SNLED27351_DRIVER_COUNT] bool snled27351_write_register(uint8_t addr, uint8_t reg, uint8_t data) { // If the transaction fails function returns false. - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if SNLED27351_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < SNLED27351_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { return false; } #endif @@ -79,26 +78,26 @@ bool 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. - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // Iterate over the pwm_buffer contents at 16 byte intervals. for (int i = 0; i < SNLED27351_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // Copy the data from i to i+15. // Device will auto-increment register for data after the first byte // Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer. for (int j = 0; j < 16; j++) { - g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; + i2c_transfer_buffer[1 + j] = pwm_buffer[i + j]; } #if SNLED27351_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < SNLED27351_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 17, SNLED27351_I2C_TIMEOUT) != 0) { return false; } #endif diff --git a/drivers/led/snled27351.c b/drivers/led/snled27351.c index b22a4af779..d985e4c5f1 100644 --- a/drivers/led/snled27351.c +++ b/drivers/led/snled27351.c @@ -37,8 +37,7 @@ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[65]; +uint8_t i2c_transfer_buffer[65]; // These buffers match the SNLED27351 PWM registers. // The control buffers match the PG0 LED On/Off registers. @@ -54,17 +53,17 @@ bool g_led_control_registers_update_required[SNLED27351_DRIVER_COUNT] bool snled27351_write_register(uint8_t addr, uint8_t reg, uint8_t data) { // If the transaction fails function returns false. - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if SNLED27351_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < SNLED27351_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, SNLED27351_I2C_TIMEOUT) != 0) { return false; } #endif @@ -82,22 +81,22 @@ bool snled27351_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) { // Iterate over the pwm_buffer contents at 64 byte intervals. for (uint8_t i = 0; i < SNLED27351_PWM_REGISTER_COUNT; i += 64) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // Copy the data from i to i+63. // Device will auto-increment register for data after the first byte // Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer. for (uint8_t j = 0; j < 64; j++) { - g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; + i2c_transfer_buffer[1 + j] = pwm_buffer[i + j]; } #if SNLED27351_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < SNLED27351_I2C_PERSISTENCE; i++) { - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT) != 0) { + if (i2c_transmit(addr << 1, i2c_transfer_buffer, 65, SNLED27351_I2C_TIMEOUT) != 0) { return false; } #endif diff --git a/keyboards/input_club/k_type/is31fl3733-dual.c b/keyboards/input_club/k_type/is31fl3733-dual.c index baa3e70833..385416439a 100644 --- a/keyboards/input_club/k_type/is31fl3733-dual.c +++ b/keyboards/input_club/k_type/is31fl3733-dual.c @@ -60,8 +60,7 @@ # define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE #endif -// Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[20]; +uint8_t i2c_transfer_buffer[20]; // These buffers match the IS31FL3733 PWM registers. // The control buffers match the page 0 LED On/Off registers. @@ -77,17 +76,17 @@ bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] bool is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data) { // If the transaction fails function returns false. - g_twi_transfer_buffer[0] = reg; - g_twi_transfer_buffer[1] = data; + i2c_transfer_buffer[0] = reg; + i2c_transfer_buffer[1] = data; #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } #endif @@ -103,26 +102,26 @@ bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffe // Assumes page 1 is already selected. // If any of the transactions fails function returns false. // Transmit PWM registers in 12 transfers of 16 bytes. - // g_twi_transfer_buffer[] is 20 bytes + // i2c_transfer_buffer[] is 20 bytes // Iterate over the pwm_buffer contents at 16 byte intervals. for (int i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) { - g_twi_transfer_buffer[0] = i; + i2c_transfer_buffer[0] = i; // Copy the data from i to i+15. // Device will auto-increment register for data after the first byte // Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer. for (int j = 0; j < 16; j++) { - g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; + i2c_transfer_buffer[1 + j] = pwm_buffer[i + j]; } #if IS31FL3733_I2C_PERSISTENCE > 0 for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) { - if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } } #else - if (i2c_transmit(index, addr << 1, g_twi_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { + if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 17, IS31FL3733_I2C_TIMEOUT) != 0) { return false; } #endif