Skip to content

Commit 0ecd8ab

Browse files
jr-ossSh3Rm4n
authored andcommitted
test: Add uart test to read data while status is busy
1 parent 4880c7c commit 0ecd8ab

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

testsuite/tests/uart.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,30 @@ mod tests {
445445

446446
state.serial1 = Some(serial);
447447
}
448+
449+
#[test]
450+
fn test_busy_does_not_prevent_reading_data_register(state: &mut super::State) {
451+
let mut serial = state.serial1.take().unwrap();
452+
453+
while serial.is_busy() {}
454+
455+
let b1 = TEST_MSG[0];
456+
let b2 = TEST_MSG[1];
457+
458+
unwrap!(nb::block!(serial.write(b1)));
459+
while !serial.is_busy() {} // Wait until reception b1 started
460+
while serial.is_busy() {} // Wait until reception b1 complete
461+
unwrap!(nb::block!(serial.write(b2)));
462+
while !serial.is_busy() {} // Wait until reception b2 started
463+
464+
let c1 = unwrap!(nb::block!(serial.read())); // b1 in data register, b2 in shift register
465+
let c2 = unwrap!(nb::block!(serial.read())); // wait for b2 in data register
466+
467+
assert_eq!(b1, c1);
468+
assert_eq!(b2, c2);
469+
470+
state.serial1 = Some(serial);
471+
}
448472
}
449473

450474
// TODO: This maybe can be moved into a function inside the

0 commit comments

Comments
 (0)