diff --git a/docs/i2c_driver.md b/docs/i2c_driver.md index faff0a1d7b..2457e8e7b9 100644 --- a/docs/i2c_driver.md +++ b/docs/i2c_driver.md @@ -197,11 +197,11 @@ Receive multiple bytes from the selected I2C device. --- -### `i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-writereg +### `i2c_status_t i2c_write_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-write-register Writes to a register with an 8-bit address on the I2C device. -#### Arguments :id=api-i2c-writereg-arguments +#### Arguments :id=api-i2c-write-register-arguments - `uint8_t devaddr` The 7-bit I2C address of the device. @@ -214,17 +214,17 @@ Writes to a register with an 8-bit address on the I2C device. - `uint16_t timeout` The time in milliseconds to wait for a response from the target device. -#### Return Value :id=api-i2c-writereg-return +#### Return Value :id=api-i2c-write-register-return `I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`. --- -### `i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-writereg16 +### `i2c_status_t i2c_write_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-write-register16 Writes to a register with a 16-bit address (big endian) on the I2C device. -#### Arguments :id=api-i2c-writereg16-arguments +#### Arguments :id=api-i2c-write-register16-arguments - `uint8_t devaddr` The 7-bit I2C address of the device. @@ -237,17 +237,17 @@ Writes to a register with a 16-bit address (big endian) on the I2C device. - `uint16_t timeout` The time in milliseconds to wait for a response from the target device. -#### Return Value :id=api-i2c-writereg16-return +#### Return Value :id=api-i2c-write-register16-return `I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`. --- -### `i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-readreg +### `i2c_status_t i2c_read_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-read-register Reads from a register with an 8-bit address on the I2C device. -#### Arguments :id=api-i2c-readreg-arguments +#### Arguments :id=api-i2c-read-register-arguments - `uint8_t devaddr` The 7-bit I2C address of the device. @@ -258,17 +258,17 @@ Reads from a register with an 8-bit address on the I2C device. - `uint16_t timeout` The time in milliseconds to wait for a response from the target device. -#### Return Value :id=api-i2c-readreg-return +#### Return Value :id=api-i2c-read-register-return `I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`. --- -### `i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` +### `i2c_status_t i2c_read_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)` :id=api-i2c-read-register16 Reads from a register with a 16-bit address (big endian) on the I2C device. -#### Arguments :id=api-i2c-readreg16-arguments +#### Arguments :id=api-i2c-read-register16-arguments - `uint8_t devaddr` The 7-bit I2C address of the device. @@ -279,7 +279,7 @@ Reads from a register with a 16-bit address (big endian) on the I2C device. - `uint16_t timeout` The time in milliseconds to wait for a response from the target device. -#### Return Value :id=api-i2c-readreg16-return +#### Return Value :id=api-i2c-read-register16-return `I2C_STATUS_TIMEOUT` if the timeout period elapses, `I2C_STATUS_ERROR` if some other error occurs, otherwise `I2C_STATUS_SUCCESS`. diff --git a/drivers/gpio/mcp23018.c b/drivers/gpio/mcp23018.c index 41cbfe087e..3eca4f9d34 100644 --- a/drivers/gpio/mcp23018.c +++ b/drivers/gpio/mcp23018.c @@ -33,13 +33,13 @@ bool mcp23018_set_config(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf) uint8_t cmdDirection = port ? CMD_IODIRB : CMD_IODIRA; uint8_t cmdPullup = port ? CMD_GPPUB : CMD_GPPUA; - i2c_status_t ret = i2c_writeReg(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { dprintf("mcp23018_set_config::directionFAILED::%u\n", ret); return false; } - ret = i2c_writeReg(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT); + ret = i2c_write_register(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { dprintf("mcp23018_set_config::pullupFAILED::%u\n", ret); return false; @@ -52,7 +52,7 @@ bool mcp23018_set_output(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf) uint8_t addr = SLAVE_TO_ADDR(slave_addr); uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA; - i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { dprintf("mcp23018_set_output::FAILED::%u\n", ret); return false; @@ -65,7 +65,7 @@ bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) { uint8_t addr = SLAVE_TO_ADDR(slave_addr); uint8_t conf[2] = {confA, confB}; - i2c_status_t ret = i2c_writeReg(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { dprintf("mcp23018_set_output::FAILED::%u\n", ret); return false; @@ -78,7 +78,7 @@ bool mcp23018_readPins(uint8_t slave_addr, mcp23018_port_t port, uint8_t* out) { uint8_t addr = SLAVE_TO_ADDR(slave_addr); uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA; - i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT); + i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { dprintf("mcp23018_readPins::FAILED::%u\n", ret); return false; @@ -97,7 +97,7 @@ bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* out) { data16 data = {.u16 = 0}; - i2c_status_t ret = i2c_readReg(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT); + i2c_status_t ret = i2c_read_register(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { dprintf("mcp23018_readPins::FAILED::%u\n", ret); return false; diff --git a/drivers/gpio/pca9505.c b/drivers/gpio/pca9505.c index 5803746c96..4a11724ecf 100644 --- a/drivers/gpio/pca9505.c +++ b/drivers/gpio/pca9505.c @@ -66,7 +66,7 @@ bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) { break; } - i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9505_set_config::FAILED\n"); return false; @@ -96,7 +96,7 @@ bool pca9505_set_polarity(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) break; } - i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9505_set_polarity::FAILED\n"); return false; @@ -126,7 +126,7 @@ bool pca9505_set_output(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) { break; } - i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9505_set_output::FAILED\n"); return false; @@ -156,7 +156,7 @@ bool pca9505_readPins(uint8_t slave_addr, pca9505_port_t port, uint8_t* out) { break; } - i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT); + i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9505_readPins::FAILED\n"); return false; diff --git a/drivers/gpio/pca9555.c b/drivers/gpio/pca9555.c index adcd040083..23727d21b3 100644 --- a/drivers/gpio/pca9555.c +++ b/drivers/gpio/pca9555.c @@ -37,7 +37,7 @@ bool pca9555_set_config(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) { uint8_t addr = SLAVE_TO_ADDR(slave_addr); uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0; - i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9555_set_config::FAILED\n"); return false; @@ -50,7 +50,7 @@ bool pca9555_set_output(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) { uint8_t addr = SLAVE_TO_ADDR(slave_addr); uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0; - i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9555_set_output::FAILED\n"); return false; @@ -63,7 +63,7 @@ bool pca9555_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) { uint8_t addr = SLAVE_TO_ADDR(slave_addr); uint8_t conf[2] = {confA, confB}; - i2c_status_t ret = i2c_writeReg(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT); + i2c_status_t ret = i2c_write_register(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { dprintf("pca9555_set_output::FAILED::%u\n", ret); return false; @@ -76,7 +76,7 @@ bool pca9555_readPins(uint8_t slave_addr, pca9555_port_t port, uint8_t* out) { uint8_t addr = SLAVE_TO_ADDR(slave_addr); uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0; - i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT); + i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9555_readPins::FAILED\n"); return false; @@ -95,7 +95,7 @@ bool pca9555_readPins_all(uint8_t slave_addr, uint16_t* out) { data16 data = {.u16 = 0}; - i2c_status_t ret = i2c_readReg(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT); + i2c_status_t ret = i2c_read_register(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT); if (ret != I2C_STATUS_SUCCESS) { print("pca9555_readPins_all::FAILED\n"); return false; diff --git a/drivers/haptic/drv2605l.c b/drivers/haptic/drv2605l.c index 1ad2ad385f..a5adde5366 100644 --- a/drivers/haptic/drv2605l.c +++ b/drivers/haptic/drv2605l.c @@ -29,7 +29,7 @@ void drv2605l_write(uint8_t reg_addr, uint8_t data) { } uint8_t drv2605l_read(uint8_t reg_addr) { - i2c_readReg(DRV2605L_I2C_ADDRESS << 1, reg_addr, &drv2605l_read_buffer, 1, 100); + i2c_read_register(DRV2605L_I2C_ADDRESS << 1, reg_addr, &drv2605l_read_buffer, 1, 100); return drv2605l_read_buffer; } diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 4a2121cd7c..c674675d11 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c @@ -253,7 +253,7 @@ __attribute__((weak)) bool oled_send_data(const uint8_t *data, uint16_t size) { spi_stop(); return true; #elif defined(OLED_TRANSPORT_I2C) - i2c_status_t status = i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), I2C_DATA, data, size, OLED_I2C_TIMEOUT); + i2c_status_t status = i2c_write_register((OLED_DISPLAY_ADDRESS << 1), I2C_DATA, data, size, OLED_I2C_TIMEOUT); return (status == I2C_STATUS_SUCCESS); #endif } diff --git a/drivers/sensors/azoteq_iqs5xx.c b/drivers/sensors/azoteq_iqs5xx.c index 521f558b5f..1d688ddf25 100644 --- a/drivers/sensors/azoteq_iqs5xx.c +++ b/drivers/sensors/azoteq_iqs5xx.c @@ -107,18 +107,18 @@ static struct { i2c_status_t azoteq_iqs5xx_wake(void) { uint8_t data = 0; - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)&data, sizeof(data), 1); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)&data, sizeof(data), 1); i2c_stop(); wait_us(150); return status; } i2c_status_t azoteq_iqs5xx_end_session(void) { const uint8_t END_BYTE = 1; // any data - return i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_END_COMMS, &END_BYTE, 1, AZOTEQ_IQS5XX_TIMEOUT_MS); + return i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_END_COMMS, &END_BYTE, 1, AZOTEQ_IQS5XX_TIMEOUT_MS); } i2c_status_t azoteq_iqs5xx_get_base_data(azoteq_iqs5xx_base_data_t *base_data) { - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)base_data, 10, AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)base_data, 10, AZOTEQ_IQS5XX_TIMEOUT_MS); if (status == I2C_STATUS_SUCCESS) { azoteq_iqs5xx_end_session(); } @@ -131,7 +131,7 @@ i2c_status_t azoteq_iqs5xx_get_report_rate(azoteq_iqs5xx_report_rate_t *report_r return I2C_STATUS_ERROR; } uint16_t selected_reg = AZOTEQ_IQS5XX_REG_REPORT_RATE_ACTIVE + (2 * mode); - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS); if (end_session) { azoteq_iqs5xx_end_session(); } @@ -147,7 +147,7 @@ i2c_status_t azoteq_iqs5xx_set_report_rate(uint16_t report_rate_ms, azoteq_iqs5x azoteq_iqs5xx_report_rate_t report_rate = {0}; report_rate.h = (uint8_t)((report_rate_ms >> 8) & 0xFF); report_rate.l = (uint8_t)(report_rate_ms & 0xFF); - i2c_status_t status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)&report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)&report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS); if (end_session) { azoteq_iqs5xx_end_session(); } @@ -156,10 +156,10 @@ i2c_status_t azoteq_iqs5xx_set_report_rate(uint16_t report_rate_ms, azoteq_iqs5x i2c_status_t azoteq_iqs5xx_set_reati(bool enabled, bool end_session) { azoteq_iqs5xx_system_config_0_t config = {0}; - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); if (status == I2C_STATUS_SUCCESS) { config.reati = enabled; - status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); } if (end_session) { azoteq_iqs5xx_end_session(); @@ -169,7 +169,7 @@ i2c_status_t azoteq_iqs5xx_set_reati(bool enabled, bool end_session) { i2c_status_t azoteq_iqs5xx_set_event_mode(bool enabled, bool end_session) { azoteq_iqs5xx_system_config_1_t config = {0}; - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); if (status == I2C_STATUS_SUCCESS) { config.event_mode = enabled; config.touch_event = true; @@ -179,7 +179,7 @@ i2c_status_t azoteq_iqs5xx_set_event_mode(bool enabled, bool end_session) { config.reati_event = false; config.alp_prox_event = false; config.gesture_event = true; - status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); } if (end_session) { azoteq_iqs5xx_end_session(); @@ -189,7 +189,7 @@ i2c_status_t azoteq_iqs5xx_set_event_mode(bool enabled, bool end_session) { i2c_status_t azoteq_iqs5xx_set_gesture_config(bool end_session) { azoteq_iqs5xx_gesture_config_t config = {0}; - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS); pd_dprintf("azo scroll: %d\n", config.multi_finger_gestures.scroll); if (status == I2C_STATUS_SUCCESS) { config.single_finger_gestures.single_tap = AZOTEQ_IQS5XX_TAP_ENABLE; @@ -211,7 +211,7 @@ i2c_status_t azoteq_iqs5xx_set_gesture_config(bool end_session) { config.scroll_initial_distance = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(AZOTEQ_IQS5XX_SCROLL_INITIAL_DISTANCE); config.zoom_initial_distance = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(AZOTEQ_IQS5XX_ZOOM_INITIAL_DISTANCE); config.zoom_consecutive_distance = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(AZOTEQ_IQS5XX_ZOOM_CONSECUTIVE_DISTANCE); - status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS); } if (end_session) { azoteq_iqs5xx_end_session(); @@ -221,7 +221,7 @@ i2c_status_t azoteq_iqs5xx_set_gesture_config(bool end_session) { i2c_status_t azoteq_iqs5xx_set_xy_config(bool flip_x, bool flip_y, bool switch_xy, bool palm_reject, bool end_session) { azoteq_iqs5xx_xy_config_0_t config = {0}; - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); if (status == I2C_STATUS_SUCCESS) { if (flip_x) { config.flip_x = !config.flip_x; @@ -233,7 +233,7 @@ i2c_status_t azoteq_iqs5xx_set_xy_config(bool flip_x, bool flip_y, bool switch_x config.switch_xy_axis = !config.switch_xy_axis; } config.palm_reject = palm_reject; - status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS); } if (end_session) { azoteq_iqs5xx_end_session(); @@ -243,11 +243,11 @@ i2c_status_t azoteq_iqs5xx_set_xy_config(bool flip_x, bool flip_y, bool switch_x i2c_status_t azoteq_iqs5xx_reset_suspend(bool reset, bool suspend, bool end_session) { azoteq_iqs5xx_system_control_1_t config = {0}; - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); if (status == I2C_STATUS_SUCCESS) { config.reset = reset; config.suspend = suspend; - status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS); } if (end_session) { azoteq_iqs5xx_end_session(); @@ -260,14 +260,14 @@ void azoteq_iqs5xx_set_cpi(uint16_t cpi) { azoteq_iqs5xx_resolution_t resolution = {0}; resolution.x_resolution = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(MIN(azoteq_iqs5xx_device_resolution_t.resolution_x, AZOTEQ_IQS5XX_INCH_TO_RESOLUTION_X(cpi))); resolution.y_resolution = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(MIN(azoteq_iqs5xx_device_resolution_t.resolution_y, AZOTEQ_IQS5XX_INCH_TO_RESOLUTION_Y(cpi))); - i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS); } } uint16_t azoteq_iqs5xx_get_cpi(void) { if (azoteq_iqs5xx_product_number != AZOTEQ_IQS5XX_UNKNOWN) { azoteq_iqs5xx_resolution_t resolution = {0}; - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS); if (status == I2C_STATUS_SUCCESS) { return AZOTEQ_IQS5XX_RESOLUTION_X_TO_INCH(AZOTEQ_IQS5XX_SWAP_H_L_BYTES(resolution.x_resolution)); } @@ -276,7 +276,7 @@ uint16_t azoteq_iqs5xx_get_cpi(void) { } uint16_t azoteq_iqs5xx_get_product(void) { - i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PRODUCT_NUMBER, (uint8_t *)&azoteq_iqs5xx_product_number, sizeof(uint16_t), AZOTEQ_IQS5XX_TIMEOUT_MS); + i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PRODUCT_NUMBER, (uint8_t *)&azoteq_iqs5xx_product_number, sizeof(uint16_t), AZOTEQ_IQS5XX_TIMEOUT_MS); if (status == I2C_STATUS_SUCCESS) { azoteq_iqs5xx_product_number = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(azoteq_iqs5xx_product_number); } diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c index 3c11e5f079..c9b9bece5f 100644 --- a/drivers/sensors/cirque_pinnacle_i2c.c +++ b/drivers/sensors/cirque_pinnacle_i2c.c @@ -14,9 +14,9 @@ extern bool touchpad_init; void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { uint8_t cmdByte = READ_MASK | address; // Form the READ command byte if (touchpad_init) { - i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); - if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { - pd_dprintf("error cirque_pinnacle i2c_readReg\n"); + i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); + if (i2c_read_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { + pd_dprintf("error cirque_pinnacle i2c_read_register\n"); touchpad_init = false; } i2c_stop(); @@ -28,8 +28,8 @@ void RAP_Write(uint8_t address, uint8_t data) { uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte if (touchpad_init) { - if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { - pd_dprintf("error cirque_pinnacle i2c_writeReg\n"); + if (i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { + pd_dprintf("error cirque_pinnacle i2c_write_register\n"); touchpad_init = false; } i2c_stop(); diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c index 326e59744f..9c6d26d73d 100644 --- a/drivers/sensors/pimoroni_trackball.c +++ b/drivers/sensors/pimoroni_trackball.c @@ -56,13 +56,13 @@ void pimoroni_trackball_set_cpi(uint16_t cpi) { void pimoroni_trackball_set_rgbw(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { uint8_t data[4] = {r, g, b, w}; - __attribute__((unused)) i2c_status_t status = i2c_writeReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, data, sizeof(data), PIMORONI_TRACKBALL_TIMEOUT); + __attribute__((unused)) i2c_status_t status = i2c_write_register(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, data, sizeof(data), PIMORONI_TRACKBALL_TIMEOUT); pd_dprintf("Trackball RGBW i2c_status_t: %d\n", status); } i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data) { - i2c_status_t status = i2c_readReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT); + i2c_status_t status = i2c_read_register(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT); #ifdef POINTING_DEVICE_DEBUG static uint16_t d_timer; 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; } diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c index 58939f3e00..0183103707 100644 --- a/platforms/avr/drivers/i2c_master.c +++ b/platforms/avr/drivers/i2c_master.c @@ -189,7 +189,7 @@ i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16 return (status < 0) ? status : I2C_STATUS_SUCCESS; } -i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_write_register(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { i2c_status_t status = i2c_start(devaddr | 0x00, timeout); if (status >= 0) { status = i2c_write(regaddr, timeout); @@ -204,7 +204,7 @@ i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, return status; } -i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_write_register16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { i2c_status_t status = i2c_start(devaddr | 0x00, timeout); if (status >= 0) { status = i2c_write(regaddr >> 8, timeout); @@ -223,7 +223,7 @@ i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* da return status; } -i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_read_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { i2c_status_t status = i2c_start(devaddr, timeout); if (status < 0) { goto error; @@ -256,7 +256,7 @@ error: return (status < 0) ? status : I2C_STATUS_SUCCESS; } -i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_read_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { i2c_status_t status = i2c_start(devaddr, timeout); if (status < 0) { goto error; diff --git a/platforms/avr/drivers/i2c_master.h b/platforms/avr/drivers/i2c_master.h index 04ef126c80..18587c4a57 100644 --- a/platforms/avr/drivers/i2c_master.h +++ b/platforms/avr/drivers/i2c_master.h @@ -21,6 +21,13 @@ #include +// ### DEPRECATED - DO NOT USE ### +#define i2c_writeReg(devaddr, regaddr, data, length, timeout) i2c_write_register(devaddr, regaddr, data, length, timeout) +#define i2c_writeReg16(devaddr, regaddr, data, length, timeout) i2c_write_register16(devaddr, regaddr, data, length, timeout) +#define i2c_readReg(devaddr, regaddr, data, length, timeout) i2c_read_register(devaddr, regaddr, data, length, timeout) +#define i2c_readReg16(devaddr, regaddr, data, length, timeout) i2c_read_register16(devaddr, regaddr, data, length, timeout) +// ############################### + #define I2C_READ 0x01 #define I2C_WRITE 0x00 @@ -40,8 +47,8 @@ int16_t i2c_read_ack(uint16_t timeout); int16_t i2c_read_nack(uint16_t timeout); i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout); i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_write_register(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_write_register16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_read_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_read_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); void i2c_stop(void); diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c index 7c49f9d005..5ee2738e6d 100644 --- a/platforms/chibios/drivers/i2c_master.c +++ b/platforms/chibios/drivers/i2c_master.c @@ -170,7 +170,7 @@ i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16 return i2c_epilogue(status); } -i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_write_register(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { i2c_address = devaddr; i2cStart(&I2C_DRIVER, &i2cconfig); @@ -184,7 +184,7 @@ i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, return i2c_epilogue(status); } -i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_write_register16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) { i2c_address = devaddr; i2cStart(&I2C_DRIVER, &i2cconfig); @@ -199,14 +199,14 @@ i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* da return i2c_epilogue(status); } -i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_read_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { i2c_address = devaddr; i2cStart(&I2C_DRIVER, &i2cconfig); msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), ®addr, 1, data, length, TIME_MS2I(timeout)); return i2c_epilogue(status); } -i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { +i2c_status_t i2c_read_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) { i2c_address = devaddr; i2cStart(&I2C_DRIVER, &i2cconfig); uint8_t register_packet[2] = {regaddr >> 8, regaddr & 0xFF}; diff --git a/platforms/chibios/drivers/i2c_master.h b/platforms/chibios/drivers/i2c_master.h index deee7ecc08..5f16367831 100644 --- a/platforms/chibios/drivers/i2c_master.h +++ b/platforms/chibios/drivers/i2c_master.h @@ -26,6 +26,13 @@ #include +// ### DEPRECATED - DO NOT USE ### +#define i2c_writeReg(devaddr, regaddr, data, length, timeout) i2c_write_register(devaddr, regaddr, data, length, timeout) +#define i2c_writeReg16(devaddr, regaddr, data, length, timeout) i2c_write_register16(devaddr, regaddr, data, length, timeout) +#define i2c_readReg(devaddr, regaddr, data, length, timeout) i2c_read_register(devaddr, regaddr, data, length, timeout) +#define i2c_readReg16(devaddr, regaddr, data, length, timeout) i2c_read_register16(devaddr, regaddr, data, length, timeout) +// ############################### + typedef int16_t i2c_status_t; #define I2C_STATUS_SUCCESS (0) @@ -36,8 +43,8 @@ void i2c_init(void); i2c_status_t i2c_start(uint8_t address); i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout); i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_writeReg16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); -i2c_status_t i2c_readReg16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_write_register(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_write_register16(uint8_t devaddr, uint16_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_read_register(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); +i2c_status_t i2c_read_register16(uint8_t devaddr, uint16_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); void i2c_stop(void); diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index aade3c98d7..83edc34859 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c @@ -56,7 +56,7 @@ i2c_status_t transport_trigger_callback(int8_t id) { // Kick off the "callback executor", now that data has been written to the slave split_shmem->transaction_id = id; split_transaction_desc_t *trans = &split_transaction_table[I2C_EXECUTE_CALLBACK]; - return i2c_writeReg(SLAVE_I2C_ADDRESS, trans->initiator2target_offset, split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size, SLAVE_I2C_TIMEOUT); + return i2c_write_register(SLAVE_I2C_ADDRESS, trans->initiator2target_offset, split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size, SLAVE_I2C_TIMEOUT); } bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length) { @@ -65,7 +65,7 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, if (initiator2target_length > 0) { size_t len = trans->initiator2target_buffer_size < initiator2target_length ? trans->initiator2target_buffer_size : initiator2target_length; memcpy(split_trans_initiator2target_buffer(trans), initiator2target_buf, len); - if ((status = i2c_writeReg(SLAVE_I2C_ADDRESS, trans->initiator2target_offset, split_trans_initiator2target_buffer(trans), len, SLAVE_I2C_TIMEOUT)) < 0) { + if ((status = i2c_write_register(SLAVE_I2C_ADDRESS, trans->initiator2target_offset, split_trans_initiator2target_buffer(trans), len, SLAVE_I2C_TIMEOUT)) < 0) { return false; } } @@ -77,7 +77,7 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, if (target2initiator_length > 0) { size_t len = trans->target2initiator_buffer_size < target2initiator_length ? trans->target2initiator_buffer_size : target2initiator_length; - if ((status = i2c_readReg(SLAVE_I2C_ADDRESS, trans->target2initiator_offset, split_trans_target2initiator_buffer(trans), len, SLAVE_I2C_TIMEOUT)) < 0) { + if ((status = i2c_read_register(SLAVE_I2C_ADDRESS, trans->target2initiator_offset, split_trans_target2initiator_buffer(trans), len, SLAVE_I2C_TIMEOUT)) < 0) { return false; } memcpy(target2initiator_buf, split_trans_target2initiator_buffer(trans), len);