mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-15 06:26:49 +00:00
feat(i2c_master): Add an api for retrieveing handle via port
This commit is contained in:
@@ -345,3 +345,19 @@ TEST_CASE("I2C master transaction receive check nack return value", "[i2c]")
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, i2c_master_receive(dev_handle, data_rd, DATA_LENGTH, -1));
|
||||
_test_i2c_del_bus_device(bus_handle, dev_handle);
|
||||
}
|
||||
|
||||
TEST_CASE("Test get handle with known port", "[i2c]")
|
||||
{
|
||||
i2c_master_bus_handle_t handle;
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, i2c_master_get_bus_handle(10, &handle));
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, i2c_master_get_bus_handle(0, &handle));
|
||||
|
||||
i2c_master_bus_handle_t bus_handle;
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
_test_i2c_new_bus_device(&bus_handle, &dev_handle);
|
||||
TEST_ESP_OK(i2c_master_get_bus_handle(0, &handle));
|
||||
|
||||
// Check the handle retrieved is as same as original handle
|
||||
TEST_ASSERT((uint32_t)bus_handle == (uint32_t)handle);
|
||||
_test_i2c_del_bus_device(bus_handle, dev_handle);
|
||||
}
|
||||
|
Reference in New Issue
Block a user