Refactor embassy-usb address handling to allow reordering of status resoponse

This commit is contained in:
chemicstry
2023-01-11 17:47:12 +01:00
committed by Dario Nieuwenhuis
parent 96b97c4711
commit ce842fe28c
5 changed files with 44 additions and 38 deletions

View File

@ -489,18 +489,6 @@ impl<'d, T: Instance> driver::Bus for Bus<'d, T> {
.await
}
#[inline]
fn set_address(&mut self, addr: u8) {
let regs = T::regs();
trace!("setting addr: {}", addr);
unsafe {
regs.daddr().write(|w| {
w.set_ef(true);
w.set_add(addr);
})
}
}
fn endpoint_set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool) {
// This can race, so do a retry loop.
let reg = T::regs().epr(ep_addr.index() as _);
@ -1017,4 +1005,17 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
});
}
}
async fn accept_set_address(&mut self, addr: u8) {
self.accept().await;
let regs = T::regs();
trace!("setting addr: {}", addr);
unsafe {
regs.daddr().write(|w| {
w.set_ef(true);
w.set_add(addr);
})
}
}
}