aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-05-30 00:35:27 +0200
committerDario Nieuwenhuis <[email protected]>2022-05-30 00:35:27 +0200
commita7383840e7067df2d436601b8ca4a48384673254 (patch)
treeb7607339d6cc5a096ecd24abbe52f3cf0dc577f2 /embassy-nrf/src
parent883e28a0fb80f9139c0236ce44597c23a0917e4d (diff)
usb: make ControlPipe accept, reject async.
Diffstat (limited to 'embassy-nrf/src')
-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 9155eb37a..842abf162 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> {
616 type SetupFuture<'a> = impl Future<Output = [u8;8]> + 'a where Self: 'a; 616 type SetupFuture<'a> = impl Future<Output = [u8;8]> + 'a where Self: 'a;
617 type DataOutFuture<'a> = impl Future<Output = Result<usize, EndpointError>> + 'a where Self: 'a; 617 type DataOutFuture<'a> = impl Future<Output = Result<usize, EndpointError>> + 'a where Self: 'a;
618 type DataInFuture<'a> = impl Future<Output = Result<(), EndpointError>> + 'a where Self: 'a; 618 type DataInFuture<'a> = impl Future<Output = Result<(), EndpointError>> + 'a where Self: 'a;
619 type AcceptFuture<'a> = impl Future<Output = ()> + 'a where Self: 'a;
620 type RejectFuture<'a> = impl Future<Output = ()> + 'a where Self: 'a;
619 621
620 fn max_packet_size(&self) -> usize { 622 fn max_packet_size(&self) -> usize {
621 usize::from(self.max_packet_size) 623 usize::from(self.max_packet_size)
@@ -740,15 +742,19 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
740 } 742 }
741 } 743 }
742 744
743 fn accept(&mut self) { 745 fn accept<'a>(&'a mut self) -> Self::AcceptFuture<'a> {
744 let regs = T::regs(); 746 async move {
745 regs.tasks_ep0status 747 let regs = T::regs();
746 .write(|w| w.tasks_ep0status().bit(true)); 748 regs.tasks_ep0status
749 .write(|w| w.tasks_ep0status().bit(true));
750 }
747 } 751 }
748 752
749 fn reject(&mut self) { 753 fn reject<'a>(&'a mut self) -> Self::RejectFuture<'a> {
750 let regs = T::regs(); 754 async move {
751 regs.tasks_ep0stall.write(|w| w.tasks_ep0stall().bit(true)); 755 let regs = T::regs();
756 regs.tasks_ep0stall.write(|w| w.tasks_ep0stall().bit(true));
757 }
752 } 758 }
753} 759}
754 760