diff options
author | yiancar <yiangosyiangou@cytanet.com.cy> | 2018-05-14 16:17:24 +0200 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-05-14 16:17:24 +0200 |
commit | a98a91cf1b923107e9f26df316c1ef2192ff14f7 (patch) | |
tree | 112b22b9ee2f212b4a58e57d2e4b4906d1ef7636 /drivers/avr/is31fl3731.c | |
parent | f42ec8aa866386ed0ab8faf7acf9c396aa482519 (diff) | |
download | qmk_firmware-a98a91cf1b923107e9f26df316c1ef2192ff14f7.tar.gz qmk_firmware-a98a91cf1b923107e9f26df316c1ef2192ff14f7.tar.xz |
Rgb matrix fixes, I2C library can now retry if it has failed (#2943)
* Added Modular keyboards L,R and NUM
Created code modules for the 3 modules of the modular keyboard.
Original idea by MechboardsUK. Uses i2c implementation similar to lets
split
* Remove modular from master
This is to fix incorrect branching
* General fixes for RGB_matrix
- Complited speed support for all effects
- Fixed raindrop effects to initialized after toggle
- Fixed raindrop effects to use all available LEDs
- Fixed effect step reverse function
- Moved RGB_MATRIX_SOLID_REACTIVE under correct flag
* Documentation update for RGBmatrix
* More doc updates
* I2C library can now retry if it has failed
- Replaced the original TWIlib by LFKeyboard's modified version
- Allows for an extra argument on TWITransmitData, if blocking is set to 1 function will retry to transmit on failure. Good for noisy boards.
* RGB Matrix, use alternative I2C library
TWIlib seems to be hanging for me sometimes probably due to ISR routine. I have used i2c_master as a good alternative.
Note: this commit is for Wilba6582 to verify before merge
* Update rgb_matrix.c
* RGB matrix cleanup
- Remove TWIlib
Diffstat (limited to 'drivers/avr/is31fl3731.c')
-rw-r--r-- | drivers/avr/is31fl3731.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/drivers/avr/is31fl3731.c b/drivers/avr/is31fl3731.c index e5941cf41..c7a99e3a3 100644 --- a/drivers/avr/is31fl3731.c +++ b/drivers/avr/is31fl3731.c @@ -20,7 +20,7 @@ #include <avr/io.h> #include <util/delay.h> #include <string.h> -#include "TWIlib.h" +#include "i2c_master.h" #include "progmem.h" // This is a 7-bit address, that gets left-shifted and bit 0 @@ -50,7 +50,7 @@ #define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' // Transfer buffer for TWITransmitData() -uint8_t g_twi_transfer_buffer[TXMAXBUFLEN]; +uint8_t g_twi_transfer_buffer[20]; // These buffers match the IS31FL3731 PWM registers 0x24-0xB3. // Storing them like this is optimal for I2C transfers to the registers. @@ -80,17 +80,11 @@ bool g_led_control_registers_update_required = false; void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data ) { - g_twi_transfer_buffer[0] = (addr << 1) | 0x00; - g_twi_transfer_buffer[1] = reg; - g_twi_transfer_buffer[2] = data; - - // Set the error code to have no relevant information - TWIInfo.errorCode = TWI_NO_RELEVANT_INFO; - // Continuously attempt to transmit data until a successful transmission occurs - //while ( TWIInfo.errorCode != 0xFF ) - //{ - TWITransmitData( g_twi_transfer_buffer, 3, 0 ); - //} + g_twi_transfer_buffer[0] = reg; + g_twi_transfer_buffer[1] = data; + + //Transmit data until succesful + while(i2c_transmit(addr << 1, g_twi_transfer_buffer,2) != 0); } void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ) @@ -100,29 +94,21 @@ void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer ) // transmit PWM registers in 9 transfers of 16 bytes // g_twi_transfer_buffer[] is 20 bytes - // set the I2C address - g_twi_transfer_buffer[0] = (addr << 1) | 0x00; - // iterate over the pwm_buffer contents at 16 byte intervals for ( int i = 0; i < 144; i += 16 ) { // set the first register, e.g. 0x24, 0x34, 0x44, etc. - g_twi_transfer_buffer[1] = 0x24 + i; + g_twi_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 for ( int j = 0; j < 16; j++ ) { - g_twi_transfer_buffer[2 + j] = pwm_buffer[i + j]; + g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j]; } - // Set the error code to have no relevant information - TWIInfo.errorCode = TWI_NO_RELEVANT_INFO; - // Continuously attempt to transmit data until a successful transmission occurs - while ( TWIInfo.errorCode != 0xFF ) - { - TWITransmitData( g_twi_transfer_buffer, 16 + 2, 0 ); - } + //Transmit buffer until succesful + while(i2c_transmit(addr << 1, g_twi_transfer_buffer,17) != 0); } } |