- ESP_OK: Create I2C master device successfully. - ESP_ERR_INVALID_ARG: I2C bus initialization failed because of invalid argument. - ESP_ERR_NO_MEM: Create I2C bus failed because of out of memory.
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.
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.
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