pub trait DfuRuntimeOps {
    const WILL_DETACH: bool = true;
    const MANIFESTATION_TOLERANT: bool = false;
    const CAN_DNLOAD: bool = true;
    const CAN_UPLOAD: bool = true;
    const DETACH_TIMEOUT_MS: u16 = 255u16;
    const MAX_TRANSFER_SIZE: u16 = 2_048u16;

    // Required method
    fn detach(&mut self);

    // Provided method
    fn allow(&mut self, timeout: u16) -> Option<u16> { ... }
}
Expand description

Trait that defines device-specific operations for DfuRuntimeClass.

Provided Associated Constants§

source

const WILL_DETACH: bool = true

Device will perform detach-attach sequence on DFU_DETACH, host must not issue USB reset

This is especially useful if the firmware jumps to bootloader by performing system reset, so there is no need for host to issue USB reset.

If this is set to false then the device should start a timer counting the amount of milliseconds in wDetachTimeout of DFU_DETACH request. It shall enable DFU mode if USB reset is detected within this timeout.

source

const MANIFESTATION_TOLERANT: bool = false

Bootloader is able to communicate via USB during Manifestation phase

source

const CAN_DNLOAD: bool = true

Bootloader can download firmware to device

source

const CAN_UPLOAD: bool = true

Bootloader can read device firmware and upload it to host

source

const DETACH_TIMEOUT_MS: u16 = 255u16

Max time for which the device will wait for USB reset after DFU_DETACH

The actual time specified in DFU_DETACH wDetachTimeout can be lower than this value. When [WILL_DETACH] is set to true then device should not wait for USB reset anyway.

source

const MAX_TRANSFER_SIZE: u16 = 2_048u16

Bootloader maximum transfer size in bytes per control-write transaction

Required Methods§

source

fn detach(&mut self)

Switch to DFU mode

Handler that should reconfigure device to DFU mode. User application should perform any necessary system cleanup and switch to DFU mode, which most often means that the application should jump to DFU-capable bootloader.

Note

When [WILL_DETACH] is set to false, this handler will be called after USB reset is detected, unless timeout occurs. It is usually simpler to use this mode.

When [WILL_DETACH] is set to true, it will not be called immediately (because the detach request needs to be accepted). Instead, the class will wait for the timeout value as returned from DfuRuntimeOps::allow and when it reaches 0 (in DfuRuntimeClass::tick) this method will be called.

Provided Methods§

source

fn allow(&mut self, timeout: u16) -> Option<u16>

Determines whether DFU_DETACH request should be accepted

This method receives the wDetachTimeout value from detach request. Default implementation accepts all requests using unmodified timeout value.

This method can be used to reject DFU_DETACH requests (by returning None) unless certain condition is met, e.g. to prevent unauthorized firmware upgrades.

One could use this method to immediately start some system cleanup jobs, instead of waiting for call to DfuRuntimeOps::detach.

Implementors§