DFUClass

Struct DFUClass 

Source
pub struct DFUClass<B: UsbBus, M: DFUMemIO> { /* private fields */ }
Expand description

DFU protocol USB class implementation for usb-device library.

Implementations§

Source§

impl<B: UsbBus, M: DFUMemIO> DFUClass<B, M>

Source

pub fn new(alloc: &UsbBusAllocator<B>, mem: M) -> Self

Creates a new DFUClass with the provided UsbBus and DFUMemIO

Source

pub fn release(self) -> M

This function will consume self and return the owned memory argument that was moved in the call to new()

Source

pub fn set_unexpected_reset_state(&mut self)

This function may be called just after DFUClass::new() to set DFU error state to “Device detected unexpected power on reset” instead of the usual dfuIdle.

Source

pub fn set_firmware_corrupted_state(&mut self)

This function may be called just after DFUClass::new() to set DFU error state to “Device’s firmware is corrupt. It cannot return to run-time (non-DFU) operations” instead of the usual dfuIdle.

Source

pub fn get_address_pointer(&self) -> u32

Return current Address Pointer value.

Trait Implementations§

Source§

impl<B: UsbBus, M: DFUMemIO> UsbClass<B> for DFUClass<B, M>

Source§

fn get_configuration_descriptors( &self, writer: &mut DescriptorWriter<'_>, ) -> Result<()>

Called when a GET_DESCRIPTOR request is received for a configuration descriptor. When called, the implementation should write its interface, endpoint and any extra class descriptors into writer. The configuration descriptor itself will be written by UsbDevice and shouldn’t be written by classes. Read more
Source§

fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str>

Gets a class-specific string descriptor. Read more
Source§

fn control_in(&mut self, xfer: ControlIn<'_, '_, '_, B>)

Called when a control request is received with direction DeviceToHost. Read more
Source§

fn control_out(&mut self, xfer: ControlOut<'_, '_, '_, B>)

Called when a control request is received with direction HostToDevice. Read more
Source§

fn reset(&mut self)

Called after a USB reset after the bus reset sequence is complete.
Source§

fn poll(&mut self)

Called whenever the UsbDevice is polled.
Source§

fn get_bos_descriptors( &self, writer: &mut BosWriter<'_, '_>, ) -> Result<(), UsbError>

Called when a GET_DESCRIPTOR request is received for a BOS descriptor. When called, the implementation should write its blobs such as capability descriptors into writer. The BOS descriptor itself will be written by UsbDevice and shouldn’t be written by classes.
Source§

fn endpoint_setup(&mut self, addr: EndpointAddress)

Called when endpoint with address addr has received a SETUP packet. Implementing this shouldn’t be necessary in most cases, but is provided for completeness’ sake. Read more
Source§

fn endpoint_out(&mut self, addr: EndpointAddress)

Called when endpoint with address addr has received data (OUT packet). Read more
Source§

fn endpoint_in_complete(&mut self, addr: EndpointAddress)

Called when endpoint with address addr has completed transmitting data (IN packet). Read more
Source§

fn get_alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>

Called when the interfaces alternate setting state is requested. Read more
Source§

fn set_alt_setting( &mut self, interface: InterfaceNumber, alternative: u8, ) -> bool

Called when the interfaces alternate setting state is altered. Read more

Auto Trait Implementations§

§

impl<B, M> Freeze for DFUClass<B, M>
where M: Freeze,

§

impl<B, M> RefUnwindSafe for DFUClass<B, M>

§

impl<B, M> Send for DFUClass<B, M>
where M: Send, B: Send,

§

impl<B, M> Sync for DFUClass<B, M>
where M: Sync,

§

impl<B, M> Unpin for DFUClass<B, M>
where M: Unpin, B: Unpin,

§

impl<B, M> UnwindSafe for DFUClass<B, M>
where M: UnwindSafe, B: UnwindSafe,

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.