Skip to content

Commit 4a0fff5

Browse files
committed
Remove debug code, rustfmt
1 parent c612089 commit 4a0fff5

File tree

2 files changed

+16
-223
lines changed

2 files changed

+16
-223
lines changed

hal/src/thumbv6m/usb/bus.rs

Lines changed: 8 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ impl UsbBus {
586586
dp_pad: impl AnyPin<Id = PA25>,
587587
_usb: USB,
588588
) -> Self {
589-
dbgprint!("******** UsbBus::new\n");
590589
pm.apbbmask.modify(|_, w| w.usb_().set_bit());
591590

592591
let desc = RefCell::new(Descriptors::new());
@@ -612,12 +611,6 @@ impl Inner {
612611

613612
fn set_stall<EP: Into<EndpointAddress>>(&self, ep: EP, stall: bool) {
614613
let ep = ep.into();
615-
dbgprint!(
616-
"UsbBus::stall={} for {:?} {}\n",
617-
stall,
618-
ep.direction(),
619-
ep.index()
620-
);
621614
if ep.is_out() {
622615
if let Ok(mut bank) = self.bank0(ep) {
623616
bank.set_stall(stall);
@@ -626,47 +619,6 @@ impl Inner {
626619
bank.set_stall(stall);
627620
}
628621
}
629-
630-
#[allow(unused_variables)]
631-
fn print_epstatus(&self, ep: usize, label: &str) {
632-
let status = self.epstatus(ep).read();
633-
let epint = self.epintflag(ep).read();
634-
let intflag = self.usb().intflag.read();
635-
636-
#[allow(unused_mut)]
637-
let mut desc = self.desc.borrow_mut();
638-
639-
dbgprint!("ep{} status {}:\n bk1rdy={} stallrq1={} stall1={} trcpt1={} trfail1={} byte_count1={} multi_packet_size1={}\n bk0rdy={} stallrq0={} stall0={} trcpt0={} trfail0={} byte_count0={} multi_packet_size0={}\n curbk={} dtglin={} dtglout={} rxstp={} lpmsusp={} lpmnyet={} ramacer={} uprsm={} eorsm={} wakeup={} eorst={} sof={} suspend={}\n",
640-
ep, label,
641-
status.bk1rdy().bit() as u8,
642-
status.stallrq1().bit() as u8,
643-
epint.stall1().bit() as u8,
644-
epint.trcpt1().bit() as u8,
645-
epint.trfail1().bit() as u8,
646-
desc.bank(ep, 1).get_byte_count(),
647-
desc.bank(ep, 1).get_multi_packet_size(),
648-
status.bk0rdy().bit() as u8,
649-
status.stallrq0().bit() as u8,
650-
epint.stall0().bit() as u8,
651-
epint.trcpt0().bit() as u8,
652-
epint.trfail0().bit() as u8,
653-
desc.bank(ep, 0).get_byte_count(),
654-
desc.bank(ep, 0).get_multi_packet_size(),
655-
status.curbk().bit() as u8,
656-
status.dtglin().bit() as u8,
657-
status.dtglout().bit() as u8,
658-
epint.rxstp().bit() as u8,
659-
intflag.lpmsusp().bit() as u8,
660-
intflag.lpmnyet().bit() as u8,
661-
intflag.ramacer().bit() as u8,
662-
intflag.uprsm().bit() as u8,
663-
intflag.eorsm().bit() as u8,
664-
intflag.wakeup().bit() as u8,
665-
intflag.eorst().bit() as u8,
666-
intflag.sof().bit() as u8,
667-
intflag.suspend().bit() as u8,
668-
);
669-
}
670622
}
671623

672624
#[derive(Copy, Clone)]
@@ -679,7 +631,6 @@ enum FlushConfigMode {
679631

680632
impl Inner {
681633
fn enable(&mut self) {
682-
dbgprint!("UsbBus::enable\n");
683634
let usb = self.usb();
684635
usb.ctrla.modify(|_, w| w.swrst().set_bit());
685636
while usb.syncbusy.read().swrst().bit_is_set() {}
@@ -786,16 +737,12 @@ impl Inner {
786737
/// protocol_reset is called by the USB HAL when it detects the host has
787738
/// performed a USB reset.
788739
fn protocol_reset(&self) {
789-
dbgprint!("UsbBus::reset\n");
790740
self.flush_eps(FlushConfigMode::ProtocolReset);
791741
}
792742

793-
fn suspend(&self) {
794-
dbgprint!("UsbBus::suspend\n");
795-
}
796-
fn resume(&self) {
797-
dbgprint!("UsbBus::resume\n");
798-
}
743+
fn suspend(&self) {}
744+
745+
fn resume(&self) {}
799746

800747
fn alloc_ep(
801748
&mut self,
@@ -822,15 +769,6 @@ impl Inner {
822769

823770
let buffer = self.buffers.borrow_mut().allocate_buffer(allocated_size)?;
824771

825-
dbgprint!(
826-
"UsbBus::alloc_ep dir={:?} addr={:?} type={:?} max_packet_size={} interval={}\n",
827-
dir,
828-
addr,
829-
ep_type,
830-
max_packet_size,
831-
interval
832-
);
833-
834772
let mut endpoints = self.endpoints.borrow_mut();
835773

836774
let idx = match addr {
@@ -848,13 +786,10 @@ impl Inner {
848786
buffer,
849787
)?;
850788

851-
dbgprint!("alloc_ep -> {:?}\n", addr);
852-
853789
Ok(addr)
854790
}
855791

856792
fn set_device_address(&self, addr: u8) {
857-
dbgprint!("UsbBus::set_device_address addr={}\n", addr);
858793
self.usb()
859794
.dadd
860795
.write(|w| unsafe { w.dadd().bits(addr).adden().set_bit() });
@@ -865,7 +800,6 @@ impl Inner {
865800
if intflags.eorst().bit() {
866801
// end of reset interrupt
867802
self.usb().intflag.write(|w| w.eorst().set_bit());
868-
dbgprint!("PollResult::Reset\n");
869803
return PollResult::Reset;
870804
}
871805
// As the suspend & wakup interrupts/states cannot distinguish between
@@ -892,7 +826,6 @@ impl Inner {
892826
if let Ok(bank1) = self.bank1(EndpointAddress::from_parts(idx, UsbDirection::In)) {
893827
if bank1.is_transfer_complete() {
894828
bank1.clear_transfer_complete();
895-
dbgprint!("ep {} WRITE DONE\n", ep);
896829
ep_in_complete |= mask;
897830
// Continuing (and hence not setting masks to indicate complete
898831
// OUT transfers) is necessary for operation to proceed beyond
@@ -908,12 +841,12 @@ impl Inner {
908841

909842
if let Ok(bank0) = self.bank0(EndpointAddress::from_parts(idx, UsbDirection::Out)) {
910843
if bank0.received_setup_interrupt() {
911-
dbgprint!("ep {} GOT SETUP\n", ep);
912844
ep_setup |= mask;
913845
// usb-device crate:
914-
// "This event should continue to be reported until the packet
915-
// is read." So we don't clear the flag here,
916-
// instead it is cleared in the read handler.
846+
// "This event should continue to be reported until the
847+
// packet is read."
848+
// So we don't clear the flag here, instead it is cleared in
849+
// the read handler.
917850
}
918851

919852
// Use the bk0rdy flag via is_ready() to indicate that data has been
@@ -922,7 +855,6 @@ impl Inner {
922855
// earlier poll() which cleared trcpt0. bk0rdy is cleared in the
923856
// endpoint read().
924857
if bank0.is_ready() {
925-
dbgprint!("ep {} READABLE\n", ep);
926858
ep_out |= mask;
927859
}
928860

@@ -948,13 +880,6 @@ impl Inner {
948880

949881
if bank.is_ready() {
950882
// Waiting for the host to pick up the existing data
951-
dbgprint!(
952-
"UsbBus::write {} bytes {:?} to ep {:?} -> BUSY trcpt1={}\n",
953-
buf.len(),
954-
buf,
955-
ep,
956-
bank.is_transfer_complete()
957-
);
958883
return Err(UsbError::WouldBlock);
959884
}
960885

@@ -963,14 +888,6 @@ impl Inner {
963888
bank.clear_transfer_complete();
964889
bank.set_ready(true); // ready to be sent
965890

966-
dbgprint!(
967-
"UsbBus::write {} bytes {:?} to ep {:?} -> {:?}\n",
968-
buf.len(),
969-
buf,
970-
ep,
971-
size
972-
);
973-
974891
size
975892
}
976893

@@ -985,28 +902,9 @@ impl Inner {
985902
bank.clear_received_setup_interrupt();
986903
}
987904

988-
// self.print_epstatus(idx, "read");
989905
bank.set_ready(false);
990906

991-
drop(bank);
992-
993-
match size {
994-
Ok(size) => {
995-
//dbgprint!("UsbBus::read {} bytes ok", size);
996-
dbgprint!(
997-
"UsbBus::read {} bytes from ep {:?} -> {:?}\n",
998-
size,
999-
ep,
1000-
&buf[..size as usize]
1001-
);
1002-
Ok(size)
1003-
}
1004-
Err(err) => {
1005-
dbgprint!("UsbBus::read from ep {:?} -> {:?}\n", ep, err);
1006-
self.print_epstatus(ep.index(), "after read");
1007-
Err(err)
1008-
}
1009-
}
907+
size
1010908
} else {
1011909
Err(UsbError::WouldBlock)
1012910
}

0 commit comments

Comments
 (0)