Skip to content

Commit a869c0d

Browse files
committed
test(port_arm_m): keep the USB device alive after completing each test
The USB device is used to deliver the test result and receive commands, so it must be kept alive even after the test completion. All tests are now passing on `rp_pico`.
1 parent addfa44 commit a869c0d

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/r3_port_arm_m_test_driver/src/board_rp2040.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ fn panic(info: &PanicInfo) -> ! {
1818

1919
r3_support_rp2040::sprintln!("{}{}", mux::BEGIN_MAIN, info);
2020

21-
// TODO: keep polling
22-
loop {}
21+
enter_poll_loop();
22+
}
23+
24+
/// Start polling USB so that we can deliver the test result and reset the
25+
/// device when requested.
26+
pub fn enter_poll_loop() -> ! {
27+
loop {
28+
usbstdio::poll::<Options>();
29+
}
2330
}
2431

2532
struct Logger;

src/r3_port_arm_m_test_driver/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ macro_rules! instantiate_test {
4949
crate::board_rp2040::mux::BEGIN_MAIN,
5050
);
5151

52+
#[cfg(feature = "board-rp_pico")]
53+
board_rp2040::enter_poll_loop();
54+
5255
loop {}
5356
}
5457

src/r3_support_rp2040/src/usbstdio.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -221,24 +221,6 @@ impl UsbStdioGlobal {
221221
}
222222
}
223223

224-
// TODO:
225-
//
226-
// - The USB controller needs to be periodically polled to work correctly.
227-
// The panic handler should poll USB instead of doing nothing.
228-
//
229-
// - We also need to handle incoming data. The test driver will need this to
230-
// hold off the test execution until requested and to prepare the target for
231-
// a subsequent test run.
232-
//
233-
// - If there's incoming data, the interrupt will not be deassserted until
234-
// `SerialPort::read` is called. And `SerialPort::read` does not consume
235-
// the incoming data if its internal buffer is full.
236-
//
237-
// The only way to do flow control seems to be disabling or ignoring USB
238-
// interrupts. Of course, this can only be done for a few milliseconds, the
239-
// upper bound defined by the USB specification.
240-
//
241-
242224
struct Deque<T, const LEN: usize> {
243225
buf: [T; LEN],
244226
start: usize,

0 commit comments

Comments
 (0)