atsam4ls2b_pac/abdacb/
cr.rs1#[doc = "Register `CR` reader"]
2pub struct R(crate::R<CR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CR` writer"]
17pub struct W(crate::W<CR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CR_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<CR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `EN` reader - Enable"]
38pub type EN_R = crate::BitReader<ENSELECT_A>;
39#[doc = "Enable\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum ENSELECT_A {
42 #[doc = "0: Audio DAC is disabled"]
43 _0 = 0,
44 #[doc = "1: Audio DAC is enabled"]
45 _1 = 1,
46}
47impl From<ENSELECT_A> for bool {
48 #[inline(always)]
49 fn from(variant: ENSELECT_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl EN_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> ENSELECT_A {
57 match self.bits {
58 false => ENSELECT_A::_0,
59 true => ENSELECT_A::_1,
60 }
61 }
62 #[doc = "Checks if the value of the field is `_0`"]
63 #[inline(always)]
64 pub fn is_0(&self) -> bool {
65 *self == ENSELECT_A::_0
66 }
67 #[doc = "Checks if the value of the field is `_1`"]
68 #[inline(always)]
69 pub fn is_1(&self) -> bool {
70 *self == ENSELECT_A::_1
71 }
72}
73#[doc = "Field `EN` writer - Enable"]
74pub type EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, ENSELECT_A, O>;
75impl<'a, const O: u8> EN_W<'a, O> {
76 #[doc = "Audio DAC is disabled"]
77 #[inline(always)]
78 pub fn _0(self) -> &'a mut W {
79 self.variant(ENSELECT_A::_0)
80 }
81 #[doc = "Audio DAC is enabled"]
82 #[inline(always)]
83 pub fn _1(self) -> &'a mut W {
84 self.variant(ENSELECT_A::_1)
85 }
86}
87#[doc = "Field `SWAP` reader - Swap Channels"]
88pub type SWAP_R = crate::BitReader<SWAPSELECT_A>;
89#[doc = "Swap Channels\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum SWAPSELECT_A {
92 #[doc = "0: The CHANNEL0 and CHANNEL1 samples will not be swapped when writing the Audio DAC Sample Data Register (SDR)"]
93 _0 = 0,
94 #[doc = "1: The CHANNEL0 and CHANNEL1 samples will be swapped when writing the Audio DAC Sample Data Register (SDR)"]
95 _1 = 1,
96}
97impl From<SWAPSELECT_A> for bool {
98 #[inline(always)]
99 fn from(variant: SWAPSELECT_A) -> Self {
100 variant as u8 != 0
101 }
102}
103impl SWAP_R {
104 #[doc = "Get enumerated values variant"]
105 #[inline(always)]
106 pub fn variant(&self) -> SWAPSELECT_A {
107 match self.bits {
108 false => SWAPSELECT_A::_0,
109 true => SWAPSELECT_A::_1,
110 }
111 }
112 #[doc = "Checks if the value of the field is `_0`"]
113 #[inline(always)]
114 pub fn is_0(&self) -> bool {
115 *self == SWAPSELECT_A::_0
116 }
117 #[doc = "Checks if the value of the field is `_1`"]
118 #[inline(always)]
119 pub fn is_1(&self) -> bool {
120 *self == SWAPSELECT_A::_1
121 }
122}
123#[doc = "Field `SWAP` writer - Swap Channels"]
124pub type SWAP_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, SWAPSELECT_A, O>;
125impl<'a, const O: u8> SWAP_W<'a, O> {
126 #[doc = "The CHANNEL0 and CHANNEL1 samples will not be swapped when writing the Audio DAC Sample Data Register (SDR)"]
127 #[inline(always)]
128 pub fn _0(self) -> &'a mut W {
129 self.variant(SWAPSELECT_A::_0)
130 }
131 #[doc = "The CHANNEL0 and CHANNEL1 samples will be swapped when writing the Audio DAC Sample Data Register (SDR)"]
132 #[inline(always)]
133 pub fn _1(self) -> &'a mut W {
134 self.variant(SWAPSELECT_A::_1)
135 }
136}
137#[doc = "Field `ALTUPR` reader - Alternative up-sampling ratio"]
138pub type ALTUPR_R = crate::BitReader<bool>;
139#[doc = "Field `ALTUPR` writer - Alternative up-sampling ratio"]
140pub type ALTUPR_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, bool, O>;
141#[doc = "Field `CMOC` reader - Common mode offset control"]
142pub type CMOC_R = crate::BitReader<bool>;
143#[doc = "Field `CMOC` writer - Common mode offset control"]
144pub type CMOC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, bool, O>;
145#[doc = "Field `MONO` reader - Mono mode"]
146pub type MONO_R = crate::BitReader<bool>;
147#[doc = "Field `MONO` writer - Mono mode"]
148pub type MONO_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, bool, O>;
149#[doc = "Field `SWRST` reader - Software reset"]
150pub type SWRST_R = crate::BitReader<bool>;
151#[doc = "Field `SWRST` writer - Software reset"]
152pub type SWRST_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, bool, O>;
153#[doc = "Field `DATAFORMAT` reader - Data word format"]
154pub type DATAFORMAT_R = crate::FieldReader<u8, u8>;
155#[doc = "Field `DATAFORMAT` writer - Data word format"]
156pub type DATAFORMAT_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CR_SPEC, u8, u8, 3, O>;
157#[doc = "Field `FS` reader - Sampling frequency"]
158pub type FS_R = crate::FieldReader<u8, u8>;
159#[doc = "Field `FS` writer - Sampling frequency"]
160pub type FS_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CR_SPEC, u8, u8, 4, O>;
161impl R {
162 #[doc = "Bit 0 - Enable"]
163 #[inline(always)]
164 pub fn en(&self) -> EN_R {
165 EN_R::new((self.bits & 1) != 0)
166 }
167 #[doc = "Bit 1 - Swap Channels"]
168 #[inline(always)]
169 pub fn swap(&self) -> SWAP_R {
170 SWAP_R::new(((self.bits >> 1) & 1) != 0)
171 }
172 #[doc = "Bit 3 - Alternative up-sampling ratio"]
173 #[inline(always)]
174 pub fn altupr(&self) -> ALTUPR_R {
175 ALTUPR_R::new(((self.bits >> 3) & 1) != 0)
176 }
177 #[doc = "Bit 4 - Common mode offset control"]
178 #[inline(always)]
179 pub fn cmoc(&self) -> CMOC_R {
180 CMOC_R::new(((self.bits >> 4) & 1) != 0)
181 }
182 #[doc = "Bit 5 - Mono mode"]
183 #[inline(always)]
184 pub fn mono(&self) -> MONO_R {
185 MONO_R::new(((self.bits >> 5) & 1) != 0)
186 }
187 #[doc = "Bit 7 - Software reset"]
188 #[inline(always)]
189 pub fn swrst(&self) -> SWRST_R {
190 SWRST_R::new(((self.bits >> 7) & 1) != 0)
191 }
192 #[doc = "Bits 16:18 - Data word format"]
193 #[inline(always)]
194 pub fn dataformat(&self) -> DATAFORMAT_R {
195 DATAFORMAT_R::new(((self.bits >> 16) & 7) as u8)
196 }
197 #[doc = "Bits 24:27 - Sampling frequency"]
198 #[inline(always)]
199 pub fn fs(&self) -> FS_R {
200 FS_R::new(((self.bits >> 24) & 0x0f) as u8)
201 }
202}
203impl W {
204 #[doc = "Bit 0 - Enable"]
205 #[inline(always)]
206 #[must_use]
207 pub fn en(&mut self) -> EN_W<0> {
208 EN_W::new(self)
209 }
210 #[doc = "Bit 1 - Swap Channels"]
211 #[inline(always)]
212 #[must_use]
213 pub fn swap(&mut self) -> SWAP_W<1> {
214 SWAP_W::new(self)
215 }
216 #[doc = "Bit 3 - Alternative up-sampling ratio"]
217 #[inline(always)]
218 #[must_use]
219 pub fn altupr(&mut self) -> ALTUPR_W<3> {
220 ALTUPR_W::new(self)
221 }
222 #[doc = "Bit 4 - Common mode offset control"]
223 #[inline(always)]
224 #[must_use]
225 pub fn cmoc(&mut self) -> CMOC_W<4> {
226 CMOC_W::new(self)
227 }
228 #[doc = "Bit 5 - Mono mode"]
229 #[inline(always)]
230 #[must_use]
231 pub fn mono(&mut self) -> MONO_W<5> {
232 MONO_W::new(self)
233 }
234 #[doc = "Bit 7 - Software reset"]
235 #[inline(always)]
236 #[must_use]
237 pub fn swrst(&mut self) -> SWRST_W<7> {
238 SWRST_W::new(self)
239 }
240 #[doc = "Bits 16:18 - Data word format"]
241 #[inline(always)]
242 #[must_use]
243 pub fn dataformat(&mut self) -> DATAFORMAT_W<16> {
244 DATAFORMAT_W::new(self)
245 }
246 #[doc = "Bits 24:27 - Sampling frequency"]
247 #[inline(always)]
248 #[must_use]
249 pub fn fs(&mut self) -> FS_W<24> {
250 FS_W::new(self)
251 }
252 #[doc = "Writes raw bits to the register."]
253 #[inline(always)]
254 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
255 self.0.bits(bits);
256 self
257 }
258}
259#[doc = "Control 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 [cr](index.html) module"]
260pub struct CR_SPEC;
261impl crate::RegisterSpec for CR_SPEC {
262 type Ux = u32;
263}
264#[doc = "`read()` method returns [cr::R](R) reader structure"]
265impl crate::Readable for CR_SPEC {
266 type Reader = R;
267}
268#[doc = "`write(|w| ..)` method takes [cr::W](W) writer structure"]
269impl crate::Writable for CR_SPEC {
270 type Writer = W;
271 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
272 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
273}
274#[doc = "`reset()` method sets CR to value 0"]
275impl crate::Resettable for CR_SPEC {
276 const RESET_VALUE: Self::Ux = 0;
277}