fix(const): use mask as constant value instead magic number
This commit is contained in:
parent
b1dd7eea9d
commit
7c3fcdabcc
|
@ -84,6 +84,8 @@ pub(crate) const ONE_MS_16_MGHZ: u32 = 16000;
|
|||
const UDINT_BYTE: u8 = 0x7d;
|
||||
const USBINT_BYTE: u8 = 0x01;
|
||||
const UEINTX_BYTE: u8 = 0xdf;
|
||||
const UENUM_MASK: u8 = 0b111;
|
||||
|
||||
pub(crate) trait InterruptCleaner {
|
||||
fn clear_interrupts(&mut self) -> &mut Self;
|
||||
}
|
||||
|
@ -142,9 +144,8 @@ impl<const L: usize> UsbDevice<L> {
|
|||
endpoint_index: usize,
|
||||
) -> Result<(), UsbError> {
|
||||
let usb = self.usb.borrow(cs);
|
||||
let endpoint_index = endpoint_index as u8;
|
||||
|
||||
if endpoint_index >= 7 {
|
||||
if endpoint_index >= MAX_ENDPOINTS {
|
||||
return Err(UsbError::InvalidEndpoint);
|
||||
}
|
||||
|
||||
|
@ -152,9 +153,9 @@ impl<const L: usize> UsbDevice<L> {
|
|||
return Err(UsbError::InvalidState);
|
||||
}
|
||||
|
||||
usb.uenum.write(|w| w.bits(endpoint_index));
|
||||
usb.uenum.write(|w| w.bits(endpoint_index as u8));
|
||||
|
||||
if usb.uenum.read().bits() & 7 /* 0b111 */ != endpoint_index {
|
||||
if usb.uenum.read().bits() & UENUM_MASK != endpoint_index as u8 {
|
||||
return Err(UsbError::InvalidEndpoint);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue