avr_device/devices/attiny85/tc0/
tccr0b.rs1#[doc = "Register `TCCR0B` reader"]
2pub struct R(crate::R<TCCR0B_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<TCCR0B_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<TCCR0B_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<TCCR0B_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `TCCR0B` writer"]
17pub struct W(crate::W<TCCR0B_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<TCCR0B_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<TCCR0B_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<TCCR0B_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CS0` reader - Clock Select"]
38pub type CS0_R = crate::FieldReader<u8, CS0_A>;
39#[doc = "Clock Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CS0_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/64"]
50 PRESCALE_64 = 3,
51 #[doc = "4: Running, CLK/256"]
52 PRESCALE_256 = 4,
53 #[doc = "5: Running, CLK/1024"]
54 PRESCALE_1024 = 5,
55 #[doc = "6: Running, ExtClk Tx Falling Edge"]
56 EXT_FALLING = 6,
57 #[doc = "7: Running, ExtClk Tx Rising Edge"]
58 EXT_RISING = 7,
59}
60impl From<CS0_A> for u8 {
61 #[inline(always)]
62 fn from(variant: CS0_A) -> Self {
63 variant as _
64 }
65}
66impl CS0_R {
67 #[doc = "Get enumerated values variant"]
68 #[inline(always)]
69 pub fn variant(&self) -> CS0_A {
70 match self.bits {
71 0 => CS0_A::NO_CLOCK,
72 1 => CS0_A::DIRECT,
73 2 => CS0_A::PRESCALE_8,
74 3 => CS0_A::PRESCALE_64,
75 4 => CS0_A::PRESCALE_256,
76 5 => CS0_A::PRESCALE_1024,
77 6 => CS0_A::EXT_FALLING,
78 7 => CS0_A::EXT_RISING,
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 == CS0_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 == CS0_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 == CS0_A::PRESCALE_8
96 }
97 #[doc = "Checks if the value of the field is `PRESCALE_64`"]
98 #[inline(always)]
99 pub fn is_prescale_64(&self) -> bool {
100 *self == CS0_A::PRESCALE_64
101 }
102 #[doc = "Checks if the value of the field is `PRESCALE_256`"]
103 #[inline(always)]
104 pub fn is_prescale_256(&self) -> bool {
105 *self == CS0_A::PRESCALE_256
106 }
107 #[doc = "Checks if the value of the field is `PRESCALE_1024`"]
108 #[inline(always)]
109 pub fn is_prescale_1024(&self) -> bool {
110 *self == CS0_A::PRESCALE_1024
111 }
112 #[doc = "Checks if the value of the field is `EXT_FALLING`"]
113 #[inline(always)]
114 pub fn is_ext_falling(&self) -> bool {
115 *self == CS0_A::EXT_FALLING
116 }
117 #[doc = "Checks if the value of the field is `EXT_RISING`"]
118 #[inline(always)]
119 pub fn is_ext_rising(&self) -> bool {
120 *self == CS0_A::EXT_RISING
121 }
122}
123#[doc = "Field `CS0` writer - Clock Select"]
124pub type CS0_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TCCR0B_SPEC, u8, CS0_A, 3, O>;
125impl<'a, const O: u8> CS0_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(CS0_A::NO_CLOCK)
130 }
131 #[doc = "Running, No Prescaling"]
132 #[inline(always)]
133 pub fn direct(self) -> &'a mut W {
134 self.variant(CS0_A::DIRECT)
135 }
136 #[doc = "Running, CLK/8"]
137 #[inline(always)]
138 pub fn prescale_8(self) -> &'a mut W {
139 self.variant(CS0_A::PRESCALE_8)
140 }
141 #[doc = "Running, CLK/64"]
142 #[inline(always)]
143 pub fn prescale_64(self) -> &'a mut W {
144 self.variant(CS0_A::PRESCALE_64)
145 }
146 #[doc = "Running, CLK/256"]
147 #[inline(always)]
148 pub fn prescale_256(self) -> &'a mut W {
149 self.variant(CS0_A::PRESCALE_256)
150 }
151 #[doc = "Running, CLK/1024"]
152 #[inline(always)]
153 pub fn prescale_1024(self) -> &'a mut W {
154 self.variant(CS0_A::PRESCALE_1024)
155 }
156 #[doc = "Running, ExtClk Tx Falling Edge"]
157 #[inline(always)]
158 pub fn ext_falling(self) -> &'a mut W {
159 self.variant(CS0_A::EXT_FALLING)
160 }
161 #[doc = "Running, ExtClk Tx Rising Edge"]
162 #[inline(always)]
163 pub fn ext_rising(self) -> &'a mut W {
164 self.variant(CS0_A::EXT_RISING)
165 }
166}
167#[doc = "Field `WGM02` reader - Waveform Generation Mode High Bit (Enable Top: *OCRA* for `PWM` modes)"]
168pub type WGM02_R = crate::BitReader<bool>;
169#[doc = "Field `WGM02` writer - Waveform Generation Mode High Bit (Enable Top: *OCRA* for `PWM` modes)"]
170pub type WGM02_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR0B_SPEC, bool, O>;
171#[doc = "Field `FOC0B` writer - Force Output Compare B"]
172pub type FOC0B_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR0B_SPEC, bool, O>;
173#[doc = "Field `FOC0A` writer - Force Output Compare A"]
174pub type FOC0A_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR0B_SPEC, bool, O>;
175impl R {
176 #[doc = "Bits 0:2 - Clock Select"]
177 #[inline(always)]
178 pub fn cs0(&self) -> CS0_R {
179 CS0_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 wgm02(&self) -> WGM02_R {
184 WGM02_R::new(((self.bits >> 3) & 1) != 0)
185 }
186}
187impl W {
188 #[doc = "Bits 0:2 - Clock Select"]
189 #[inline(always)]
190 #[must_use]
191 pub fn cs0(&mut self) -> CS0_W<0> {
192 CS0_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 wgm02(&mut self) -> WGM02_W<3> {
198 WGM02_W::new(self)
199 }
200 #[doc = "Bit 6 - Force Output Compare B"]
201 #[inline(always)]
202 #[must_use]
203 pub fn foc0b(&mut self) -> FOC0B_W<6> {
204 FOC0B_W::new(self)
205 }
206 #[doc = "Bit 7 - Force Output Compare A"]
207 #[inline(always)]
208 #[must_use]
209 pub fn foc0a(&mut self) -> FOC0A_W<7> {
210 FOC0A_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/Counter 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 [tccr0b](index.html) module"]
220pub struct TCCR0B_SPEC;
221impl crate::RegisterSpec for TCCR0B_SPEC {
222 type Ux = u8;
223}
224#[doc = "`read()` method returns [tccr0b::R](R) reader structure"]
225impl crate::Readable for TCCR0B_SPEC {
226 type Reader = R;
227}
228#[doc = "`write(|w| ..)` method takes [tccr0b::W](W) writer structure"]
229impl crate::Writable for TCCR0B_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 TCCR0B to value 0"]
235impl crate::Resettable for TCCR0B_SPEC {
236 const RESET_VALUE: Self::Ux = 0;
237}