atsame70q21/qspi/
qspi_smr.rs

1#[doc = "Register `QSPI_SMR` reader"]
2pub struct R(crate::R<QSPI_SMR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<QSPI_SMR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<QSPI_SMR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<QSPI_SMR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `QSPI_SMR` writer"]
17pub struct W(crate::W<QSPI_SMR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<QSPI_SMR_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<QSPI_SMR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<QSPI_SMR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Scrambling/Unscrambling Enable\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum SCREN_A {
40    #[doc = "0: The scrambling/unscrambling is disabled."]
41    DISABLED = 0,
42    #[doc = "1: The scrambling/unscrambling is enabled."]
43    ENABLED = 1,
44}
45impl From<SCREN_A> for bool {
46    #[inline(always)]
47    fn from(variant: SCREN_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `SCREN` reader - Scrambling/Unscrambling Enable"]
52pub struct SCREN_R(crate::FieldReader<bool, SCREN_A>);
53impl SCREN_R {
54    #[inline(always)]
55    pub(crate) fn new(bits: bool) -> Self {
56        SCREN_R(crate::FieldReader::new(bits))
57    }
58    #[doc = r"Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> SCREN_A {
61        match self.bits {
62            false => SCREN_A::DISABLED,
63            true => SCREN_A::ENABLED,
64        }
65    }
66    #[doc = "Checks if the value of the field is `DISABLED`"]
67    #[inline(always)]
68    pub fn is_disabled(&self) -> bool {
69        **self == SCREN_A::DISABLED
70    }
71    #[doc = "Checks if the value of the field is `ENABLED`"]
72    #[inline(always)]
73    pub fn is_enabled(&self) -> bool {
74        **self == SCREN_A::ENABLED
75    }
76}
77impl core::ops::Deref for SCREN_R {
78    type Target = crate::FieldReader<bool, SCREN_A>;
79    #[inline(always)]
80    fn deref(&self) -> &Self::Target {
81        &self.0
82    }
83}
84#[doc = "Field `SCREN` writer - Scrambling/Unscrambling Enable"]
85pub struct SCREN_W<'a> {
86    w: &'a mut W,
87}
88impl<'a> SCREN_W<'a> {
89    #[doc = r"Writes `variant` to the field"]
90    #[inline(always)]
91    pub fn variant(self, variant: SCREN_A) -> &'a mut W {
92        self.bit(variant.into())
93    }
94    #[doc = "The scrambling/unscrambling is disabled."]
95    #[inline(always)]
96    pub fn disabled(self) -> &'a mut W {
97        self.variant(SCREN_A::DISABLED)
98    }
99    #[doc = "The scrambling/unscrambling is enabled."]
100    #[inline(always)]
101    pub fn enabled(self) -> &'a mut W {
102        self.variant(SCREN_A::ENABLED)
103    }
104    #[doc = r"Sets the field bit"]
105    #[inline(always)]
106    pub fn set_bit(self) -> &'a mut W {
107        self.bit(true)
108    }
109    #[doc = r"Clears the field bit"]
110    #[inline(always)]
111    pub fn clear_bit(self) -> &'a mut W {
112        self.bit(false)
113    }
114    #[doc = r"Writes raw bits to the field"]
115    #[inline(always)]
116    pub fn bit(self, value: bool) -> &'a mut W {
117        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
118        self.w
119    }
120}
121#[doc = "Field `RVDIS` reader - Scrambling/Unscrambling Random Value Disable"]
122pub struct RVDIS_R(crate::FieldReader<bool, bool>);
123impl RVDIS_R {
124    #[inline(always)]
125    pub(crate) fn new(bits: bool) -> Self {
126        RVDIS_R(crate::FieldReader::new(bits))
127    }
128}
129impl core::ops::Deref for RVDIS_R {
130    type Target = crate::FieldReader<bool, bool>;
131    #[inline(always)]
132    fn deref(&self) -> &Self::Target {
133        &self.0
134    }
135}
136#[doc = "Field `RVDIS` writer - Scrambling/Unscrambling Random Value Disable"]
137pub struct RVDIS_W<'a> {
138    w: &'a mut W,
139}
140impl<'a> RVDIS_W<'a> {
141    #[doc = r"Sets the field bit"]
142    #[inline(always)]
143    pub fn set_bit(self) -> &'a mut W {
144        self.bit(true)
145    }
146    #[doc = r"Clears the field bit"]
147    #[inline(always)]
148    pub fn clear_bit(self) -> &'a mut W {
149        self.bit(false)
150    }
151    #[doc = r"Writes raw bits to the field"]
152    #[inline(always)]
153    pub fn bit(self, value: bool) -> &'a mut W {
154        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
155        self.w
156    }
157}
158impl R {
159    #[doc = "Bit 0 - Scrambling/Unscrambling Enable"]
160    #[inline(always)]
161    pub fn scren(&self) -> SCREN_R {
162        SCREN_R::new((self.bits & 0x01) != 0)
163    }
164    #[doc = "Bit 1 - Scrambling/Unscrambling Random Value Disable"]
165    #[inline(always)]
166    pub fn rvdis(&self) -> RVDIS_R {
167        RVDIS_R::new(((self.bits >> 1) & 0x01) != 0)
168    }
169}
170impl W {
171    #[doc = "Bit 0 - Scrambling/Unscrambling Enable"]
172    #[inline(always)]
173    pub fn scren(&mut self) -> SCREN_W {
174        SCREN_W { w: self }
175    }
176    #[doc = "Bit 1 - Scrambling/Unscrambling Random Value Disable"]
177    #[inline(always)]
178    pub fn rvdis(&mut self) -> RVDIS_W {
179        RVDIS_W { w: self }
180    }
181    #[doc = "Writes raw bits to the register."]
182    #[inline(always)]
183    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
184        self.0.bits(bits);
185        self
186    }
187}
188#[doc = "Scrambling Mode Register\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 [qspi_smr](index.html) module"]
189pub struct QSPI_SMR_SPEC;
190impl crate::RegisterSpec for QSPI_SMR_SPEC {
191    type Ux = u32;
192}
193#[doc = "`read()` method returns [qspi_smr::R](R) reader structure"]
194impl crate::Readable for QSPI_SMR_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [qspi_smr::W](W) writer structure"]
198impl crate::Writable for QSPI_SMR_SPEC {
199    type Writer = W;
200}
201#[doc = "`reset()` method sets QSPI_SMR to value 0"]
202impl crate::Resettable for QSPI_SMR_SPEC {
203    #[inline(always)]
204    fn reset_value() -> Self::Ux {
205        0
206    }
207}