feat: separate constructor for UsbDevice and UsbBusAllocator

This commit is contained in:
doryan 2025-04-25 15:40:19 +04:00
parent f399278d2c
commit 995bfd0169

View File

@ -83,14 +83,19 @@ pub(crate) const ONE_MS_16_MGHZ: u32 = 16000;
impl<const L: usize> UsbDevice<L> { impl<const L: usize> UsbDevice<L> {
#[inline] #[inline]
pub fn create_usb_allocator(pll: PLL, usb: USB_DEVICE) -> UsbBusAllocator<Self> { pub fn new(pll: PLL, usb: USB_DEVICE) -> Self {
UsbBusAllocator::new(Self { Self {
pll: Mutex::new(pll), pll: Mutex::new(pll),
usb: Mutex::new(usb), usb: Mutex::new(usb),
ep_table: [USBEndpoint::default(); L], ep_table: [USBEndpoint::default(); L],
pending_ins: Mutex::new(Cell::new(0u8)), pending_ins: Mutex::new(Cell::new(0u8)),
dpram_already_used: 0, dpram_already_used: 0,
}) }
}
#[inline]
pub fn into_usb_allocator(self) -> UsbBusAllocator<Self> {
UsbBusAllocator::new(self)
} }
#[inline(always)] #[inline(always)]