msp430fr2355/sys/
syscfg0.rs

1#[doc = "Register `SYSCFG0` reader"]
2pub struct R(crate::R<SYSCFG0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SYSCFG0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SYSCFG0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SYSCFG0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SYSCFG0` writer"]
17pub struct W(crate::W<SYSCFG0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SYSCFG0_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<SYSCFG0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SYSCFG0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `PFWP` reader - Program FRAM write protection"]
38pub type PFWP_R = crate::BitReader<PFWP_A>;
39#[doc = "Program FRAM write protection\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum PFWP_A {
42    #[doc = "0: Program FRAM write enable"]
43    PFWP_0 = 0,
44    #[doc = "1: Program FRAM write protected (not writable)"]
45    PFWP_1 = 1,
46}
47impl From<PFWP_A> for bool {
48    #[inline(always)]
49    fn from(variant: PFWP_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl PFWP_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> PFWP_A {
57        match self.bits {
58            false => PFWP_A::PFWP_0,
59            true => PFWP_A::PFWP_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `PFWP_0`"]
63    #[inline(always)]
64    pub fn is_pfwp_0(&self) -> bool {
65        *self == PFWP_A::PFWP_0
66    }
67    #[doc = "Checks if the value of the field is `PFWP_1`"]
68    #[inline(always)]
69    pub fn is_pfwp_1(&self) -> bool {
70        *self == PFWP_A::PFWP_1
71    }
72}
73#[doc = "Field `PFWP` writer - Program FRAM write protection"]
74pub type PFWP_W<'a, const O: u8> = crate::BitWriter<'a, u16, SYSCFG0_SPEC, PFWP_A, O>;
75impl<'a, const O: u8> PFWP_W<'a, O> {
76    #[doc = "Program FRAM write enable"]
77    #[inline(always)]
78    pub fn pfwp_0(self) -> &'a mut W {
79        self.variant(PFWP_A::PFWP_0)
80    }
81    #[doc = "Program FRAM write protected (not writable)"]
82    #[inline(always)]
83    pub fn pfwp_1(self) -> &'a mut W {
84        self.variant(PFWP_A::PFWP_1)
85    }
86}
87#[doc = "Field `DFWP` reader - Data FRAM write protection"]
88pub type DFWP_R = crate::BitReader<DFWP_A>;
89#[doc = "Data FRAM write protection\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum DFWP_A {
92    #[doc = "0: Data FRAM write enable"]
93    DFWP_0 = 0,
94    #[doc = "1: Data FRAM write protected (not writable)"]
95    DFWP_1 = 1,
96}
97impl From<DFWP_A> for bool {
98    #[inline(always)]
99    fn from(variant: DFWP_A) -> Self {
100        variant as u8 != 0
101    }
102}
103impl DFWP_R {
104    #[doc = "Get enumerated values variant"]
105    #[inline(always)]
106    pub fn variant(&self) -> DFWP_A {
107        match self.bits {
108            false => DFWP_A::DFWP_0,
109            true => DFWP_A::DFWP_1,
110        }
111    }
112    #[doc = "Checks if the value of the field is `DFWP_0`"]
113    #[inline(always)]
114    pub fn is_dfwp_0(&self) -> bool {
115        *self == DFWP_A::DFWP_0
116    }
117    #[doc = "Checks if the value of the field is `DFWP_1`"]
118    #[inline(always)]
119    pub fn is_dfwp_1(&self) -> bool {
120        *self == DFWP_A::DFWP_1
121    }
122}
123#[doc = "Field `DFWP` writer - Data FRAM write protection"]
124pub type DFWP_W<'a, const O: u8> = crate::BitWriter<'a, u16, SYSCFG0_SPEC, DFWP_A, O>;
125impl<'a, const O: u8> DFWP_W<'a, O> {
126    #[doc = "Data FRAM write enable"]
127    #[inline(always)]
128    pub fn dfwp_0(self) -> &'a mut W {
129        self.variant(DFWP_A::DFWP_0)
130    }
131    #[doc = "Data FRAM write protected (not writable)"]
132    #[inline(always)]
133    pub fn dfwp_1(self) -> &'a mut W {
134        self.variant(DFWP_A::DFWP_1)
135    }
136}
137#[doc = "Field `FRWPOA` reader - Program FRAM write protection offset address from the beginning of Program FRAM. The offset increases by 1KB resolution"]
138pub type FRWPOA_R = crate::FieldReader<u8, u8>;
139#[doc = "Field `FRWPOA` writer - Program FRAM write protection offset address from the beginning of Program FRAM. The offset increases by 1KB resolution"]
140pub type FRWPOA_W<'a, const O: u8> = crate::FieldWriter<'a, u16, SYSCFG0_SPEC, u8, u8, 6, O>;
141#[doc = "Field `FRWPPW` reader - FRAM protection password, FRAM protection password. Write with 0A5h to unlock the FRAM protection registers. Always reads as 096h"]
142pub type FRWPPW_R = crate::FieldReader<u8, u8>;
143#[doc = "Field `FRWPPW` writer - FRAM protection password, FRAM protection password. Write with 0A5h to unlock the FRAM protection registers. Always reads as 096h"]
144pub type FRWPPW_W<'a, const O: u8> = crate::FieldWriter<'a, u16, SYSCFG0_SPEC, u8, u8, 8, O>;
145impl R {
146    #[doc = "Bit 0 - Program FRAM write protection"]
147    #[inline(always)]
148    pub fn pfwp(&self) -> PFWP_R {
149        PFWP_R::new((self.bits & 1) != 0)
150    }
151    #[doc = "Bit 1 - Data FRAM write protection"]
152    #[inline(always)]
153    pub fn dfwp(&self) -> DFWP_R {
154        DFWP_R::new(((self.bits >> 1) & 1) != 0)
155    }
156    #[doc = "Bits 2:7 - Program FRAM write protection offset address from the beginning of Program FRAM. The offset increases by 1KB resolution"]
157    #[inline(always)]
158    pub fn frwpoa(&self) -> FRWPOA_R {
159        FRWPOA_R::new(((self.bits >> 2) & 0x3f) as u8)
160    }
161    #[doc = "Bits 8:15 - FRAM protection password, FRAM protection password. Write with 0A5h to unlock the FRAM protection registers. Always reads as 096h"]
162    #[inline(always)]
163    pub fn frwppw(&self) -> FRWPPW_R {
164        FRWPPW_R::new(((self.bits >> 8) & 0xff) as u8)
165    }
166}
167impl W {
168    #[doc = "Bit 0 - Program FRAM write protection"]
169    #[inline(always)]
170    pub fn pfwp(&mut self) -> PFWP_W<0> {
171        PFWP_W::new(self)
172    }
173    #[doc = "Bit 1 - Data FRAM write protection"]
174    #[inline(always)]
175    pub fn dfwp(&mut self) -> DFWP_W<1> {
176        DFWP_W::new(self)
177    }
178    #[doc = "Bits 2:7 - Program FRAM write protection offset address from the beginning of Program FRAM. The offset increases by 1KB resolution"]
179    #[inline(always)]
180    pub fn frwpoa(&mut self) -> FRWPOA_W<2> {
181        FRWPOA_W::new(self)
182    }
183    #[doc = "Bits 8:15 - FRAM protection password, FRAM protection password. Write with 0A5h to unlock the FRAM protection registers. Always reads as 096h"]
184    #[inline(always)]
185    pub fn frwppw(&mut self) -> FRWPPW_W<8> {
186        FRWPPW_W::new(self)
187    }
188    #[doc = "Writes raw bits to the register."]
189    #[inline(always)]
190    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
191        self.0.bits(bits);
192        self
193    }
194}
195#[doc = "System Configuration Register 0\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [syscfg0](index.html) module"]
196pub struct SYSCFG0_SPEC;
197impl crate::RegisterSpec for SYSCFG0_SPEC {
198    type Ux = u16;
199}
200#[doc = "`read()` method returns [syscfg0::R](R) reader structure"]
201impl crate::Readable for SYSCFG0_SPEC {
202    type Reader = R;
203}
204#[doc = "`write(|w| ..)` method takes [syscfg0::W](W) writer structure"]
205impl crate::Writable for SYSCFG0_SPEC {
206    type Writer = W;
207}
208#[doc = "`reset()` method sets SYSCFG0 to value 0"]
209impl crate::Resettable for SYSCFG0_SPEC {
210    #[inline(always)]
211    fn reset_value() -> Self::Ux {
212        0
213    }
214}