Ver código fonte

kimera: Improve robustness of output port of IO expander

- Avoid output pin short to GND issue
kimera
Kai Ryu 9 anos atrás
pai
commit
b61da41afa
1 arquivos alterados com 9 adições e 4 exclusões
  1. 9
    4
      keyboard/kimera/kimera.c

+ 9
- 4
keyboard/kimera/kimera.c Ver arquivo

/* set all output registers to 0xFF */ /* set all output registers to 0xFF */
init_data(0xFF); init_data(0xFF);
for (uint8_t exp = 0; exp < EXP_COUNT; exp++) { for (uint8_t exp = 0; exp < EXP_COUNT; exp++) {
expander_write_output(exp, data[exp]);
expander_write_config(exp, data[exp]);
} }
} }


if (px != UNCONFIGURED) { if (px != UNCONFIGURED) {
uint8_t exp = PX_TO_EXP(px); uint8_t exp = PX_TO_EXP(px);
data[exp][PX_TO_PORT(px)] &= ~(1 << PX_TO_PIN(px)); data[exp][PX_TO_PORT(px)] &= ~(1 << PX_TO_PIN(px));
expander_write_output(exp, data[exp]);
expander_write_config(exp, data[exp]);
} }
} }


void expander_init(uint8_t exp) void expander_init(uint8_t exp)
{ {
init_data(0xFF);
init_data(0x00);


/* write inversion register */ /* write inversion register */
/* /*
*/ */


/* set output bit */ /* set output bit */
/*
for (uint8_t row = 0; row < row_count; row++) { for (uint8_t row = 0; row < row_count; row++) {
uint8_t px = row_mapping[row]; uint8_t px = row_mapping[row];
if (px != UNCONFIGURED) { if (px != UNCONFIGURED) {
data[PX_TO_EXP(px)][PX_TO_PORT(px)] &= ~(1 << PX_TO_PIN(px)); data[PX_TO_EXP(px)][PX_TO_PORT(px)] &= ~(1 << PX_TO_PIN(px));
} }
} }
*/


/* write config registers */ /* write config registers */
expander_write_config(exp, data[exp]);
//expander_write_config(exp, data[exp]);

/* write output registers */
expander_write_output(exp, data[exp]);
} }


uint8_t expander_write(uint8_t exp, uint8_t command, uint8_t *data) uint8_t expander_write(uint8_t exp, uint8_t command, uint8_t *data)