feat(i2c_master): Add an api for retrieveing handle via port

This commit is contained in:
C.S.M
2024-10-25 16:06:15 +08:00
parent ff673e8016
commit cecfd7a4a0
6 changed files with 81 additions and 1 deletions

View File

@@ -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);
}