pub type R = crate::R<POWERrs>;
pub type W = crate::W<POWERrs>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PWRCTRL {
PowerOff = 0,
PowerOn = 3,
}
impl From<PWRCTRL> for u8 {
#[inline(always)]
fn from(variant: PWRCTRL) -> Self {
variant as _
}
}
impl crate::FieldSpec for PWRCTRL {
type Ux = u8;
}
impl crate::IsEnum for PWRCTRL {}
pub type PWRCTRL_R = crate::FieldReader<PWRCTRL>;
impl PWRCTRL_R {
#[inline(always)]
pub const fn variant(&self) -> Option<PWRCTRL> {
match self.bits {
0 => Some(PWRCTRL::PowerOff),
3 => Some(PWRCTRL::PowerOn),
_ => None,
}
}
#[inline(always)]
pub fn is_power_off(&self) -> bool {
*self == PWRCTRL::PowerOff
}
#[inline(always)]
pub fn is_power_on(&self) -> bool {
*self == PWRCTRL::PowerOn
}
}
pub type PWRCTRL_W<'a, REG> = crate::FieldWriter<'a, REG, 2, PWRCTRL>;
impl<'a, REG> PWRCTRL_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn power_off(self) -> &'a mut crate::W<REG> {
self.variant(PWRCTRL::PowerOff)
}
#[inline(always)]
pub fn power_on(self) -> &'a mut crate::W<REG> {
self.variant(PWRCTRL::PowerOn)
}
}
impl R {
#[inline(always)]
pub fn pwrctrl(&self) -> PWRCTRL_R {
PWRCTRL_R::new((self.bits & 3) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("POWER")
.field("pwrctrl", &self.pwrctrl())
.finish()
}
}
impl W {
#[inline(always)]
pub fn pwrctrl(&mut self) -> PWRCTRL_W<POWERrs> {
PWRCTRL_W::new(self, 0)
}
}
pub struct POWERrs;
impl crate::RegisterSpec for POWERrs {
type Ux = u32;
}
impl crate::Readable for POWERrs {}
impl crate::Writable for POWERrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for POWERrs {}