diff options
| author | alexmoon <[email protected]> | 2022-04-06 22:10:18 -0400 |
|---|---|---|
| committer | alexmoon <[email protected]> | 2022-04-07 10:51:26 -0400 |
| commit | 6abbfa9a92ec9feb03e30846bccb66272020601d (patch) | |
| tree | 78ab2f5f6ccbb45e108520395252f0e6b45665a2 /embassy-usb/src/lib.rs | |
| parent | a1754ac8a820d9cae97cf214969faf3090b37c76 (diff) | |
Async-ify Driver::enable and UsbDeviceBuilder::build
Diffstat (limited to 'embassy-usb/src/lib.rs')
| -rw-r--r-- | embassy-usb/src/lib.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs index f833a86d8..e98cbdee3 100644 --- a/embassy-usb/src/lib.rs +++ b/embassy-usb/src/lib.rs | |||
| @@ -72,7 +72,7 @@ pub struct UsbDevice<'d, D: Driver<'d>> { | |||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | impl<'d, D: Driver<'d>> UsbDevice<'d, D> { | 74 | impl<'d, D: Driver<'d>> UsbDevice<'d, D> { |
| 75 | pub(crate) fn build( | 75 | pub(crate) async fn build( |
| 76 | mut driver: D, | 76 | mut driver: D, |
| 77 | config: Config<'d>, | 77 | config: Config<'d>, |
| 78 | device_descriptor: &'d [u8], | 78 | device_descriptor: &'d [u8], |
| @@ -80,17 +80,17 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> { | |||
| 80 | bos_descriptor: &'d [u8], | 80 | bos_descriptor: &'d [u8], |
| 81 | interfaces: Vec<(u8, &'d mut dyn ControlHandler), MAX_INTERFACE_COUNT>, | 81 | interfaces: Vec<(u8, &'d mut dyn ControlHandler), MAX_INTERFACE_COUNT>, |
| 82 | control_buf: &'d mut [u8], | 82 | control_buf: &'d mut [u8], |
| 83 | ) -> Self { | 83 | ) -> UsbDevice<'d, D> { |
| 84 | let control = driver | 84 | let control = driver |
| 85 | .alloc_control_pipe(config.max_packet_size_0 as u16) | 85 | .alloc_control_pipe(config.max_packet_size_0 as u16) |
| 86 | .expect("failed to alloc control endpoint"); | 86 | .expect("failed to alloc control endpoint"); |
| 87 | 87 | ||
| 88 | // Enable the USB bus. | 88 | // Enable the USB bus. |
| 89 | // This prevent further allocation by consuming the driver. | 89 | // This prevent further allocation by consuming the driver. |
| 90 | let driver = driver.enable(); | 90 | let bus = driver.enable().await; |
| 91 | 91 | ||
| 92 | Self { | 92 | Self { |
| 93 | bus: driver, | 93 | bus, |
| 94 | config, | 94 | config, |
| 95 | control: ControlPipe::new(control), | 95 | control: ControlPipe::new(control), |
| 96 | device_descriptor, | 96 | device_descriptor, |
