aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb
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-usb
parent883e28a0fb80f9139c0236ce44597c23a0917e4d (diff)
usb: make ControlPipe accept, reject async.
Diffstat (limited to 'embassy-usb')
-rw-r--r--embassy-usb/src/driver.rs10
-rw-r--r--embassy-usb/src/lib.rs6
2 files changed, 11 insertions, 5 deletions
diff --git a/embassy-usb/src/driver.rs b/embassy-usb/src/driver.rs
index 9cd4afdab..0680df7a5 100644
--- a/embassy-usb/src/driver.rs
+++ b/embassy-usb/src/driver.rs
@@ -144,6 +144,12 @@ pub trait ControlPipe {
144 type DataInFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a 144 type DataInFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a
145 where 145 where
146 Self: 'a; 146 Self: 'a;
147 type AcceptFuture<'a>: Future<Output = ()> + 'a
148 where
149 Self: 'a;
150 type RejectFuture<'a>: Future<Output = ()> + 'a
151 where
152 Self: 'a;
147 153
148 /// Maximum packet size for the control pipe 154 /// Maximum packet size for the control pipe
149 fn max_packet_size(&self) -> usize; 155 fn max_packet_size(&self) -> usize;
@@ -171,12 +177,12 @@ pub trait ControlPipe {
171 /// Accepts a control request. 177 /// Accepts a control request.
172 /// 178 ///
173 /// Causes the STATUS packet for the current request to be ACKed. 179 /// Causes the STATUS packet for the current request to be ACKed.
174 fn accept(&mut self); 180 fn accept<'a>(&'a mut self) -> Self::AcceptFuture<'a>;
175 181
176 /// Rejects a control request. 182 /// Rejects a control request.
177 /// 183 ///
178 /// Sets a STALL condition on the pipe to indicate an error. 184 /// Sets a STALL condition on the pipe to indicate an error.
179 fn reject(&mut self); 185 fn reject<'a>(&'a mut self) -> Self::RejectFuture<'a>;
180} 186}
181 187
182pub trait EndpointIn: Endpoint { 188pub trait EndpointIn: Endpoint {
diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs
index 9101d81bd..b691bf11e 100644
--- a/embassy-usb/src/lib.rs
+++ b/embassy-usb/src/lib.rs
@@ -306,7 +306,7 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
306 } 306 }
307 } 307 }
308 } 308 }
309 InResponse::Rejected => self.control.reject(), 309 InResponse::Rejected => self.control.reject().await,
310 } 310 }
311 } 311 }
312 312
@@ -337,8 +337,8 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
337 trace!(" control out data: {:02x?}", data); 337 trace!(" control out data: {:02x?}", data);
338 338
339 match self.inner.handle_control_out(req, data) { 339 match self.inner.handle_control_out(req, data) {
340 OutResponse::Accepted => self.control.accept(), 340 OutResponse::Accepted => self.control.accept().await,
341 OutResponse::Rejected => self.control.reject(), 341 OutResponse::Rejected => self.control.reject().await,
342 } 342 }
343 } 343 }
344} 344}