aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb/src/builder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-usb/src/builder.rs')
-rw-r--r--embassy-usb/src/builder.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/embassy-usb/src/builder.rs b/embassy-usb/src/builder.rs
index c8a9db7a4..4bbcd3e56 100644
--- a/embassy-usb/src/builder.rs
+++ b/embassy-usb/src/builder.rs
@@ -122,7 +122,7 @@ pub struct UsbDeviceBuilder<'d, D: Driver<'d>> {
122 interfaces: Vec<(u8, &'d mut dyn ControlHandler), MAX_INTERFACE_COUNT>, 122 interfaces: Vec<(u8, &'d mut dyn ControlHandler), MAX_INTERFACE_COUNT>,
123 control_buf: &'d mut [u8], 123 control_buf: &'d mut [u8],
124 124
125 bus: D, 125 driver: D,
126 next_interface_number: u8, 126 next_interface_number: u8,
127 next_string_index: u8, 127 next_string_index: u8,
128 128
@@ -139,7 +139,7 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
139 /// large enough for the length of the largest control request (in or out) 139 /// large enough for the length of the largest control request (in or out)
140 /// anticipated by any class added to the device. 140 /// anticipated by any class added to the device.
141 pub fn new( 141 pub fn new(
142 bus: D, 142 driver: D,
143 config: Config<'d>, 143 config: Config<'d>,
144 device_descriptor_buf: &'d mut [u8], 144 device_descriptor_buf: &'d mut [u8],
145 config_descriptor_buf: &'d mut [u8], 145 config_descriptor_buf: &'d mut [u8],
@@ -173,7 +173,7 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
173 bos_descriptor.bos(); 173 bos_descriptor.bos();
174 174
175 UsbDeviceBuilder { 175 UsbDeviceBuilder {
176 bus, 176 driver,
177 config, 177 config,
178 interfaces: Vec::new(), 178 interfaces: Vec::new(),
179 control_buf, 179 control_buf,
@@ -187,12 +187,12 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
187 } 187 }
188 188
189 /// Creates the [`UsbDevice`] instance with the configuration in this builder. 189 /// Creates the [`UsbDevice`] instance with the configuration in this builder.
190 pub fn build(mut self) -> UsbDevice<'d, D> { 190 pub async fn build(mut self) -> UsbDevice<'d, D> {
191 self.config_descriptor.end_configuration(); 191 self.config_descriptor.end_configuration();
192 self.bos_descriptor.end_bos(); 192 self.bos_descriptor.end_bos();
193 193
194 UsbDevice::build( 194 UsbDevice::build(
195 self.bus, 195 self.driver,
196 self.config, 196 self.config,
197 self.device_descriptor.into_buf(), 197 self.device_descriptor.into_buf(),
198 self.config_descriptor.into_buf(), 198 self.config_descriptor.into_buf(),
@@ -200,6 +200,7 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
200 self.interfaces, 200 self.interfaces,
201 self.control_buf, 201 self.control_buf,
202 ) 202 )
203 .await
203 } 204 }
204 205
205 /// Allocates a new interface number. 206 /// Allocates a new interface number.
@@ -251,7 +252,7 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
251 max_packet_size: u16, 252 max_packet_size: u16,
252 interval: u8, 253 interval: u8,
253 ) -> Result<D::EndpointIn, EndpointAllocError> { 254 ) -> Result<D::EndpointIn, EndpointAllocError> {
254 self.bus 255 self.driver
255 .alloc_endpoint_in(ep_addr, ep_type, max_packet_size, interval) 256 .alloc_endpoint_in(ep_addr, ep_type, max_packet_size, interval)
256 } 257 }
257 258
@@ -266,7 +267,7 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
266 max_packet_size: u16, 267 max_packet_size: u16,
267 interval: u8, 268 interval: u8,
268 ) -> Result<D::EndpointOut, EndpointAllocError> { 269 ) -> Result<D::EndpointOut, EndpointAllocError> {
269 self.bus 270 self.driver
270 .alloc_endpoint_out(ep_addr, ep_type, max_packet_size, interval) 271 .alloc_endpoint_out(ep_addr, ep_type, max_packet_size, interval)
271 } 272 }
272 273
@@ -306,7 +307,7 @@ impl<'d, D: Driver<'d>> UsbDeviceBuilder<'d, D> {
306 /// feasibly recoverable. 307 /// feasibly recoverable.
307 #[inline] 308 #[inline]
308 pub fn alloc_control_pipe(&mut self, max_packet_size: u16) -> D::ControlPipe { 309 pub fn alloc_control_pipe(&mut self, max_packet_size: u16) -> D::ControlPipe {
309 self.bus 310 self.driver
310 .alloc_control_pipe(max_packet_size) 311 .alloc_control_pipe(max_packet_size)
311 .expect("alloc_control_pipe failed") 312 .expect("alloc_control_pipe failed")
312 } 313 }