Merge pull request #2928 from bobrippling/feat/usb-stall

rp: implement usb stall
This commit is contained in:
Dario Nieuwenhuis 2024-05-13 01:38:47 +02:00 committed by GitHub
commit 763b57449f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -412,12 +412,41 @@ impl<'d, T: Instance> driver::Bus for Bus<'d, T> {
.await
}
fn endpoint_set_stalled(&mut self, _ep_addr: EndpointAddress, _stalled: bool) {
todo!();
fn endpoint_set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool) {
let n = ep_addr.index();
if n == 0 {
T::regs().ep_stall_arm().modify(|w| {
if ep_addr.is_in() {
w.set_ep0_in(stalled);
} else {
w.set_ep0_out(stalled);
}
});
}
let ctrl = if ep_addr.is_in() {
T::dpram().ep_in_buffer_control(n)
} else {
T::dpram().ep_out_buffer_control(n)
};
ctrl.modify(|w| w.set_stall(stalled));
let wakers = if ep_addr.is_in() { &EP_IN_WAKERS } else { &EP_OUT_WAKERS };
wakers[n].wake();
}
fn endpoint_is_stalled(&mut self, _ep_addr: EndpointAddress) -> bool {
todo!();
fn endpoint_is_stalled(&mut self, ep_addr: EndpointAddress) -> bool {
let n = ep_addr.index();
let ctrl = if ep_addr.is_in() {
T::dpram().ep_in_buffer_control(n)
} else {
T::dpram().ep_out_buffer_control(n)
};
ctrl.read().stall()
}
fn endpoint_set_enabled(&mut self, ep_addr: EndpointAddress, enabled: bool) {