embassy-usb

Crates

git

Versions

default

Flavors

usb_dfu

Function usb_dfu 

Source
pub fn usb_dfu<'d, D: Driver<'d>, H: Handler>(
    builder: &mut Builder<'d, D>,
    state: &'d mut DfuState<H>,
    func_modifier: impl Fn(&mut FunctionBuilder<'_, 'd, D>),
)
Expand description

An implementation of the USB DFU 1.1 runtime protocol

This function will add a DFU interface descriptor to the provided Builder, and register the provided Control as a handler for the USB device. The USB builder can be used as normal once this is complete. The handler is responsive to DFU GetStatus and Detach commands.

Once a detach command, followed by a USB reset is received by the host, a magic number will be written into the bootloader state partition to indicate that it should expose a DFU device, and a software reset will be issued.

To apply USB DFU updates, the bootloader must be capable of recognizing the DFU magic and exposing a device to handle the full DFU transaction with the host.