Compare commits

..

No commits in common. "ae466a8aad625d3edd289d2b928019929defa8ef" and "29e5edde8abbb286d9fac38eeb0d8074589b1706" have entirely different histories.

2 changed files with 12 additions and 10 deletions

View File

@ -38,11 +38,9 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
// If ep_aadr not provided, or current endpoint is allocated, try to find next free endpoint, otherwise return UsbError. // // If ep_aadr not provided, or current endpoint is allocated, try to find next free endpoint, otherwise return UsbError. //
_ => { _ => {
let index = self let index = self.ep_table[1..]
.ep_table
.iter() .iter()
.enumerate() .enumerate()
.skip(1)
.find(|(index, ep)| { .find(|(index, ep)| {
!ep.is_allocated && max_packet_size <= ENDPOINTS_ALLOC_LAYOUT[*index] !ep.is_allocated && max_packet_size <= ENDPOINTS_ALLOC_LAYOUT[*index]
}) })

View File

@ -84,6 +84,7 @@ 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 new(pll: PLL, usb: USB_DEVICE) -> UsbBusAllocator<Self> { pub fn new(pll: PLL, usb: USB_DEVICE) -> UsbBusAllocator<Self> {
if L > 1 {
UsbBusAllocator::new(Self { UsbBusAllocator::new(Self {
pll: Mutex::new(pll), pll: Mutex::new(pll),
usb: Mutex::new(usb), usb: Mutex::new(usb),
@ -91,6 +92,9 @@ impl<const L: usize> UsbDevice<L> {
pending_ins: Mutex::new(Cell::new(0u8)), pending_ins: Mutex::new(Cell::new(0u8)),
dpram_already_used: 0, dpram_already_used: 0,
}) })
} else {
panic!("Endpoint table cannot be with length <= 1")
}
} }
#[inline(always)] #[inline(always)]