aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/usb/otg.rs4
-rw-r--r--embassy-usb-synopsys-otg/src/lib.rs14
2 files changed, 10 insertions, 8 deletions
diff --git a/embassy-stm32/src/usb/otg.rs b/embassy-stm32/src/usb/otg.rs
index c59aae87f..0525718e1 100644
--- a/embassy-stm32/src/usb/otg.rs
+++ b/embassy-stm32/src/usb/otg.rs
@@ -161,7 +161,7 @@ impl<'d, T: Instance> embassy_usb_driver::Driver<'d> for Driver<'d, T> {
161 max_packet_size: u16, 161 max_packet_size: u16,
162 interval_ms: u8, 162 interval_ms: u8,
163 ) -> Result<Self::EndpointIn, EndpointAllocError> { 163 ) -> Result<Self::EndpointIn, EndpointAllocError> {
164 self.inner.alloc_endpoint(ep_type, max_packet_size, interval_ms) 164 self.inner.alloc_endpoint_in(ep_type, max_packet_size, interval_ms)
165 } 165 }
166 166
167 fn alloc_endpoint_out( 167 fn alloc_endpoint_out(
@@ -170,7 +170,7 @@ impl<'d, T: Instance> embassy_usb_driver::Driver<'d> for Driver<'d, T> {
170 max_packet_size: u16, 170 max_packet_size: u16,
171 interval_ms: u8, 171 interval_ms: u8,
172 ) -> Result<Self::EndpointOut, EndpointAllocError> { 172 ) -> Result<Self::EndpointOut, EndpointAllocError> {
173 self.inner.alloc_endpoint(ep_type, max_packet_size, interval_ms) 173 self.inner.alloc_endpoint_out(ep_type, max_packet_size, interval_ms)
174 } 174 }
175 175
176 fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) { 176 fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) {
diff --git a/embassy-usb-synopsys-otg/src/lib.rs b/embassy-usb-synopsys-otg/src/lib.rs
index 6d6cc9b0f..59a99796c 100644
--- a/embassy-usb-synopsys-otg/src/lib.rs
+++ b/embassy-usb-synopsys-otg/src/lib.rs
@@ -276,7 +276,7 @@ impl Default for Config {
276 } 276 }
277} 277}
278 278
279/// USB driver. 279/// USB OTG driver.
280pub struct Driver<'d> { 280pub struct Driver<'d> {
281 config: Config, 281 config: Config,
282 ep_in: [Option<EndpointData>; MAX_EP_COUNT], 282 ep_in: [Option<EndpointData>; MAX_EP_COUNT],
@@ -287,13 +287,15 @@ pub struct Driver<'d> {
287} 287}
288 288
289impl<'d> Driver<'d> { 289impl<'d> Driver<'d> {
290 /// Initializes USB OTG peripheral. 290 /// Initializes the USB OTG peripheral.
291 /// 291 ///
292 /// # Arguments 292 /// # Arguments
293 /// 293 ///
294 /// * `ep_out_buffer` - An internal buffer used to temporarily store received packets. 294 /// * `ep_out_buffer` - An internal buffer used to temporarily store received packets.
295 /// Must be large enough to fit all OUT endpoint max packet sizes. 295 /// Must be large enough to fit all OUT endpoint max packet sizes.
296 /// Endpoint allocation will fail if it is too small. 296 /// Endpoint allocation will fail if it is too small.
297 /// * `instance` - The USB OTG peripheral instance and its configuration.
298 /// * `config` - The USB driver configuration.
297 pub fn new(ep_out_buffer: &'d mut [u8], instance: OtgInstance<'d>, config: Config) -> Self { 299 pub fn new(ep_out_buffer: &'d mut [u8], instance: OtgInstance<'d>, config: Config) -> Self {
298 Self { 300 Self {
299 config, 301 config,
@@ -305,13 +307,13 @@ impl<'d> Driver<'d> {
305 } 307 }
306 } 308 }
307 309
308 // Returns total amount of words (u32) allocated in dedicated FIFO 310 /// Returns the total amount of words (u32) allocated in dedicated FIFO.
309 fn allocated_fifo_words(&self) -> u16 { 311 fn allocated_fifo_words(&self) -> u16 {
310 self.instance.extra_rx_fifo_words + ep_fifo_size(&self.ep_out) + ep_fifo_size(&self.ep_in) 312 self.instance.extra_rx_fifo_words + ep_fifo_size(&self.ep_out) + ep_fifo_size(&self.ep_in)
311 } 313 }
312 314
313 /// Creates an [`Endpoint`] with the given parameters. 315 /// Creates an [`Endpoint`] with the given parameters.
314 pub fn alloc_endpoint<D: Dir>( 316 fn alloc_endpoint<D: Dir>(
315 &mut self, 317 &mut self,
316 ep_type: EndpointType, 318 ep_type: EndpointType,
317 max_packet_size: u16, 319 max_packet_size: u16,
@@ -919,7 +921,7 @@ impl<'d> embassy_usb_driver::Bus for Bus<'d> {
919} 921}
920 922
921/// USB endpoint direction. 923/// USB endpoint direction.
922pub trait Dir { 924trait Dir {
923 /// Returns the direction value. 925 /// Returns the direction value.
924 fn dir() -> Direction; 926 fn dir() -> Direction;
925} 927}
@@ -1279,7 +1281,7 @@ fn ep0_mpsiz(max_packet_size: u16) -> u16 {
1279// Using OtgInstance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps 1281// Using OtgInstance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps
1280pub const MAX_EP_COUNT: usize = 9; 1282pub const MAX_EP_COUNT: usize = 9;
1281 1283
1282/// USB instance. 1284/// Hardware-dependent USB IP configuration.
1283pub struct OtgInstance<'d> { 1285pub struct OtgInstance<'d> {
1284 /// The USB peripheral. 1286 /// The USB peripheral.
1285 pub regs: Otg, 1287 pub regs: Otg,