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§
Sourceconst WILL_DETACH: bool = true
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.
Sourceconst MANIFESTATION_TOLERANT: bool = false
const MANIFESTATION_TOLERANT: bool = false
Bootloader is able to communicate via USB during Manifestation phase
Sourceconst CAN_DNLOAD: bool = true
const CAN_DNLOAD: bool = true
Bootloader can download firmware to device
Sourceconst CAN_UPLOAD: bool = true
const CAN_UPLOAD: bool = true
Bootloader can read device firmware and upload it to host
Sourceconst DETACH_TIMEOUT_MS: u16 = 255u16
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.
Sourceconst MAX_TRANSFER_SIZE: u16 = 2_048u16
const MAX_TRANSFER_SIZE: u16 = 2_048u16
Bootloader maximum transfer size in bytes per control-write transaction
Required Methods§
Sourcefn detach(&mut self)
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§
Sourcefn allow(&mut self, timeout: u16) -> Option<u16>
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
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.