wip
This commit is contained in:
parent
ef8de0e6f0
commit
5e66140fbc
|
@ -65,11 +65,12 @@ uint8_t i2c_start(uint8_t address)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
|
||||
int8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
|
||||
{
|
||||
i2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
return i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
|
||||
int8_t result = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
void i2c_init(void);
|
||||
uint8_t i2c_start(uint8_t address);
|
||||
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
int8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
uint8_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length);
|
||||
uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#define ISSI_BANK_FUNCTIONREG 0x0B // FIXME: Not on 3235?
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
#define ISSI_TIMEOUT 100
|
||||
#define ISSI_TIMEOUT 255
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
|
@ -73,9 +73,9 @@ bool g_rgb7seg_buffer_update_required = false;
|
|||
bool g_rgb7seg_control_registers_update_required = false;
|
||||
|
||||
void IS31FL3235A_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
xprintf("IS31FL3235A_write_register(0x%x, 0x%x, 0x%x);\n", addr, reg, data);
|
||||
g_3235a_transfer_buffer[0] = reg;
|
||||
g_3235a_transfer_buffer[1] = data;
|
||||
xprintf("IS31FL3235A_write_register(0x%x, 0x%x, 0x%x); g_3235a_transfer_buffer:0x%x\n", addr, reg, data, g_3235a_transfer_buffer);
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
|
@ -84,7 +84,13 @@ void IS31FL3235A_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
|||
}
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_3235a_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
if (i2c_transmit(addr << 1, g_3235a_transfer_buffer, 2, ISSI_TIMEOUT) == -1) {
|
||||
// When we encounter a timeout ChibiOS says the bus must be reset as it's in an unknown state
|
||||
xprintf("i2c transmit timeout, resetting i2c bus!\n");
|
||||
i2c_stop(ISSI_TIMEOUT);
|
||||
wait_ms(5);
|
||||
i2c_start(ISSI_TIMEOUT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -111,9 +117,13 @@ void IS31FL3235A_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
|||
break;
|
||||
}
|
||||
#else
|
||||
if (!i2c_transmit(addr << 1, g_3235a_transfer_buffer, 17, ISSI_TIMEOUT)) {
|
||||
xprintf("Could not contact i2c device 0x%x!\n", addr << 1);
|
||||
}
|
||||
if (i2c_transmit(addr << 1, g_3235a_transfer_buffer, 17, ISSI_TIMEOUT) == -1) {
|
||||
// When we encounter a timeout ChibiOS says the bus must be reset as it's in an unknown state
|
||||
xprintf("i2c transmit timeout, resetting i2c bus!\n");
|
||||
i2c_stop(ISSI_TIMEOUT);
|
||||
wait_ms(5);
|
||||
i2c_start(ISSI_TIMEOUT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -132,14 +142,37 @@ void IS31FL3235A_init(uint8_t addr) {
|
|||
// this delay was copied from other drivers, might not be needed
|
||||
wait_ms(10);
|
||||
|
||||
// This is how the Arduino code does init...
|
||||
uint8_t i = 0;
|
||||
|
||||
for (i=0x2A; i<=0x45; i++) {
|
||||
IS31FL3235A_write_register(addr, i, 0xFF); // Turn off all LEDs
|
||||
}
|
||||
|
||||
for (i=0x05; i<=0x20; i++) {
|
||||
IS31FL3235A_write_register(addr, i, 0x00); // Write all PWM set 0x00
|
||||
}
|
||||
|
||||
IS31FL3235A_write_register(addr, 0x25, 0x00); //update PWM&Control registers
|
||||
IS31FL3235A_write_register(addr, 0x4B, 0x01); //frequency setting 22KHz
|
||||
IS31FL3235A_write_register(addr, 0x00, 0x01); //normal operation
|
||||
|
||||
// This is how the Arduino code does LED turn on
|
||||
IS31FL3235A_write_register(addr, 0x05, 0xFF); // set PWM
|
||||
IS31FL3235A_write_register(addr, 0x25, 0x00); // update PWM&Control registers
|
||||
IS31FL3235A_write_register(addr, 0x08, 0xFF); // set PWM
|
||||
IS31FL3235A_write_register(addr, 0x25, 0x00); // update PWM&Control registers
|
||||
IS31FL3235A_write_register(addr, 0x12, 0xFF); // set PWM
|
||||
IS31FL3235A_write_register(addr, 0x25, 0x00); // update PWM&Control registers
|
||||
|
||||
// FIXME: This is for testing, turn on OUT1 at full brightness
|
||||
IS31FL3235A_write_register(addr, 0x2A, 0xFF);
|
||||
IS31FL3235A_write_register(addr, 0x05, 0x00);
|
||||
//IS31FL3235A_write_register(addr, 0x2A, 0xFF);
|
||||
//IS31FL3235A_write_register(addr, 0x05, 0x00);
|
||||
|
||||
// I think this finally turns it on?
|
||||
IS31FL3235A_write_register(addr, 0x25, 0x00); //update PWM&Control registers
|
||||
//IS31FL3235A_write_register(addr, 0x25, 0x00); //update PWM&Control registers
|
||||
//IS31FL3235A_write_register(addr, 0x4B, 0x01); //frequency setting 22KHz
|
||||
IS31FL3235A_write_register(addr, 0x00, 0x01); //normal operation
|
||||
//IS31FL3235A_write_register(addr, 0x00, 0x01); //normal operation
|
||||
}
|
||||
|
||||
void IS31FL3235A_set_value(int index, uint8_t value) {
|
||||
|
|
|
@ -128,16 +128,14 @@ void rgb7seg_task(void) {
|
|||
}
|
||||
|
||||
void rgb7seg_init(void) {
|
||||
#ifdef IS31FL3235A_DRIVER_ADDR_1
|
||||
IS31FL3235A_init(IS31FL3235A_DRIVER_ADDR_1);
|
||||
#endif
|
||||
#ifdef IS31FL3235A_DRIVER_ADDR_2
|
||||
IS31FL3235A_init(IS31FL3235A_DRIVER_ADDR_1);
|
||||
#if IS31FL3235A_COUNT > 1
|
||||
IS31FL3235A_init(IS31FL3235A_DRIVER_ADDR_2);
|
||||
#endif
|
||||
#ifdef IS31FL3235A_DRIVER_ADDR_3
|
||||
#if IS31FL3235A_COUNT > 2
|
||||
IS31FL3235A_init(IS31FL3235A_DRIVER_ADDR_3);
|
||||
#endif
|
||||
#ifdef IS31FL3235A_DRIVER_ADDR_4
|
||||
#if IS31FL3235A_COUNT > 3
|
||||
IS31FL3235A_init(IS31FL3235A_DRIVER_ADDR_4);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
*
|
||||
*/
|
||||
#define MATRIX_ROW_PINS { B0, B1, B2, A15, A10 }
|
||||
#define MATRIX_COL_PINS { A2, A3, A6, B14, B15, A8, A9, A7, B3, B4, C14, C15, C13, B5, B6 }
|
||||
#define MATRIX_COL_PINS { A2, A3, A6, B14, B15, A8, A9, A7, B3, B4, C15, C14, C13, B5, B6 }
|
||||
#define UNUSED_PINS { A0, A1, A9, B7, B8, B9, B10, B11, B12, B13 }
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
|
|
|
@ -37,6 +37,17 @@
|
|||
/* Locking resynchronize hack */
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#define IS31FL3235A_COUNT 1
|
||||
//#define I2C_DRIVER I2CD1
|
||||
#define I2C1_BANK GPIOB
|
||||
#define I2C1_SCL 8
|
||||
#define I2C1_SDA 9
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
* @brief Enables the I2C subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_I2C FALSE
|
||||
#define HAL_USE_I2C TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
/*
|
||||
* I2C driver system settings.
|
||||
*/
|
||||
#define STM32_I2C_USE_I2C1 FALSE
|
||||
#define STM32_I2C_USE_I2C1 TRUE
|
||||
#define STM32_I2C_USE_I2C2 FALSE
|
||||
#define STM32_I2C_BUSY_TIMEOUT 50
|
||||
#define STM32_I2C_I2C1_IRQ_PRIORITY 10
|
||||
|
|
|
@ -17,6 +17,8 @@ DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave
|
|||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
QWIIC_ENABLE = RGB7SEG
|
||||
|
||||
BACKLIGHT_ENABLE = yes
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
#define BACKLIGHT_LEVELS 10
|
||||
|
||||
// For the rgb7seg
|
||||
#define IS31FL3235A_COUNT 4
|
||||
#define IS31FL3235A_COUNT 1
|
||||
#define I2C_DRIVER I2CD2
|
||||
#define I2C1_BANK GPIOA
|
||||
#define I2C1_SCL 9
|
||||
|
|
Loading…
Reference in New Issue