From a522b1f15627c69f94cbc814968be5a63519b8e3 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 16 Jan 2024 13:26:40 +1100 Subject: i2c: rename read/write register functions (#22905) --- keyboards/3w6/rev1/matrix.c | 6 ++--- .../keymaps/default_pimoroni/pimoroni_trackball.c | 2 +- keyboards/3w6/rev2/matrix.c | 6 ++--- keyboards/argyle/matrix.c | 6 ++--- keyboards/barleycorn_smd/matrix.c | 6 ++--- keyboards/ergodox_stm32/ergodox_stm32.c | 8 +++--- keyboards/ergodox_stm32/matrix.c | 4 +-- keyboards/fc660c/ad5258.c | 6 ++--- keyboards/fc980c/ad5258.c | 6 ++--- keyboards/frobiac/blackbowl/matrix.c | 8 +++--- keyboards/handwired/d48/ds1307.c | 4 +-- keyboards/handwired/dactyl/matrix.c | 12 ++++----- .../handwired/onekey/keymaps/i2c_scanner/keymap.c | 2 +- keyboards/kagizaraya/chidori/board.c | 30 +++++++++++----------- keyboards/matrix/abelx/aw9523b.c | 14 +++++----- keyboards/matrix/abelx/tca6424.c | 4 +-- keyboards/matrix/m20add/tca6424.c | 4 +-- keyboards/rate/pistachio_pro/lib/bme280.c | 14 +++++----- keyboards/rgbkb/common/touch_encoder.c | 4 +-- keyboards/sx60/matrix.c | 4 +-- keyboards/sx60/sx60.c | 4 +-- keyboards/system76/launch_1/usb_mux.c | 4 +-- keyboards/torn/mcp23018.c | 4 +-- keyboards/touchpad/matrix.c | 2 +- keyboards/yiancardesigns/barleycorn/matrix.c | 6 ++--- keyboards/yiancardesigns/gingham/gingham.c | 4 +-- keyboards/yiancardesigns/gingham/matrix.c | 10 ++++---- keyboards/yiancardesigns/seigaiha/matrix.c | 6 ++--- keyboards/yiancardesigns/seigaiha/seigaiha.c | 2 +- keyboards/zsa/moonlander/matrix.c | 2 +- 30 files changed, 97 insertions(+), 97 deletions(-) (limited to 'keyboards') diff --git a/keyboards/3w6/rev1/matrix.c b/keyboards/3w6/rev1/matrix.c index 8bb6c77aaa..aa3e43fbe0 100644 --- a/keyboards/3w6/rev1/matrix.c +++ b/keyboards/3w6/rev1/matrix.c @@ -70,7 +70,7 @@ uint8_t init_tca9555(void) { // This means: we will write on pins 0 to 2 on port 1. read rest 0b11111000, }; - tca9555_status = i2c_writeReg(I2C_ADDR, IODIRA, conf, 2, I2C_TIMEOUT); + tca9555_status = i2c_write_register(I2C_ADDR, IODIRA, conf, 2, I2C_TIMEOUT); return tca9555_status; } @@ -189,7 +189,7 @@ static matrix_row_t read_cols(uint8_t row) { } else { uint8_t data = 0; uint8_t ports[2] = {0}; - tca9555_status = i2c_readReg(I2C_ADDR, IREGP0, ports, 2, I2C_TIMEOUT); + tca9555_status = i2c_read_register(I2C_ADDR, IREGP0, ports, 2, I2C_TIMEOUT); if (tca9555_status) { // if there was an error // do nothing return 0; @@ -252,7 +252,7 @@ static void select_row(uint8_t row) { } uint8_t ports[2] = {port0, port1}; - tca9555_status = i2c_writeReg(I2C_ADDR, OREGP0, ports, 2, I2C_TIMEOUT); + tca9555_status = i2c_write_register(I2C_ADDR, OREGP0, ports, 2, I2C_TIMEOUT); // Select the desired row by writing a byte for the entire GPIOB bus where only the bit representing the row we want to select is a zero (write instruction) and every other bit is a one. // Note that the row - MATRIX_ROWS_PER_SIDE reflects the fact that being on the right hand, the columns are numbered from MATRIX_ROWS_PER_SIDE to MATRIX_ROWS, but the pins we want to write to are indexed from zero up on the GPIOB bus. } diff --git a/keyboards/3w6/rev2/keymaps/default_pimoroni/pimoroni_trackball.c b/keyboards/3w6/rev2/keymaps/default_pimoroni/pimoroni_trackball.c index a6661cdc07..35a85b5476 100644 --- a/keyboards/3w6/rev2/keymaps/default_pimoroni/pimoroni_trackball.c +++ b/keyboards/3w6/rev2/keymaps/default_pimoroni/pimoroni_trackball.c @@ -120,7 +120,7 @@ bool pointing_device_task(void) { static uint16_t debounce_timer; uint8_t state[5] = {}; if (timer_elapsed(i2c_timeout_timer) > I2C_WAITCHECK) { - if (i2c_readReg(TRACKBALL_WRITE, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) { + if (i2c_read_register(TRACKBALL_WRITE, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) { if (!state[4] && !debounce) { if (scrolling) { #ifdef PIMORONI_TRACKBALL_INVERT_X diff --git a/keyboards/3w6/rev2/matrix.c b/keyboards/3w6/rev2/matrix.c index 49cb09a9f8..da7a5344e5 100644 --- a/keyboards/3w6/rev2/matrix.c +++ b/keyboards/3w6/rev2/matrix.c @@ -70,7 +70,7 @@ uint8_t init_tca9555(void) { // This means: we will write on pins 0 to 3 on port 1. read rest 0b11110000, }; - tca9555_status = i2c_writeReg(I2C_ADDR, IODIRA, conf, 2, I2C_TIMEOUT); + tca9555_status = i2c_write_register(I2C_ADDR, IODIRA, conf, 2, I2C_TIMEOUT); return tca9555_status; } @@ -189,7 +189,7 @@ static matrix_row_t read_cols(uint8_t row) { } else { uint8_t data = 0; uint8_t port0 = 0; - tca9555_status = i2c_readReg(I2C_ADDR, IREGP0, &port0, 1, I2C_TIMEOUT); + tca9555_status = i2c_read_register(I2C_ADDR, IREGP0, &port0, 1, I2C_TIMEOUT); if (tca9555_status) { // if there was an error // do nothing return 0; @@ -250,7 +250,7 @@ static void select_row(uint8_t row) { default: break; } - tca9555_status = i2c_writeReg(I2C_ADDR, OREGP1, &port1, 1, I2C_TIMEOUT); + tca9555_status = i2c_write_register(I2C_ADDR, OREGP1, &port1, 1, I2C_TIMEOUT); // Select the desired row by writing a byte for the entire GPIOB bus where only the bit representing the row we want to select is a zero (write instruction) and every other bit is a one. // Note that the row - MATRIX_ROWS_PER_SIDE reflects the fact that being on the right hand, the columns are numbered from MATRIX_ROWS_PER_SIDE to MATRIX_ROWS, but the pins we want to write to are indexed from zero up on the GPIOB bus. } diff --git a/keyboards/argyle/matrix.c b/keyboards/argyle/matrix.c index 7430c6d9d8..d723392a01 100644 --- a/keyboards/argyle/matrix.c +++ b/keyboards/argyle/matrix.c @@ -78,9 +78,9 @@ static void init_pins(void) { unselect_rows(); // Set I/O uint8_t send_data = 0xFF; - 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 (col_pins[x] != NO_PIN) { @@ -111,7 +111,7 @@ static bool matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t curre matrix_output_select_delay(); uint8_t port_expander_buffer; - i2c_readReg((PORT_EXPANDER_ADDRESS << 1), 0x09, &port_expander_buffer, 1, 20); + i2c_read_register((PORT_EXPANDER_ADDRESS << 1), 0x09, &port_expander_buffer, 1, 20); // For each col... // matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; diff --git a/keyboards/barleycorn_smd/matrix.c b/keyboards/barleycorn_smd/matrix.c index b717452f3d..315093c8a9 100644 --- a/keyboards/barleycorn_smd/matrix.c +++ b/keyboards/barleycorn_smd/matrix.c @@ -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++) { diff --git a/keyboards/ergodox_stm32/ergodox_stm32.c b/keyboards/ergodox_stm32/ergodox_stm32.c index 2a919506dc..99d51866f7 100644 --- a/keyboards/ergodox_stm32/ergodox_stm32.c +++ b/keyboards/ergodox_stm32/ergodox_stm32.c @@ -59,16 +59,16 @@ uint8_t init_mcp23017(void) { uint8_t data[2]; data[0] = 0x0; data[1] = 0b00111111; - mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_IODIRA, data, 2, 50000); + mcp23017_status = i2c_write_register(I2C_ADDR, I2C_IODIRA, data, 2, 50000); if (mcp23017_status) goto out; data[0] = 0xFFU; - mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPIOA, data, 1, 5000); + mcp23017_status = i2c_write_register(I2C_ADDR, I2C_GPIOA, data, 1, 5000); if (mcp23017_status) goto out; - mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPPUB, data+1, 1, 2); + mcp23017_status = i2c_write_register(I2C_ADDR, I2C_GPPUB, data+1, 1, 2); if (mcp23017_status) goto out; out: return mcp23017_status; - // i2c_readReg(I2C_ADDR, ); + // i2c_read_register(I2C_ADDR, ); } diff --git a/keyboards/ergodox_stm32/matrix.c b/keyboards/ergodox_stm32/matrix.c index 3eb35cd7bb..6acd2dda22 100644 --- a/keyboards/ergodox_stm32/matrix.c +++ b/keyboards/ergodox_stm32/matrix.c @@ -134,7 +134,7 @@ static matrix_row_t read_cols(uint8_t row) { uint8_t data = 0xFF; if (!mcp23017_status) { uint8_t regAddr = I2C_GPIOB; - mcp23017_status = i2c_readReg(I2C_ADDR, regAddr, &data, 1, 10); + mcp23017_status = i2c_read_register(I2C_ADDR, regAddr, &data, 1, 10); } if (mcp23017_status) { return 0; @@ -174,7 +174,7 @@ static void select_row(uint8_t row) { if (row < MATRIX_ROWS_PER_SIDE) { if (!mcp23017_status) { uint8_t data = (0xFF & ~(1 << row)); - mcp23017_status = i2c_writeReg(I2C_ADDR, I2C_GPIOA, &data, 1, 10); + mcp23017_status = i2c_write_register(I2C_ADDR, I2C_GPIOA, &data, 1, 10); } } else { GPIOB->BRR = 0x1 << (row+1); diff --git a/keyboards/fc660c/ad5258.c b/keyboards/fc660c/ad5258.c index f7ff2f3dc1..9d33c10ce4 100644 --- a/keyboards/fc660c/ad5258.c +++ b/keyboards/fc660c/ad5258.c @@ -35,18 +35,18 @@ void ad5258_init(void) { uint8_t ad5258_read_rdac(void) { // read RDAC register uint8_t ret = 0; - i2c_readReg(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &ret, 1, 100); + i2c_read_register(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &ret, 1, 100); return ret; } uint8_t ad5258_read_eeprom(void) { uint8_t ret = 0; - i2c_readReg(AD5258_I2C_ADDRESS, AD5258_INST_EEPROM, &ret, 1, 100); + i2c_read_register(AD5258_I2C_ADDRESS, AD5258_INST_EEPROM, &ret, 1, 100); return ret; } void ad5258_write_rdac(uint8_t rdac) { // write RDAC register: uint8_t data = rdac & 0x3F; - i2c_writeReg(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &data, 1, 100); + i2c_write_register(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &data, 1, 100); } diff --git a/keyboards/fc980c/ad5258.c b/keyboards/fc980c/ad5258.c index f7ff2f3dc1..9d33c10ce4 100644 --- a/keyboards/fc980c/ad5258.c +++ b/keyboards/fc980c/ad5258.c @@ -35,18 +35,18 @@ void ad5258_init(void) { uint8_t ad5258_read_rdac(void) { // read RDAC register uint8_t ret = 0; - i2c_readReg(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &ret, 1, 100); + i2c_read_register(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &ret, 1, 100); return ret; } uint8_t ad5258_read_eeprom(void) { uint8_t ret = 0; - i2c_readReg(AD5258_I2C_ADDRESS, AD5258_INST_EEPROM, &ret, 1, 100); + i2c_read_register(AD5258_I2C_ADDRESS, AD5258_INST_EEPROM, &ret, 1, 100); return ret; } void ad5258_write_rdac(uint8_t rdac) { // write RDAC register: uint8_t data = rdac & 0x3F; - i2c_writeReg(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &data, 1, 100); + i2c_write_register(AD5258_I2C_ADDRESS, AD5258_INST_RDAC, &data, 1, 100); } diff --git a/keyboards/frobiac/blackbowl/matrix.c b/keyboards/frobiac/blackbowl/matrix.c index 727e26ddc1..2a2c2618ab 100644 --- a/keyboards/frobiac/blackbowl/matrix.c +++ b/keyboards/frobiac/blackbowl/matrix.c @@ -45,10 +45,10 @@ void matrix_init_custom(void) { uint8_t pullup[2] = {0, expander_input_mask}; for (uint8_t i = 0; i < 2; ++i) { - expander_status = i2c_writeReg(i2c_addr[i], IODIRA, direction, 2, I2C_TIMEOUT); + expander_status = i2c_write_register(i2c_addr[i], IODIRA, direction, 2, I2C_TIMEOUT); if (expander_status) return; - expander_status = i2c_writeReg(i2c_addr[i], GPPUA, pullup, 2, I2C_TIMEOUT); + expander_status = i2c_write_register(i2c_addr[i], GPPUA, pullup, 2, I2C_TIMEOUT); } } @@ -79,7 +79,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) // On both expanders: select col and read rows for (size_t i = 0; i < 2; ++i) { if (!expander_status) { - expander_status = i2c_writeReg(i2c_addr[i], EXPANDER_COL_REGISTER, &port, 1, I2C_TIMEOUT); + expander_status = i2c_write_register(i2c_addr[i], EXPANDER_COL_REGISTER, &port, 1, I2C_TIMEOUT); } wait_us(30); @@ -87,7 +87,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) return false; } - expander_status = i2c_readReg(i2c_addr[i], EXPANDER_ROW_REGISTER, &column_state[i], 1, I2C_TIMEOUT); + expander_status = i2c_read_register(i2c_addr[i], EXPANDER_ROW_REGISTER, &column_state[i], 1, I2C_TIMEOUT); column_state[i] = (~column_state[i]) & ((1 << MATRIX_ROWS_PER_SIDE) - 1); } diff --git a/keyboards/handwired/d48/ds1307.c b/keyboards/handwired/d48/ds1307.c index f6b57d50d2..2b3a88f315 100644 --- a/keyboards/handwired/d48/ds1307.c +++ b/keyboards/handwired/d48/ds1307.c @@ -8,12 +8,12 @@ void ds1307_set_time(uint8_t h, uint8_t m, uint8_t s) { ((h % 10) | ((h / 10) << 4)) & 0x3F, 0, 0, 0, 0, 0 }; // 24-hour mode - i2c_writeReg(DS1307_ADDR, 0, data, 8, 100); + i2c_write_register(DS1307_ADDR, 0, data, 8, 100); } void ds1307_get_time(uint8_t *h, uint8_t *m, uint8_t *s) { uint8_t data[3]; - i2c_readReg(DS1307_ADDR, 0, data, 3, 100); + i2c_read_register(DS1307_ADDR, 0, data, 3, 100); i2c_stop(); *s = (data[0] & 0b1111) + ((data[0] & 0b1110000) >> 4) * 10; *m = (data[1] & 0b1111) + ((data[1] & 0b1110000) >> 4) * 10; diff --git a/keyboards/handwired/dactyl/matrix.c b/keyboards/handwired/dactyl/matrix.c index d87fe4cbd1..140f4236c1 100644 --- a/keyboards/handwired/dactyl/matrix.c +++ b/keyboards/handwired/dactyl/matrix.c @@ -216,10 +216,10 @@ void init_expander(void) { #endif - expander_status = i2c_writeReg(I2C_ADDR, IODIRA, direction, 2, I2C_TIMEOUT); + expander_status = i2c_write_register(I2C_ADDR, IODIRA, direction, 2, I2C_TIMEOUT); if (expander_status) return; - expander_status = i2c_writeReg(I2C_ADDR, GPPUA, pullup, 2, I2C_TIMEOUT); + expander_status = i2c_write_register(I2C_ADDR, GPPUA, pullup, 2, I2C_TIMEOUT); } uint8_t matrix_scan(void) @@ -333,7 +333,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) // Read columns from expander, unless it's in an error state if (! expander_status) { uint8_t state = 0; - expander_status = i2c_readReg(I2C_ADDR, EXPANDER_COL_REGISTER, &state, 1, I2C_TIMEOUT); + expander_status = i2c_read_register(I2C_ADDR, EXPANDER_COL_REGISTER, &state, 1, I2C_TIMEOUT); if (! expander_status) { current_matrix[current_row] |= (~state) & expander_input_pin_mask; } @@ -359,7 +359,7 @@ static void select_row(uint8_t row) { // set active row low : 0 // set other rows hi-Z : 1 uint8_t port = 0xFF & ~(1<led_status[led_index] = status; uint8_t iodir = board_merge_led_config(board, 0xff); uint8_t data = board_merge_led_status(board, 0x00); - i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&iodir, sizeof(iodir), BOARD_I2C_TIMEOUT); - i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_OLATB, (const uint8_t*)&data, sizeof(data), BOARD_I2C_TIMEOUT); + i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&iodir, sizeof(iodir), BOARD_I2C_TIMEOUT); + i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_OLATB, (const uint8_t*)&data, sizeof(data), BOARD_I2C_TIMEOUT); } static uint8_t board_merge_led_config(board_info_t* board, uint8_t iodir) { @@ -86,30 +86,30 @@ static bool board_slave_config(board_info_t* board) { i2c_status_t res = 0; // Set to input - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRA, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRA, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); if (res < 0) return false; // RESTRICTION: LEDs only on PORT B. set = board_merge_led_config(board, set); - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); if (res < 0) return false; set = 0xff; // Pull up for input - enable - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPPUA, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPPUA, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); if (res < 0) return false; - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPPUB, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPPUB, (const uint8_t*)&set, sizeof(set), BOARD_I2C_TIMEOUT); if (res < 0) return false; // Disable interrupt - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPINTENA, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPINTENA, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); if (res < 0) return false; - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPINTENB, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPINTENB, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); if (res < 0) return false; // Polarity - same logic - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_IPOLA, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_IPOLA, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); if (res < 0) return false; - res = i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_IPOLB, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); + res = i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_IPOLB, (const uint8_t*)&clear, sizeof(clear), BOARD_I2C_TIMEOUT); if (res < 0) return false; return true; @@ -203,7 +203,7 @@ static uint8_t board_read_slave_cols(board_info_t* board) { return 0xff; } uint8_t data = 0xff; - i2c_status_t res = i2c_readReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPIOA, &data, sizeof(data), BOARD_I2C_TIMEOUT); + i2c_status_t res = i2c_read_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_GPIOA, &data, sizeof(data), BOARD_I2C_TIMEOUT); return (res < 0) ? 0xff : data; } @@ -214,8 +214,8 @@ static void board_select_slave_row(board_info_t* board, uint8_t board_row) { uint8_t pin = board->row_pins[board_row]; uint8_t iodir = board_merge_led_config(board, PIN2MASK(pin)); uint8_t status = board_merge_led_status(board, PIN2MASK(pin)); - i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&iodir, sizeof(iodir), BOARD_I2C_TIMEOUT); - i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_OLATB, (const uint8_t*)&status, sizeof(status), BOARD_I2C_TIMEOUT); + i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&iodir, sizeof(iodir), BOARD_I2C_TIMEOUT); + i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_OLATB, (const uint8_t*)&status, sizeof(status), BOARD_I2C_TIMEOUT); } static void board_unselect_slave_rows(board_info_t* board) { @@ -224,8 +224,8 @@ static void board_unselect_slave_rows(board_info_t* board) { } uint8_t iodir = board_merge_led_config(board, 0xff); uint8_t data = board_merge_led_status(board, 0x00); - i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&iodir, sizeof(iodir), BOARD_I2C_TIMEOUT); - i2c_writeReg(EXPANDER_ADDR(board->i2c_address), EXPANDER_OLATB, (const uint8_t*)&data, sizeof(data), BOARD_I2C_TIMEOUT); + i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_IODIRB, (const uint8_t*)&iodir, sizeof(iodir), BOARD_I2C_TIMEOUT); + i2c_write_register(EXPANDER_ADDR(board->i2c_address), EXPANDER_OLATB, (const uint8_t*)&data, sizeof(data), BOARD_I2C_TIMEOUT); } static void board_unselect_slave_row(board_info_t* board, uint8_t board_row) { board_unselect_slave_rows(board); } diff --git a/keyboards/matrix/abelx/aw9523b.c b/keyboards/matrix/abelx/aw9523b.c index 8c6e8eaccf..860a71740d 100644 --- a/keyboards/matrix/abelx/aw9523b.c +++ b/keyboards/matrix/abelx/aw9523b.c @@ -51,15 +51,15 @@ void aw9523b_init(uint8_t addr) i2c_init(); // reset chip uint8_t data = 0; - i2c_writeReg(addr, AW9523B_RESET, &data, 1, TIMEOUT); + i2c_write_register(addr, AW9523B_RESET, &data, 1, TIMEOUT); wait_ms(1); // set max led current data = 0x03; // 37mA/4 - i2c_writeReg(addr, AW9523B_CTL, &data, 1, TIMEOUT); + i2c_write_register(addr, AW9523B_CTL, &data, 1, TIMEOUT); // set port to led mode data = 0; - i2c_writeReg(addr, AW9523B_P0_LED, &data, 1, TIMEOUT); - i2c_writeReg(addr, AW9523B_P1_LED, &data, 1, TIMEOUT); + i2c_write_register(addr, AW9523B_P0_LED, &data, 1, TIMEOUT); + i2c_write_register(addr, AW9523B_P1_LED, &data, 1, TIMEOUT); // clear pwm buff for (uint8_t i = 0; i < 16; i++) { aw9523b_pwm_buf[i] = 0; @@ -91,9 +91,9 @@ void aw9523b_update_pwm_buffers(uint8_t addr) if (aw9523b_pwm_dirty) { for (uint8_t i = 0; i < AW9523B_RGB_NUM; i++){ aw9523b_led led = g_aw9523b_leds[i]; - i2c_writeReg(addr, led.r, &aw9523b_pwm_buf[PWM2BUF(led.r)], 1, TIMEOUT); - i2c_writeReg(addr, led.g, &aw9523b_pwm_buf[PWM2BUF(led.g)], 1, TIMEOUT); - i2c_writeReg(addr, led.b, &aw9523b_pwm_buf[PWM2BUF(led.b)], 1, TIMEOUT); + i2c_write_register(addr, led.r, &aw9523b_pwm_buf[PWM2BUF(led.r)], 1, TIMEOUT); + i2c_write_register(addr, led.g, &aw9523b_pwm_buf[PWM2BUF(led.g)], 1, TIMEOUT); + i2c_write_register(addr, led.b, &aw9523b_pwm_buf[PWM2BUF(led.b)], 1, TIMEOUT); } aw9523b_pwm_dirty = false; } diff --git a/keyboards/matrix/abelx/tca6424.c b/keyboards/matrix/abelx/tca6424.c index 44dc7909d8..c632157256 100644 --- a/keyboards/matrix/abelx/tca6424.c +++ b/keyboards/matrix/abelx/tca6424.c @@ -47,13 +47,13 @@ void tca6424_init(void) static void write_port(uint8_t p, uint8_t d) { - i2c_writeReg(TCA6424_ADDR, p, &d, 1, TIMEOUT); + i2c_write_register(TCA6424_ADDR, p, &d, 1, TIMEOUT); } static uint8_t read_port(uint8_t port) { uint8_t data = 0; - i2c_readReg(TCA6424_ADDR, port, &data, 1, TIMEOUT); + i2c_read_register(TCA6424_ADDR, port, &data, 1, TIMEOUT); return data; } diff --git a/keyboards/matrix/m20add/tca6424.c b/keyboards/matrix/m20add/tca6424.c index 38cea9f15f..c6ffa4c2fe 100644 --- a/keyboards/matrix/m20add/tca6424.c +++ b/keyboards/matrix/m20add/tca6424.c @@ -45,13 +45,13 @@ void tca6424_init(void) static void write_port(uint8_t p, uint8_t d) { - i2c_writeReg(TCA6424_ADDR, p, &d, 1, TIMEOUT); + i2c_write_register(TCA6424_ADDR, p, &d, 1, TIMEOUT); } static uint8_t read_port(uint8_t port) { uint8_t data = 0; - i2c_readReg(TCA6424_ADDR, port, &data, 1, TIMEOUT); + i2c_read_register(TCA6424_ADDR, port, &data, 1, TIMEOUT); return data; } diff --git a/keyboards/rate/pistachio_pro/lib/bme280.c b/keyboards/rate/pistachio_pro/lib/bme280.c index f3dc231dc5..ac7a4873ba 100644 --- a/keyboards/rate/pistachio_pro/lib/bme280.c +++ b/keyboards/rate/pistachio_pro/lib/bme280.c @@ -102,9 +102,9 @@ static int32_t t_fine; static void readTrim(void) { uint8_t data[32]; - i2c_readReg(BME280_ADDRESS, BME280_REG_CALIB00, &data[0], 24, I2C_BME280_TIMEOUT); - i2c_readReg(BME280_ADDRESS, BME280_REG_CALIB25, &data[25], 1, I2C_BME280_TIMEOUT); - i2c_readReg(BME280_ADDRESS, BME280_REG_CALIB26, &data[25], 7, I2C_BME280_TIMEOUT); + i2c_read_register(BME280_ADDRESS, BME280_REG_CALIB00, &data[0], 24, I2C_BME280_TIMEOUT); + i2c_read_register(BME280_ADDRESS, BME280_REG_CALIB25, &data[25], 1, I2C_BME280_TIMEOUT); + i2c_read_register(BME280_ADDRESS, BME280_REG_CALIB26, &data[25], 7, I2C_BME280_TIMEOUT); dig_T1 = (data[1] << 8) | data[0]; dig_T2 = (data[3] << 8) | data[2]; @@ -131,7 +131,7 @@ static void readTrim(void) { static void readData(void) { uint8_t data[8]; - i2c_readReg(BME280_ADDRESS, 0xF7, &data[0], 8, I2C_BME280_TIMEOUT); + i2c_read_register(BME280_ADDRESS, 0xF7, &data[0], 8, I2C_BME280_TIMEOUT); pres_raw = data[0]; pres_raw = (pres_raw<<8) | data[1]; @@ -210,9 +210,9 @@ void bme280_init(void) { config_reg = BME280_CONFIG_VAL; i2c_init(); - i2c_writeReg(BME280_ADDRESS, BME280_REG_CTRL_HUM, &ctrl_hum_reg, 1, I2C_BME280_TIMEOUT); - i2c_writeReg(BME280_ADDRESS, BME280_REG_CTRL_MEAS, &ctrl_meas_reg, 1, I2C_BME280_TIMEOUT); - i2c_writeReg(BME280_ADDRESS, BME280_REG_CONFIG, &config_reg, 1, I2C_BME280_TIMEOUT); + i2c_write_register(BME280_ADDRESS, BME280_REG_CTRL_HUM, &ctrl_hum_reg, 1, I2C_BME280_TIMEOUT); + i2c_write_register(BME280_ADDRESS, BME280_REG_CTRL_MEAS, &ctrl_meas_reg, 1, I2C_BME280_TIMEOUT); + i2c_write_register(BME280_ADDRESS, BME280_REG_CONFIG, &config_reg, 1, I2C_BME280_TIMEOUT); readTrim(); return; diff --git a/keyboards/rgbkb/common/touch_encoder.c b/keyboards/rgbkb/common/touch_encoder.c index 5f0e4f0cca..18037b8fb5 100644 --- a/keyboards/rgbkb/common/touch_encoder.c +++ b/keyboards/rgbkb/common/touch_encoder.c @@ -125,7 +125,7 @@ bool touch_slave_init = false; slave_touch_status_t touch_slave_state = { 0, 0 }; static bool write_register8(uint8_t address, uint8_t data) { - i2c_status_t status = i2c_writeReg((I2C_ADDRESS << 1), address, &data, sizeof(data), I2C_TIMEOUT); + i2c_status_t status = i2c_write_register((I2C_ADDRESS << 1), address, &data, sizeof(data), I2C_TIMEOUT); if (status != I2C_STATUS_SUCCESS) { xprintf("write_register8 %d failed %d\n", address, status); } @@ -133,7 +133,7 @@ static bool write_register8(uint8_t address, uint8_t data) { } static bool read_register(uint8_t address, uint8_t* data, uint16_t length) { - i2c_status_t status = i2c_readReg((I2C_ADDRESS << 1), address, data, length, I2C_TIMEOUT); + i2c_status_t status = i2c_read_register((I2C_ADDRESS << 1), address, data, length, I2C_TIMEOUT); if (status != I2C_STATUS_SUCCESS) { xprintf("read_register %d failed %d\n", address, status); return false; diff --git a/keyboards/sx60/matrix.c b/keyboards/sx60/matrix.c index 66bc494be6..22f37db539 100644 --- a/keyboards/sx60/matrix.c +++ b/keyboards/sx60/matrix.c @@ -214,7 +214,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) return 0; } else { uint8_t data = 0; - mcp23018_status = i2c_readReg(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); + mcp23018_status = i2c_read_register(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); if (!mcp23018_status) { current_matrix[current_row] |= (~((uint16_t)data) << 8); } @@ -245,7 +245,7 @@ static void select_row(uint8_t row) set active row output : 1 set other rows hi-Z : 1 */ uint8_t port = 0xFF & ~(1<addr << 1, 0x1D, cc, 1, I2C_TIMEOUT); } +i2c_status_t ptn5110_get_cc_status(struct PTN5110* self, uint8_t* cc) { return i2c_read_register(self->addr << 1, 0x1D, cc, 1, I2C_TIMEOUT); } // Set PTN5110 SSMUX orientation. // Returns zero on success or a negative number on error. @@ -362,7 +362,7 @@ i2c_status_t ptn5110_set_ssmux(struct PTN5110* self, bool orientation) { return // Write PTN5110 COMMAND. // Returns zero on success or negative number on error. -i2c_status_t ptn5110_command(struct PTN5110* self, uint8_t command) { return i2c_writeReg(self->addr << 1, 0x23, &command, 1, I2C_TIMEOUT); } +i2c_status_t ptn5110_command(struct PTN5110* self, uint8_t command) { return i2c_write_register(self->addr << 1, 0x23, &command, 1, I2C_TIMEOUT); } // Set orientation of PTN5110 operating as a sink, call this once. // Returns zero on success or a negative number on error. diff --git a/keyboards/torn/mcp23018.c b/keyboards/torn/mcp23018.c index 12c4f9bc7f..ba26e67ba9 100644 --- a/keyboards/torn/mcp23018.c +++ b/keyboards/torn/mcp23018.c @@ -48,7 +48,7 @@ i2c_status_t mcp23018_writeReg(uint8_t regaddr, const uint8_t* data, uint16_t le return mcp23018_status; } - mcp23018_status = i2c_writeReg((MCP23018_ADDR << 1), regaddr, data, length, MCP23018_TIMEOUT); + mcp23018_status = i2c_write_register((MCP23018_ADDR << 1), regaddr, data, length, MCP23018_TIMEOUT); return mcp23018_status; } @@ -57,6 +57,6 @@ i2c_status_t mcp23018_readReg(uint8_t regaddr, uint8_t* data, uint16_t length) { return mcp23018_status; } - mcp23018_status = i2c_readReg((MCP23018_ADDR << 1), regaddr, data, length, MCP23018_TIMEOUT); + mcp23018_status = i2c_read_register((MCP23018_ADDR << 1), regaddr, data, length, MCP23018_TIMEOUT); return mcp23018_status; } diff --git a/keyboards/touchpad/matrix.c b/keyboards/touchpad/matrix.c index 6bffb826bd..87944cb7cc 100644 --- a/keyboards/touchpad/matrix.c +++ b/keyboards/touchpad/matrix.c @@ -38,7 +38,7 @@ volatile uint8_t LEDs[6][6] = {{0}};//Stores current LED values //Read data from the cap touch IC uint8_t readDataFromTS(uint8_t reg) { uint8_t rx[1] = { 0 }; - if (i2c_readReg(0x1C << 1, reg, rx, 1, 100) == 0) { + if (i2c_read_register(0x1C << 1, reg, rx, 1, 100) == 0) { return rx[0]; } return 0; diff --git a/keyboards/yiancardesigns/barleycorn/matrix.c b/keyboards/yiancardesigns/barleycorn/matrix.c index 99366d6098..9ef2926566 100644 --- a/keyboards/yiancardesigns/barleycorn/matrix.c +++ b/keyboards/yiancardesigns/barleycorn/matrix.c @@ -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++) { diff --git a/keyboards/yiancardesigns/gingham/gingham.c b/keyboards/yiancardesigns/gingham/gingham.c index 496ae35705..f34d4d7cfd 100644 --- a/keyboards/yiancardesigns/gingham/gingham.c +++ b/keyboards/yiancardesigns/gingham/gingham.c @@ -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; } diff --git a/keyboards/yiancardesigns/gingham/matrix.c b/keyboards/yiancardesigns/gingham/matrix.c index 47c8830565..d17518b494 100644 --- a/keyboards/yiancardesigns/gingham/matrix.c +++ b/keyboards/yiancardesigns/gingham/matrix.c @@ -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 : diff --git a/keyboards/yiancardesigns/seigaiha/matrix.c b/keyboards/yiancardesigns/seigaiha/matrix.c index 212b8015f0..55ee239db4 100644 --- a/keyboards/yiancardesigns/seigaiha/matrix.c +++ b/keyboards/yiancardesigns/seigaiha/matrix.c @@ -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++) { diff --git a/keyboards/yiancardesigns/seigaiha/seigaiha.c b/keyboards/yiancardesigns/seigaiha/seigaiha.c index 7a39637b91..03d420f053 100644 --- a/keyboards/yiancardesigns/seigaiha/seigaiha.c +++ b/keyboards/yiancardesigns/seigaiha/seigaiha.c @@ -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) { diff --git a/keyboards/zsa/moonlander/matrix.c b/keyboards/zsa/moonlander/matrix.c index 36017fcd12..aa97d0721f 100644 --- a/keyboards/zsa/moonlander/matrix.c +++ b/keyboards/zsa/moonlander/matrix.c @@ -144,7 +144,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { // read col mcp23018_tx[0] = 0x13; // GPIOB - if (MSG_OK != i2c_readReg(MCP23018_DEFAULT_ADDRESS << 1, mcp23018_tx[0], &mcp23018_rx[0], 1, MOONLANDER_I2C_TIMEOUT)) { + if (MSG_OK != i2c_read_register(MCP23018_DEFAULT_ADDRESS << 1, mcp23018_tx[0], &mcp23018_rx[0], 1, MOONLANDER_I2C_TIMEOUT)) { dprintf("error vert\n"); mcp23018_initd = false; } -- cgit v1.2.3