avr_device/devices/atmega2560/tc3/
tccr3b.rs

1#[doc = "Register `TCCR3B` reader"]
2pub struct R(crate::R<TCCR3B_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TCCR3B_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TCCR3B_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TCCR3B_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TCCR3B` writer"]
17pub struct W(crate::W<TCCR3B_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TCCR3B_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<TCCR3B_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TCCR3B_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CS3` reader - Prescaler source of Timer/Counter 3"]
38pub type CS3_R = crate::FieldReader<u8, CS3_A>;
39#[doc = "Prescaler source of Timer/Counter 3\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CS3_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<CS3_A> for u8 {
61    #[inline(always)]
62    fn from(variant: CS3_A) -> Self {
63        variant as _
64    }
65}
66impl CS3_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> CS3_A {
70        match self.bits {
71            0 => CS3_A::NO_CLOCK,
72            1 => CS3_A::DIRECT,
73            2 => CS3_A::PRESCALE_8,
74            3 => CS3_A::PRESCALE_64,
75            4 => CS3_A::PRESCALE_256,
76            5 => CS3_A::PRESCALE_1024,
77            6 => CS3_A::EXT_FALLING,
78            7 => CS3_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 == CS3_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 == CS3_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 == CS3_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 == CS3_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 == CS3_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 == CS3_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 == CS3_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 == CS3_A::EXT_RISING
121    }
122}
123#[doc = "Field `CS3` writer - Prescaler source of Timer/Counter 3"]
124pub type CS3_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TCCR3B_SPEC, u8, CS3_A, 3, O>;
125impl<'a, const O: u8> CS3_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(CS3_A::NO_CLOCK)
130    }
131    #[doc = "Running, No Prescaling"]
132    #[inline(always)]
133    pub fn direct(self) -> &'a mut W {
134        self.variant(CS3_A::DIRECT)
135    }
136    #[doc = "Running, CLK/8"]
137    #[inline(always)]
138    pub fn prescale_8(self) -> &'a mut W {
139        self.variant(CS3_A::PRESCALE_8)
140    }
141    #[doc = "Running, CLK/64"]
142    #[inline(always)]
143    pub fn prescale_64(self) -> &'a mut W {
144        self.variant(CS3_A::PRESCALE_64)
145    }
146    #[doc = "Running, CLK/256"]
147    #[inline(always)]
148    pub fn prescale_256(self) -> &'a mut W {
149        self.variant(CS3_A::PRESCALE_256)
150    }
151    #[doc = "Running, CLK/1024"]
152    #[inline(always)]
153    pub fn prescale_1024(self) -> &'a mut W {
154        self.variant(CS3_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(CS3_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(CS3_A::EXT_RISING)
165    }
166}
167#[doc = "Field `WGM3` reader - Waveform Generation Mode"]
168pub type WGM3_R = crate::FieldReader<u8, u8>;
169#[doc = "Field `WGM3` writer - Waveform Generation Mode"]
170pub type WGM3_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TCCR3B_SPEC, u8, u8, 2, O>;
171#[doc = "Field `ICES3` reader - Input Capture 3 Edge Select"]
172pub type ICES3_R = crate::BitReader<bool>;
173#[doc = "Field `ICES3` writer - Input Capture 3 Edge Select"]
174pub type ICES3_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR3B_SPEC, bool, O>;
175#[doc = "Field `ICNC3` reader - Input Capture 3 Noise Canceler"]
176pub type ICNC3_R = crate::BitReader<bool>;
177#[doc = "Field `ICNC3` writer - Input Capture 3 Noise Canceler"]
178pub type ICNC3_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR3B_SPEC, bool, O>;
179impl R {
180    #[doc = "Bits 0:2 - Prescaler source of Timer/Counter 3"]
181    #[inline(always)]
182    pub fn cs3(&self) -> CS3_R {
183        CS3_R::new(self.bits & 7)
184    }
185    #[doc = "Bits 3:4 - Waveform Generation Mode"]
186    #[inline(always)]
187    pub fn wgm3(&self) -> WGM3_R {
188        WGM3_R::new((self.bits >> 3) & 3)
189    }
190    #[doc = "Bit 6 - Input Capture 3 Edge Select"]
191    #[inline(always)]
192    pub fn ices3(&self) -> ICES3_R {
193        ICES3_R::new(((self.bits >> 6) & 1) != 0)
194    }
195    #[doc = "Bit 7 - Input Capture 3 Noise Canceler"]
196    #[inline(always)]
197    pub fn icnc3(&self) -> ICNC3_R {
198        ICNC3_R::new(((self.bits >> 7) & 1) != 0)
199    }
200}
201impl W {
202    #[doc = "Bits 0:2 - Prescaler source of Timer/Counter 3"]
203    #[inline(always)]
204    #[must_use]
205    pub fn cs3(&mut self) -> CS3_W<0> {
206        CS3_W::new(self)
207    }
208    #[doc = "Bits 3:4 - Waveform Generation Mode"]
209    #[inline(always)]
210    #[must_use]
211    pub fn wgm3(&mut self) -> WGM3_W<3> {
212        WGM3_W::new(self)
213    }
214    #[doc = "Bit 6 - Input Capture 3 Edge Select"]
215    #[inline(always)]
216    #[must_use]
217    pub fn ices3(&mut self) -> ICES3_W<6> {
218        ICES3_W::new(self)
219    }
220    #[doc = "Bit 7 - Input Capture 3 Noise Canceler"]
221    #[inline(always)]
222    #[must_use]
223    pub fn icnc3(&mut self) -> ICNC3_W<7> {
224        ICNC3_W::new(self)
225    }
226    #[doc = "Writes raw bits to the register."]
227    #[inline(always)]
228    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
229        self.0.bits(bits);
230        self
231    }
232}
233#[doc = "Timer/Counter3 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 [tccr3b](index.html) module"]
234pub struct TCCR3B_SPEC;
235impl crate::RegisterSpec for TCCR3B_SPEC {
236    type Ux = u8;
237}
238#[doc = "`read()` method returns [tccr3b::R](R) reader structure"]
239impl crate::Readable for TCCR3B_SPEC {
240    type Reader = R;
241}
242#[doc = "`write(|w| ..)` method takes [tccr3b::W](W) writer structure"]
243impl crate::Writable for TCCR3B_SPEC {
244    type Writer = W;
245    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
246    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
247}
248#[doc = "`reset()` method sets TCCR3B to value 0"]
249impl crate::Resettable for TCCR3B_SPEC {
250    const RESET_VALUE: Self::Ux = 0;
251}