feat(conditions): use if let ... conditions instead match
This commit is contained in:
parent
18a3368565
commit
b1dd7eea9d
|
@ -169,41 +169,42 @@ impl<const L: usize> UsbDevice<L> {
|
||||||
let usb = self.usb.borrow(cs);
|
let usb = self.usb.borrow(cs);
|
||||||
let current_endpoint = self.ep_table[endpoint_index];
|
let current_endpoint = self.ep_table[endpoint_index];
|
||||||
|
|
||||||
match self.select_endpoint(cs, endpoint_index) {
|
let select_endpoint_result = self.select_endpoint(cs, endpoint_index);
|
||||||
Ok(_) => {
|
|
||||||
// Enable endpoint. //
|
|
||||||
|
|
||||||
usb.ueconx.modify(|_, w| w.epen().set_bit());
|
if select_endpoint_result.is_err() {
|
||||||
usb.uecfg1x.modify(|_, w| w.alloc().clear_bit());
|
select_endpoint_result
|
||||||
|
} else {
|
||||||
|
// Enable endpoint. //
|
||||||
|
|
||||||
// Set markered endpoint parameters to uecfg0x/1x register. //
|
usb.ueconx.modify(|_, w| w.epen().set_bit());
|
||||||
|
usb.uecfg1x.modify(|_, w| w.alloc().clear_bit());
|
||||||
|
|
||||||
usb.uecfg0x.modify(|_, w| {
|
// Set markered endpoint parameters to uecfg0x/1x register. //
|
||||||
w.epdir()
|
|
||||||
.bit(current_endpoint.ep_dir)
|
|
||||||
.eptype()
|
|
||||||
.bits(current_endpoint.ep_type)
|
|
||||||
});
|
|
||||||
|
|
||||||
usb.uecfg1x.modify(|_, w| {
|
usb.uecfg0x.modify(|_, w| {
|
||||||
w.epbk()
|
w.epdir()
|
||||||
.bits(0)
|
.bit(current_endpoint.ep_dir)
|
||||||
.epsize()
|
.eptype()
|
||||||
.bits(current_endpoint.size)
|
.bits(current_endpoint.ep_type)
|
||||||
.alloc()
|
});
|
||||||
.set_bit()
|
|
||||||
});
|
|
||||||
|
|
||||||
if usb.uesta0x.read().cfgok().bit_is_clear() {
|
usb.uecfg1x.modify(|_, w| {
|
||||||
Err(UsbError::EndpointMemoryOverflow)
|
w.epbk()
|
||||||
} else {
|
.bits(0)
|
||||||
usb.ueienx
|
.epsize()
|
||||||
.modify(|_, w| w.rxoute().set_bit().rxstpe().set_bit());
|
.bits(current_endpoint.size)
|
||||||
|
.alloc()
|
||||||
|
.set_bit()
|
||||||
|
});
|
||||||
|
|
||||||
Ok(())
|
if usb.uesta0x.read().cfgok().bit_is_clear() {
|
||||||
}
|
Err(UsbError::EndpointMemoryOverflow)
|
||||||
|
} else {
|
||||||
|
usb.ueienx
|
||||||
|
.modify(|_, w| w.rxoute().set_bit().rxstpe().set_bit());
|
||||||
|
|
||||||
|
select_endpoint_result
|
||||||
}
|
}
|
||||||
Err(exception) => Err(exception),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue