Skip to content

Commit

Permalink
LED drivers: update I2C API usage (qmk#22951)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Jan 24, 2024
1 parent d96ac70 commit 728aa57
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 100 deletions.
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3218-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ bool g_led_control_registers_update_required = false;
void is31fl3218_write_register(uint8_t reg, uint8_t data) {
#if IS31FL3218_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT);
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT);
#endif
}

void is31fl3218_write_pwm_buffer(void) {
#if IS31FL3218_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT);
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT);
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3218.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ bool g_led_control_registers_update_required = false;
void is31fl3218_write_register(uint8_t reg, uint8_t data) {
#if IS31FL3218_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT);
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, reg, &data, 1, IS31FL3218_I2C_TIMEOUT);
#endif
}

void is31fl3218_write_pwm_buffer(void) {
#if IS31FL3218_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT);
i2c_write_register(IS31FL3218_I2C_ADDRESS << 1, IS31FL3218_REG_PWM, g_pwm_buffer, 18, IS31FL3218_I2C_TIMEOUT);
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3731-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ bool g_led_control_registers_update_required[IS31FL3731_DRIVER_COUNT]
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3731_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT);
#endif
}

Expand All @@ -65,10 +65,10 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3731_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3731_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT);
i2c_write_register(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3731.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ bool g_led_control_registers_update_required[IS31FL3731_DRIVER_COUNT]
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3731_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3731_I2C_TIMEOUT);
#endif
}

Expand All @@ -64,10 +64,10 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3731_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3731_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3731_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT);
i2c_write_register(addr << 1, IS31FL3731_FRAME_REG_PWM + i, g_pwm_buffer[index] + i, 16, IS31FL3731_I2C_TIMEOUT);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3733-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT]
void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3733_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT);
#endif
}

Expand All @@ -97,10 +97,10 @@ void is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3733_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3733_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT);
i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3733.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT]
void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3733_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3733_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3733_I2C_TIMEOUT);
#endif
}

Expand All @@ -96,10 +96,10 @@ void is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3733_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3733_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3733_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT);
i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3733_I2C_TIMEOUT);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3736-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ bool g_led_control_registers_update_required[IS31FL3736_DRIVER_COUNT]
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3736_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT);
#endif
}

Expand All @@ -81,10 +81,10 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3736_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3736_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT);
i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3736.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ bool g_led_control_registers_update_required[IS31FL3736_DRIVER_COUNT]
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3736_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3736_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3736_I2C_TIMEOUT);
#endif
}

Expand All @@ -81,10 +81,10 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3736_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3736_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3736_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT);
i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3736_I2C_TIMEOUT);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3737-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ bool g_led_control_registers_update_required[IS31FL3737_DRIVER_COUNT]
void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3737_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT);
#endif
}

Expand All @@ -84,10 +84,10 @@ void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3737_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3737_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT);
i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT);
#endif
}
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3737.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ bool g_led_control_registers_update_required[IS31FL3737_DRIVER_COUNT]
void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3737_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3737_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3737_I2C_TIMEOUT);
#endif
}

Expand All @@ -84,10 +84,10 @@ void is31fl3737_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3737_PWM_REGISTER_COUNT; i += 16) {
#if IS31FL3737_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3737_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT);
i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 16, IS31FL3737_I2C_TIMEOUT);
#endif
}
}
Expand Down
12 changes: 6 additions & 6 deletions drivers/led/issi/is31fl3741-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ uint8_t g_scaling_registers[IS31FL3741_DRIVER_COUNT][IS31FL3741_SCALING_REGISTER
void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT);
#endif
}

Expand All @@ -89,20 +89,20 @@ void is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t index) {

#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3741_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT);
i2c_write_register(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT);
#endif
}

// transfer the left cause the total number is 351
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT);
i2c_write_register(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT);
#endif
}

Expand Down
12 changes: 6 additions & 6 deletions drivers/led/issi/is31fl3741.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ uint8_t g_scaling_registers[IS31FL3741_DRIVER_COUNT][IS31FL3741_SCALING_REGISTER
void is31fl3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3741_I2C_TIMEOUT);
#endif
}

Expand All @@ -89,20 +89,20 @@ void is31fl3741_write_pwm_buffer(uint8_t addr, uint8_t index) {

#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3741_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT);
i2c_write_register(addr << 1, i % 180, g_pwm_buffer[index] + i, 18, IS31FL3741_I2C_TIMEOUT);
#endif
}

// transfer the left cause the total number is 351
#if IS31FL3741_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3741_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT);
i2c_write_register(addr << 1, 162, g_pwm_buffer[index] + 342, 9, IS31FL3741_I2C_TIMEOUT);
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3742a-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ uint8_t g_scaling_registers[IS31FL3742A_DRIVER_COUNT][IS31FL3742A_SCALING_REGIST
void is31fl3742a_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
#if IS31FL3742A_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3742A_I2C_PERSISTENCE; i++) {
if (i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT);
i2c_write_register(addr << 1, reg, &data, 1, IS31FL3742A_I2C_TIMEOUT);
#endif
}

Expand All @@ -82,10 +82,10 @@ void is31fl3742a_write_pwm_buffer(uint8_t addr, uint8_t index) {
for (uint8_t i = 0; i < IS31FL3742A_PWM_REGISTER_COUNT; i += 30) {
#if IS31FL3742A_I2C_PERSISTENCE > 0
for (uint8_t j = 0; j < IS31FL3742A_I2C_PERSISTENCE; j++) {
if (i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 30, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
if (i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 30, IS31FL3742A_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) break;
}
#else
i2c_writeReg(addr << 1, i, g_pwm_buffer[index] + i, 30, IS31FL3742A_I2C_TIMEOUT);
i2c_write_register(addr << 1, i, g_pwm_buffer[index] + i, 30, IS31FL3742A_I2C_TIMEOUT);
#endif
}
}
Expand Down
Loading

0 comments on commit 728aa57

Please sign in to comment.