Skip to content

Commit

Permalink
is31fl3733: change write_register() return type to void (qmk#22824)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and nuess0r committed Sep 8, 2024
1 parent fd5968a commit cd19b0d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 30 deletions.
12 changes: 3 additions & 9 deletions drivers/led/issi/is31fl3733-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,17 @@ bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false};
uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0};
bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false};

bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
// If the transaction fails function returns false.
void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t 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, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT);
#endif
return true;
}

void is31fl3733_select_page(uint8_t addr, uint8_t page) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/led/issi/is31fl3733-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT];

void is31fl3733_init_drivers(void);
void is31fl3733_init(uint8_t addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
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);

Expand Down
12 changes: 3 additions & 9 deletions drivers/led/issi/is31fl3733.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,17 @@ bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false};
uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0};
bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false};

bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
// If the transaction fails function returns false.
void is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t 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, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT);
#endif
return true;
}

void is31fl3733_select_page(uint8_t addr, uint8_t page) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/led/issi/is31fl3733.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT];

void is31fl3733_init_drivers(void);
void is31fl3733_init(uint8_t addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
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);

Expand Down
12 changes: 3 additions & 9 deletions keyboards/input_club/k_type/is31fl3733-dual.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,17 @@ bool g_pwm_buffer_update_required[IS31FL3733_DRIVER_COUNT] = {false};
uint8_t g_led_control_registers[IS31FL3733_DRIVER_COUNT][IS31FL3733_LED_CONTROL_REGISTER_COUNT] = {0};
bool g_led_control_registers_update_required[IS31FL3733_DRIVER_COUNT] = {false};

bool is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data) {
// If the transaction fails function returns false.
void is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t 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, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) == 0) break;
}
#else
if (i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT) != 0) {
return false;
}
i2c_transmit(index, addr << 1, i2c_transfer_buffer, 2, IS31FL3733_I2C_TIMEOUT);
#endif
return true;
}

void is31fl3733_select_page(uint8_t index, uint8_t addr, uint8_t page) {
Expand Down
2 changes: 1 addition & 1 deletion keyboards/input_club/k_type/is31fl3733-dual.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT];

void is31fl3733_init_drivers(void);
void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data);
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);

Expand Down

0 comments on commit cd19b0d

Please sign in to comment.