use crate::{Register, IER};
impl<R: Register> IER<R> {
#[inline]
pub fn write(&self, val: InterruptTypes) {
unsafe { self.0.get().write_volatile(R::from(val.0)) }
}
#[inline]
pub fn read(&self) -> InterruptTypes {
InterruptTypes(unsafe { self.0.get().read_volatile() }.val())
}
}
#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)]
#[repr(transparent)]
pub struct InterruptTypes(u8);
impl InterruptTypes {
pub const ZERO: Self = Self(0);
const RDA: u8 = 1 << 0;
const THRE: u8 = 1 << 1;
const RLS: u8 = 1 << 2;
const MS: u8 = 1 << 3;
#[inline]
pub const fn enable_rda(self) -> Self {
Self(self.0 | Self::RDA)
}
#[inline]
pub const fn disable_rda(self) -> Self {
Self(self.0 & !Self::RDA)
}
#[inline]
pub const fn rda_enabled(self) -> bool {
self.0 & Self::RDA == Self::RDA
}
#[inline]
pub const fn enable_thre(self) -> Self {
Self(self.0 | Self::THRE)
}
#[inline]
pub const fn disable_thre(self) -> Self {
Self(self.0 & !Self::THRE)
}
#[inline]
pub const fn thre_enabled(self) -> bool {
self.0 & Self::THRE == Self::THRE
}
#[inline]
pub const fn enable_rls(self) -> Self {
Self(self.0 | Self::RLS)
}
#[inline]
pub const fn disable_rls(self) -> Self {
Self(self.0 & !Self::RLS)
}
#[inline]
pub const fn rls_enabled(self) -> bool {
self.0 & Self::RLS == Self::RLS
}
#[inline]
pub const fn enable_ms(self) -> Self {
Self(self.0 | Self::MS)
}
#[inline]
pub const fn disable_ms(self) -> Self {
Self(self.0 & !Self::MS)
}
#[inline]
pub const fn ms_enabled(self) -> bool {
self.0 & Self::MS == Self::MS
}
}