Struct stm32_hal2::usb::UsbBus[][src]

pub struct UsbBus<USB> { /* fields omitted */ }
Expand description

USB peripheral driver for STM32 microcontrollers.

Implementations

impl<USB> UsbBus<USB> where
    USB: UsbPeripheral
[src]

pub fn new(peripheral: USB) -> UsbBusAllocator<UsbBus<USB>>[src]

Constructs a new USB peripheral driver.

pub fn free(self) -> USB[src]

pub fn force_reenumeration<F>(&self, disconnect: F) where
    F: FnOnce(), 
[src]

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

Mostly used for development. By calling this at the start of your program ensures that the host re-enumerates your device after a new program has been flashed.

disconnect parameter is used to provide a custom disconnect function. This function will be called with USB peripheral powered down and interrupts disabled. It should perform disconnect in a platform-specific way.

Trait Implementations

impl<USB> UsbBus for UsbBus<USB> where
    USB: UsbPeripheral
[src]

pub fn alloc_ep(
    &mut self,
    ep_dir: UsbDirection,
    ep_addr: Option<EndpointAddress>,
    ep_type: EndpointType,
    max_packet_size: u16,
    _interval: u8
) -> Result<EndpointAddress, UsbError>
[src]

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

pub fn enable(&mut self)[src]

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. Read more

pub fn reset(&self)[src]

Performs a USB reset. This method should reset the platform-specific peripheral as well as ensure that all endpoints previously allocate with alloc_ep are initialized as specified. Read more

pub fn set_device_address(&self, addr: u8)[src]

Sets the device USB address to addr.

pub fn poll(&self) -> PollResult[src]

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

pub fn write(
    &self,
    ep_addr: EndpointAddress,
    buf: &[u8]
) -> Result<usize, UsbError>
[src]

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

pub fn read(
    &self,
    ep_addr: EndpointAddress,
    buf: &mut [u8]
) -> Result<usize, UsbError>
[src]

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

pub fn set_stalled(&self, ep_addr: EndpointAddress, stalled: bool)[src]

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

pub fn is_stalled(&self, ep_addr: EndpointAddress) -> bool[src]

Gets whether the STALL condition is set for an endpoint.

pub fn suspend(&self)[src]

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. Read more

pub fn resume(&self)[src]

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

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

const QUIRK_SET_ADDRESS_BEFORE_STATUS: bool

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

Auto Trait Implementations

impl<USB> Send for UsbBus<USB> where
    USB: Send

impl<USB> Sync for UsbBus<USB> where
    USB: Send + Sync

impl<USB> Unpin for UsbBus<USB> where
    USB: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.