mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
[cxx]: fixed I2C master timeout
This commit is contained in:
parent
1546c28a5f
commit
eebf301acc
@ -475,7 +475,7 @@ TReturn I2CTransfer<TReturn>::do_transfer(i2c_port_t i2c_num, uint8_t i2c_addr)
|
||||
|
||||
CHECK_THROW_SPECIFIC(i2c_master_stop(cmd_link.handle), I2CException);
|
||||
|
||||
CHECK_THROW_SPECIFIC(i2c_master_cmd_begin(i2c_num, cmd_link.handle, 1000 / portTICK_RATE_MS), I2CTransferException);
|
||||
CHECK_THROW_SPECIFIC(i2c_master_cmd_begin(i2c_num, cmd_link.handle, driver_timeout / portTICK_RATE_MS), I2CTransferException);
|
||||
|
||||
return process_result();
|
||||
}
|
||||
|
@ -69,6 +69,16 @@ TEST_CASE("I2CMaster SDA and SCL equal", "[cxx i2c][leaks=300]")
|
||||
TEST_THROW(I2CMaster(0, 0, 0, 400000), I2CException);
|
||||
}
|
||||
|
||||
TEST_CASE("I2Transfer timeout", "[cxx i2c][leaks=300]")
|
||||
{
|
||||
std::vector<uint8_t> data = {MAGIC_TEST_NUMBER};
|
||||
|
||||
// I2CWrite directly inherits from I2CTransfer; it's representative for I2CRead and I2CComposed, too.
|
||||
I2CWrite writer(data, chrono::milliseconds(50));
|
||||
|
||||
TEST_THROW(writer.do_transfer(I2C_MASTER_NUM, ADDR), I2CTransferException);
|
||||
}
|
||||
|
||||
// TODO The I2C driver tests are disabled, so disable them here, too. Probably due to no runners.
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2, ESP32S3)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user