diff --git a/hil-test/tests/i2c.rs b/hil-test/tests/i2c.rs index 159d4cd33..de4ad6dfc 100644 --- a/hil-test/tests/i2c.rs +++ b/hil-test/tests/i2c.rs @@ -112,12 +112,12 @@ mod tests { // state ctx.i2c .write_read(NON_EXISTENT_ADDRESS, &[0xaa], &mut read_data) - .ok(); + .expect_err("Expected error for non-existent address"); // do the real read which should succeed ctx.i2c .write_read(DUT_ADDRESS, READ_DATA_COMMAND, &mut read_data) - .ok(); + .unwrap(); assert_ne!(read_data, [0u8; 22]) } @@ -135,7 +135,7 @@ mod tests { Operation::Read(&mut read_data), ], ) - .ok(); + .unwrap(); assert_ne!(read_data, [0u8; 22]) } @@ -167,12 +167,12 @@ mod tests { // state i2c.write_read_async(NON_EXISTENT_ADDRESS, &[0xaa], &mut read_data) .await - .ok(); + .expect_err("Expected error for non-existent address"); // do the real read which should succeed i2c.write_read_async(DUT_ADDRESS, READ_DATA_COMMAND, &mut read_data) .await - .ok(); + .unwrap(); assert_ne!(read_data, [0u8; 22]) } @@ -191,11 +191,25 @@ mod tests { ], ) .await - .ok(); + .unwrap(); assert_ne!(read_data, [0u8; 22]) } + // This is still an issue on ESP32-S2 + #[cfg(not(esp32s2))] + #[test] + async fn test_timeout_when_scl_kept_low(ctx: Context) { + let mut i2c = ctx.i2c.into_async(); + + esp_hal::gpio::InputSignal::I2CEXT0_SCL.connect_to(&esp_hal::gpio::Level::Low); + + let mut read_data = [0u8; 22]; + // will run into an error but it should return at least + i2c.write_read(DUT_ADDRESS, READ_DATA_COMMAND, &mut read_data) + .expect_err("Expected timeout error"); + } + // This is still an issue on ESP32-S2 #[cfg(not(esp32s2))] #[test] @@ -208,7 +222,7 @@ mod tests { // will run into an error but it should return at least i2c.write_read_async(DUT_ADDRESS, READ_DATA_COMMAND, &mut read_data) .await - .ok(); + .expect_err("Expected timeout error"); } #[test]