aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb-dfu/src
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2023-12-19 16:33:05 +0100
committerUlf Lilleengen <[email protected]>2023-12-19 16:33:05 +0100
commit9ddf8b08e448caca3825fc47aa737247323d8725 (patch)
tree5bbb53d608b475b4f2fcd07243f85854799843f8 /embassy-usb-dfu/src
parentc995732b0e08b3157aa8886da2e5ce4a36af6e93 (diff)
docs: document usb-logger and usb-dfu
Diffstat (limited to 'embassy-usb-dfu/src')
-rw-r--r--embassy-usb-dfu/src/application.rs1
-rw-r--r--embassy-usb-dfu/src/consts.rs12
-rw-r--r--embassy-usb-dfu/src/dfu.rs (renamed from embassy-usb-dfu/src/bootloader.rs)1
-rw-r--r--embassy-usb-dfu/src/lib.rs11
4 files changed, 19 insertions, 6 deletions
diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs
index 75689db26..f0d7626f6 100644
--- a/embassy-usb-dfu/src/application.rs
+++ b/embassy-usb-dfu/src/application.rs
@@ -24,6 +24,7 @@ pub struct Control<'d, STATE: NorFlash, RST: Reset> {
24} 24}
25 25
26impl<'d, STATE: NorFlash, RST: Reset> Control<'d, STATE, RST> { 26impl<'d, STATE: NorFlash, RST: Reset> Control<'d, STATE, RST> {
27 /// Create a new DFU instance to expose a DFU interface.
27 pub fn new(firmware_state: BlockingFirmwareState<'d, STATE>, attrs: DfuAttributes) -> Self { 28 pub fn new(firmware_state: BlockingFirmwareState<'d, STATE>, attrs: DfuAttributes) -> Self {
28 Control { 29 Control {
29 firmware_state, 30 firmware_state,
diff --git a/embassy-usb-dfu/src/consts.rs b/embassy-usb-dfu/src/consts.rs
index b359a107e..f8a056e5c 100644
--- a/embassy-usb-dfu/src/consts.rs
+++ b/embassy-usb-dfu/src/consts.rs
@@ -1,3 +1,4 @@
1//! USB DFU constants.
1pub(crate) const USB_CLASS_APPN_SPEC: u8 = 0xFE; 2pub(crate) const USB_CLASS_APPN_SPEC: u8 = 0xFE;
2pub(crate) const APPN_SPEC_SUBCLASS_DFU: u8 = 0x01; 3pub(crate) const APPN_SPEC_SUBCLASS_DFU: u8 = 0x01;
3#[allow(unused)] 4#[allow(unused)]
@@ -18,10 +19,15 @@ defmt::bitflags! {
18 19
19#[cfg(not(feature = "defmt"))] 20#[cfg(not(feature = "defmt"))]
20bitflags::bitflags! { 21bitflags::bitflags! {
22 /// Attributes supported by the DFU controller.
21 pub struct DfuAttributes: u8 { 23 pub struct DfuAttributes: u8 {
24 /// Generate WillDetache sequence on bus.
22 const WILL_DETACH = 0b0000_1000; 25 const WILL_DETACH = 0b0000_1000;
26 /// Device can communicate during manifestation phase.
23 const MANIFESTATION_TOLERANT = 0b0000_0100; 27 const MANIFESTATION_TOLERANT = 0b0000_0100;
28 /// Capable of upload.
24 const CAN_UPLOAD = 0b0000_0010; 29 const CAN_UPLOAD = 0b0000_0010;
30 /// Capable of download.
25 const CAN_DOWNLOAD = 0b0000_0001; 31 const CAN_DOWNLOAD = 0b0000_0001;
26 } 32 }
27} 33}
@@ -29,7 +35,7 @@ bitflags::bitflags! {
29#[derive(Copy, Clone, PartialEq, Eq)] 35#[derive(Copy, Clone, PartialEq, Eq)]
30#[repr(u8)] 36#[repr(u8)]
31#[allow(unused)] 37#[allow(unused)]
32pub enum State { 38pub(crate) enum State {
33 AppIdle = 0, 39 AppIdle = 0,
34 AppDetach = 1, 40 AppDetach = 1,
35 DfuIdle = 2, 41 DfuIdle = 2,
@@ -46,7 +52,7 @@ pub enum State {
46#[derive(Copy, Clone, PartialEq, Eq)] 52#[derive(Copy, Clone, PartialEq, Eq)]
47#[repr(u8)] 53#[repr(u8)]
48#[allow(unused)] 54#[allow(unused)]
49pub enum Status { 55pub(crate) enum Status {
50 Ok = 0x00, 56 Ok = 0x00,
51 ErrTarget = 0x01, 57 ErrTarget = 0x01,
52 ErrFile = 0x02, 58 ErrFile = 0x02,
@@ -67,7 +73,7 @@ pub enum Status {
67 73
68#[derive(Copy, Clone, PartialEq, Eq)] 74#[derive(Copy, Clone, PartialEq, Eq)]
69#[repr(u8)] 75#[repr(u8)]
70pub enum Request { 76pub(crate) enum Request {
71 Detach = 0, 77 Detach = 0,
72 Dnload = 1, 78 Dnload = 1,
73 Upload = 2, 79 Upload = 2,
diff --git a/embassy-usb-dfu/src/bootloader.rs b/embassy-usb-dfu/src/dfu.rs
index d41e6280d..e99aa70c3 100644
--- a/embassy-usb-dfu/src/bootloader.rs
+++ b/embassy-usb-dfu/src/dfu.rs
@@ -23,6 +23,7 @@ pub struct Control<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_S
23} 23}
24 24
25impl<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> Control<'d, DFU, STATE, RST, BLOCK_SIZE> { 25impl<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> Control<'d, DFU, STATE, RST, BLOCK_SIZE> {
26 /// Create a new DFU instance to handle DFU transfers.
26 pub fn new(updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes) -> Self { 27 pub fn new(updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes) -> Self {
27 Self { 28 Self {
28 updater, 29 updater,
diff --git a/embassy-usb-dfu/src/lib.rs b/embassy-usb-dfu/src/lib.rs
index 389bb33f2..eaa4b6e33 100644
--- a/embassy-usb-dfu/src/lib.rs
+++ b/embassy-usb-dfu/src/lib.rs
@@ -1,12 +1,14 @@
1#![no_std] 1#![no_std]
2#![doc = include_str!("../README.md")]
3#![warn(missing_docs)]
2mod fmt; 4mod fmt;
3 5
4pub mod consts; 6pub mod consts;
5 7
6#[cfg(feature = "dfu")] 8#[cfg(feature = "dfu")]
7mod bootloader; 9mod dfu;
8#[cfg(feature = "dfu")] 10#[cfg(feature = "dfu")]
9pub use self::bootloader::*; 11pub use self::dfu::*;
10 12
11#[cfg(feature = "application")] 13#[cfg(feature = "application")]
12mod application; 14mod application;
@@ -17,7 +19,7 @@ pub use self::application::*;
17 all(feature = "dfu", feature = "application"), 19 all(feature = "dfu", feature = "application"),
18 not(any(feature = "dfu", feature = "application")) 20 not(any(feature = "dfu", feature = "application"))
19))] 21))]
20compile_error!("usb-dfu must be compiled with exactly one of `bootloader`, or `application` features"); 22compile_error!("usb-dfu must be compiled with exactly one of `dfu`, or `application` features");
21 23
22/// Provides a platform-agnostic interface for initiating a system reset. 24/// Provides a platform-agnostic interface for initiating a system reset.
23/// 25///
@@ -26,9 +28,11 @@ compile_error!("usb-dfu must be compiled with exactly one of `bootloader`, or `a
26/// 28///
27/// If alternate behaviour is desired, a custom implementation of Reset can be provided as a type argument to the usb_dfu function. 29/// If alternate behaviour is desired, a custom implementation of Reset can be provided as a type argument to the usb_dfu function.
28pub trait Reset { 30pub trait Reset {
31 /// Reset the device.
29 fn sys_reset() -> !; 32 fn sys_reset() -> !;
30} 33}
31 34
35/// Reset immediately.
32#[cfg(feature = "esp32c3-hal")] 36#[cfg(feature = "esp32c3-hal")]
33pub struct ResetImmediate; 37pub struct ResetImmediate;
34 38
@@ -40,6 +44,7 @@ impl Reset for ResetImmediate {
40 } 44 }
41} 45}
42 46
47/// Reset immediately.
43#[cfg(feature = "cortex-m")] 48#[cfg(feature = "cortex-m")]
44pub struct ResetImmediate; 49pub struct ResetImmediate;
45 50