1021: rp usb: wait for accept() completion r=Dirbaio a=mkj

This fixes failures when `defmt` feature isn't enabled (timing related). 

Co-authored-by: Matt Johnston <matt@ucc.asn.au>
This commit is contained in:
bors[bot] 2022-10-21 19:48:49 +00:00 committed by GitHub
commit 73d06dd67b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -811,8 +811,8 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
async move { async move {
trace!("control: accept"); trace!("control: accept");
let bufcontrol = T::dpram().ep_in_buffer_control(0);
unsafe { unsafe {
let bufcontrol = T::dpram().ep_in_buffer_control(0);
bufcontrol.write(|w| { bufcontrol.write(|w| {
w.set_length(0, 0); w.set_length(0, 0);
w.set_pid(0, true); w.set_pid(0, true);
@ -826,6 +826,18 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
w.set_available(0, true); w.set_available(0, true);
}); });
} }
// wait for completion before returning, needed so
// set_address() doesn't happen early.
poll_fn(|cx| {
EP_IN_WAKERS[0].register(cx.waker());
if unsafe { bufcontrol.read().available(0) } {
Poll::Pending
} else {
Poll::Ready(())
}
})
.await;
} }
} }