va416xx/tim0/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub type R = crate::R<CtrlSpec>;
3#[doc = "Register `CTRL` writer"]
4pub type W = crate::W<CtrlSpec>;
5#[doc = "Field `ENABLE` reader - Counter Enable"]
6pub type EnableR = crate::BitReader;
7#[doc = "Field `ENABLE` writer - Counter Enable"]
8pub type EnableW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `ACTIVE` reader - Counter Active"]
10pub type ActiveR = crate::BitReader;
11#[doc = "Field `AUTO_DISABLE` reader - Auto Disables the counter (set ENABLE to 0) when the count reaches 0"]
12pub type AutoDisableR = crate::BitReader;
13#[doc = "Field `AUTO_DISABLE` writer - Auto Disables the counter (set ENABLE to 0) when the count reaches 0"]
14pub type AutoDisableW<'a, REG> = crate::BitWriter<'a, REG>;
15#[doc = "Field `AUTO_DEACTIVATE` reader - Auto Deactivate the counter (set ACTIVE to 0) when the count reaches 0"]
16pub type AutoDeactivateR = crate::BitReader;
17#[doc = "Field `AUTO_DEACTIVATE` writer - Auto Deactivate the counter (set ACTIVE to 0) when the count reaches 0"]
18pub type AutoDeactivateW<'a, REG> = crate::BitWriter<'a, REG>;
19#[doc = "Field `IRQ_ENB` reader - Interrupt Enable"]
20pub type IrqEnbR = crate::BitReader;
21#[doc = "Field `IRQ_ENB` writer - Interrupt Enable"]
22pub type IrqEnbW<'a, REG> = crate::BitWriter<'a, REG>;
23#[doc = "Counter Status Selection\n\nValue on reset: 0"]
24#[cfg_attr(feature = "defmt", derive(defmt::Format))]
25#[derive(Clone, Copy, Debug, PartialEq, Eq)]
26#[repr(u8)]
27pub enum StatusSel {
28    #[doc = "0: Single cycle pulse when the counter reaches 0"]
29    Done = 0,
30    #[doc = "1: Returns the counter ACTIVE bit"]
31    Active = 1,
32    #[doc = "2: Toggles the STATUS bit everytime the counter reaches 0. Basically a divide by 2 counter output."]
33    Toggle = 2,
34    #[doc = "3: Selects the Pulse Width Modulated output. It 1 when the counter value is >= the PWMA_VALUE"]
35    Pwma = 3,
36    #[doc = "4: Selects the Pulse Width Modulated output. It 1 when the counter value is < the PWMA_VALUE and value is > PWMA_VALUE"]
37    Pwmb = 4,
38    #[doc = "5: Returns the counter ENABLED bit"]
39    Enabled = 5,
40    #[doc = "6: Selects the Pulse Width Modulated output. It 1 when the counter value is <= the PWMA_VALUE and value is >= 0"]
41    PwmaActive = 6,
42}
43impl From<StatusSel> for u8 {
44    #[inline(always)]
45    fn from(variant: StatusSel) -> Self {
46        variant as _
47    }
48}
49impl crate::FieldSpec for StatusSel {
50    type Ux = u8;
51}
52impl crate::IsEnum for StatusSel {}
53#[doc = "Field `STATUS_SEL` reader - Counter Status Selection"]
54pub type StatusSelR = crate::FieldReader<StatusSel>;
55impl StatusSelR {
56    #[doc = "Get enumerated values variant"]
57    #[inline(always)]
58    pub const fn variant(&self) -> Option<StatusSel> {
59        match self.bits {
60            0 => Some(StatusSel::Done),
61            1 => Some(StatusSel::Active),
62            2 => Some(StatusSel::Toggle),
63            3 => Some(StatusSel::Pwma),
64            4 => Some(StatusSel::Pwmb),
65            5 => Some(StatusSel::Enabled),
66            6 => Some(StatusSel::PwmaActive),
67            _ => None,
68        }
69    }
70    #[doc = "Single cycle pulse when the counter reaches 0"]
71    #[inline(always)]
72    pub fn is_done(&self) -> bool {
73        *self == StatusSel::Done
74    }
75    #[doc = "Returns the counter ACTIVE bit"]
76    #[inline(always)]
77    pub fn is_active(&self) -> bool {
78        *self == StatusSel::Active
79    }
80    #[doc = "Toggles the STATUS bit everytime the counter reaches 0. Basically a divide by 2 counter output."]
81    #[inline(always)]
82    pub fn is_toggle(&self) -> bool {
83        *self == StatusSel::Toggle
84    }
85    #[doc = "Selects the Pulse Width Modulated output. It 1 when the counter value is >= the PWMA_VALUE"]
86    #[inline(always)]
87    pub fn is_pwma(&self) -> bool {
88        *self == StatusSel::Pwma
89    }
90    #[doc = "Selects the Pulse Width Modulated output. It 1 when the counter value is < the PWMA_VALUE and value is > PWMA_VALUE"]
91    #[inline(always)]
92    pub fn is_pwmb(&self) -> bool {
93        *self == StatusSel::Pwmb
94    }
95    #[doc = "Returns the counter ENABLED bit"]
96    #[inline(always)]
97    pub fn is_enabled(&self) -> bool {
98        *self == StatusSel::Enabled
99    }
100    #[doc = "Selects the Pulse Width Modulated output. It 1 when the counter value is <= the PWMA_VALUE and value is >= 0"]
101    #[inline(always)]
102    pub fn is_pwma_active(&self) -> bool {
103        *self == StatusSel::PwmaActive
104    }
105}
106#[doc = "Field `STATUS_SEL` writer - Counter Status Selection"]
107pub type StatusSelW<'a, REG> = crate::FieldWriter<'a, REG, 3, StatusSel>;
108impl<'a, REG> StatusSelW<'a, REG>
109where
110    REG: crate::Writable + crate::RegisterSpec,
111    REG::Ux: From<u8>,
112{
113    #[doc = "Single cycle pulse when the counter reaches 0"]
114    #[inline(always)]
115    pub fn done(self) -> &'a mut crate::W<REG> {
116        self.variant(StatusSel::Done)
117    }
118    #[doc = "Returns the counter ACTIVE bit"]
119    #[inline(always)]
120    pub fn active(self) -> &'a mut crate::W<REG> {
121        self.variant(StatusSel::Active)
122    }
123    #[doc = "Toggles the STATUS bit everytime the counter reaches 0. Basically a divide by 2 counter output."]
124    #[inline(always)]
125    pub fn toggle(self) -> &'a mut crate::W<REG> {
126        self.variant(StatusSel::Toggle)
127    }
128    #[doc = "Selects the Pulse Width Modulated output. It 1 when the counter value is >= the PWMA_VALUE"]
129    #[inline(always)]
130    pub fn pwma(self) -> &'a mut crate::W<REG> {
131        self.variant(StatusSel::Pwma)
132    }
133    #[doc = "Selects the Pulse Width Modulated output. It 1 when the counter value is < the PWMA_VALUE and value is > PWMA_VALUE"]
134    #[inline(always)]
135    pub fn pwmb(self) -> &'a mut crate::W<REG> {
136        self.variant(StatusSel::Pwmb)
137    }
138    #[doc = "Returns the counter ENABLED bit"]
139    #[inline(always)]
140    pub fn enabled(self) -> &'a mut crate::W<REG> {
141        self.variant(StatusSel::Enabled)
142    }
143    #[doc = "Selects the Pulse Width Modulated output. It 1 when the counter value is <= the PWMA_VALUE and value is >= 0"]
144    #[inline(always)]
145    pub fn pwma_active(self) -> &'a mut crate::W<REG> {
146        self.variant(StatusSel::PwmaActive)
147    }
148}
149#[doc = "Field `STATUS_INV` reader - Invert the Output Status"]
150pub type StatusInvR = crate::BitReader;
151#[doc = "Field `STATUS_INV` writer - Invert the Output Status"]
152pub type StatusInvW<'a, REG> = crate::BitWriter<'a, REG>;
153#[doc = "Field `REQ_STOP` reader - Stop Request"]
154pub type ReqStopR = crate::BitReader;
155#[doc = "Field `REQ_STOP` writer - Stop Request"]
156pub type ReqStopW<'a, REG> = crate::BitWriter<'a, REG>;
157impl R {
158    #[doc = "Bit 0 - Counter Enable"]
159    #[inline(always)]
160    pub fn enable(&self) -> EnableR {
161        EnableR::new((self.bits & 1) != 0)
162    }
163    #[doc = "Bit 1 - Counter Active"]
164    #[inline(always)]
165    pub fn active(&self) -> ActiveR {
166        ActiveR::new(((self.bits >> 1) & 1) != 0)
167    }
168    #[doc = "Bit 2 - Auto Disables the counter (set ENABLE to 0) when the count reaches 0"]
169    #[inline(always)]
170    pub fn auto_disable(&self) -> AutoDisableR {
171        AutoDisableR::new(((self.bits >> 2) & 1) != 0)
172    }
173    #[doc = "Bit 3 - Auto Deactivate the counter (set ACTIVE to 0) when the count reaches 0"]
174    #[inline(always)]
175    pub fn auto_deactivate(&self) -> AutoDeactivateR {
176        AutoDeactivateR::new(((self.bits >> 3) & 1) != 0)
177    }
178    #[doc = "Bit 4 - Interrupt Enable"]
179    #[inline(always)]
180    pub fn irq_enb(&self) -> IrqEnbR {
181        IrqEnbR::new(((self.bits >> 4) & 1) != 0)
182    }
183    #[doc = "Bits 5:7 - Counter Status Selection"]
184    #[inline(always)]
185    pub fn status_sel(&self) -> StatusSelR {
186        StatusSelR::new(((self.bits >> 5) & 7) as u8)
187    }
188    #[doc = "Bit 8 - Invert the Output Status"]
189    #[inline(always)]
190    pub fn status_inv(&self) -> StatusInvR {
191        StatusInvR::new(((self.bits >> 8) & 1) != 0)
192    }
193    #[doc = "Bit 9 - Stop Request"]
194    #[inline(always)]
195    pub fn req_stop(&self) -> ReqStopR {
196        ReqStopR::new(((self.bits >> 9) & 1) != 0)
197    }
198}
199impl W {
200    #[doc = "Bit 0 - Counter Enable"]
201    #[inline(always)]
202    pub fn enable(&mut self) -> EnableW<'_, CtrlSpec> {
203        EnableW::new(self, 0)
204    }
205    #[doc = "Bit 2 - Auto Disables the counter (set ENABLE to 0) when the count reaches 0"]
206    #[inline(always)]
207    pub fn auto_disable(&mut self) -> AutoDisableW<'_, CtrlSpec> {
208        AutoDisableW::new(self, 2)
209    }
210    #[doc = "Bit 3 - Auto Deactivate the counter (set ACTIVE to 0) when the count reaches 0"]
211    #[inline(always)]
212    pub fn auto_deactivate(&mut self) -> AutoDeactivateW<'_, CtrlSpec> {
213        AutoDeactivateW::new(self, 3)
214    }
215    #[doc = "Bit 4 - Interrupt Enable"]
216    #[inline(always)]
217    pub fn irq_enb(&mut self) -> IrqEnbW<'_, CtrlSpec> {
218        IrqEnbW::new(self, 4)
219    }
220    #[doc = "Bits 5:7 - Counter Status Selection"]
221    #[inline(always)]
222    pub fn status_sel(&mut self) -> StatusSelW<'_, CtrlSpec> {
223        StatusSelW::new(self, 5)
224    }
225    #[doc = "Bit 8 - Invert the Output Status"]
226    #[inline(always)]
227    pub fn status_inv(&mut self) -> StatusInvW<'_, CtrlSpec> {
228        StatusInvW::new(self, 8)
229    }
230    #[doc = "Bit 9 - Stop Request"]
231    #[inline(always)]
232    pub fn req_stop(&mut self) -> ReqStopW<'_, CtrlSpec> {
233        ReqStopW::new(self, 9)
234    }
235}
236#[doc = "Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
237pub struct CtrlSpec;
238impl crate::RegisterSpec for CtrlSpec {
239    type Ux = u32;
240}
241#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
242impl crate::Readable for CtrlSpec {}
243#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
244impl crate::Writable for CtrlSpec {
245    type Safety = crate::Unsafe;
246}
247#[doc = "`reset()` method sets CTRL to value 0"]
248impl crate::Resettable for CtrlSpec {}