aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb-dfu/src/application.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-usb-dfu/src/application.rs')
-rw-r--r--embassy-usb-dfu/src/application.rs21
1 files changed, 6 insertions, 15 deletions
diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs
index 2646d100d..4b7b72073 100644
--- a/embassy-usb-dfu/src/application.rs
+++ b/embassy-usb-dfu/src/application.rs
@@ -2,7 +2,7 @@ use embassy_boot::BlockingFirmwareState;
2use embassy_time::{Duration, Instant}; 2use embassy_time::{Duration, Instant};
3use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; 3use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType};
4use embassy_usb::driver::Driver; 4use embassy_usb::driver::Driver;
5use embassy_usb::{msos, Builder, Handler}; 5use embassy_usb::{Builder, FunctionBuilder, Handler};
6use embedded_storage::nor_flash::NorFlash; 6use embedded_storage::nor_flash::NorFlash;
7 7
8use crate::consts::{ 8use crate::consts::{
@@ -130,22 +130,13 @@ pub fn usb_dfu<'d, D: Driver<'d>, MARK: DfuMarker, RST: Reset>(
130 builder: &mut Builder<'d, D>, 130 builder: &mut Builder<'d, D>,
131 handler: &'d mut Control<MARK, RST>, 131 handler: &'d mut Control<MARK, RST>,
132 timeout: Duration, 132 timeout: Duration,
133 winusb_guids: Option<&'d [&str]>, 133 func_modifier: impl Fn(&mut FunctionBuilder<'_, 'd, D>),
134) { 134) {
135 let mut func = builder.function(0x00, 0x00, 0x00); 135 let mut func = builder.function(0x00, 0x00, 0x00);
136 if let Some(winusb_guids) = winusb_guids { 136
137 // We add MSOS headers so that the device automatically gets assigned the WinUSB driver on Windows. 137 // Here we give users the opportunity to add their own function level MSOS headers for instance.
138 // Otherwise users need to do this manually using a tool like Zadig. 138 // This is useful when DFU functionality is part of a composite USB device.
139 // 139 func_modifier(&mut func);
140 // Adding them here on the function level appears to only be needed for compositive devices.
141 // In addition to being on the function level, they should also be added to the device level.
142 //
143 func.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", ""));
144 func.msos_feature(msos::RegistryPropertyFeatureDescriptor::new(
145 "DeviceInterfaceGUIDs",
146 msos::PropertyData::RegMultiSz(winusb_guids),
147 ));
148 }
149 140
150 let mut iface = func.interface(); 141 let mut iface = func.interface();
151 let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_RT, None); 142 let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_RT, None);