mk66f18/fb/
csmr.rs

1#[doc = "Reader of register CSMR%s"]
2pub type R = crate::R<u32, super::CSMR>;
3#[doc = "Writer for register CSMR%s"]
4pub type W = crate::W<u32, super::CSMR>;
5#[doc = "Register CSMR%s `reset()`'s with value 0"]
6impl crate::ResetValue for super::CSMR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Valid\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum V_A {
16    #[doc = "0: Chip-select is invalid."]
17    _0,
18    #[doc = "1: Chip-select is valid."]
19    _1,
20}
21impl From<V_A> for bool {
22    #[inline(always)]
23    fn from(variant: V_A) -> Self {
24        match variant {
25            V_A::_0 => false,
26            V_A::_1 => true,
27        }
28    }
29}
30#[doc = "Reader of field `V`"]
31pub type V_R = crate::R<bool, V_A>;
32impl V_R {
33    #[doc = r"Get enumerated values variant"]
34    #[inline(always)]
35    pub fn variant(&self) -> V_A {
36        match self.bits {
37            false => V_A::_0,
38            true => V_A::_1,
39        }
40    }
41    #[doc = "Checks if the value of the field is `_0`"]
42    #[inline(always)]
43    pub fn is_0(&self) -> bool {
44        *self == V_A::_0
45    }
46    #[doc = "Checks if the value of the field is `_1`"]
47    #[inline(always)]
48    pub fn is_1(&self) -> bool {
49        *self == V_A::_1
50    }
51}
52#[doc = "Write proxy for field `V`"]
53pub struct V_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> V_W<'a> {
57    #[doc = r"Writes `variant` to the field"]
58    #[inline(always)]
59    pub fn variant(self, variant: V_A) -> &'a mut W {
60        {
61            self.bit(variant.into())
62        }
63    }
64    #[doc = "Chip-select is invalid."]
65    #[inline(always)]
66    pub fn _0(self) -> &'a mut W {
67        self.variant(V_A::_0)
68    }
69    #[doc = "Chip-select is valid."]
70    #[inline(always)]
71    pub fn _1(self) -> &'a mut W {
72        self.variant(V_A::_1)
73    }
74    #[doc = r"Sets the field bit"]
75    #[inline(always)]
76    pub fn set_bit(self) -> &'a mut W {
77        self.bit(true)
78    }
79    #[doc = r"Clears the field bit"]
80    #[inline(always)]
81    pub fn clear_bit(self) -> &'a mut W {
82        self.bit(false)
83    }
84    #[doc = r"Writes raw bits to the field"]
85    #[inline(always)]
86    pub fn bit(self, value: bool) -> &'a mut W {
87        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
88        self.w
89    }
90}
91#[doc = "Write Protect\n\nValue on reset: 0"]
92#[derive(Clone, Copy, Debug, PartialEq)]
93pub enum WP_A {
94    #[doc = "0: Write accesses are allowed."]
95    _0,
96    #[doc = "1: Write accesses are not allowed. Attempting to write to the range of addresses for which the WP bit is set results in a bus error termination of the internal cycle and no external cycle."]
97    _1,
98}
99impl From<WP_A> for bool {
100    #[inline(always)]
101    fn from(variant: WP_A) -> Self {
102        match variant {
103            WP_A::_0 => false,
104            WP_A::_1 => true,
105        }
106    }
107}
108#[doc = "Reader of field `WP`"]
109pub type WP_R = crate::R<bool, WP_A>;
110impl WP_R {
111    #[doc = r"Get enumerated values variant"]
112    #[inline(always)]
113    pub fn variant(&self) -> WP_A {
114        match self.bits {
115            false => WP_A::_0,
116            true => WP_A::_1,
117        }
118    }
119    #[doc = "Checks if the value of the field is `_0`"]
120    #[inline(always)]
121    pub fn is_0(&self) -> bool {
122        *self == WP_A::_0
123    }
124    #[doc = "Checks if the value of the field is `_1`"]
125    #[inline(always)]
126    pub fn is_1(&self) -> bool {
127        *self == WP_A::_1
128    }
129}
130#[doc = "Write proxy for field `WP`"]
131pub struct WP_W<'a> {
132    w: &'a mut W,
133}
134impl<'a> WP_W<'a> {
135    #[doc = r"Writes `variant` to the field"]
136    #[inline(always)]
137    pub fn variant(self, variant: WP_A) -> &'a mut W {
138        {
139            self.bit(variant.into())
140        }
141    }
142    #[doc = "Write accesses are allowed."]
143    #[inline(always)]
144    pub fn _0(self) -> &'a mut W {
145        self.variant(WP_A::_0)
146    }
147    #[doc = "Write accesses are not allowed. Attempting to write to the range of addresses for which the WP bit is set results in a bus error termination of the internal cycle and no external cycle."]
148    #[inline(always)]
149    pub fn _1(self) -> &'a mut W {
150        self.variant(WP_A::_1)
151    }
152    #[doc = r"Sets the field bit"]
153    #[inline(always)]
154    pub fn set_bit(self) -> &'a mut W {
155        self.bit(true)
156    }
157    #[doc = r"Clears the field bit"]
158    #[inline(always)]
159    pub fn clear_bit(self) -> &'a mut W {
160        self.bit(false)
161    }
162    #[doc = r"Writes raw bits to the field"]
163    #[inline(always)]
164    pub fn bit(self, value: bool) -> &'a mut W {
165        self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
166        self.w
167    }
168}
169#[doc = "Base Address Mask\n\nValue on reset: 0"]
170#[derive(Clone, Copy, Debug, PartialEq)]
171pub enum BAM_A {
172    #[doc = "0: The corresponding address bit in CSAR is used in the chip-select decode."]
173    _0,
174    #[doc = "1: The corresponding address bit in CSAR is a don't care in the chip-select decode."]
175    _1,
176}
177impl From<BAM_A> for u16 {
178    #[inline(always)]
179    fn from(variant: BAM_A) -> Self {
180        match variant {
181            BAM_A::_0 => 0,
182            BAM_A::_1 => 1,
183        }
184    }
185}
186#[doc = "Reader of field `BAM`"]
187pub type BAM_R = crate::R<u16, BAM_A>;
188impl BAM_R {
189    #[doc = r"Get enumerated values variant"]
190    #[inline(always)]
191    pub fn variant(&self) -> crate::Variant<u16, BAM_A> {
192        use crate::Variant::*;
193        match self.bits {
194            0 => Val(BAM_A::_0),
195            1 => Val(BAM_A::_1),
196            i => Res(i),
197        }
198    }
199    #[doc = "Checks if the value of the field is `_0`"]
200    #[inline(always)]
201    pub fn is_0(&self) -> bool {
202        *self == BAM_A::_0
203    }
204    #[doc = "Checks if the value of the field is `_1`"]
205    #[inline(always)]
206    pub fn is_1(&self) -> bool {
207        *self == BAM_A::_1
208    }
209}
210#[doc = "Write proxy for field `BAM`"]
211pub struct BAM_W<'a> {
212    w: &'a mut W,
213}
214impl<'a> BAM_W<'a> {
215    #[doc = r"Writes `variant` to the field"]
216    #[inline(always)]
217    pub fn variant(self, variant: BAM_A) -> &'a mut W {
218        unsafe { self.bits(variant.into()) }
219    }
220    #[doc = "The corresponding address bit in CSAR is used in the chip-select decode."]
221    #[inline(always)]
222    pub fn _0(self) -> &'a mut W {
223        self.variant(BAM_A::_0)
224    }
225    #[doc = "The corresponding address bit in CSAR is a don't care in the chip-select decode."]
226    #[inline(always)]
227    pub fn _1(self) -> &'a mut W {
228        self.variant(BAM_A::_1)
229    }
230    #[doc = r"Writes raw bits to the field"]
231    #[inline(always)]
232    pub unsafe fn bits(self, value: u16) -> &'a mut W {
233        self.w.bits = (self.w.bits & !(0xffff << 16)) | (((value as u32) & 0xffff) << 16);
234        self.w
235    }
236}
237impl R {
238    #[doc = "Bit 0 - Valid"]
239    #[inline(always)]
240    pub fn v(&self) -> V_R {
241        V_R::new((self.bits & 0x01) != 0)
242    }
243    #[doc = "Bit 8 - Write Protect"]
244    #[inline(always)]
245    pub fn wp(&self) -> WP_R {
246        WP_R::new(((self.bits >> 8) & 0x01) != 0)
247    }
248    #[doc = "Bits 16:31 - Base Address Mask"]
249    #[inline(always)]
250    pub fn bam(&self) -> BAM_R {
251        BAM_R::new(((self.bits >> 16) & 0xffff) as u16)
252    }
253}
254impl W {
255    #[doc = "Bit 0 - Valid"]
256    #[inline(always)]
257    pub fn v(&mut self) -> V_W {
258        V_W { w: self }
259    }
260    #[doc = "Bit 8 - Write Protect"]
261    #[inline(always)]
262    pub fn wp(&mut self) -> WP_W {
263        WP_W { w: self }
264    }
265    #[doc = "Bits 16:31 - Base Address Mask"]
266    #[inline(always)]
267    pub fn bam(&mut self) -> BAM_W {
268        BAM_W { w: self }
269    }
270}