avr_device/devices/atmega32u4/tc4/
tccr4c.rs

1#[doc = "Register `TCCR4C` reader"]
2pub struct R(crate::R<TCCR4C_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TCCR4C_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TCCR4C_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TCCR4C_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TCCR4C` writer"]
17pub struct W(crate::W<TCCR4C_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TCCR4C_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<TCCR4C_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TCCR4C_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `PWM4D` reader - Pulse Width Modulator D Enable"]
38pub type PWM4D_R = crate::BitReader<bool>;
39#[doc = "Field `PWM4D` writer - Pulse Width Modulator D Enable"]
40pub type PWM4D_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR4C_SPEC, bool, O>;
41#[doc = "Field `FOC4D` writer - Force Output Compare Match 4D"]
42pub type FOC4D_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR4C_SPEC, bool, O>;
43#[doc = "Field `COM4D` reader - Comparator D Output Mode"]
44pub type COM4D_R = crate::FieldReader<u8, COM4D_A>;
45#[doc = "Comparator D Output Mode\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47#[repr(u8)]
48pub enum COM4D_A {
49    #[doc = "0: Normal port operation, OCix disconnected"]
50    DISCONNECTED = 0,
51    #[doc = "1: Toggle OCix on Compare Match (Might depend on WGM)"]
52    MATCH_TOGGLE = 1,
53    #[doc = "2: Clear OCix on Compare Match (If PWM is enabled, OCix is set at TOP)"]
54    MATCH_CLEAR = 2,
55    #[doc = "3: Set OCix on Compare Match (If PWM is enabled, OCix is cleared at TOP)"]
56    MATCH_SET = 3,
57}
58impl From<COM4D_A> for u8 {
59    #[inline(always)]
60    fn from(variant: COM4D_A) -> Self {
61        variant as _
62    }
63}
64impl COM4D_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> COM4D_A {
68        match self.bits {
69            0 => COM4D_A::DISCONNECTED,
70            1 => COM4D_A::MATCH_TOGGLE,
71            2 => COM4D_A::MATCH_CLEAR,
72            3 => COM4D_A::MATCH_SET,
73            _ => unreachable!(),
74        }
75    }
76    #[doc = "Checks if the value of the field is `DISCONNECTED`"]
77    #[inline(always)]
78    pub fn is_disconnected(&self) -> bool {
79        *self == COM4D_A::DISCONNECTED
80    }
81    #[doc = "Checks if the value of the field is `MATCH_TOGGLE`"]
82    #[inline(always)]
83    pub fn is_match_toggle(&self) -> bool {
84        *self == COM4D_A::MATCH_TOGGLE
85    }
86    #[doc = "Checks if the value of the field is `MATCH_CLEAR`"]
87    #[inline(always)]
88    pub fn is_match_clear(&self) -> bool {
89        *self == COM4D_A::MATCH_CLEAR
90    }
91    #[doc = "Checks if the value of the field is `MATCH_SET`"]
92    #[inline(always)]
93    pub fn is_match_set(&self) -> bool {
94        *self == COM4D_A::MATCH_SET
95    }
96}
97#[doc = "Field `COM4D` writer - Comparator D Output Mode"]
98pub type COM4D_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TCCR4C_SPEC, u8, COM4D_A, 2, O>;
99impl<'a, const O: u8> COM4D_W<'a, O> {
100    #[doc = "Normal port operation, OCix disconnected"]
101    #[inline(always)]
102    pub fn disconnected(self) -> &'a mut W {
103        self.variant(COM4D_A::DISCONNECTED)
104    }
105    #[doc = "Toggle OCix on Compare Match (Might depend on WGM)"]
106    #[inline(always)]
107    pub fn match_toggle(self) -> &'a mut W {
108        self.variant(COM4D_A::MATCH_TOGGLE)
109    }
110    #[doc = "Clear OCix on Compare Match (If PWM is enabled, OCix is set at TOP)"]
111    #[inline(always)]
112    pub fn match_clear(self) -> &'a mut W {
113        self.variant(COM4D_A::MATCH_CLEAR)
114    }
115    #[doc = "Set OCix on Compare Match (If PWM is enabled, OCix is cleared at TOP)"]
116    #[inline(always)]
117    pub fn match_set(self) -> &'a mut W {
118        self.variant(COM4D_A::MATCH_SET)
119    }
120}
121#[doc = "Field `COM4B0S` reader - Comparator B Output Mode"]
122pub type COM4B0S_R = crate::BitReader<bool>;
123#[doc = "Field `COM4B0S` writer - Comparator B Output Mode"]
124pub type COM4B0S_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR4C_SPEC, bool, O>;
125#[doc = "Field `COM4B1S` reader - Comparator B Output Mode"]
126pub type COM4B1S_R = crate::BitReader<bool>;
127#[doc = "Field `COM4B1S` writer - Comparator B Output Mode"]
128pub type COM4B1S_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR4C_SPEC, bool, O>;
129#[doc = "Field `COM4A0S` reader - Comparator A Output Mode"]
130pub type COM4A0S_R = crate::BitReader<bool>;
131#[doc = "Field `COM4A0S` writer - Comparator A Output Mode"]
132pub type COM4A0S_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR4C_SPEC, bool, O>;
133#[doc = "Field `COM4A1S` reader - Comparator A Output Mode"]
134pub type COM4A1S_R = crate::BitReader<bool>;
135#[doc = "Field `COM4A1S` writer - Comparator A Output Mode"]
136pub type COM4A1S_W<'a, const O: u8> = crate::BitWriter<'a, u8, TCCR4C_SPEC, bool, O>;
137impl R {
138    #[doc = "Bit 0 - Pulse Width Modulator D Enable"]
139    #[inline(always)]
140    pub fn pwm4d(&self) -> PWM4D_R {
141        PWM4D_R::new((self.bits & 1) != 0)
142    }
143    #[doc = "Bits 2:3 - Comparator D Output Mode"]
144    #[inline(always)]
145    pub fn com4d(&self) -> COM4D_R {
146        COM4D_R::new((self.bits >> 2) & 3)
147    }
148    #[doc = "Bit 4 - Comparator B Output Mode"]
149    #[inline(always)]
150    pub fn com4b0s(&self) -> COM4B0S_R {
151        COM4B0S_R::new(((self.bits >> 4) & 1) != 0)
152    }
153    #[doc = "Bit 5 - Comparator B Output Mode"]
154    #[inline(always)]
155    pub fn com4b1s(&self) -> COM4B1S_R {
156        COM4B1S_R::new(((self.bits >> 5) & 1) != 0)
157    }
158    #[doc = "Bit 6 - Comparator A Output Mode"]
159    #[inline(always)]
160    pub fn com4a0s(&self) -> COM4A0S_R {
161        COM4A0S_R::new(((self.bits >> 6) & 1) != 0)
162    }
163    #[doc = "Bit 7 - Comparator A Output Mode"]
164    #[inline(always)]
165    pub fn com4a1s(&self) -> COM4A1S_R {
166        COM4A1S_R::new(((self.bits >> 7) & 1) != 0)
167    }
168}
169impl W {
170    #[doc = "Bit 0 - Pulse Width Modulator D Enable"]
171    #[inline(always)]
172    #[must_use]
173    pub fn pwm4d(&mut self) -> PWM4D_W<0> {
174        PWM4D_W::new(self)
175    }
176    #[doc = "Bit 1 - Force Output Compare Match 4D"]
177    #[inline(always)]
178    #[must_use]
179    pub fn foc4d(&mut self) -> FOC4D_W<1> {
180        FOC4D_W::new(self)
181    }
182    #[doc = "Bits 2:3 - Comparator D Output Mode"]
183    #[inline(always)]
184    #[must_use]
185    pub fn com4d(&mut self) -> COM4D_W<2> {
186        COM4D_W::new(self)
187    }
188    #[doc = "Bit 4 - Comparator B Output Mode"]
189    #[inline(always)]
190    #[must_use]
191    pub fn com4b0s(&mut self) -> COM4B0S_W<4> {
192        COM4B0S_W::new(self)
193    }
194    #[doc = "Bit 5 - Comparator B Output Mode"]
195    #[inline(always)]
196    #[must_use]
197    pub fn com4b1s(&mut self) -> COM4B1S_W<5> {
198        COM4B1S_W::new(self)
199    }
200    #[doc = "Bit 6 - Comparator A Output Mode"]
201    #[inline(always)]
202    #[must_use]
203    pub fn com4a0s(&mut self) -> COM4A0S_W<6> {
204        COM4A0S_W::new(self)
205    }
206    #[doc = "Bit 7 - Comparator A Output Mode"]
207    #[inline(always)]
208    #[must_use]
209    pub fn com4a1s(&mut self) -> COM4A1S_W<7> {
210        COM4A1S_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 4 Control Register C\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 [tccr4c](index.html) module"]
220pub struct TCCR4C_SPEC;
221impl crate::RegisterSpec for TCCR4C_SPEC {
222    type Ux = u8;
223}
224#[doc = "`read()` method returns [tccr4c::R](R) reader structure"]
225impl crate::Readable for TCCR4C_SPEC {
226    type Reader = R;
227}
228#[doc = "`write(|w| ..)` method takes [tccr4c::W](W) writer structure"]
229impl crate::Writable for TCCR4C_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 TCCR4C to value 0"]
235impl crate::Resettable for TCCR4C_SPEC {
236    const RESET_VALUE: Self::Ux = 0;
237}