avr_device/devices/atmega4809/adc0/
ctrlb.rs1#[doc = "Register `CTRLB` reader"]
2pub struct R(crate::R<CTRLB_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRLB_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRLB_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRLB_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRLB` writer"]
17pub struct W(crate::W<CTRLB_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRLB_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<CTRLB_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRLB_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `SAMPNUM` reader - Accumulation Samples"]
38pub type SAMPNUM_R = crate::FieldReader<u8, SAMPNUM_A>;
39#[doc = "Accumulation Samples\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum SAMPNUM_A {
43 #[doc = "0: 1 ADC sample"]
44 ACC1 = 0,
45 #[doc = "1: Accumulate 2 samples"]
46 ACC2 = 1,
47 #[doc = "2: Accumulate 4 samples"]
48 ACC4 = 2,
49 #[doc = "3: Accumulate 8 samples"]
50 ACC8 = 3,
51 #[doc = "4: Accumulate 16 samples"]
52 ACC16 = 4,
53 #[doc = "5: Accumulate 32 samples"]
54 ACC32 = 5,
55 #[doc = "6: Accumulate 64 samples"]
56 ACC64 = 6,
57}
58impl From<SAMPNUM_A> for u8 {
59 #[inline(always)]
60 fn from(variant: SAMPNUM_A) -> Self {
61 variant as _
62 }
63}
64impl SAMPNUM_R {
65 #[doc = "Get enumerated values variant"]
66 #[inline(always)]
67 pub fn variant(&self) -> Option<SAMPNUM_A> {
68 match self.bits {
69 0 => Some(SAMPNUM_A::ACC1),
70 1 => Some(SAMPNUM_A::ACC2),
71 2 => Some(SAMPNUM_A::ACC4),
72 3 => Some(SAMPNUM_A::ACC8),
73 4 => Some(SAMPNUM_A::ACC16),
74 5 => Some(SAMPNUM_A::ACC32),
75 6 => Some(SAMPNUM_A::ACC64),
76 _ => None,
77 }
78 }
79 #[doc = "Checks if the value of the field is `ACC1`"]
80 #[inline(always)]
81 pub fn is_acc1(&self) -> bool {
82 *self == SAMPNUM_A::ACC1
83 }
84 #[doc = "Checks if the value of the field is `ACC2`"]
85 #[inline(always)]
86 pub fn is_acc2(&self) -> bool {
87 *self == SAMPNUM_A::ACC2
88 }
89 #[doc = "Checks if the value of the field is `ACC4`"]
90 #[inline(always)]
91 pub fn is_acc4(&self) -> bool {
92 *self == SAMPNUM_A::ACC4
93 }
94 #[doc = "Checks if the value of the field is `ACC8`"]
95 #[inline(always)]
96 pub fn is_acc8(&self) -> bool {
97 *self == SAMPNUM_A::ACC8
98 }
99 #[doc = "Checks if the value of the field is `ACC16`"]
100 #[inline(always)]
101 pub fn is_acc16(&self) -> bool {
102 *self == SAMPNUM_A::ACC16
103 }
104 #[doc = "Checks if the value of the field is `ACC32`"]
105 #[inline(always)]
106 pub fn is_acc32(&self) -> bool {
107 *self == SAMPNUM_A::ACC32
108 }
109 #[doc = "Checks if the value of the field is `ACC64`"]
110 #[inline(always)]
111 pub fn is_acc64(&self) -> bool {
112 *self == SAMPNUM_A::ACC64
113 }
114}
115#[doc = "Field `SAMPNUM` writer - Accumulation Samples"]
116pub type SAMPNUM_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CTRLB_SPEC, u8, SAMPNUM_A, 3, O>;
117impl<'a, const O: u8> SAMPNUM_W<'a, O> {
118 #[doc = "1 ADC sample"]
119 #[inline(always)]
120 pub fn acc1(self) -> &'a mut W {
121 self.variant(SAMPNUM_A::ACC1)
122 }
123 #[doc = "Accumulate 2 samples"]
124 #[inline(always)]
125 pub fn acc2(self) -> &'a mut W {
126 self.variant(SAMPNUM_A::ACC2)
127 }
128 #[doc = "Accumulate 4 samples"]
129 #[inline(always)]
130 pub fn acc4(self) -> &'a mut W {
131 self.variant(SAMPNUM_A::ACC4)
132 }
133 #[doc = "Accumulate 8 samples"]
134 #[inline(always)]
135 pub fn acc8(self) -> &'a mut W {
136 self.variant(SAMPNUM_A::ACC8)
137 }
138 #[doc = "Accumulate 16 samples"]
139 #[inline(always)]
140 pub fn acc16(self) -> &'a mut W {
141 self.variant(SAMPNUM_A::ACC16)
142 }
143 #[doc = "Accumulate 32 samples"]
144 #[inline(always)]
145 pub fn acc32(self) -> &'a mut W {
146 self.variant(SAMPNUM_A::ACC32)
147 }
148 #[doc = "Accumulate 64 samples"]
149 #[inline(always)]
150 pub fn acc64(self) -> &'a mut W {
151 self.variant(SAMPNUM_A::ACC64)
152 }
153}
154impl R {
155 #[doc = "Bits 0:2 - Accumulation Samples"]
156 #[inline(always)]
157 pub fn sampnum(&self) -> SAMPNUM_R {
158 SAMPNUM_R::new(self.bits & 7)
159 }
160}
161impl W {
162 #[doc = "Bits 0:2 - Accumulation Samples"]
163 #[inline(always)]
164 #[must_use]
165 pub fn sampnum(&mut self) -> SAMPNUM_W<0> {
166 SAMPNUM_W::new(self)
167 }
168 #[doc = "Writes raw bits to the register."]
169 #[inline(always)]
170 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
171 self.0.bits(bits);
172 self
173 }
174}
175#[doc = "Control B\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 [ctrlb](index.html) module"]
176pub struct CTRLB_SPEC;
177impl crate::RegisterSpec for CTRLB_SPEC {
178 type Ux = u8;
179}
180#[doc = "`read()` method returns [ctrlb::R](R) reader structure"]
181impl crate::Readable for CTRLB_SPEC {
182 type Reader = R;
183}
184#[doc = "`write(|w| ..)` method takes [ctrlb::W](W) writer structure"]
185impl crate::Writable for CTRLB_SPEC {
186 type Writer = W;
187 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
188 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
189}
190#[doc = "`reset()` method sets CTRLB to value 0"]
191impl crate::Resettable for CTRLB_SPEC {
192 const RESET_VALUE: Self::Ux = 0;
193}