use crate::{Register, IIR_FCR};
impl<R: Register> IIR_FCR<R> {
#[inline]
pub fn read(&self) -> InterruptIdentification {
InterruptIdentification(unsafe { self.0.get().read_volatile() }.val())
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[repr(transparent)]
pub struct InterruptIdentification(u8);
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum PendingInterrupt {
ReceiverLineStatus,
ReceivedDataAvailable,
ReceivedDataTimeout,
TransmitterHoldingRegisterEmpty,
ModemStatus,
}
impl InterruptIdentification {
#[inline]
pub const fn pending_interrupts(&self) -> Option<PendingInterrupt> {
match self.0 & 0b1111 {
0b0110 => Some(PendingInterrupt::ReceiverLineStatus),
0b0100 => Some(PendingInterrupt::ReceivedDataAvailable),
0b1100 => Some(PendingInterrupt::ReceivedDataTimeout),
0b0010 => Some(PendingInterrupt::TransmitterHoldingRegisterEmpty),
0b0000 => Some(PendingInterrupt::ModemStatus),
0b0001 => None,
_ => unreachable!(),
}
}
#[inline]
pub const fn fifos_enabled(&self) -> bool {
self.0 & 0b1100_0000 == 0b1100_0000
}
}