avr_device/devices/atmega328p/tc1/
tccr1a.rs

1#[doc = "Register `TCCR1A` reader"]
2pub struct R(crate::R<TCCR1A_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TCCR1A_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TCCR1A_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TCCR1A_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TCCR1A` writer"]
17pub struct W(crate::W<TCCR1A_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TCCR1A_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<TCCR1A_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TCCR1A_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `WGM1` reader - Waveform Generation Mode"]
38pub type WGM1_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `WGM1` writer - Waveform Generation Mode"]
40pub type WGM1_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TCCR1A_SPEC, u8, u8, 2, O>;
41#[doc = "Field `COM1B` reader - Compare Output Mode 1B, bits"]
42pub type COM1B_R = crate::FieldReader<u8, COM1B_A>;
43#[doc = "Compare Output Mode 1B, bits\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum COM1B_A {
47    #[doc = "0: Normal port operation, OCix disconnected"]
48    DISCONNECTED = 0,
49    #[doc = "1: Toggle OCix on Compare Match (Might depend on WGM)"]
50    MATCH_TOGGLE = 1,
51    #[doc = "2: Clear OCix on Compare Match (If PWM is enabled, OCix is set at BOTTOM)"]
52    MATCH_CLEAR = 2,
53    #[doc = "3: Set OCix on Compare Match (If PWM is enabled, OCix is cleared at BOTTOM)"]
54    MATCH_SET = 3,
55}
56impl From<COM1B_A> for u8 {
57    #[inline(always)]
58    fn from(variant: COM1B_A) -> Self {
59        variant as _
60    }
61}
62impl COM1B_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> COM1B_A {
66        match self.bits {
67            0 => COM1B_A::DISCONNECTED,
68            1 => COM1B_A::MATCH_TOGGLE,
69            2 => COM1B_A::MATCH_CLEAR,
70            3 => COM1B_A::MATCH_SET,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `DISCONNECTED`"]
75    #[inline(always)]
76    pub fn is_disconnected(&self) -> bool {
77        *self == COM1B_A::DISCONNECTED
78    }
79    #[doc = "Checks if the value of the field is `MATCH_TOGGLE`"]
80    #[inline(always)]
81    pub fn is_match_toggle(&self) -> bool {
82        *self == COM1B_A::MATCH_TOGGLE
83    }
84    #[doc = "Checks if the value of the field is `MATCH_CLEAR`"]
85    #[inline(always)]
86    pub fn is_match_clear(&self) -> bool {
87        *self == COM1B_A::MATCH_CLEAR
88    }
89    #[doc = "Checks if the value of the field is `MATCH_SET`"]
90    #[inline(always)]
91    pub fn is_match_set(&self) -> bool {
92        *self == COM1B_A::MATCH_SET
93    }
94}
95#[doc = "Field `COM1B` writer - Compare Output Mode 1B, bits"]
96pub type COM1B_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TCCR1A_SPEC, u8, COM1B_A, 2, O>;
97impl<'a, const O: u8> COM1B_W<'a, O> {
98    #[doc = "Normal port operation, OCix disconnected"]
99    #[inline(always)]
100    pub fn disconnected(self) -> &'a mut W {
101        self.variant(COM1B_A::DISCONNECTED)
102    }
103    #[doc = "Toggle OCix on Compare Match (Might depend on WGM)"]
104    #[inline(always)]
105    pub fn match_toggle(self) -> &'a mut W {
106        self.variant(COM1B_A::MATCH_TOGGLE)
107    }
108    #[doc = "Clear OCix on Compare Match (If PWM is enabled, OCix is set at BOTTOM)"]
109    #[inline(always)]
110    pub fn match_clear(self) -> &'a mut W {
111        self.variant(COM1B_A::MATCH_CLEAR)
112    }
113    #[doc = "Set OCix on Compare Match (If PWM is enabled, OCix is cleared at BOTTOM)"]
114    #[inline(always)]
115    pub fn match_set(self) -> &'a mut W {
116        self.variant(COM1B_A::MATCH_SET)
117    }
118}
119#[doc = "Field `COM1A` reader - Compare Output Mode 1A, bits"]
120pub use COM1B_R as COM1A_R;
121#[doc = "Field `COM1A` writer - Compare Output Mode 1A, bits"]
122pub use COM1B_W as COM1A_W;
123impl R {
124    #[doc = "Bits 0:1 - Waveform Generation Mode"]
125    #[inline(always)]
126    pub fn wgm1(&self) -> WGM1_R {
127        WGM1_R::new(self.bits & 3)
128    }
129    #[doc = "Bits 4:5 - Compare Output Mode 1B, bits"]
130    #[inline(always)]
131    pub fn com1b(&self) -> COM1B_R {
132        COM1B_R::new((self.bits >> 4) & 3)
133    }
134    #[doc = "Bits 6:7 - Compare Output Mode 1A, bits"]
135    #[inline(always)]
136    pub fn com1a(&self) -> COM1A_R {
137        COM1A_R::new((self.bits >> 6) & 3)
138    }
139}
140impl W {
141    #[doc = "Bits 0:1 - Waveform Generation Mode"]
142    #[inline(always)]
143    #[must_use]
144    pub fn wgm1(&mut self) -> WGM1_W<0> {
145        WGM1_W::new(self)
146    }
147    #[doc = "Bits 4:5 - Compare Output Mode 1B, bits"]
148    #[inline(always)]
149    #[must_use]
150    pub fn com1b(&mut self) -> COM1B_W<4> {
151        COM1B_W::new(self)
152    }
153    #[doc = "Bits 6:7 - Compare Output Mode 1A, bits"]
154    #[inline(always)]
155    #[must_use]
156    pub fn com1a(&mut self) -> COM1A_W<6> {
157        COM1A_W::new(self)
158    }
159    #[doc = "Writes raw bits to the register."]
160    #[inline(always)]
161    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
162        self.0.bits(bits);
163        self
164    }
165}
166#[doc = "Timer/Counter1 Control Register A\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 [tccr1a](index.html) module"]
167pub struct TCCR1A_SPEC;
168impl crate::RegisterSpec for TCCR1A_SPEC {
169    type Ux = u8;
170}
171#[doc = "`read()` method returns [tccr1a::R](R) reader structure"]
172impl crate::Readable for TCCR1A_SPEC {
173    type Reader = R;
174}
175#[doc = "`write(|w| ..)` method takes [tccr1a::W](W) writer structure"]
176impl crate::Writable for TCCR1A_SPEC {
177    type Writer = W;
178    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
179    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
180}
181#[doc = "`reset()` method sets TCCR1A to value 0"]
182impl crate::Resettable for TCCR1A_SPEC {
183    const RESET_VALUE: Self::Ux = 0;
184}