embassy_stm32_plus/builder/usb/
buf.rs

1/// usb buffer
2pub struct UsbBuf<const DD: usize, const CD: usize, const BD: usize, const CB: usize> {
3    pub device_descriptor: [u8; DD],
4    pub config_descriptor: [u8; CD],
5    pub bos_descriptor: [u8; BD],
6    pub control_buf: [u8; CB],
7}
8
9/// custom method
10impl<const DD: usize, const CD: usize, const BD: usize, const CB: usize> UsbBuf<DD, CD, BD, CB> {
11    /// create usb buf
12    pub fn new(device_descriptor: [u8; DD], config_descriptor: [u8; CD], bos_descriptor: [u8; BD], control_buf: [u8; CB]) -> Self {
13        Self { device_descriptor, config_descriptor, bos_descriptor, control_buf }
14    }
15}
16
17/// support default
18impl Default for UsbBuf<256, 256, 256, 7> {
19    fn default() -> Self {
20        Self {
21            device_descriptor: [0; 256],
22            config_descriptor: [0; 256],
23            bos_descriptor: [0; 256],
24            control_buf: [0; 7],
25        }
26    }
27}