[embassy-usb-dfu] accept closure to customise DFU function
This provides a more generic interface for users to customise the DFU function instead of restricting customisation to DFU headers.
This commit is contained in:
@@ -70,11 +70,15 @@ async fn main(_spawner: Spawner) {
|
||||
msos::PropertyData::RegMultiSz(DEVICE_INTERFACE_GUIDS),
|
||||
));
|
||||
|
||||
// For non-composite devices:
|
||||
usb_dfu(&mut builder, &mut state, Duration::from_millis(2500), None);
|
||||
|
||||
// Or for composite devices:
|
||||
// usb_dfu(&mut builder, &mut state, Duration::from_millis(2500), Some(DEVICE_INTERFACE_GUIDS));
|
||||
usb_dfu(&mut builder, &mut state, Duration::from_millis(2500), |func| {
|
||||
// You likely don't have to add these function level headers if your USB device is not composite
|
||||
// (i.e. if your device does not expose another interface in addition to DFU)
|
||||
func.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", ""));
|
||||
func.msos_feature(msos::RegistryPropertyFeatureDescriptor::new(
|
||||
"DeviceInterfaceGUIDs",
|
||||
msos::PropertyData::RegMultiSz(DEVICE_INTERFACE_GUIDS),
|
||||
));
|
||||
});
|
||||
|
||||
let mut dev = builder.build();
|
||||
dev.run().await
|
||||
|
||||
@@ -78,11 +78,15 @@ fn main() -> ! {
|
||||
msos::PropertyData::RegMultiSz(DEVICE_INTERFACE_GUIDS),
|
||||
));
|
||||
|
||||
// For non-composite devices:
|
||||
usb_dfu::<_, _, _, _, 4096>(&mut builder, &mut state, None);
|
||||
|
||||
// Or for composite devices:
|
||||
// usb_dfu::<_, _, _, _, 4096>(&mut builder, &mut state, Some(DEVICE_INTERFACE_GUIDS));
|
||||
usb_dfu::<_, _, _, _, 4096>(&mut builder, &mut state, |func| {
|
||||
// You likely don't have to add these function level headers if your USB device is not composite
|
||||
// (i.e. if your device does not expose another interface in addition to DFU)
|
||||
func.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", ""));
|
||||
func.msos_feature(msos::RegistryPropertyFeatureDescriptor::new(
|
||||
"DeviceInterfaceGUIDs",
|
||||
msos::PropertyData::RegMultiSz(DEVICE_INTERFACE_GUIDS),
|
||||
));
|
||||
});
|
||||
|
||||
let mut dev = builder.build();
|
||||
embassy_futures::block_on(dev.run());
|
||||
|
||||
Reference in New Issue
Block a user