avr_device/devices/atmega2560/tc2/
tccr2b.rs1#[doc = "Register `TCCR2B` reader"]
2pub struct R(crate::R<TCCR2B_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<TCCR2B_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<TCCR2B_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<TCCR2B_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `TCCR2B` writer"]
17pub struct W(crate::W<TCCR2B_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<TCCR2B_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<TCCR2B_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<TCCR2B_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CS2` reader - Clock Select bits"]
38pub type CS2_R = crate::FieldReader<u8, CS2_A>;
39#[doc = "Clock Select bits\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CS2_A {
43 #[doc = "0: No clock source (Timer/Counter stopped)"]
44 NO_CLOCK = 0,
45 #[doc = "1: Running, No Prescaling"]
46 DIRECT = 1,
47 #[doc = "2: Running, CLK/8"]
48 PRESCALE_8 = 2,
49 #[doc = "3: Running, CLK/32"]
50 PRESCALE_32 = 3,
51 #[doc = "4: Running, CLK/64"]
52 PRESCALE_64 = 4,
53 #[doc = "5: Running, CLK/128"]
54 PRESCALE_128 = 5,
55 #[doc = "6: Running, CLK/256"]
56 PRESCALE_256 = 6,
57 #[doc = "7: Running, CLK/1024"]
58 PRESCALE_1024 = 7,
59}
60impl From<CS2_A> for u8 {
61 #[inline(always)]
62 fn from(variant: CS2_A) -> Self {
63 variant as _
64 }
65}
66impl CS2_R {
67 #[doc = "Get enumerated values variant"]
68 #[inline(always)]
69 pub fn variant(&self) -> CS2_A {
70 match self.bits {
71 0 => CS2_A::NO_CLOCK,
72 1 => CS2_A::DIRECT,
73 2 => CS2_A::PRESCALE_8,
74 3 => CS2_A::PRESCALE_32,
75 4 => CS2_A::PRESCALE_64,
76 5 => CS2_A::PRESCALE_128,
77 6 => CS2_A::PRESCALE_256,
78 7 => CS2_A::PRESCALE_1024,
79 _ => unreachable!(),
80 }
81 }
82 #[doc = "Checks if the value of the field is `NO_CLOCK`"]
83 #[inline(always)]
84 pub fn is_no_clock(&self) -> bool {
85 *self == CS2_A::NO_CLOCK
86 }
87 #[doc = "Checks if the value of the field is `DIRECT`"]
88 #[inline(always)]
89 pub fn is_direct(&self) -> bool {
90 *self == CS2_A::DIRECT
91 }
92 #[doc = "Checks if the value of the field is `PRESCALE_8`"]
93 #[inline(always)]
94 pub fn is_prescale_8(&self) -> bool {
95 *self == CS2_A::PRESCALE_8
96 }
97 #[doc = "Checks if the value of the field is `PRESCALE_32`"]
98 #[inline(always)]
99 pub fn is_prescale_32(&self) -> bool {
100 *self == CS2_A::PRESCALE_32
101 }
102 #[doc = "Checks if the value of the field is `PRESCALE_64`"]
103 #[inline(always)]
104 pub fn is_prescale_64(&self) -> bool {
105 *self == CS2_A::PRESCALE_64
106 }
107 #[doc = "Checks if the value of the field is `PRESCALE_128`"]
108 #[inline(always)]
109 pub fn is_prescale_128(&self) -> bool {
110 *self == CS2_A::PRESCALE_128
111 }
112 #[doc = "Checks if the value of the field is `PRESCALE_256`"]
113 #[inline(always)]
114 pub fn is_prescale_256(&self) -> bool {
115 *self == CS2_A::PRESCALE_256
116 }
117 #[doc = "Checks if the value of the field is `PRESCALE_1024`"]
118 #[inline(always)]
119 pub fn is_prescale_1024(&self) -> bool {
120 *self == CS2_A::PRESCALE_1024
121 }
122}
123#[doc = "Field `CS2` writer - Clock Select bits"]
124pub type CS2_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TCCR2B_SPEC, u8, CS2_A, 3, O>;
125impl<'a, const O: u8> CS2_W<'a, O> {
126 #[doc = "No clock source (Timer/Counter stopped)"]
127 #[inline(always)]
128 pub fn no_clock(self) -> &'a mut W {
129 self.variant(CS2_A::NO_CLOCK)
130 }
131 #[doc = "Running, No Prescaling"]
132 #[inline(always)]
133 pub fn direct(self) -> &'a mut W {
134 self.variant(CS2_A::DIRECT)
135 }
136 #[doc = "Running, CLK/8"]
137 #[inline(always)]
138 pub fn prescale_8(self) -> &'a mut W {
139 self.variant(CS2_A::PRESCALE_8)
140 }
141 #[doc = "Running, CLK/32"]
142 #[inline(always)]
143 pub fn prescale_32(self) -> &'a mut W {
144 self.variant(CS2_A::PRESCALE_32)
145 }
146 #[doc = "Running, CLK/64"]
147 #[inline(always)]
148 pub fn prescale_64(self) -> &'a mut W {
149 self.variant(CS2_A::PRESCALE_64)
150 }
151 #[doc = "Running, CLK/128"]
152 #[inline(always)]
153 pub fn prescale_128(self) -> &'a mut W {
154 self.variant(CS2_A::PRESCALE_128)
155 }
156 #[doc = "Running, CLK/256"]
157 #[inline(always)]
158 pub fn prescale_256(self) -> &'a mut W {
159 self.variant(CS2_A::PRESCALE_256)
160 }
161 #[doc = "Running, CLK/1024"]
162 #[inline(always)]
163 pub fn prescale_1024(self) -> &'a mut W {
164 self.variant(CS2_A::PRESCALE_1024)
165 }
166}
167#[doc = "Field `WGM22` reader - Waveform Generation Mode High Bit (Enable Top: *OCRA* for `PWM` modes)"]
168pub type WGM22_R = crate::BitReader<bool>;
169#[doc = "Field `WGM22` writer - Waveform Generation Mode High Bit (Enable Top: *OCRA* for `PWM` modes)"]
170pub type WGM22_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR2B_SPEC, bool, O>;
171#[doc = "Field `FOC2B` writer - Force Output Compare B"]
172pub type FOC2B_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR2B_SPEC, bool, O>;
173#[doc = "Field `FOC2A` writer - Force Output Compare A"]
174pub type FOC2A_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR2B_SPEC, bool, O>;
175impl R {
176 #[doc = "Bits 0:2 - Clock Select bits"]
177 #[inline(always)]
178 pub fn cs2(&self) -> CS2_R {
179 CS2_R::new(self.bits & 7)
180 }
181 #[doc = "Bit 3 - Waveform Generation Mode High Bit (Enable Top: *OCRA* for `PWM` modes)"]
182 #[inline(always)]
183 pub fn wgm22(&self) -> WGM22_R {
184 WGM22_R::new(((self.bits >> 3) & 1) != 0)
185 }
186}
187impl W {
188 #[doc = "Bits 0:2 - Clock Select bits"]
189 #[inline(always)]
190 #[must_use]
191 pub fn cs2(&mut self) -> CS2_W<0> {
192 CS2_W::new(self)
193 }
194 #[doc = "Bit 3 - Waveform Generation Mode High Bit (Enable Top: *OCRA* for `PWM` modes)"]
195 #[inline(always)]
196 #[must_use]
197 pub fn wgm22(&mut self) -> WGM22_W<3> {
198 WGM22_W::new(self)
199 }
200 #[doc = "Bit 6 - Force Output Compare B"]
201 #[inline(always)]
202 #[must_use]
203 pub fn foc2b(&mut self) -> FOC2B_W<6> {
204 FOC2B_W::new(self)
205 }
206 #[doc = "Bit 7 - Force Output Compare A"]
207 #[inline(always)]
208 #[must_use]
209 pub fn foc2a(&mut self) -> FOC2A_W<7> {
210 FOC2A_W::new(self)
211 }
212 #[doc = "Writes raw bits to the register."]
213 #[inline(always)]
214 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
215 self.0.bits(bits);
216 self
217 }
218}
219#[doc = "Timer/Counter2 Control Register 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 [tccr2b](index.html) module"]
220pub struct TCCR2B_SPEC;
221impl crate::RegisterSpec for TCCR2B_SPEC {
222 type Ux = u8;
223}
224#[doc = "`read()` method returns [tccr2b::R](R) reader structure"]
225impl crate::Readable for TCCR2B_SPEC {
226 type Reader = R;
227}
228#[doc = "`write(|w| ..)` method takes [tccr2b::W](W) writer structure"]
229impl crate::Writable for TCCR2B_SPEC {
230 type Writer = W;
231 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
232 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
233}
234#[doc = "`reset()` method sets TCCR2B to value 0"]
235impl crate::Resettable for TCCR2B_SPEC {
236 const RESET_VALUE: Self::Ux = 0;
237}