pub type R = crate::R<OPTCRrs>;
pub type W = crate::W<OPTCRrs>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OPTLOCKR {
Unlocked = 0,
Locked = 1,
}
impl From<OPTLOCKR> for bool {
#[inline(always)]
fn from(variant: OPTLOCKR) -> Self {
variant as u8 != 0
}
}
pub type OPTLOCK_R = crate::BitReader<OPTLOCKR>;
impl OPTLOCK_R {
#[inline(always)]
pub const fn variant(&self) -> OPTLOCKR {
match self.bits {
false => OPTLOCKR::Unlocked,
true => OPTLOCKR::Locked,
}
}
#[inline(always)]
pub fn is_unlocked(&self) -> bool {
*self == OPTLOCKR::Unlocked
}
#[inline(always)]
pub fn is_locked(&self) -> bool {
*self == OPTLOCKR::Locked
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OPTLOCKW {
Set = 1,
}
impl From<OPTLOCKW> for bool {
#[inline(always)]
fn from(variant: OPTLOCKW) -> Self {
variant as u8 != 0
}
}
pub type OPTLOCK_W<'a, REG> = crate::BitWriter<'a, REG, OPTLOCKW>;
impl<'a, REG> OPTLOCK_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn set_(self) -> &'a mut crate::W<REG> {
self.variant(OPTLOCKW::Set)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OPTSTRTR {
Complete = 0,
Requested = 1,
}
impl From<OPTSTRTR> for bool {
#[inline(always)]
fn from(variant: OPTSTRTR) -> Self {
variant as u8 != 0
}
}
pub type OPTSTRT_R = crate::BitReader<OPTSTRTR>;
impl OPTSTRT_R {
#[inline(always)]
pub const fn variant(&self) -> OPTSTRTR {
match self.bits {
false => OPTSTRTR::Complete,
true => OPTSTRTR::Requested,
}
}
#[inline(always)]
pub fn is_complete(&self) -> bool {
*self == OPTSTRTR::Complete
}
#[inline(always)]
pub fn is_requested(&self) -> bool {
*self == OPTSTRTR::Requested
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OPTSTRTW {
Set = 1,
}
impl From<OPTSTRTW> for bool {
#[inline(always)]
fn from(variant: OPTSTRTW) -> Self {
variant as u8 != 0
}
}
pub type OPTSTRT_W<'a, REG> = crate::BitWriter<'a, REG, OPTSTRTW>;
impl<'a, REG> OPTSTRT_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn set_(self) -> &'a mut crate::W<REG> {
self.variant(OPTSTRTW::Set)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum BOR_LEV {
BorOff = 0,
BorLevel1 = 1,
BorLevel2 = 2,
BorLevel3 = 3,
}
impl From<BOR_LEV> for u8 {
#[inline(always)]
fn from(variant: BOR_LEV) -> Self {
variant as _
}
}
impl crate::FieldSpec for BOR_LEV {
type Ux = u8;
}
impl crate::IsEnum for BOR_LEV {}
pub type BOR_LEV_R = crate::FieldReader<BOR_LEV>;
impl BOR_LEV_R {
#[inline(always)]
pub const fn variant(&self) -> BOR_LEV {
match self.bits {
0 => BOR_LEV::BorOff,
1 => BOR_LEV::BorLevel1,
2 => BOR_LEV::BorLevel2,
3 => BOR_LEV::BorLevel3,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_bor_off(&self) -> bool {
*self == BOR_LEV::BorOff
}
#[inline(always)]
pub fn is_bor_level1(&self) -> bool {
*self == BOR_LEV::BorLevel1
}
#[inline(always)]
pub fn is_bor_level2(&self) -> bool {
*self == BOR_LEV::BorLevel2
}
#[inline(always)]
pub fn is_bor_level3(&self) -> bool {
*self == BOR_LEV::BorLevel3
}
}
pub type BOR_LEV_W<'a, REG> = crate::FieldWriter<'a, REG, 2, BOR_LEV, crate::Safe>;
impl<'a, REG> BOR_LEV_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn bor_off(self) -> &'a mut crate::W<REG> {
self.variant(BOR_LEV::BorOff)
}
#[inline(always)]
pub fn bor_level1(self) -> &'a mut crate::W<REG> {
self.variant(BOR_LEV::BorLevel1)
}
#[inline(always)]
pub fn bor_level2(self) -> &'a mut crate::W<REG> {
self.variant(BOR_LEV::BorLevel2)
}
#[inline(always)]
pub fn bor_level3(self) -> &'a mut crate::W<REG> {
self.variant(BOR_LEV::BorLevel3)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WDG_SW {
Hardware = 0,
Software = 1,
}
impl From<WDG_SW> for bool {
#[inline(always)]
fn from(variant: WDG_SW) -> Self {
variant as u8 != 0
}
}
pub type WDG_SW_R = crate::BitReader<WDG_SW>;
impl WDG_SW_R {
#[inline(always)]
pub const fn variant(&self) -> WDG_SW {
match self.bits {
false => WDG_SW::Hardware,
true => WDG_SW::Software,
}
}
#[inline(always)]
pub fn is_hardware(&self) -> bool {
*self == WDG_SW::Hardware
}
#[inline(always)]
pub fn is_software(&self) -> bool {
*self == WDG_SW::Software
}
}
pub type WDG_SW_W<'a, REG> = crate::BitWriter<'a, REG, WDG_SW>;
impl<'a, REG> WDG_SW_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn hardware(self) -> &'a mut crate::W<REG> {
self.variant(WDG_SW::Hardware)
}
#[inline(always)]
pub fn software(self) -> &'a mut crate::W<REG> {
self.variant(WDG_SW::Software)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum N_RST_STOP {
Reset = 0,
NoReset = 1,
}
impl From<N_RST_STOP> for bool {
#[inline(always)]
fn from(variant: N_RST_STOP) -> Self {
variant as u8 != 0
}
}
pub type N_RST_STOP_R = crate::BitReader<N_RST_STOP>;
impl N_RST_STOP_R {
#[inline(always)]
pub const fn variant(&self) -> N_RST_STOP {
match self.bits {
false => N_RST_STOP::Reset,
true => N_RST_STOP::NoReset,
}
}
#[inline(always)]
pub fn is_reset(&self) -> bool {
*self == N_RST_STOP::Reset
}
#[inline(always)]
pub fn is_no_reset(&self) -> bool {
*self == N_RST_STOP::NoReset
}
}
pub type N_RST_STOP_W<'a, REG> = crate::BitWriter<'a, REG, N_RST_STOP>;
impl<'a, REG> N_RST_STOP_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn reset(self) -> &'a mut crate::W<REG> {
self.variant(N_RST_STOP::Reset)
}
#[inline(always)]
pub fn no_reset(self) -> &'a mut crate::W<REG> {
self.variant(N_RST_STOP::NoReset)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum N_RST_STDBY {
Reset = 0,
NoReset = 1,
}
impl From<N_RST_STDBY> for bool {
#[inline(always)]
fn from(variant: N_RST_STDBY) -> Self {
variant as u8 != 0
}
}
pub type N_RST_STDBY_R = crate::BitReader<N_RST_STDBY>;
impl N_RST_STDBY_R {
#[inline(always)]
pub const fn variant(&self) -> N_RST_STDBY {
match self.bits {
false => N_RST_STDBY::Reset,
true => N_RST_STDBY::NoReset,
}
}
#[inline(always)]
pub fn is_reset(&self) -> bool {
*self == N_RST_STDBY::Reset
}
#[inline(always)]
pub fn is_no_reset(&self) -> bool {
*self == N_RST_STDBY::NoReset
}
}
pub type N_RST_STDBY_W<'a, REG> = crate::BitWriter<'a, REG, N_RST_STDBY>;
impl<'a, REG> N_RST_STDBY_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn reset(self) -> &'a mut crate::W<REG> {
self.variant(N_RST_STDBY::Reset)
}
#[inline(always)]
pub fn no_reset(self) -> &'a mut crate::W<REG> {
self.variant(N_RST_STDBY::NoReset)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum RDP {
Level0 = 170,
Level2 = 204,
Level1 = 0,
}
impl From<RDP> for u8 {
#[inline(always)]
fn from(variant: RDP) -> Self {
variant as _
}
}
impl crate::FieldSpec for RDP {
type Ux = u8;
}
impl crate::IsEnum for RDP {}
pub type RDP_R = crate::FieldReader<RDP>;
impl RDP_R {
#[inline(always)]
pub const fn variant(&self) -> RDP {
match self.bits {
170 => RDP::Level0,
204 => RDP::Level2,
_ => RDP::Level1,
}
}
#[inline(always)]
pub fn is_level0(&self) -> bool {
*self == RDP::Level0
}
#[inline(always)]
pub fn is_level2(&self) -> bool {
*self == RDP::Level2
}
#[inline(always)]
pub fn is_level1(&self) -> bool {
matches!(self.variant(), RDP::Level1)
}
}
pub type RDP_W<'a, REG> = crate::FieldWriter<'a, REG, 8, RDP, crate::Safe>;
impl<'a, REG> RDP_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn level0(self) -> &'a mut crate::W<REG> {
self.variant(RDP::Level0)
}
#[inline(always)]
pub fn level2(self) -> &'a mut crate::W<REG> {
self.variant(RDP::Level2)
}
#[inline(always)]
pub fn level1(self) -> &'a mut crate::W<REG> {
self.variant(RDP::Level1)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum N_WRP0 {
Active = 0,
Inactive = 1,
}
impl From<N_WRP0> for bool {
#[inline(always)]
fn from(variant: N_WRP0) -> Self {
variant as u8 != 0
}
}
pub type N_WRP_R = crate::BitReader<N_WRP0>;
impl N_WRP_R {
#[inline(always)]
pub const fn variant(&self) -> N_WRP0 {
match self.bits {
false => N_WRP0::Active,
true => N_WRP0::Inactive,
}
}
#[inline(always)]
pub fn is_active(&self) -> bool {
*self == N_WRP0::Active
}
#[inline(always)]
pub fn is_inactive(&self) -> bool {
*self == N_WRP0::Inactive
}
}
pub type N_WRP_W<'a, REG> = crate::BitWriter<'a, REG, N_WRP0>;
impl<'a, REG> N_WRP_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn active(self) -> &'a mut crate::W<REG> {
self.variant(N_WRP0::Active)
}
#[inline(always)]
pub fn inactive(self) -> &'a mut crate::W<REG> {
self.variant(N_WRP0::Inactive)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SPRMOD {
Disabled = 0,
Enabled = 1,
}
impl From<SPRMOD> for bool {
#[inline(always)]
fn from(variant: SPRMOD) -> Self {
variant as u8 != 0
}
}
pub type SPRMOD_R = crate::BitReader<SPRMOD>;
impl SPRMOD_R {
#[inline(always)]
pub const fn variant(&self) -> SPRMOD {
match self.bits {
false => SPRMOD::Disabled,
true => SPRMOD::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == SPRMOD::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == SPRMOD::Enabled
}
}
pub type SPRMOD_W<'a, REG> = crate::BitWriter<'a, REG, SPRMOD>;
impl<'a, REG> SPRMOD_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(SPRMOD::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(SPRMOD::Enabled)
}
}
impl R {
#[inline(always)]
pub fn optlock(&self) -> OPTLOCK_R {
OPTLOCK_R::new((self.bits & 1) != 0)
}
#[inline(always)]
pub fn optstrt(&self) -> OPTSTRT_R {
OPTSTRT_R::new(((self.bits >> 1) & 1) != 0)
}
#[inline(always)]
pub fn bor_lev(&self) -> BOR_LEV_R {
BOR_LEV_R::new(((self.bits >> 2) & 3) as u8)
}
#[inline(always)]
pub fn wdg_sw(&self) -> WDG_SW_R {
WDG_SW_R::new(((self.bits >> 5) & 1) != 0)
}
#[inline(always)]
pub fn n_rst_stop(&self) -> N_RST_STOP_R {
N_RST_STOP_R::new(((self.bits >> 6) & 1) != 0)
}
#[inline(always)]
pub fn n_rst_stdby(&self) -> N_RST_STDBY_R {
N_RST_STDBY_R::new(((self.bits >> 7) & 1) != 0)
}
#[inline(always)]
pub fn rdp(&self) -> RDP_R {
RDP_R::new(((self.bits >> 8) & 0xff) as u8)
}
#[inline(always)]
pub fn n_wrp(&self, n: u8) -> N_WRP_R {
#[allow(clippy::no_effect)]
[(); 12][n as usize];
N_WRP_R::new(((self.bits >> (n + 16)) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp_iter(&self) -> impl Iterator<Item = N_WRP_R> + '_ {
(0..12).map(move |n| N_WRP_R::new(((self.bits >> (n + 16)) & 1) != 0))
}
#[inline(always)]
pub fn n_wrp0(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 16) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp1(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 17) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp2(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 18) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp3(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 19) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp4(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 20) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp5(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 21) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp6(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 22) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp7(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 23) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp8(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 24) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp9(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 25) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp10(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 26) & 1) != 0)
}
#[inline(always)]
pub fn n_wrp11(&self) -> N_WRP_R {
N_WRP_R::new(((self.bits >> 27) & 1) != 0)
}
#[inline(always)]
pub fn sprmod(&self) -> SPRMOD_R {
SPRMOD_R::new(((self.bits >> 31) & 1) != 0)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("OPTCR")
.field("optlock", &self.optlock())
.field("optstrt", &self.optstrt())
.field("bor_lev", &self.bor_lev())
.field("wdg_sw", &self.wdg_sw())
.field("n_rst_stop", &self.n_rst_stop())
.field("n_rst_stdby", &self.n_rst_stdby())
.field("rdp", &self.rdp())
.field("sprmod", &self.sprmod())
.field("n_wrp0", &self.n_wrp0())
.field("n_wrp1", &self.n_wrp1())
.field("n_wrp2", &self.n_wrp2())
.field("n_wrp3", &self.n_wrp3())
.field("n_wrp4", &self.n_wrp4())
.field("n_wrp5", &self.n_wrp5())
.field("n_wrp6", &self.n_wrp6())
.field("n_wrp7", &self.n_wrp7())
.field("n_wrp8", &self.n_wrp8())
.field("n_wrp9", &self.n_wrp9())
.field("n_wrp10", &self.n_wrp10())
.field("n_wrp11", &self.n_wrp11())
.finish()
}
}
impl W {
#[inline(always)]
pub fn optlock(&mut self) -> OPTLOCK_W<OPTCRrs> {
OPTLOCK_W::new(self, 0)
}
#[inline(always)]
pub fn optstrt(&mut self) -> OPTSTRT_W<OPTCRrs> {
OPTSTRT_W::new(self, 1)
}
#[inline(always)]
pub fn bor_lev(&mut self) -> BOR_LEV_W<OPTCRrs> {
BOR_LEV_W::new(self, 2)
}
#[inline(always)]
pub fn wdg_sw(&mut self) -> WDG_SW_W<OPTCRrs> {
WDG_SW_W::new(self, 5)
}
#[inline(always)]
pub fn n_rst_stop(&mut self) -> N_RST_STOP_W<OPTCRrs> {
N_RST_STOP_W::new(self, 6)
}
#[inline(always)]
pub fn n_rst_stdby(&mut self) -> N_RST_STDBY_W<OPTCRrs> {
N_RST_STDBY_W::new(self, 7)
}
#[inline(always)]
pub fn rdp(&mut self) -> RDP_W<OPTCRrs> {
RDP_W::new(self, 8)
}
#[inline(always)]
pub fn n_wrp(&mut self, n: u8) -> N_WRP_W<OPTCRrs> {
#[allow(clippy::no_effect)]
[(); 12][n as usize];
N_WRP_W::new(self, n + 16)
}
#[inline(always)]
pub fn n_wrp0(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 16)
}
#[inline(always)]
pub fn n_wrp1(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 17)
}
#[inline(always)]
pub fn n_wrp2(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 18)
}
#[inline(always)]
pub fn n_wrp3(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 19)
}
#[inline(always)]
pub fn n_wrp4(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 20)
}
#[inline(always)]
pub fn n_wrp5(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 21)
}
#[inline(always)]
pub fn n_wrp6(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 22)
}
#[inline(always)]
pub fn n_wrp7(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 23)
}
#[inline(always)]
pub fn n_wrp8(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 24)
}
#[inline(always)]
pub fn n_wrp9(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 25)
}
#[inline(always)]
pub fn n_wrp10(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 26)
}
#[inline(always)]
pub fn n_wrp11(&mut self) -> N_WRP_W<OPTCRrs> {
N_WRP_W::new(self, 27)
}
#[inline(always)]
pub fn sprmod(&mut self) -> SPRMOD_W<OPTCRrs> {
SPRMOD_W::new(self, 31)
}
}
pub struct OPTCRrs;
impl crate::RegisterSpec for OPTCRrs {
type Ux = u32;
}
impl crate::Readable for OPTCRrs {}
impl crate::Writable for OPTCRrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for OPTCRrs {
const RESET_VALUE: u32 = 0x14;
}