Skip to main content

i2c_master_device_change_address

Function i2c_master_device_change_address 

Source
pub unsafe extern "C" fn i2c_master_device_change_address(
    i2c_dev: i2c_master_dev_handle_t,
    new_device_address: u16,
    timeout_ms: c_int,
) -> esp_err_t
Expand description

@brief Change the I2C device address at runtime.

This function updates the device address of an existing I2C device handle. It is useful for devices that support dynamic address assignment or when switching communication to a device with a different address on the same bus.

@param[in] i2c_dev I2C device handle. @param[in] new_device_address The new device address. @param[in] timeout_ms Timeout for the address change operation, in milliseconds.

@return - ESP_OK: Address successfully changed. - ESP_ERR_INVALID_ARG: Invalid arguments (e.g., NULL handle or invalid address). - ESP_ERR_TIMEOUT: Operation timed out.

@note - This function does not send commands to the I2C device. It only updates the address used in subsequent transactions through the I2C handle. - Ensure that the new address is valid and does not conflict with other devices on the bus.