Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RGB matrix & LED Matrix support for IS31FL3729 #21944

Merged
merged 26 commits into from
Feb 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3d17202
Added support IS31FL3729 LED Driver
HorrorTroll Aug 31, 2023
771e87a
Update driver code
HorrorTroll Sep 2, 2023
a9ee959
Fix up buggy PWM and delete unused functions
HorrorTroll Sep 3, 2023
e255ad0
Initial IS31FL3729 cleanup
Xelus22 Sep 4, 2023
3ff017b
Fixed some issues
HorrorTroll Sep 5, 2023
7434673
SImplify register declaration header for is31fl3729
dexter93 Sep 5, 2023
a3c2702
Clean up and fixed pwm_buffer
HorrorTroll Sep 6, 2023
719896f
Added support for LED Matrix
HorrorTroll Sep 6, 2023
2e4b955
Added docs for RGB Matrix & LED Matrix
HorrorTroll Sep 6, 2023
a02bb7a
Drivers name cleanup
HorrorTroll Sep 7, 2023
21ea867
Formatting lint error
HorrorTroll Sep 7, 2023
3e18101
Use define for I2C Address
HorrorTroll Sep 16, 2023
af82d20
Added missing Spread Spectrum register for noise reduction
HorrorTroll Sep 17, 2023
bd8d828
Add define for noise reduction
HorrorTroll Sep 17, 2023
7330e31
Add define to change matrix mode on Configuration register
HorrorTroll Sep 19, 2023
071b6b9
Resolved fauxpark suggest changes
HorrorTroll Sep 23, 2023
b5cf6bf
Resolved conflict again
HorrorTroll Nov 6, 2023
d3ab72f
Resolved changes again
HorrorTroll Dec 13, 2023
050038a
Another suggest change resolved
HorrorTroll Dec 29, 2023
10ae2ec
Revert docs change back to original state
HorrorTroll Dec 29, 2023
6dd473f
Resolved changes again
HorrorTroll Jan 6, 2024
2f5e08e
Resolve changes
HorrorTroll Jan 25, 2024
bfd8c4d
Resolved
HorrorTroll Feb 8, 2024
96ce46d
Resolved
HorrorTroll Feb 13, 2024
52394b2
update PWM register defines
HorrorTroll Feb 13, 2024
b2c9fa5
Resolved
HorrorTroll Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Drivers name cleanup
  • Loading branch information
HorrorTroll committed Feb 13, 2024
commit a02bb7a306d1ddeffa350abbcbd4c6f5858d17d5
18 changes: 9 additions & 9 deletions docs/feature_led_matrix.md
fauxpark marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -19,20 +19,20 @@ You can use between 1 and 4 IS31FL3729 IC's. Do not specify `LED_DRIVER_ADDR_<N>

| Variable | Description | Default |
|----------|-------------|---------|
| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `LED_DRIVER_COUNT` | (Required) How many LED driver IC's are present | |
| `IS31FL3729_I2C_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `IS31FL3729_I2C_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `IS31FL3729_CONFIGURATION` | (Optional) Configuration for the Configuration Register | 0x01 |
| `IS31FL3729_GLOBALCURRENT` | (Optional) Configuration for the Global Current Register | 0x40 |
| `IS31FL3729_PULLDOWNUP` | (Optional) Configuration for the Pull Up & Pull Down Register | 0x33 |
| `IS31FL3729_PWM_FREQUENCY` | (Optional) Configuration for the PWM Setting Register | 0x01 |
| `IS31FL3729_DRIVER_COUNT` | (Required) How many LED driver IC's are present | |
| `LED_MATRIX_LED_COUNT` | (Required) How many LED lights are present across all drivers | |
| `LED_DRIVER_ADDR_1` | (Required) Address for the first LED driver | |
| `LED_DRIVER_ADDR_2` | (Optional) Address for the second LED driver | |
| `LED_DRIVER_ADDR_3` | (Optional) Address for the third LED driver | |
| `LED_DRIVER_ADDR_4` | (Optional) Address for the fourth LED driver | |
| `ISSI_CONFIGURATION` | (Optional) Configuration for the Configuration Register | 0x01 |
| `ISSI_GLOBALCURRENT` | (Optional) Configuration for the Global Current Register | 0x40 |
| `ISSI_PULLDOWNUP` | (Optional) Configuration for the Pull Up & Pull Down Register | 0x33 |
| `ISSI_PWM_SET` | (Optional) Configuration for the PWM Setting Register | 0x01 |

Drivers does support many matrix layout by using SWS on Configuration Register. Default is using 15 x 9 matrix layout (15 CS pin & 9 SW pin). More info [in datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3729_DS.pdf)
Drivers does support many matrix layout by using SWS on `IS31FL3729_CONFIGURATION`. Default is using 15 x 9 matrix layout (15 CS pin & 9 SW pin). More info [in datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3729_DS.pdf)

| Variable | Description | Settings |
|----------|-------------|----------|
@@ -57,7 +57,7 @@ Here is an example using 2 drivers.
#define LED_DRIVER_ADDR_1 0b0110100
#define LED_DRIVER_ADDR_2 0b0110101

#define LED_DRIVER_COUNT 2
#define IS31FL3729_DRIVER_COUNT 2
#define LED_DRIVER_1_LED_TOTAL 39
#define LED_DRIVER_2_LED_TOTAL 28
#define LED_MATRIX_LED_COUNT (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)
18 changes: 9 additions & 9 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
@@ -19,20 +19,20 @@ You can use between 1 and 4 IS31FL3729 IC's. Do not specify `DRIVER_ADDR_<N>` de

| Variable | Description | Default |
|----------|-------------|---------|
| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
| `IS31FL3729_I2C_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `IS31FL3729_I2C_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `IS31FL3729_CONFIGURATION` | (Optional) Configuration for the Configuration Register | 0x01 |
| `IS31FL3729_GLOBALCURRENT` | (Optional) Configuration for the Global Current Register | 0x40 |
| `IS31FL3729_PULLDOWNUP` | (Optional) Configuration for the Pull Up & Pull Down Register | 0x33 |
| `IS31FL3729_PWM_FREQUENCY` | (Optional) Configuration for the PWM Frequency Register | 0x01 |
| `IS31FL3729_DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
| `RGB_MATRIX_LED_COUNT` | (Required) How many RGB lights are present across all drivers | |
| `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
| `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
| `DRIVER_ADDR_3` | (Optional) Address for the third RGB driver | |
| `DRIVER_ADDR_4` | (Optional) Address for the fourth RGB driver | |
| `ISSI_CONFIGURATION` | (Optional) Configuration for the Configuration Register | 0x01 |
| `ISSI_GLOBALCURRENT` | (Optional) Configuration for the Global Current Register | 0x40 |
| `ISSI_PULLDOWNUP` | (Optional) Configuration for the Pull Up & Pull Down Register | 0x33 |
| `ISSI_PWM_SET` | (Optional) Configuration for the PWM Setting Register | 0x01 |

Drivers does support many matrix layout by using SWS on Configuration Register. Default for RGB Matrix is 15 x 9 matrix layout (15 CS pin & 9 SW pin). More info [in datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3729_DS.pdf)
Drivers does support many matrix layout by using SWS on `IS31FL3729_CONFIGURATION`. RGB Matrix is only supported 15 x 9 matrix layout (15 CS pin & 9 SW pin). More info [in datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3729_DS.pdf)

Here is an example using 2 drivers.

@@ -47,7 +47,7 @@ Here is an example using 2 drivers.
#define DRIVER_ADDR_1 0b0110100
#define DRIVER_ADDR_2 0b0110101

#define DRIVER_COUNT 2
#define IS31FL3729_DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 39
#define DRIVER_2_LED_TOTAL 28
#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
86 changes: 43 additions & 43 deletions drivers/led/issi/is31fl3729-simple.c
HorrorTroll marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -32,87 +32,87 @@
// 11 <-> VCC
// ADDR represents A2:A1 of the 7-bit address.
// The result is: 0b01101(ADDR)
#define ISSI_ADDR_DEFAULT 0x68
#define IS31FL3729_I2C_ADDRESS_DEFAULT 0x68

// Registers
#define ISSI_REG_SCALING 0x90
#define ISSI_REG_CONFIGURATION 0xA0
#define ISSI_REG_GLOBALCURRENT 0xA1
#define ISSI_REG_PULLDOWNUP 0xB0
#define ISSI_REG_RESET 0xCF
#define ISSI_REG_PWM_SET 0xB2
#define IS31FL3729_REG_SCALING 0x90
#define IS31FL3729_REG_CONFIGURATION 0xA0
#define IS31FL3729_REG_GLOBALCURRENT 0xA1
#define IS31FL3729_REG_PULLDOWNUP 0xB0
#define IS31FL3729_REG_RESET 0xCF
#define IS31FL3729_REG_PWM_FREQUENCY 0xB2

// Set defaults for Timeout and Persistence
#ifndef ISSI_TIMEOUT
# define ISSI_TIMEOUT 100
#ifndef IS31FL3729_I2C_TIMEOUT
# define IS31FL3729_I2C_TIMEOUT 100
#endif
#ifndef ISSI_PERSISTENCE
# define ISSI_PERSISTENCE 0
#ifndef IS31FL3729_I2C_PERSISTENCE
# define IS31FL3729_I2C_PERSISTENCE 0
#endif

// Set defaults for Registers
#ifndef ISSI_CONFIGURATION
# define ISSI_CONFIGURATION 0x01
#ifndef IS31FL3729_CONFIGURATION
# define IS31FL3729_CONFIGURATION 0x01
#endif
#ifndef ISSI_GLOBALCURRENT
# define ISSI_GLOBALCURRENT 0x40
#ifndef IS31FL3729_GLOBALCURRENT
# define IS31FL3729_GLOBALCURRENT 0x40
#endif
#ifndef ISSI_PULLDOWNUP
# define ISSI_PULLDOWNUP 0x33
#ifndef IS31FL3729_PULLDOWNUP
# define IS31FL3729_PULLDOWNUP 0x33
#endif
#ifndef ISSI_PWM_SET
# define ISSI_PWM_SET 0x01
#ifndef IS31FL3729_PWM_FREQUENCY
# define IS31FL3729_PWM_FREQUENCY 0x01
#endif

// Set buffer sizes
#define ISSI_MAX_LEDS 143
#define ISSI_MAX_SCALINGS 16
#define IS31FL3729_MAX_LEDS 143
#define IS31FL3729_MAX_SCALINGS 16

// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];

// These buffers match the PWM & scaling registers.
// Storing them like this is optimal for I2C transfers to the registers.
uint8_t g_pwm_buffer[LED_DRIVER_COUNT][ISSI_MAX_LEDS];
bool g_pwm_buffer_update_required[LED_DRIVER_COUNT] = {false};
uint8_t g_pwm_buffer[IS31FL3729_DRIVER_COUNT][IS31FL3729_MAX_LEDS];
bool g_pwm_buffer_update_required[IS31FL3729_DRIVER_COUNT] = {false};

uint8_t g_scaling_registers[LED_DRIVER_COUNT][ISSI_MAX_SCALINGS];
bool g_scaling_registers_update_required[LED_DRIVER_COUNT] = {false};
uint8_t g_scaling_registers[IS31FL3729_DRIVER_COUNT][IS31FL3729_MAX_SCALINGS];
bool g_scaling_registers_update_required[IS31FL3729_DRIVER_COUNT] = {false};

void is31fl3729_write_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;

#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 IS31FL3729_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3729_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3729_I2C_TIMEOUT) == 0) break;
}
#else
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3729_I2C_TIMEOUT);
#endif
}

bool is31fl3729_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// iterate over the pwm_buffer contents at ISSI_MAX_SCALINGS byte intervals
// iterate over the pwm_buffer contents at IS31FL3729_MAX_SCALINGS byte intervals
// datasheet does not mention it, but it auto-increments in 15x9 mode, and
// hence does not require us to skip any addresses
for (int i = 0; i <= ISSI_MAX_LEDS; i += ISSI_MAX_SCALINGS) {
for (int i = 0; i <= IS31FL3729_MAX_LEDS; i += IS31FL3729_MAX_SCALINGS) {
g_twi_transfer_buffer[0] = i;

// copy the data from i to i+ISSI_MAX_SCALINGS
// copy the data from i to i+IS31FL3729_MAX_SCALINGS
// device will auto-increment register for data after the first byte
// thus this sets registers 0x01-0x10, 0x11-0x20, etc. in one transfer
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, ISSI_MAX_SCALINGS);
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, IS31FL3729_MAX_SCALINGS);

#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, ISSI_MAX_SCALINGS + 1, ISSI_TIMEOUT) != 0) {
#if IS31FL3729_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3729_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, IS31FL3729_MAX_SCALINGS + 1, IS31FL3729_I2C_TIMEOUT) != 0) {
return false;
}
}
#else
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, ISSI_MAX_SCALINGS + 1, ISSI_TIMEOUT) != 0) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, IS31FL3729_MAX_SCALINGS + 1, IS31FL3729_I2C_TIMEOUT) != 0) {
return false;
}
#endif
@@ -128,16 +128,16 @@ void is31fl3729_init(uint8_t addr) {
// then disable software shutdown.

// Set Pull up & Down for SWx CSy
is31fl3729_write_register(addr, ISSI_REG_PULLDOWNUP, ISSI_PULLDOWNUP);
is31fl3729_write_register(addr, IS31FL3729_REG_PULLDOWNUP, IS31FL3729_PULLDOWNUP);

// Set PWM Frequency Register if applicable
is31fl3729_write_register(addr, ISSI_REG_PWM_SET, ISSI_PWM_SET);
is31fl3729_write_register(addr, IS31FL3729_REG_PWM_FREQUENCY, IS31FL3729_PWM_FREQUENCY);

// Set Golbal Current Control Register
is31fl3729_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
is31fl3729_write_register(addr, IS31FL3729_REG_GLOBALCURRENT, IS31FL3729_GLOBALCURRENT);

// Set to Normal operation
is31fl3729_write_register(addr, ISSI_REG_CONFIGURATION, ISSI_CONFIGURATION);
is31fl3729_write_register(addr, IS31FL3729_REG_CONFIGURATION, IS31FL3729_CONFIGURATION);

// Wait 10ms to ensure the device has woken up.
wait_ms(10);
@@ -189,8 +189,8 @@ void is31fl3729_update_pwm_buffers(uint8_t addr, uint8_t index) {

void is31fl3729_update_led_control_registers(uint8_t addr, uint8_t index) {
if (g_scaling_registers_update_required[index]) {
for (int i = 0; i < ISSI_MAX_SCALINGS; i++) {
is31fl3729_write_register(addr, ISSI_REG_SCALING + i, g_scaling_registers[index][i]);
for (int i = 0; i < IS31FL3729_MAX_SCALINGS; i++) {
is31fl3729_write_register(addr, IS31FL3729_REG_SCALING + i, g_scaling_registers[index][i]);
}

g_scaling_registers_update_required[index] = false;
86 changes: 43 additions & 43 deletions drivers/led/issi/is31fl3729.c
Original file line number Diff line number Diff line change
@@ -32,87 +32,87 @@
// 11 <-> VCC
// ADDR represents A2:A1 of the 7-bit address.
// The result is: 0b01101(ADDR)
#define ISSI_ADDR_DEFAULT 0x68
#define IS31FL3729_I2C_ADDRESS_DEFAULT 0x68

// Registers
#define ISSI_REG_SCALING 0x90
#define ISSI_REG_CONFIGURATION 0xA0
#define ISSI_REG_GLOBALCURRENT 0xA1
#define ISSI_REG_PULLDOWNUP 0xB0
#define ISSI_REG_RESET 0xCF
#define ISSI_REG_PWM_SET 0xB2
#define IS31FL3729_REG_SCALING 0x90
#define IS31FL3729_REG_CONFIGURATION 0xA0
#define IS31FL3729_REG_GLOBALCURRENT 0xA1
#define IS31FL3729_REG_PULLDOWNUP 0xB0
#define IS31FL3729_REG_RESET 0xCF
#define IS31FL3729_REG_PWM_FREQUENCY 0xB2

// Set defaults for Timeout and Persistence
#ifndef ISSI_TIMEOUT
# define ISSI_TIMEOUT 100
#ifndef IS31FL3729_I2C_TIMEOUT
# define IS31FL3729_I2C_TIMEOUT 100
#endif
#ifndef ISSI_PERSISTENCE
# define ISSI_PERSISTENCE 0
#ifndef IS31FL3729_I2C_PERSISTENCE
# define IS31FL3729_I2C_PERSISTENCE 0
#endif

// Set defaults for Registers
#ifndef ISSI_CONFIGURATION
# define ISSI_CONFIGURATION 0x01
#ifndef IS31FL3729_CONFIGURATION
# define IS31FL3729_CONFIGURATION 0x01
#endif
#ifndef ISSI_GLOBALCURRENT
# define ISSI_GLOBALCURRENT 0x40
#ifndef IS31FL3729_GLOBALCURRENT
# define IS31FL3729_GLOBALCURRENT 0x40
#endif
#ifndef ISSI_PULLDOWNUP
# define ISSI_PULLDOWNUP 0x33
#ifndef IS31FL3729_PULLDOWNUP
# define IS31FL3729_PULLDOWNUP 0x33
#endif
#ifndef ISSI_PWM_SET
# define ISSI_PWM_SET 0x01
#ifndef IS31FL3729_PWM_FREQUENCY
# define IS31FL3729_PWM_FREQUENCY 0x01
#endif

// Set buffer sizes
#define ISSI_MAX_LEDS 143
#define ISSI_MAX_SCALINGS 16
#define IS31FL3729_MAX_LEDS 143
#define IS31FL3729_MAX_SCALINGS 16

// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];

// These buffers match the PWM & scaling registers.
// Storing them like this is optimal for I2C transfers to the registers.
uint8_t g_pwm_buffer[DRIVER_COUNT][ISSI_MAX_LEDS];
bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
uint8_t g_pwm_buffer[IS31FL3729_DRIVER_COUNT][IS31FL3729_MAX_LEDS];
bool g_pwm_buffer_update_required[IS31FL3729_DRIVER_COUNT] = {false};

uint8_t g_scaling_registers[DRIVER_COUNT][ISSI_MAX_SCALINGS];
bool g_scaling_registers_update_required[DRIVER_COUNT] = {false};
uint8_t g_scaling_registers[IS31FL3729_DRIVER_COUNT][IS31FL3729_MAX_SCALINGS];
bool g_scaling_registers_update_required[IS31FL3729_DRIVER_COUNT] = {false};

void is31fl3729_write_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;

#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 IS31FL3729_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3729_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3729_I2C_TIMEOUT) == 0) break;
}
#else
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, IS31FL3729_I2C_TIMEOUT);
#endif
}

bool is31fl3729_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// iterate over the pwm_buffer contents at ISSI_MAX_SCALINGS byte intervals
// iterate over the pwm_buffer contents at IS31FL3729_MAX_SCALINGS byte intervals
// datasheet does not mention it, but it auto-increments in 15x9 mode, and
// hence does not require us to skip any addresses
for (int i = 0; i <= ISSI_MAX_LEDS; i += ISSI_MAX_SCALINGS) {
for (int i = 0; i <= IS31FL3729_MAX_LEDS; i += IS31FL3729_MAX_SCALINGS) {
g_twi_transfer_buffer[0] = i;

// copy the data from i to i+ISSI_MAX_SCALINGS
// copy the data from i to i+IS31FL3729_MAX_SCALINGS
// device will auto-increment register for data after the first byte
// thus this sets registers 0x01-0x10, 0x11-0x20, etc. in one transfer
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, ISSI_MAX_SCALINGS);
memcpy(g_twi_transfer_buffer + 1, pwm_buffer + i, IS31FL3729_MAX_SCALINGS);

#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, ISSI_MAX_SCALINGS + 1, ISSI_TIMEOUT) != 0) {
#if IS31FL3729_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3729_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, IS31FL3729_MAX_SCALINGS + 1, IS31FL3729_I2C_TIMEOUT) != 0) {
return false;
}
}
#else
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, ISSI_MAX_SCALINGS + 1, ISSI_TIMEOUT) != 0) {
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, IS31FL3729_MAX_SCALINGS + 1, IS31FL3729_I2C_TIMEOUT) != 0) {
return false;
}
#endif
@@ -128,16 +128,16 @@ void is31fl3729_init(uint8_t addr) {
// then disable software shutdown.

// Set Pull up & Down for SWx CSy
is31fl3729_write_register(addr, ISSI_REG_PULLDOWNUP, ISSI_PULLDOWNUP);
is31fl3729_write_register(addr, IS31FL3729_REG_PULLDOWNUP, IS31FL3729_PULLDOWNUP);

// Set PWM Frequency Register if applicable
is31fl3729_write_register(addr, ISSI_REG_PWM_SET, ISSI_PWM_SET);
is31fl3729_write_register(addr, IS31FL3729_REG_PWM_FREQUENCY, IS31FL3729_PWM_FREQUENCY);

// Set Golbal Current Control Register
is31fl3729_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
is31fl3729_write_register(addr, IS31FL3729_REG_GLOBALCURRENT, IS31FL3729_GLOBALCURRENT);

// Set to Normal operation
is31fl3729_write_register(addr, ISSI_REG_CONFIGURATION, ISSI_CONFIGURATION);
is31fl3729_write_register(addr, IS31FL3729_REG_CONFIGURATION, IS31FL3729_CONFIGURATION);

// Wait 10ms to ensure the device has woken up.
wait_ms(10);
@@ -201,8 +201,8 @@ void is31fl3729_update_pwm_buffers(uint8_t addr, uint8_t index) {

void is31fl3729_update_led_control_registers(uint8_t addr, uint8_t index) {
if (g_scaling_registers_update_required[index]) {
for (int i = 0; i < ISSI_MAX_SCALINGS; i++) {
is31fl3729_write_register(addr, ISSI_REG_SCALING + i, g_scaling_registers[index][i]);
for (int i = 0; i < IS31FL3729_MAX_SCALINGS; i++) {
is31fl3729_write_register(addr, IS31FL3729_REG_SCALING + i, g_scaling_registers[index][i]);
}

g_scaling_registers_update_required[index] = false;