i2c: rename read/write register functions (#22905)

This commit is contained in:
Ryan 2024-01-16 13:26:40 +11:00 committed by GitHub
parent e1f59a6efc
commit a522b1f156
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 184 additions and 170 deletions

View file

@ -42,9 +42,9 @@ static void init_pins(void) {
unselect_rows();
// Set I/O
uint8_t send_data[2] = { 0xFF, 0x03};
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x00, &send_data[0], 2, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x00, &send_data[0], 2, 20);
// Set Pull-up
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x0C, &send_data[0], 2, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x0C, &send_data[0], 2, 20);
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
if ( x < 8 ) {
@ -75,7 +75,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
matrix_io_delay();
uint8_t port_expander_col_buffer[2];
i2c_readReg((PORT_EXPANDER_ADDRESS << 1), 0x12, &port_expander_col_buffer[0], 2, 20);
i2c_read_register((PORT_EXPANDER_ADDRESS << 1), 0x12, &port_expander_col_buffer[0], 2, 20);
// For each col...
for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {

View file

@ -22,7 +22,7 @@ void matrix_init_kb(void) {
// Due to the way the port expander is setup both LEDs are already outputs. This is set n matrix.copy
//Turn the red LED on as power indicator.
send_data = 0x10;
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x09, &send_data, 1, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x09, &send_data, 1, 20);
matrix_init_user();
}
@ -31,7 +31,7 @@ bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
send_data = led_state.caps_lock ? 0x18 : 0x10;
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x09, &send_data, 1, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x09, &send_data, 1, 20);
}
return res;
}

View file

@ -42,9 +42,9 @@ static void init_pins(void) {
unselect_rows();
// Set I/O
uint8_t send_data = 0x07;
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x00, &send_data, 1, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x00, &send_data, 1, 20);
// Set Pull-up
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x06, &send_data, 1, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x06, &send_data, 1, 20);
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
if ( (x > 0) && (x < 12) ) {
@ -80,15 +80,15 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Select the col pin to read (active low)
switch (col_index) {
case 0 :
i2c_readReg((PORT_EXPANDER_ADDRESS << 1), 0x09, &pin_state, 1, 20);
i2c_read_register((PORT_EXPANDER_ADDRESS << 1), 0x09, &pin_state, 1, 20);
pin_state = pin_state & 0x01;
break;
case 12 :
i2c_readReg((PORT_EXPANDER_ADDRESS << 1), 0x09, &pin_state, 1, 20);
i2c_read_register((PORT_EXPANDER_ADDRESS << 1), 0x09, &pin_state, 1, 20);
pin_state = pin_state & (1 << 2);
break;
case 13 :
i2c_readReg((PORT_EXPANDER_ADDRESS << 1), 0x09, &pin_state, 1, 20);
i2c_read_register((PORT_EXPANDER_ADDRESS << 1), 0x09, &pin_state, 1, 20);
pin_state = pin_state & (1 << 1);
break;
default :

View file

@ -42,9 +42,9 @@ static void init_pins(void) {
unselect_rows();
// Set I/O
uint8_t send_data = 0x1F;
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x00, &send_data, 1, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x00, &send_data, 1, 20);
// Set Pull-up
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x06, &send_data, 1, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x06, &send_data, 1, 20);
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
if ( x < 10 ) {
@ -75,7 +75,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
matrix_io_delay();
uint8_t port_expander_col_buffer;
i2c_readReg((PORT_EXPANDER_ADDRESS << 1), 0x09, &port_expander_col_buffer, 1, 20);
i2c_read_register((PORT_EXPANDER_ADDRESS << 1), 0x09, &port_expander_col_buffer, 1, 20);
// For each col...
for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {

View file

@ -26,7 +26,7 @@ void led_update_ports(led_t led_state) {
} else {
send_data &= ~(1 << 5);
}
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x0A, &send_data, 1, 20);
i2c_write_register((PORT_EXPANDER_ADDRESS << 1), 0x0A, &send_data, 1, 20);
}
__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {