code improvement
change variable names + using if let conditions instead match for Result/Options values
This commit is contained in:
parent
e27c5e7803
commit
c5788c5b2e
16
src/lib.rs
16
src/lib.rs
|
@ -146,9 +146,11 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
|||
}
|
||||
|
||||
fn is_stalled(&self, ep_addr: EndpointAddress) -> bool {
|
||||
free(|cs| match self.select_endpoint(cs, ep_addr.index()) {
|
||||
Ok(_) => self.usb.borrow(cs).ueconx.read().stallrq().bit_is_set(),
|
||||
Err(_) => false,
|
||||
free(|cs| {
|
||||
if self.select_endpoint(cs, ep_addr.index()).is_ok() {
|
||||
return self.usb.borrow(cs).ueconx.read().stallrq().bit_is_set();
|
||||
}
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -223,8 +225,8 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
|||
free(|cs| {
|
||||
let usb = self.usb.borrow(cs);
|
||||
|
||||
if let Err(error) = self.select_endpoint(cs, ep_addr.index()) {
|
||||
Err(error)
|
||||
if let Err(usb_error) = self.select_endpoint(cs, ep_addr.index()) {
|
||||
Err(usb_error)
|
||||
} else {
|
||||
let ep = &self.ep_table[ep_addr.index()];
|
||||
|
||||
|
@ -261,11 +263,11 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
|||
.write(|w| w.clear_interrupts().rxouti().clear_bit());
|
||||
|
||||
let mut bytes_read = 0;
|
||||
for slot in buf {
|
||||
for data in buf {
|
||||
if usb.ueintx.read().rwal().bit_is_clear() {
|
||||
break;
|
||||
}
|
||||
*slot = usb.uedatx.read().bits();
|
||||
*data = usb.uedatx.read().bits();
|
||||
bytes_read += 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue