atsame54p20a/nvmctrl/
seecfg.rs

1#[doc = "Reader of register SEECFG"]
2pub type R = crate::R<u8, super::SEECFG>;
3#[doc = "Writer for register SEECFG"]
4pub type W = crate::W<u8, super::SEECFG>;
5#[doc = "Register SEECFG `reset()`'s with value 0"]
6impl crate::ResetValue for super::SEECFG {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Write Mode\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum WMODE_A {
16    #[doc = "0: A NVM write command is issued after each write in the pagebuffer"]
17    UNBUFFERED = 0,
18    #[doc = "1: A NVM write command is issued when a write to a new page is requested"]
19    BUFFERED = 1,
20}
21impl From<WMODE_A> for bool {
22    #[inline(always)]
23    fn from(variant: WMODE_A) -> Self {
24        variant as u8 != 0
25    }
26}
27#[doc = "Reader of field `WMODE`"]
28pub type WMODE_R = crate::R<bool, WMODE_A>;
29impl WMODE_R {
30    #[doc = r"Get enumerated values variant"]
31    #[inline(always)]
32    pub fn variant(&self) -> WMODE_A {
33        match self.bits {
34            false => WMODE_A::UNBUFFERED,
35            true => WMODE_A::BUFFERED,
36        }
37    }
38    #[doc = "Checks if the value of the field is `UNBUFFERED`"]
39    #[inline(always)]
40    pub fn is_unbuffered(&self) -> bool {
41        *self == WMODE_A::UNBUFFERED
42    }
43    #[doc = "Checks if the value of the field is `BUFFERED`"]
44    #[inline(always)]
45    pub fn is_buffered(&self) -> bool {
46        *self == WMODE_A::BUFFERED
47    }
48}
49#[doc = "Write proxy for field `WMODE`"]
50pub struct WMODE_W<'a> {
51    w: &'a mut W,
52}
53impl<'a> WMODE_W<'a> {
54    #[doc = r"Writes `variant` to the field"]
55    #[inline(always)]
56    pub fn variant(self, variant: WMODE_A) -> &'a mut W {
57        {
58            self.bit(variant.into())
59        }
60    }
61    #[doc = "A NVM write command is issued after each write in the pagebuffer"]
62    #[inline(always)]
63    pub fn unbuffered(self) -> &'a mut W {
64        self.variant(WMODE_A::UNBUFFERED)
65    }
66    #[doc = "A NVM write command is issued when a write to a new page is requested"]
67    #[inline(always)]
68    pub fn buffered(self) -> &'a mut W {
69        self.variant(WMODE_A::BUFFERED)
70    }
71    #[doc = r"Sets the field bit"]
72    #[inline(always)]
73    pub fn set_bit(self) -> &'a mut W {
74        self.bit(true)
75    }
76    #[doc = r"Clears the field bit"]
77    #[inline(always)]
78    pub fn clear_bit(self) -> &'a mut W {
79        self.bit(false)
80    }
81    #[doc = r"Writes raw bits to the field"]
82    #[inline(always)]
83    pub fn bit(self, value: bool) -> &'a mut W {
84        self.w.bits = (self.w.bits & !0x01) | ((value as u8) & 0x01);
85        self.w
86    }
87}
88#[doc = "Reader of field `APRDIS`"]
89pub type APRDIS_R = crate::R<bool, bool>;
90#[doc = "Write proxy for field `APRDIS`"]
91pub struct APRDIS_W<'a> {
92    w: &'a mut W,
93}
94impl<'a> APRDIS_W<'a> {
95    #[doc = r"Sets the field bit"]
96    #[inline(always)]
97    pub fn set_bit(self) -> &'a mut W {
98        self.bit(true)
99    }
100    #[doc = r"Clears the field bit"]
101    #[inline(always)]
102    pub fn clear_bit(self) -> &'a mut W {
103        self.bit(false)
104    }
105    #[doc = r"Writes raw bits to the field"]
106    #[inline(always)]
107    pub fn bit(self, value: bool) -> &'a mut W {
108        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u8) & 0x01) << 1);
109        self.w
110    }
111}
112impl R {
113    #[doc = "Bit 0 - Write Mode"]
114    #[inline(always)]
115    pub fn wmode(&self) -> WMODE_R {
116        WMODE_R::new((self.bits & 0x01) != 0)
117    }
118    #[doc = "Bit 1 - Automatic Page Reallocation Disable"]
119    #[inline(always)]
120    pub fn aprdis(&self) -> APRDIS_R {
121        APRDIS_R::new(((self.bits >> 1) & 0x01) != 0)
122    }
123}
124impl W {
125    #[doc = "Bit 0 - Write Mode"]
126    #[inline(always)]
127    pub fn wmode(&mut self) -> WMODE_W {
128        WMODE_W { w: self }
129    }
130    #[doc = "Bit 1 - Automatic Page Reallocation Disable"]
131    #[inline(always)]
132    pub fn aprdis(&mut self) -> APRDIS_W {
133        APRDIS_W { w: self }
134    }
135}