Hide the Dir trait

This commit is contained in:
Dániel Buga 2024-04-26 18:13:10 +02:00
parent 91c42e0b9e
commit 50aefb4174
2 changed files with 10 additions and 8 deletions

View File

@ -161,7 +161,7 @@ impl<'d, T: Instance> embassy_usb_driver::Driver<'d> for Driver<'d, T> {
max_packet_size: u16,
interval_ms: u8,
) -> Result<Self::EndpointIn, EndpointAllocError> {
self.inner.alloc_endpoint(ep_type, max_packet_size, interval_ms)
self.inner.alloc_endpoint_in(ep_type, max_packet_size, interval_ms)
}
fn alloc_endpoint_out(
@ -170,7 +170,7 @@ impl<'d, T: Instance> embassy_usb_driver::Driver<'d> for Driver<'d, T> {
max_packet_size: u16,
interval_ms: u8,
) -> Result<Self::EndpointOut, EndpointAllocError> {
self.inner.alloc_endpoint(ep_type, max_packet_size, interval_ms)
self.inner.alloc_endpoint_out(ep_type, max_packet_size, interval_ms)
}
fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) {

View File

@ -276,7 +276,7 @@ impl Default for Config {
}
}
/// USB driver.
/// USB OTG driver.
pub struct Driver<'d> {
config: Config,
ep_in: [Option<EndpointData>; MAX_EP_COUNT],
@ -287,13 +287,15 @@ pub struct Driver<'d> {
}
impl<'d> Driver<'d> {
/// Initializes USB OTG peripheral.
/// Initializes the USB OTG peripheral.
///
/// # Arguments
///
/// * `ep_out_buffer` - An internal buffer used to temporarily store received packets.
/// Must be large enough to fit all OUT endpoint max packet sizes.
/// Endpoint allocation will fail if it is too small.
/// * `instance` - The USB OTG peripheral instance and its configuration.
/// * `config` - The USB driver configuration.
pub fn new(ep_out_buffer: &'d mut [u8], instance: OtgInstance<'d>, config: Config) -> Self {
Self {
config,
@ -305,13 +307,13 @@ impl<'d> Driver<'d> {
}
}
// Returns total amount of words (u32) allocated in dedicated FIFO
/// Returns the total amount of words (u32) allocated in dedicated FIFO.
fn allocated_fifo_words(&self) -> u16 {
self.instance.extra_rx_fifo_words + ep_fifo_size(&self.ep_out) + ep_fifo_size(&self.ep_in)
}
/// Creates an [`Endpoint`] with the given parameters.
pub fn alloc_endpoint<D: Dir>(
fn alloc_endpoint<D: Dir>(
&mut self,
ep_type: EndpointType,
max_packet_size: u16,
@ -919,7 +921,7 @@ impl<'d> embassy_usb_driver::Bus for Bus<'d> {
}
/// USB endpoint direction.
pub trait Dir {
trait Dir {
/// Returns the direction value.
fn dir() -> Direction;
}
@ -1279,7 +1281,7 @@ fn ep0_mpsiz(max_packet_size: u16) -> u16 {
// Using OtgInstance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps
pub const MAX_EP_COUNT: usize = 9;
/// USB instance.
/// Hardware-dependent USB IP configuration.
pub struct OtgInstance<'d> {
/// The USB peripheral.
pub regs: Otg,