Struct rp2040_hal::usb::UsbBus

source ·
pub struct UsbBus { /* private fields */ }
Expand description

Usb bus

Implementations§

source§

impl UsbBus

source

pub fn new( ctrl_reg: USBCTRL_REGS, ctrl_dpram: USBCTRL_DPRAM, pll: UsbClock, force_vbus_detect_bit: bool, resets: &mut RESETS ) -> Self

Create new usb bus struct and bring up usb as device.

source

pub fn remote_wakeup(&self)

Generates a resume request on the bus.

source

pub fn free( self, resets: &mut RESETS ) -> (USBCTRL_REGS, USBCTRL_DPRAM, UsbClock)

Stop and free the Usb resources

Trait Implementations§

source§

impl UsbBus for UsbBus

source§

fn alloc_ep( &mut self, ep_dir: UsbDirection, ep_addr: Option<EndpointAddress>, ep_type: EndpointType, max_packet_size: u16, _interval: u8 ) -> UsbResult<EndpointAddress>

Allocates an endpoint and specified endpoint parameters. This method is called by the device and class implementations to allocate endpoints, and can only be called before enable is called. Read more
source§

fn enable(&mut self)

Enables and initializes the USB peripheral. Soon after enabling the device will be reset, so there is no need to perform a USB reset in this method.
source§

fn reset(&self)

Called when the host resets the device. This will be soon called after poll returns PollResult::Reset. This method should reset the state of all endpoints and peripheral flags back to a state suitable for enumeration, as well as ensure that all endpoints previously allocated with alloc_ep are initialized as specified.
source§

fn set_device_address(&self, addr: u8)

Sets the device USB address to addr.
source§

fn write(&self, ep_addr: EndpointAddress, buf: &[u8]) -> UsbResult<usize>

Writes a single packet of data to the specified endpoint and returns number of bytes actually written. Read more
source§

fn read(&self, ep_addr: EndpointAddress, buf: &mut [u8]) -> UsbResult<usize>

Reads a single packet of data from the specified endpoint and returns the actual length of the packet. Read more
source§

fn set_stalled(&self, ep_addr: EndpointAddress, stalled: bool)

Sets or clears the STALL condition for an endpoint. If the endpoint is an OUT endpoint, it should be prepared to receive data again.
source§

fn is_stalled(&self, ep_addr: EndpointAddress) -> bool

Gets whether the STALL condition is set for an endpoint.
source§

fn suspend(&self)

Causes the USB peripheral to enter USB suspend mode, lowering power consumption and preparing to detect a USB wakeup event. This will be called after poll returns PollResult::Suspend. The device will continue be polled, and it shall return a value other than Suspend from poll when it no longer detects the suspend condition.
source§

fn resume(&self)

Resumes from suspend mode. This may only be called after the peripheral has been previously suspended.
source§

fn poll(&self) -> PollResult

Gets information about events and incoming data. Usually called in a loop or from an interrupt handler. See the PollResult struct for more information.
source§

const QUIRK_SET_ADDRESS_BEFORE_STATUS: bool = false

Indicates that set_device_address must be called before accepting the corresponding control transfer, not after. Read more
source§

fn force_reset(&self) -> Result<(), UsbError>

Simulates a disconnect from the USB bus, causing the host to reset and re-enumerate the device. Read more

Auto Trait Implementations§

§

impl !Freeze for UsbBus

§

impl !RefUnwindSafe for UsbBus

§

impl Send for UsbBus

§

impl Sync for UsbBus

§

impl Unpin for UsbBus

§

impl UnwindSafe for UsbBus

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

§

type Remainder = Choices

source§

fn subset( self ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

source§

fn lift_into(self) -> U

Performs the indexed conversion.
source§

impl<Source> Sculptor<HNil, HNil> for Source

§

type Remainder = Source

source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.