This commit is contained in:
2024-11-14 02:14:03 +04:00
parent 7436a78885
commit 16812fe119
2 changed files with 23 additions and 10 deletions

View File

@@ -10,7 +10,9 @@ use usb_device::{
};
mod types;
use types::{UsbDevice, DPRAM_SIZE, ENDPOINTS_ALLOC_LAYOUT};
pub use types::UsbDevice;
use types::{DPRAM_SIZE, ENDPOINTS_ALLOC_LAYOUT};
impl<const L: usize> UsbBus for UsbDevice<L> {
fn alloc_ep(
@@ -104,6 +106,10 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
usb.usbcon
.modify(|_, w| w.frzclk().clear_bit().otgpade().set_bit());
self.allocated_endpoints().for_each(|(i, _)| {
self.configure_endpoint(cs, i).unwrap();
});
// Interrupts. //
usb.udien
@@ -165,12 +171,7 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
if usb.usbcon.read().frzclk().bit_is_clear() {
let (mut ep_out, mut ep_setup, mut ep_in_complete) = (0u8, 0u8, 0u8);
for (index, _ep) in self
.ep_table
.iter()
.enumerate()
.filter(|(_i, e)| e.is_allocated)
{
for (index, _ep) in self.allocated_endpoints() {
if self.select_endpoint(cs, index).is_err() {
// Endpoint selection has stopped working...
break;
@@ -273,6 +274,10 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
}
});
self.allocated_endpoints().for_each(|(i, _)| {
self.configure_endpoint(cs, i).unwrap();
});
// Reset endpoints //
usb.uerst.modify(|_, w| unsafe { w.bits(u8::MAX >> 1) });