summaryrefslogtreecommitdiff
path: root/embassy-nrf
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2022-05-30 00:35:27 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2022-05-30 00:35:27 +0200
commita7383840e7067df2d436601b8ca4a48384673254 (patch)
treeb7607339d6cc5a096ecd24abbe52f3cf0dc577f2 /embassy-nrf
parent883e28a0fb80f9139c0236ce44597c23a0917e4d (diff)
downloadembassy-a7383840e7067df2d436601b8ca4a48384673254.zip
usb: make ControlPipe accept, reject async.
Diffstat (limited to 'embassy-nrf')
-rw-r--r--embassy-nrf/src/usb.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/embassy-nrf/src/usb.rs b/embassy-nrf/src/usb.rs
index 9155eb37..842abf16 100644
--- a/embassy-nrf/src/usb.rs
+++ b/embassy-nrf/src/usb.rs
@@ -616,6 +616,8 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
type SetupFuture<'a> = impl Future<Output = [u8;8]> + 'a where Self: 'a;
type DataOutFuture<'a> = impl Future<Output = Result<usize, EndpointError>> + 'a where Self: 'a;
type DataInFuture<'a> = impl Future<Output = Result<(), EndpointError>> + 'a where Self: 'a;
+ type AcceptFuture<'a> = impl Future<Output = ()> + 'a where Self: 'a;
+ type RejectFuture<'a> = impl Future<Output = ()> + 'a where Self: 'a;
fn max_packet_size(&self) -> usize {
usize::from(self.max_packet_size)
@@ -740,15 +742,19 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
}
}
- fn accept(&mut self) {
- let regs = T::regs();
- regs.tasks_ep0status
- .write(|w| w.tasks_ep0status().bit(true));
+ fn accept<'a>(&'a mut self) -> Self::AcceptFuture<'a> {
+ async move {
+ let regs = T::regs();
+ regs.tasks_ep0status
+ .write(|w| w.tasks_ep0status().bit(true));
+ }
}
- fn reject(&mut self) {
- let regs = T::regs();
- regs.tasks_ep0stall.write(|w| w.tasks_ep0stall().bit(true));
+ fn reject<'a>(&'a mut self) -> Self::RejectFuture<'a> {
+ async move {
+ let regs = T::regs();
+ regs.tasks_ep0stall.write(|w| w.tasks_ep0stall().bit(true));
+ }
}
}