Skip to main content

atsame70q21/sdramc/
sdramc_cfr1.rs

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