Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a800e28303 | ||
|
16e254d7dc |
|
@ -190,7 +190,6 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
|||
|
||||
if usb.usbcon.read().frzclk().bit_is_clear() {
|
||||
let (mut ep_out, mut ep_in_complete, mut ep_setup) = (0u16, 0u16, 0u16);
|
||||
let pending_ins = self.pending_ins.borrow(cs);
|
||||
|
||||
for (ep_index, _ep) in self.allocated_endpoints() {
|
||||
if self.select_endpoint(cs, ep_index).is_err() {
|
||||
|
@ -205,9 +204,8 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
|||
ep_setup |= 1 << ep_index;
|
||||
}
|
||||
|
||||
if pending_ins.get() & (1 << ep_index) != 0 && ueintx.txini().bit_is_set() {
|
||||
if ueintx.txini().bit_is_set() {
|
||||
ep_in_complete |= 1 << ep_index;
|
||||
pending_ins.set(pending_ins.get() & !(1 << ep_index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -452,9 +450,6 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
|||
}
|
||||
};
|
||||
|
||||
let pending_ins = self.pending_ins.borrow(cs);
|
||||
pending_ins.set(pending_ins.get() | 1 << ep_addr.index());
|
||||
|
||||
Ok(buf.len())
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use core::cell::Cell;
|
||||
|
||||
use avr_device::{
|
||||
atmega32u4::{PLL, USB_DEVICE},
|
||||
interrupt::{CriticalSection, Mutex},
|
||||
|
@ -8,7 +6,7 @@ use usb_device::{bus::UsbBusAllocator, endpoint::EndpointType, UsbDirection, Usb
|
|||
|
||||
#[allow(unused)]
|
||||
#[derive(Default, Copy, Clone)]
|
||||
pub(crate) struct USBEndpoint {
|
||||
pub struct USBEndpoint {
|
||||
pub(crate) is_allocated: bool,
|
||||
pub(crate) size: u8,
|
||||
pub(crate) ep_type: u8,
|
||||
|
@ -72,7 +70,6 @@ pub struct UsbDevice<const L: usize> {
|
|||
pub(crate) pll: Mutex<PLL>,
|
||||
pub(crate) usb: Mutex<USB_DEVICE>,
|
||||
pub(crate) ep_table: [USBEndpoint; L],
|
||||
pub(crate) pending_ins: Mutex<Cell<u8>>,
|
||||
pub(crate) dpram_already_used: u16,
|
||||
}
|
||||
|
||||
|
@ -88,7 +85,6 @@ impl<const L: usize> UsbDevice<L> {
|
|||
pll: Mutex::new(pll),
|
||||
usb: Mutex::new(usb),
|
||||
ep_table: [USBEndpoint::default(); L],
|
||||
pending_ins: Mutex::new(Cell::new(0u8)),
|
||||
dpram_already_used: 0,
|
||||
})
|
||||
}
|
||||
|
@ -136,6 +132,10 @@ impl<const L: usize> UsbDevice<L> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_ep_table(&self) -> &[USBEndpoint] {
|
||||
&self.ep_table
|
||||
}
|
||||
|
||||
pub(crate) fn configure_endpoint(
|
||||
&self,
|
||||
cs: CriticalSection<'_>,
|
||||
|
|
Loading…
Reference in New Issue