#[doc = "Reader of register CR"]
pub type R = crate::R<u32, super::CR>;
#[doc = "Writer for register CR"]
pub type W = crate::W<u32, super::CR>;
#[doc = "Register CR `reset()`'s with value 0x8000_0000"]
impl crate::ResetValue for super::CR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0x8000_0000
}
}
#[doc = "Programming\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PG_A {
#[doc = "1: Flash programming activated"]
PROGRAM,
}
impl From<PG_A> for bool {
#[inline(always)]
fn from(variant: PG_A) -> Self {
match variant {
PG_A::PROGRAM => true,
}
}
}
#[doc = "Reader of field `PG`"]
pub type PG_R = crate::R<bool, PG_A>;
impl PG_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<bool, PG_A> {
use crate::Variant::*;
match self.bits {
true => Val(PG_A::PROGRAM),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `PROGRAM`"]
#[inline(always)]
pub fn is_program(&self) -> bool {
*self == PG_A::PROGRAM
}
}
#[doc = "Write proxy for field `PG`"]
pub struct PG_W<'a> {
w: &'a mut W,
}
impl<'a> PG_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: PG_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Flash programming activated"]
#[inline(always)]
pub fn program(self) -> &'a mut W {
self.variant(PG_A::PROGRAM)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
self.w
}
}
#[doc = "Sector Erase\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SER_A {
#[doc = "1: Erase activated for selected sector"]
SECTORERASE,
}
impl From<SER_A> for bool {
#[inline(always)]
fn from(variant: SER_A) -> Self {
match variant {
SER_A::SECTORERASE => true,
}
}
}
#[doc = "Reader of field `SER`"]
pub type SER_R = crate::R<bool, SER_A>;
impl SER_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<bool, SER_A> {
use crate::Variant::*;
match self.bits {
true => Val(SER_A::SECTORERASE),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `SECTORERASE`"]
#[inline(always)]
pub fn is_sector_erase(&self) -> bool {
*self == SER_A::SECTORERASE
}
}
#[doc = "Write proxy for field `SER`"]
pub struct SER_W<'a> {
w: &'a mut W,
}
impl<'a> SER_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: SER_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Erase activated for selected sector"]
#[inline(always)]
pub fn sector_erase(self) -> &'a mut W {
self.variant(SER_A::SECTORERASE)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
self.w
}
}
#[doc = "Mass Erase of sectors 0 to 11\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MER_A {
#[doc = "1: Erase activated for all user sectors"]
MASSERASE,
}
impl From<MER_A> for bool {
#[inline(always)]
fn from(variant: MER_A) -> Self {
match variant {
MER_A::MASSERASE => true,
}
}
}
#[doc = "Reader of field `MER`"]
pub type MER_R = crate::R<bool, MER_A>;
impl MER_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<bool, MER_A> {
use crate::Variant::*;
match self.bits {
true => Val(MER_A::MASSERASE),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `MASSERASE`"]
#[inline(always)]
pub fn is_mass_erase(&self) -> bool {
*self == MER_A::MASSERASE
}
}
#[doc = "Write proxy for field `MER`"]
pub struct MER_W<'a> {
w: &'a mut W,
}
impl<'a> MER_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: MER_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Erase activated for all user sectors"]
#[inline(always)]
pub fn mass_erase(self) -> &'a mut W {
self.variant(MER_A::MASSERASE)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
self.w
}
}
#[doc = "Reader of field `SNB`"]
pub type SNB_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `SNB`"]
pub struct SNB_W<'a> {
w: &'a mut W,
}
impl<'a> SNB_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x0f << 3)) | (((value as u32) & 0x0f) << 3);
self.w
}
}
#[doc = "Program size\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PSIZE_A {
#[doc = "0: Program x8"]
PSIZE8,
#[doc = "1: Program x16"]
PSIZE16,
#[doc = "2: Program x32"]
PSIZE32,
#[doc = "3: Program x64"]
PSIZE64,
}
impl From<PSIZE_A> for u8 {
#[inline(always)]
fn from(variant: PSIZE_A) -> Self {
match variant {
PSIZE_A::PSIZE8 => 0,
PSIZE_A::PSIZE16 => 1,
PSIZE_A::PSIZE32 => 2,
PSIZE_A::PSIZE64 => 3,
}
}
}
#[doc = "Reader of field `PSIZE`"]
pub type PSIZE_R = crate::R<u8, PSIZE_A>;
impl PSIZE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> PSIZE_A {
match self.bits {
0 => PSIZE_A::PSIZE8,
1 => PSIZE_A::PSIZE16,
2 => PSIZE_A::PSIZE32,
3 => PSIZE_A::PSIZE64,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `PSIZE8`"]
#[inline(always)]
pub fn is_psize8(&self) -> bool {
*self == PSIZE_A::PSIZE8
}
#[doc = "Checks if the value of the field is `PSIZE16`"]
#[inline(always)]
pub fn is_psize16(&self) -> bool {
*self == PSIZE_A::PSIZE16
}
#[doc = "Checks if the value of the field is `PSIZE32`"]
#[inline(always)]
pub fn is_psize32(&self) -> bool {
*self == PSIZE_A::PSIZE32
}
#[doc = "Checks if the value of the field is `PSIZE64`"]
#[inline(always)]
pub fn is_psize64(&self) -> bool {
*self == PSIZE_A::PSIZE64
}
}
#[doc = "Write proxy for field `PSIZE`"]
pub struct PSIZE_W<'a> {
w: &'a mut W,
}
impl<'a> PSIZE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: PSIZE_A) -> &'a mut W {
{
self.bits(variant.into())
}
}
#[doc = "Program x8"]
#[inline(always)]
pub fn psize8(self) -> &'a mut W {
self.variant(PSIZE_A::PSIZE8)
}
#[doc = "Program x16"]
#[inline(always)]
pub fn psize16(self) -> &'a mut W {
self.variant(PSIZE_A::PSIZE16)
}
#[doc = "Program x32"]
#[inline(always)]
pub fn psize32(self) -> &'a mut W {
self.variant(PSIZE_A::PSIZE32)
}
#[doc = "Program x64"]
#[inline(always)]
pub fn psize64(self) -> &'a mut W {
self.variant(PSIZE_A::PSIZE64)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
self.w
}
}
#[doc = "Start\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STRT_A {
#[doc = "1: Trigger an erase operation"]
START,
}
impl From<STRT_A> for bool {
#[inline(always)]
fn from(variant: STRT_A) -> Self {
match variant {
STRT_A::START => true,
}
}
}
#[doc = "Reader of field `STRT`"]
pub type STRT_R = crate::R<bool, STRT_A>;
impl STRT_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<bool, STRT_A> {
use crate::Variant::*;
match self.bits {
true => Val(STRT_A::START),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `START`"]
#[inline(always)]
pub fn is_start(&self) -> bool {
*self == STRT_A::START
}
}
#[doc = "Write proxy for field `STRT`"]
pub struct STRT_W<'a> {
w: &'a mut W,
}
impl<'a> STRT_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: STRT_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Trigger an erase operation"]
#[inline(always)]
pub fn start(self) -> &'a mut W {
self.variant(STRT_A::START)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16);
self.w
}
}
#[doc = "End of operation interrupt enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EOPIE_A {
#[doc = "0: End of operation interrupt disabled"]
DISABLED,
#[doc = "1: End of operation interrupt enabled"]
ENABLED,
}
impl From<EOPIE_A> for bool {
#[inline(always)]
fn from(variant: EOPIE_A) -> Self {
match variant {
EOPIE_A::DISABLED => false,
EOPIE_A::ENABLED => true,
}
}
}
#[doc = "Reader of field `EOPIE`"]
pub type EOPIE_R = crate::R<bool, EOPIE_A>;
impl EOPIE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> EOPIE_A {
match self.bits {
false => EOPIE_A::DISABLED,
true => EOPIE_A::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == EOPIE_A::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == EOPIE_A::ENABLED
}
}
#[doc = "Write proxy for field `EOPIE`"]
pub struct EOPIE_W<'a> {
w: &'a mut W,
}
impl<'a> EOPIE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: EOPIE_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "End of operation interrupt disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(EOPIE_A::DISABLED)
}
#[doc = "End of operation interrupt enabled"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(EOPIE_A::ENABLED)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 24)) | (((value as u32) & 0x01) << 24);
self.w
}
}
#[doc = "Error interrupt enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ERRIE_A {
#[doc = "0: Error interrupt generation disabled"]
DISABLED,
#[doc = "1: Error interrupt generation enabled"]
ENABLED,
}
impl From<ERRIE_A> for bool {
#[inline(always)]
fn from(variant: ERRIE_A) -> Self {
match variant {
ERRIE_A::DISABLED => false,
ERRIE_A::ENABLED => true,
}
}
}
#[doc = "Reader of field `ERRIE`"]
pub type ERRIE_R = crate::R<bool, ERRIE_A>;
impl ERRIE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> ERRIE_A {
match self.bits {
false => ERRIE_A::DISABLED,
true => ERRIE_A::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == ERRIE_A::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == ERRIE_A::ENABLED
}
}
#[doc = "Write proxy for field `ERRIE`"]
pub struct ERRIE_W<'a> {
w: &'a mut W,
}
impl<'a> ERRIE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: ERRIE_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Error interrupt generation disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(ERRIE_A::DISABLED)
}
#[doc = "Error interrupt generation enabled"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(ERRIE_A::ENABLED)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 25)) | (((value as u32) & 0x01) << 25);
self.w
}
}
#[doc = "Lock\n\nValue on reset: 1"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LOCK_A {
#[doc = "0: FLASH_CR register is unlocked"]
UNLOCKED,
#[doc = "1: FLASH_CR register is locked"]
LOCKED,
}
impl From<LOCK_A> for bool {
#[inline(always)]
fn from(variant: LOCK_A) -> Self {
match variant {
LOCK_A::UNLOCKED => false,
LOCK_A::LOCKED => true,
}
}
}
#[doc = "Reader of field `LOCK`"]
pub type LOCK_R = crate::R<bool, LOCK_A>;
impl LOCK_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> LOCK_A {
match self.bits {
false => LOCK_A::UNLOCKED,
true => LOCK_A::LOCKED,
}
}
#[doc = "Checks if the value of the field is `UNLOCKED`"]
#[inline(always)]
pub fn is_unlocked(&self) -> bool {
*self == LOCK_A::UNLOCKED
}
#[doc = "Checks if the value of the field is `LOCKED`"]
#[inline(always)]
pub fn is_locked(&self) -> bool {
*self == LOCK_A::LOCKED
}
}
#[doc = "Write proxy for field `LOCK`"]
pub struct LOCK_W<'a> {
w: &'a mut W,
}
impl<'a> LOCK_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: LOCK_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "FLASH_CR register is unlocked"]
#[inline(always)]
pub fn unlocked(self) -> &'a mut W {
self.variant(LOCK_A::UNLOCKED)
}
#[doc = "FLASH_CR register is locked"]
#[inline(always)]
pub fn locked(self) -> &'a mut W {
self.variant(LOCK_A::LOCKED)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
self.w
}
}
#[doc = "Reader of field `RDERRIE`"]
pub type RDERRIE_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RDERRIE`"]
pub struct RDERRIE_W<'a> {
w: &'a mut W,
}
impl<'a> RDERRIE_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 26)) | (((value as u32) & 0x01) << 26);
self.w
}
}
impl R {
#[doc = "Bit 0 - Programming"]
#[inline(always)]
pub fn pg(&self) -> PG_R {
PG_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 1 - Sector Erase"]
#[inline(always)]
pub fn ser(&self) -> SER_R {
SER_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - Mass Erase of sectors 0 to 11"]
#[inline(always)]
pub fn mer(&self) -> MER_R {
MER_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bits 3:6 - Sector number"]
#[inline(always)]
pub fn snb(&self) -> SNB_R {
SNB_R::new(((self.bits >> 3) & 0x0f) as u8)
}
#[doc = "Bits 8:9 - Program size"]
#[inline(always)]
pub fn psize(&self) -> PSIZE_R {
PSIZE_R::new(((self.bits >> 8) & 0x03) as u8)
}
#[doc = "Bit 16 - Start"]
#[inline(always)]
pub fn strt(&self) -> STRT_R {
STRT_R::new(((self.bits >> 16) & 0x01) != 0)
}
#[doc = "Bit 24 - End of operation interrupt enable"]
#[inline(always)]
pub fn eopie(&self) -> EOPIE_R {
EOPIE_R::new(((self.bits >> 24) & 0x01) != 0)
}
#[doc = "Bit 25 - Error interrupt enable"]
#[inline(always)]
pub fn errie(&self) -> ERRIE_R {
ERRIE_R::new(((self.bits >> 25) & 0x01) != 0)
}
#[doc = "Bit 31 - Lock"]
#[inline(always)]
pub fn lock(&self) -> LOCK_R {
LOCK_R::new(((self.bits >> 31) & 0x01) != 0)
}
#[doc = "Bit 26 - PCROP error interrupt enable"]
#[inline(always)]
pub fn rderrie(&self) -> RDERRIE_R {
RDERRIE_R::new(((self.bits >> 26) & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 0 - Programming"]
#[inline(always)]
pub fn pg(&mut self) -> PG_W {
PG_W { w: self }
}
#[doc = "Bit 1 - Sector Erase"]
#[inline(always)]
pub fn ser(&mut self) -> SER_W {
SER_W { w: self }
}
#[doc = "Bit 2 - Mass Erase of sectors 0 to 11"]
#[inline(always)]
pub fn mer(&mut self) -> MER_W {
MER_W { w: self }
}
#[doc = "Bits 3:6 - Sector number"]
#[inline(always)]
pub fn snb(&mut self) -> SNB_W {
SNB_W { w: self }
}
#[doc = "Bits 8:9 - Program size"]
#[inline(always)]
pub fn psize(&mut self) -> PSIZE_W {
PSIZE_W { w: self }
}
#[doc = "Bit 16 - Start"]
#[inline(always)]
pub fn strt(&mut self) -> STRT_W {
STRT_W { w: self }
}
#[doc = "Bit 24 - End of operation interrupt enable"]
#[inline(always)]
pub fn eopie(&mut self) -> EOPIE_W {
EOPIE_W { w: self }
}
#[doc = "Bit 25 - Error interrupt enable"]
#[inline(always)]
pub fn errie(&mut self) -> ERRIE_W {
ERRIE_W { w: self }
}
#[doc = "Bit 31 - Lock"]
#[inline(always)]
pub fn lock(&mut self) -> LOCK_W {
LOCK_W { w: self }
}
#[doc = "Bit 26 - PCROP error interrupt enable"]
#[inline(always)]
pub fn rderrie(&mut self) -> RDERRIE_W {
RDERRIE_W { w: self }
}
}