pub type R = crate::R<CFGR1rs>;
pub type W = crate::W<CFGR1rs>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum MEM_MODE {
MainFlash = 0,
SystemFlash = 1,
Sram = 3,
}
impl From<MEM_MODE> for u8 {
#[inline(always)]
fn from(variant: MEM_MODE) -> Self {
variant as _
}
}
impl crate::FieldSpec for MEM_MODE {
type Ux = u8;
}
impl crate::IsEnum for MEM_MODE {}
pub type MEM_MODE_R = crate::FieldReader<MEM_MODE>;
impl MEM_MODE_R {
#[inline(always)]
pub const fn variant(&self) -> Option<MEM_MODE> {
match self.bits {
0 => Some(MEM_MODE::MainFlash),
1 => Some(MEM_MODE::SystemFlash),
3 => Some(MEM_MODE::Sram),
_ => None,
}
}
#[inline(always)]
pub fn is_main_flash(&self) -> bool {
*self == MEM_MODE::MainFlash
}
#[inline(always)]
pub fn is_system_flash(&self) -> bool {
*self == MEM_MODE::SystemFlash
}
#[inline(always)]
pub fn is_sram(&self) -> bool {
*self == MEM_MODE::Sram
}
}
pub type MEM_MODE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, MEM_MODE>;
impl<'a, REG> MEM_MODE_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn main_flash(self) -> &'a mut crate::W<REG> {
self.variant(MEM_MODE::MainFlash)
}
#[inline(always)]
pub fn system_flash(self) -> &'a mut crate::W<REG> {
self.variant(MEM_MODE::SystemFlash)
}
#[inline(always)]
pub fn sram(self) -> &'a mut crate::W<REG> {
self.variant(MEM_MODE::Sram)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum UFB {
Bank1 = 0,
Bank2 = 1,
}
impl From<UFB> for bool {
#[inline(always)]
fn from(variant: UFB) -> Self {
variant as u8 != 0
}
}
pub type UFB_R = crate::BitReader<UFB>;
impl UFB_R {
#[inline(always)]
pub const fn variant(&self) -> UFB {
match self.bits {
false => UFB::Bank1,
true => UFB::Bank2,
}
}
#[inline(always)]
pub fn is_bank1(&self) -> bool {
*self == UFB::Bank1
}
#[inline(always)]
pub fn is_bank2(&self) -> bool {
*self == UFB::Bank2
}
}
pub type UFB_W<'a, REG> = crate::BitWriter<'a, REG, UFB>;
impl<'a, REG> UFB_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn bank1(self) -> &'a mut crate::W<REG> {
self.variant(UFB::Bank1)
}
#[inline(always)]
pub fn bank2(self) -> &'a mut crate::W<REG> {
self.variant(UFB::Bank2)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum BOOT_MODE {
MainFlash = 0,
SystemFlash = 1,
Sram = 3,
}
impl From<BOOT_MODE> for u8 {
#[inline(always)]
fn from(variant: BOOT_MODE) -> Self {
variant as _
}
}
impl crate::FieldSpec for BOOT_MODE {
type Ux = u8;
}
impl crate::IsEnum for BOOT_MODE {}
pub type BOOT_MODE_R = crate::FieldReader<BOOT_MODE>;
impl BOOT_MODE_R {
#[inline(always)]
pub const fn variant(&self) -> Option<BOOT_MODE> {
match self.bits {
0 => Some(BOOT_MODE::MainFlash),
1 => Some(BOOT_MODE::SystemFlash),
3 => Some(BOOT_MODE::Sram),
_ => None,
}
}
#[inline(always)]
pub fn is_main_flash(&self) -> bool {
*self == BOOT_MODE::MainFlash
}
#[inline(always)]
pub fn is_system_flash(&self) -> bool {
*self == BOOT_MODE::SystemFlash
}
#[inline(always)]
pub fn is_sram(&self) -> bool {
*self == BOOT_MODE::Sram
}
}
impl R {
#[inline(always)]
pub fn mem_mode(&self) -> MEM_MODE_R {
MEM_MODE_R::new((self.bits & 3) as u8)
}
#[inline(always)]
pub fn ufb(&self) -> UFB_R {
UFB_R::new(((self.bits >> 3) & 1) != 0)
}
#[inline(always)]
pub fn boot_mode(&self) -> BOOT_MODE_R {
BOOT_MODE_R::new(((self.bits >> 8) & 3) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CFGR1")
.field("boot_mode", &self.boot_mode())
.field("mem_mode", &self.mem_mode())
.field("ufb", &self.ufb())
.finish()
}
}
impl W {
#[inline(always)]
pub fn mem_mode(&mut self) -> MEM_MODE_W<CFGR1rs> {
MEM_MODE_W::new(self, 0)
}
#[inline(always)]
pub fn ufb(&mut self) -> UFB_W<CFGR1rs> {
UFB_W::new(self, 3)
}
}
pub struct CFGR1rs;
impl crate::RegisterSpec for CFGR1rs {
type Ux = u32;
}
impl crate::Readable for CFGR1rs {}
impl crate::Writable for CFGR1rs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for CFGR1rs {}