Compare commits
No commits in common. "5177b02ab02bc18f8d8465d58b02486cf6124317" and "5d722f41e8721d3f95ac2df85a51a141ff54b07a" have entirely different histories.
5177b02ab0
...
5d722f41e8
|
@ -44,7 +44,7 @@ void gpio_init()
|
||||||
|
|
||||||
gpio.GPIO_Speed = GPIO_Speed_2MHz;
|
gpio.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
|
|
||||||
// GAT SoftI2C, USART TX/RX; currently unused
|
// Soft I2C, USART TX/RX; currently unused
|
||||||
gpio.GPIO_Mode = GPIO_Mode_IPD;
|
gpio.GPIO_Mode = GPIO_Mode_IPD;
|
||||||
gpio.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
|
gpio.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
|
||||||
GPIO_Init(GPIOD, &gpio);
|
GPIO_Init(GPIOD, &gpio);
|
||||||
|
@ -65,13 +65,10 @@ void gpio_init()
|
||||||
gpio.GPIO_Pin = GPIO_Pin_2;
|
gpio.GPIO_Pin = GPIO_Pin_2;
|
||||||
GPIO_Init(GPIOD, &gpio);
|
GPIO_Init(GPIOD, &gpio);
|
||||||
|
|
||||||
// I2C SCL, SCA for on-board devices
|
// I2C will be handled by the driver
|
||||||
gpio.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2;
|
|
||||||
gpio.GPIO_Mode = GPIO_Mode_AF_OD;
|
|
||||||
GPIO_Init(GPIOC, &gpio);
|
|
||||||
|
|
||||||
// IS_SDB (PC3) IS31FL3729 shutdown pin (active low)
|
// IS_SDB IS31FL3729 shutdown pin (active low)
|
||||||
// WP (PC6) for EEPROM
|
// WP for EEPROM
|
||||||
GPIOC->BCR = GPIO_Pin_3;
|
GPIOC->BCR = GPIO_Pin_3;
|
||||||
GPIOC->BSHR = GPIO_Pin_6;
|
GPIOC->BSHR = GPIO_Pin_6;
|
||||||
gpio.GPIO_Mode = GPIO_Mode_Out_PP;
|
gpio.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
|
|
@ -9,23 +9,11 @@
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* sends the IS31FL3729 general config.
|
||||||
void is31fl3729_set_global_current(uint8_t i2c_addr, uint8_t global_current)
|
|
||||||
{
|
|
||||||
i2c_write_reg_8b(i2c_addr, FL3729_REG_G_CURRENT, global_current);
|
|
||||||
}
|
|
||||||
|
|
||||||
void is31fl3729_set_scaling_current(uint8_t i2c_addr, uint8_t cs, uint8_t current)
|
|
||||||
{
|
|
||||||
if (cs > 0xf) return;
|
|
||||||
|
|
||||||
i2c_write_reg_8b(i2c_addr, FL3729_REG_SCALING + cs, current);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sends the IS31FL3729 initial config.
|
|
||||||
* does not configure per-channel current sink limits; do that separately.
|
* does not configure per-channel current sink limits; do that separately.
|
||||||
* does not configure other sane defaults; do that separately.
|
* does not configure other sane defaults; do that separately.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void is31fl3729_init(uint8_t i2c_addr, uint8_t config, uint8_t global_current)
|
void is31fl3729_init(uint8_t i2c_addr, uint8_t config, uint8_t global_current)
|
||||||
{
|
{
|
||||||
// enable device
|
// enable device
|
||||||
|
@ -38,7 +26,7 @@ void is31fl3729_init(uint8_t i2c_addr, uint8_t config, uint8_t global_current)
|
||||||
|
|
||||||
// write initial config
|
// write initial config
|
||||||
i2c_write_reg_8b(i2c_addr, FL3729_REG_CONFIG, config);
|
i2c_write_reg_8b(i2c_addr, FL3729_REG_CONFIG, config);
|
||||||
is31fl3729_set_global_current(i2c_addr, global_current);
|
i2c_write_reg_8b(i2c_addr, FL3729_REG_G_CURRENT, global_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t is31fl3729_get_addr(uint8_t adpin)
|
uint8_t is31fl3729_get_addr(uint8_t adpin)
|
||||||
|
@ -47,6 +35,18 @@ uint8_t is31fl3729_get_addr(uint8_t adpin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void is31fl3729_set_global_current(uint8_t i2c_addr, uint8_t current)
|
||||||
|
{
|
||||||
|
i2c_write_reg_8b(i2c_addr, FL3729_REG_G_CURRENT, current);
|
||||||
|
}
|
||||||
|
|
||||||
|
void is31fl3729_set_scaling_current(uint8_t i2c_addr, uint8_t cs, uint8_t current)
|
||||||
|
{
|
||||||
|
if (cs > 0xf) return;
|
||||||
|
|
||||||
|
i2c_write_reg_8b(i2c_addr, FL3729_REG_SCALING + cs, current);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sets current limit of multiple outputs simultaneously, starting from CS1.
|
* sets current limit of multiple outputs simultaneously, starting from CS1.
|
||||||
* useful for initial register configuration.
|
* useful for initial register configuration.
|
||||||
|
|
|
@ -72,7 +72,7 @@ void is31fl3729_init(uint8_t i2c_addr, uint8_t config, uint8_t global_current);
|
||||||
|
|
||||||
uint8_t is31fl3729_get_addr(uint8_t adpin);
|
uint8_t is31fl3729_get_addr(uint8_t adpin);
|
||||||
|
|
||||||
void is31fl3729_set_global_current(uint8_t i2c_addr, uint8_t global_current);
|
void is31fl3729_set_global_current(uint8_t i2c_addr, uint8_t current);
|
||||||
void is31fl3729_set_scaling_current(uint8_t i2c_addr, uint8_t cs, uint8_t current);
|
void is31fl3729_set_scaling_current(uint8_t i2c_addr, uint8_t cs, uint8_t current);
|
||||||
void is31fl3729_set_scaling_current_multi(uint8_t i2c_addr, const uint8_t *current, uint8_t count);
|
void is31fl3729_set_scaling_current_multi(uint8_t i2c_addr, const uint8_t *current, uint8_t count);
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,13 @@ static uint32_t timeout;
|
||||||
|
|
||||||
void i2c_init()
|
void i2c_init()
|
||||||
{
|
{
|
||||||
|
GPIO_InitTypeDef gpio = {0};
|
||||||
I2C_InitTypeDef i2c = {0};
|
I2C_InitTypeDef i2c = {0};
|
||||||
|
|
||||||
// ensure GPIO pins are configured before initializing
|
gpio.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2;
|
||||||
|
gpio.GPIO_Mode = GPIO_Mode_AF_OD;
|
||||||
|
gpio.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
|
GPIO_Init(GPIOC, &gpio);
|
||||||
|
|
||||||
i2c.I2C_ClockSpeed = 666666;
|
i2c.I2C_ClockSpeed = 666666;
|
||||||
i2c.I2C_Mode = I2C_Mode_I2C;
|
i2c.I2C_Mode = I2C_Mode_I2C;
|
||||||
|
|
|
@ -408,12 +408,12 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
if ((i < typing_idx) || ((i == typing_idx) && typing_flash_state)) {
|
if ((i < typing_idx) || ((i == typing_idx) && typing_flash_state)) {
|
||||||
// these are on
|
// these are on
|
||||||
rgb[i][j] = typing[color][j];
|
rgb[i][j] = typing[color][j];
|
||||||
} else
|
}
|
||||||
|
|
||||||
if (i > typing_idx) { // || ((i == typing_idx) && !typing_flash_state)) {
|
if (i > typing_idx) { // || ((i == typing_idx) && !typing_flash_state)) {
|
||||||
// these are idle
|
// these are idle
|
||||||
rgb[i][j] = idle_glow[j];
|
rgb[i][j] = idle_glow[j];
|
||||||
} else
|
}
|
||||||
|
|
||||||
// flashing cursor fadeout
|
// flashing cursor fadeout
|
||||||
if ((i == typing_idx) && !typing_flash_state) {
|
if ((i == typing_idx) && !typing_flash_state) {
|
||||||
|
@ -443,16 +443,12 @@ void led_rgb_4_typing(uint8_t preview, uint8_t tick)
|
||||||
if (typing_fadeout >= 3) typing_fadeout--;
|
if (typing_fadeout >= 3) typing_fadeout--;
|
||||||
else typing_fadeout = 0;
|
else typing_fadeout = 0;
|
||||||
|
|
||||||
for (j = 0; j < 3; j++) {
|
for (i = 0; i < 9; i++) {
|
||||||
s = rgb[0][j];
|
for (j = 0; j < 3; j++) {
|
||||||
s *= typing_fadeout;
|
s = rgb[i][j];
|
||||||
rgb[0][j] = s >> 8;
|
s *= typing_fadeout;
|
||||||
}
|
rgb[i][j] = s >> 8;
|
||||||
|
}
|
||||||
for (i = 1; i < 9; i++) {
|
|
||||||
rgb[i][0] = rgb[0][0];
|
|
||||||
rgb[i][1] = rgb[0][1];
|
|
||||||
rgb[i][2] = rgb[0][2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s = cursor[color];
|
s = cursor[color];
|
||||||
|
|
Loading…
Reference in New Issue