Merge pull request #2729 from adamgreig/usb-no-dd-buf

usb: remove device_descriptor buffer, store bytes in UsbDevice.inner instead
This commit is contained in:
Dario Nieuwenhuis 2024-03-23 00:39:04 +00:00 committed by GitHub
commit cb1e4e684e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
40 changed files with 33 additions and 113 deletions

View File

@ -16,7 +16,6 @@ type CS = embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
/// The logger state containing buffers that must live as long as the USB peripheral. /// The logger state containing buffers that must live as long as the USB peripheral.
pub struct LoggerState<'d> { pub struct LoggerState<'d> {
state: State<'d>, state: State<'d>,
device_descriptor: [u8; 32],
config_descriptor: [u8; 128], config_descriptor: [u8; 128],
bos_descriptor: [u8; 16], bos_descriptor: [u8; 16],
msos_descriptor: [u8; 256], msos_descriptor: [u8; 256],
@ -28,7 +27,6 @@ impl<'d> LoggerState<'d> {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
state: State::new(), state: State::new(),
device_descriptor: [0; 32],
config_descriptor: [0; 128], config_descriptor: [0; 128],
bos_descriptor: [0; 16], bos_descriptor: [0; 16],
msos_descriptor: [0; 256], msos_descriptor: [0; 256],
@ -74,7 +72,6 @@ impl<const N: usize> UsbLogger<N> {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut state.device_descriptor,
&mut state.config_descriptor, &mut state.config_descriptor,
&mut state.bos_descriptor, &mut state.bos_descriptor,
&mut state.msos_descriptor, &mut state.msos_descriptor,

View File

@ -128,7 +128,6 @@ pub struct Builder<'d, D: Driver<'d>> {
driver: D, driver: D,
next_string_index: u8, next_string_index: u8,
device_descriptor: DescriptorWriter<'d>,
config_descriptor: DescriptorWriter<'d>, config_descriptor: DescriptorWriter<'d>,
bos_descriptor: BosWriter<'d>, bos_descriptor: BosWriter<'d>,
@ -144,7 +143,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
pub fn new( pub fn new(
driver: D, driver: D,
config: Config<'d>, config: Config<'d>,
device_descriptor_buf: &'d mut [u8],
config_descriptor_buf: &'d mut [u8], config_descriptor_buf: &'d mut [u8],
bos_descriptor_buf: &'d mut [u8], bos_descriptor_buf: &'d mut [u8],
msos_descriptor_buf: &'d mut [u8], msos_descriptor_buf: &'d mut [u8],
@ -167,11 +165,9 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
_ => panic!("invalid max_packet_size_0, the allowed values are 8, 16, 32 or 64"), _ => panic!("invalid max_packet_size_0, the allowed values are 8, 16, 32 or 64"),
} }
let mut device_descriptor = DescriptorWriter::new(device_descriptor_buf);
let mut config_descriptor = DescriptorWriter::new(config_descriptor_buf); let mut config_descriptor = DescriptorWriter::new(config_descriptor_buf);
let mut bos_descriptor = BosWriter::new(DescriptorWriter::new(bos_descriptor_buf)); let mut bos_descriptor = BosWriter::new(DescriptorWriter::new(bos_descriptor_buf));
device_descriptor.device(&config);
config_descriptor.configuration(&config); config_descriptor.configuration(&config);
bos_descriptor.bos(); bos_descriptor.bos();
@ -183,7 +179,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
control_buf, control_buf,
next_string_index: STRING_INDEX_CUSTOM_START, next_string_index: STRING_INDEX_CUSTOM_START,
device_descriptor,
config_descriptor, config_descriptor,
bos_descriptor, bos_descriptor,
@ -199,7 +194,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
self.bos_descriptor.end_bos(); self.bos_descriptor.end_bos();
// Log the number of allocator bytes actually used in descriptor buffers // Log the number of allocator bytes actually used in descriptor buffers
info!("USB: device_descriptor used: {}", self.device_descriptor.position());
info!("USB: config_descriptor used: {}", self.config_descriptor.position()); info!("USB: config_descriptor used: {}", self.config_descriptor.position());
info!("USB: bos_descriptor used: {}", self.bos_descriptor.writer.position()); info!("USB: bos_descriptor used: {}", self.bos_descriptor.writer.position());
info!("USB: msos_descriptor used: {}", msos_descriptor.len()); info!("USB: msos_descriptor used: {}", msos_descriptor.len());
@ -209,7 +203,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
self.driver, self.driver,
self.config, self.config,
self.handlers, self.handlers,
self.device_descriptor.into_buf(),
self.config_descriptor.into_buf(), self.config_descriptor.into_buf(),
self.bos_descriptor.writer.into_buf(), self.bos_descriptor.writer.into_buf(),
msos_descriptor, msos_descriptor,

View File

@ -82,30 +82,6 @@ impl<'a> DescriptorWriter<'a> {
self.position = start + length; self.position = start + length;
} }
pub(crate) fn device(&mut self, config: &Config) {
self.write(
descriptor_type::DEVICE,
&[
0x10,
0x02, // bcdUSB 2.1
config.device_class, // bDeviceClass
config.device_sub_class, // bDeviceSubClass
config.device_protocol, // bDeviceProtocol
config.max_packet_size_0, // bMaxPacketSize0
config.vendor_id as u8,
(config.vendor_id >> 8) as u8, // idVendor
config.product_id as u8,
(config.product_id >> 8) as u8, // idProduct
config.device_release as u8,
(config.device_release >> 8) as u8, // bcdDevice
config.manufacturer.map_or(0, |_| 1), // iManufacturer
config.product.map_or(0, |_| 2), // iProduct
config.serial_number.map_or(0, |_| 3), // iSerialNumber
1, // bNumConfigurations
],
);
}
pub(crate) fn configuration(&mut self, config: &Config) { pub(crate) fn configuration(&mut self, config: &Config) {
self.num_interfaces_mark = Some(self.position + 4); self.num_interfaces_mark = Some(self.position + 4);
@ -269,6 +245,33 @@ impl<'a> DescriptorWriter<'a> {
} }
} }
/// Create a new Device Descriptor array.
///
/// All device descriptors are always 18 bytes, so there's no need for
/// a variable-length buffer or DescriptorWriter.
pub(crate) fn device_descriptor(config: &Config) -> [u8; 18] {
[
18, // bLength
0x01, // bDescriptorType
0x10,
0x02, // bcdUSB 2.1
config.device_class, // bDeviceClass
config.device_sub_class, // bDeviceSubClass
config.device_protocol, // bDeviceProtocol
config.max_packet_size_0, // bMaxPacketSize0
config.vendor_id as u8,
(config.vendor_id >> 8) as u8, // idVendor
config.product_id as u8,
(config.product_id >> 8) as u8, // idProduct
config.device_release as u8,
(config.device_release >> 8) as u8, // bcdDevice
config.manufacturer.map_or(0, |_| 1), // iManufacturer
config.product.map_or(0, |_| 2), // iProduct
config.serial_number.map_or(0, |_| 3), // iSerialNumber
1, // bNumConfigurations
]
}
/// A writer for Binary Object Store descriptor. /// A writer for Binary Object Store descriptor.
pub struct BosWriter<'a> { pub struct BosWriter<'a> {
pub(crate) writer: DescriptorWriter<'a>, pub(crate) writer: DescriptorWriter<'a>,

View File

@ -168,8 +168,6 @@ struct Interface {
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct UsbBufferReport { pub struct UsbBufferReport {
/// Number of device descriptor bytes used
pub device_descriptor_used: usize,
/// Number of config descriptor bytes used /// Number of config descriptor bytes used
pub config_descriptor_used: usize, pub config_descriptor_used: usize,
/// Number of bos descriptor bytes used /// Number of bos descriptor bytes used
@ -191,7 +189,7 @@ struct Inner<'d, D: Driver<'d>> {
bus: D::Bus, bus: D::Bus,
config: Config<'d>, config: Config<'d>,
device_descriptor: &'d [u8], device_descriptor: [u8; 18],
config_descriptor: &'d [u8], config_descriptor: &'d [u8],
bos_descriptor: &'d [u8], bos_descriptor: &'d [u8],
msos_descriptor: crate::msos::MsOsDescriptorSet<'d>, msos_descriptor: crate::msos::MsOsDescriptorSet<'d>,
@ -217,7 +215,6 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
driver: D, driver: D,
config: Config<'d>, config: Config<'d>,
handlers: Vec<&'d mut dyn Handler, MAX_HANDLER_COUNT>, handlers: Vec<&'d mut dyn Handler, MAX_HANDLER_COUNT>,
device_descriptor: &'d [u8],
config_descriptor: &'d [u8], config_descriptor: &'d [u8],
bos_descriptor: &'d [u8], bos_descriptor: &'d [u8],
msos_descriptor: crate::msos::MsOsDescriptorSet<'d>, msos_descriptor: crate::msos::MsOsDescriptorSet<'d>,
@ -227,6 +224,7 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
// Start the USB bus. // Start the USB bus.
// This prevent further allocation by consuming the driver. // This prevent further allocation by consuming the driver.
let (bus, control) = driver.start(config.max_packet_size_0 as u16); let (bus, control) = driver.start(config.max_packet_size_0 as u16);
let device_descriptor = descriptor::device_descriptor(&config);
Self { Self {
control_buf, control_buf,
@ -256,7 +254,6 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
/// Useful for tuning buffer sizes for actual usage /// Useful for tuning buffer sizes for actual usage
pub fn buffer_usage(&self) -> UsbBufferReport { pub fn buffer_usage(&self) -> UsbBufferReport {
UsbBufferReport { UsbBufferReport {
device_descriptor_used: self.inner.device_descriptor.len(),
config_descriptor_used: self.inner.config_descriptor.len(), config_descriptor_used: self.inner.config_descriptor.len(),
bos_descriptor_used: self.inner.bos_descriptor.len(), bos_descriptor_used: self.inner.bos_descriptor.len(),
msos_descriptor_used: self.inner.msos_descriptor.len(), msos_descriptor_used: self.inner.msos_descriptor.len(),
@ -720,7 +717,7 @@ impl<'d, D: Driver<'d>> Inner<'d, D> {
match dtype { match dtype {
descriptor_type::BOS => InResponse::Accepted(self.bos_descriptor), descriptor_type::BOS => InResponse::Accepted(self.bos_descriptor),
descriptor_type::DEVICE => InResponse::Accepted(self.device_descriptor), descriptor_type::DEVICE => InResponse::Accepted(&self.device_descriptor),
descriptor_type::CONFIGURATION => InResponse::Accepted(self.config_descriptor), descriptor_type::CONFIGURATION => InResponse::Accepted(self.config_descriptor),
descriptor_type::STRING => { descriptor_type::STRING => {
if index == 0 { if index == 0 {

View File

@ -255,7 +255,7 @@ use sealed::*;
unsafe fn transmute_write_to<T: Sized>(t: &T, buf: &mut [u8]) { unsafe fn transmute_write_to<T: Sized>(t: &T, buf: &mut [u8]) {
let bytes = core::slice::from_raw_parts((t as *const T) as *const u8, size_of::<T>()); let bytes = core::slice::from_raw_parts((t as *const T) as *const u8, size_of::<T>());
assert!(buf.len() >= bytes.len(), "MS OS descriptor buffer full"); assert!(buf.len() >= bytes.len(), "MS OS descriptor buffer full");
(&mut buf[..bytes.len()]).copy_from_slice(bytes); buf[..bytes.len()].copy_from_slice(bytes);
} }
/// Table 9. Microsoft OS 2.0 descriptor wDescriptorType values. /// Table 9. Microsoft OS 2.0 descriptor wDescriptorType values.
@ -444,9 +444,9 @@ impl CompatibleIdFeatureDescriptor {
pub fn new(compatible_id: &str, sub_compatible_id: &str) -> Self { pub fn new(compatible_id: &str, sub_compatible_id: &str) -> Self {
assert!(compatible_id.len() <= 8 && sub_compatible_id.len() <= 8); assert!(compatible_id.len() <= 8 && sub_compatible_id.len() <= 8);
let mut cid = [0u8; 8]; let mut cid = [0u8; 8];
(&mut cid[..compatible_id.len()]).copy_from_slice(compatible_id.as_bytes()); cid[..compatible_id.len()].copy_from_slice(compatible_id.as_bytes());
let mut scid = [0u8; 8]; let mut scid = [0u8; 8];
(&mut scid[..sub_compatible_id.len()]).copy_from_slice(sub_compatible_id.as_bytes()); scid[..sub_compatible_id.len()].copy_from_slice(sub_compatible_id.as_bytes());
Self::new_raw(cid, scid) Self::new_raw(cid, scid)
} }

View File

@ -41,7 +41,6 @@ async fn main(_spawner: Spawner) {
config.product = Some("USB-DFU Runtime example"); config.product = Some("USB-DFU Runtime example");
config.serial_number = Some("1235678"); config.serial_number = Some("1235678");
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -49,7 +48,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], &mut [],

View File

@ -49,7 +49,6 @@ fn main() -> ! {
let mut buffer = AlignedBuffer([0; WRITE_SIZE]); let mut buffer = AlignedBuffer([0; WRITE_SIZE]);
let updater = BlockingFirmwareUpdater::new(fw_config, &mut buffer.0[..]); let updater = BlockingFirmwareUpdater::new(fw_config, &mut buffer.0[..]);
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 4096]; let mut control_buf = [0; 4096];
@ -57,7 +56,6 @@ fn main() -> ! {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], &mut [],

View File

@ -70,7 +70,6 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01; config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new(); static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new();
@ -78,7 +77,6 @@ async fn main(spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..], &mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..], &mut BOS_DESC.init([0; 256])[..],
&mut MSOS_DESC.init([0; 128])[..], &mut MSOS_DESC.init([0; 128])[..],

View File

@ -50,7 +50,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256]; let mut msos_descriptor = [0; 256];
@ -63,7 +62,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -43,7 +43,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256]; let mut msos_descriptor = [0; 256];
@ -55,7 +54,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -48,7 +48,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256]; let mut msos_descriptor = [0; 256];
@ -59,7 +58,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -67,7 +67,6 @@ async fn main(spawner: Spawner) {
let state = STATE.init(State::new()); let state = STATE.init(State::new());
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new(); static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new();
@ -75,7 +74,6 @@ async fn main(spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..], &mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..], &mut BOS_DESC.init([0; 256])[..],
&mut MSOS_DESC.init([0; 128])[..], &mut MSOS_DESC.init([0; 128])[..],

View File

@ -53,7 +53,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256]; let mut msos_descriptor = [0; 256];
@ -64,7 +63,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -60,7 +60,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -70,7 +69,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -64,14 +64,12 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01; config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..], &mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..], &mut BOS_DESC.init([0; 256])[..],
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -36,7 +36,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
// You can also add a Microsoft OS descriptor. // You can also add a Microsoft OS descriptor.
@ -50,7 +49,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -39,7 +39,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
// You can also add a Microsoft OS descriptor. // You can also add a Microsoft OS descriptor.
@ -53,7 +52,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -46,7 +46,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -54,7 +53,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -93,7 +93,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256]; let mut msos_descriptor = [0; 256];
@ -106,7 +105,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -71,7 +71,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256]; let mut msos_descriptor = [0; 256];
@ -80,7 +79,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -46,7 +46,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -56,7 +55,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -46,7 +46,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -57,7 +56,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -60,7 +60,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 7]; let mut control_buf = [0; 7];
@ -70,7 +69,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -54,7 +54,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 7]; let mut control_buf = [0; 7];
@ -64,7 +63,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -89,14 +89,12 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01; config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..], &mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..], &mut BOS_DESC.init([0; 256])[..],
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -69,7 +69,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
// You can also add a Microsoft OS descriptor. // You can also add a Microsoft OS descriptor.
@ -84,7 +83,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -64,7 +64,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -76,7 +75,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -117,7 +117,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256]; let mut msos_descriptor = [0; 256];
@ -130,7 +129,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut msos_descriptor, &mut msos_descriptor,

View File

@ -64,7 +64,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -74,7 +73,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -64,7 +64,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -74,7 +73,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -36,7 +36,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 7]; let mut control_buf = [0; 7];
@ -46,7 +45,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -56,7 +56,6 @@ async fn main(_spawner: Spawner) {
config.device_protocol = 0x01; config.device_protocol = 0x01;
config.composite_with_iads = true; config.composite_with_iads = true;
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -66,7 +65,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -65,7 +65,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -75,7 +74,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -65,7 +65,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -75,7 +74,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -46,7 +46,6 @@ async fn main(_spawner: Spawner) {
config.device_protocol = 0x01; config.device_protocol = 0x01;
config.composite_with_iads = true; config.composite_with_iads = true;
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -56,7 +55,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -60,7 +60,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -70,7 +69,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -79,14 +79,12 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01; config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..], &mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..], &mut BOS_DESC.init([0; 256])[..],
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -51,7 +51,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -62,7 +61,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -47,7 +47,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 7]; let mut control_buf = [0; 7];
@ -57,7 +56,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors

View File

@ -61,7 +61,6 @@ async fn main(_spawner: Spawner) {
// Create embassy-usb DeviceBuilder using the driver and config. // Create embassy-usb DeviceBuilder using the driver and config.
// It needs some buffers for building the descriptors. // It needs some buffers for building the descriptors.
let mut device_descriptor = [0; 256];
let mut config_descriptor = [0; 256]; let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256]; let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64]; let mut control_buf = [0; 64];
@ -71,7 +70,6 @@ async fn main(_spawner: Spawner) {
let mut builder = Builder::new( let mut builder = Builder::new(
driver, driver,
config, config,
&mut device_descriptor,
&mut config_descriptor, &mut config_descriptor,
&mut bos_descriptor, &mut bos_descriptor,
&mut [], // no msos descriptors &mut [], // no msos descriptors