Clippy + Tests
This commit is contained in:
parent
e7278ac2f0
commit
f9816b40e8
@ -2342,11 +2342,10 @@ fn estimate_ack_failed_reason(_register_block: &RegisterBlock) -> AcknowledgeChe
|
|||||||
} else {
|
} else {
|
||||||
// this is based on observations rather than documented behavior
|
// this is based on observations rather than documented behavior
|
||||||
if _register_block.fifo_st().read().txfifo_raddr().bits() <= 1 {
|
if _register_block.fifo_st().read().txfifo_raddr().bits() <= 1 {
|
||||||
return AcknowledgeCheckFailedReason::Address;
|
AcknowledgeCheckFailedReason::Address
|
||||||
} else {
|
} else {
|
||||||
return AcknowledgeCheckFailedReason::Data;
|
AcknowledgeCheckFailedReason::Data
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,13 +50,26 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_write_returns_ack_error_for_unknown_address(mut ctx: Context) {
|
fn empty_write_returns_ack_error_for_unknown_address(mut ctx: Context) {
|
||||||
// we don't specify the exact reason yet
|
// on some chips we can determine the ack-check-failed reason but not on all
|
||||||
|
// chips
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(any(esp32,esp32s2,esp32c2,esp32c3))] {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ctx.i2c.write(NON_EXISTENT_ADDRESS, &[]),
|
ctx.i2c.write(NON_EXISTENT_ADDRESS, &[]),
|
||||||
Err(Error::AcknowledgeCheckFailed(
|
Err(Error::AcknowledgeCheckFailed(
|
||||||
AcknowledgeCheckFailedReason::Unknown
|
AcknowledgeCheckFailedReason::Unknown
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
assert_eq!(
|
||||||
|
ctx.i2c.write(NON_EXISTENT_ADDRESS, &[]),
|
||||||
|
Err(Error::AcknowledgeCheckFailed(
|
||||||
|
AcknowledgeCheckFailedReason::Address
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert_eq!(ctx.i2c.write(DUT_ADDRESS, &[]), Ok(()));
|
assert_eq!(ctx.i2c.write(DUT_ADDRESS, &[]), Ok(()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user