aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb-synopsys-otg
diff options
context:
space:
mode:
authorDániel Buga <[email protected]>2024-04-26 18:13:10 +0200
committerDániel Buga <[email protected]>2024-04-26 18:13:15 +0200
commit50aefb417496f45a6c79abf2ac1737d737feb9ba (patch)
tree10a6adc3f57933e90277df85c487bedfaadea62f /embassy-usb-synopsys-otg
parent91c42e0b9e118d88a51fecf07dc3f41b61c0762c (diff)
Hide the Dir trait
Diffstat (limited to 'embassy-usb-synopsys-otg')
-rw-r--r--embassy-usb-synopsys-otg/src/lib.rs14
1 files changed, 8 insertions, 6 deletions
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,