Probe I2C address, if address is correct and ACK is received, this function will return ESP_OK. @attention Pull-ups must be connected to the SCL and SDA pins when this function is called. If you get `ESP_ERR_TIMEOUT while `xfer_timeout_ms` was parsed correctly, you should check the pull-up resistors. If you do not have proper resistors nearby. `flags.enable_internal_pullup` is also acceptable.
I2C master device handle that created by `i2c_master_bus_add_device`.
address
I2C device address that you want to probe.
xfer_timeout_ms
Wait timeout, in ms. Note: -1 means wait forever (Not recommended in this function).
Return value
- ESP_OK: I2C device probe successfully - ESP_ERR_NOT_FOUND: I2C probe failed, doesn't find the device with specific address you gave. - ESP_ERR_TIMEOUT: Operation timeout(larger than xfer_timeout_ms) because the bus is busy or hardware crash.
Notes
The principle of this function is to sent device address with a write command. If the device on your I2C bus, there would be an ACK signal and function returns `ESP_OK`. If the device is not on your I2C bus, there would be a NACK signal and function returns `ESP_ERR_NOT_FOUND`. `ESP_ERR_TIMEOUT` is not an expected failure, which indicated that the i2c probe not works properly, usually caused by pull-up resistors not be connected properly. Suggestion check data on SDA/SCL line to see whether there is ACK/NACK signal is on line when i2c probe function fails. There are lots of I2C devices all over the world, we assume that not all I2C device support the behavior like `device_address+nack/ack`. So, if the on line data is strange and no ack/nack got respond. Please check the device datasheet.
This function is used to send I2C read command, which is divided in three parts. -1. If read buffer is smaller than hardware fifo, it can be sent out in one single time, so the hardware command(step) is simply like start(1)->read_ack(2)->read_nack(3)->end(4) -2. If read buffer is larger than hardware fifo, it cannot be sent out in one time, so it needs to be separated in to different transactions by interrupt. In this time, the hardware command(step) simply looks like start(1)->read_part(2)--interrupt--...--read(1)->end(2). -3. If only one byte is waiting to be read. only send nack command. like start(1)->read_nack(2)->end(3)
This function is used to send I2C start or stop command, which is divided in two parts. If start command is accepted, a write address command must be followed. So prepared one address data here. Send with write or read command.
This function is used to send I2C write command, which is divided in two parts. -1. If write buffer is smaller than hardware fifo, it can be sent out in one single time, so the hardware command(step) is simply like start(1)->write(2)->end(3) -2. If write buffer is larger than hardware fifo, it cannot be sent out in one time, so it needs to be separated in to different transactions by interrupt. In this time, the hardware command(step) simply looks like start(1)->write_part(2)--interrupt--...--write(1)->end(2).
Retrieves the I2C master bus handle for a specified I2C port number. This function retrieves the I2C master bus handle for the given I2C port number. Please make sure the handle has already been initialized, and this function would simply returns the existing handle. Note that the returned handle still can't be used concurrently