d1_pac/timer/
avs_cnt_ctl.rs

1#[doc = "Register `avs_cnt_ctl` reader"]
2pub type R = crate::R<AVS_CNT_CTL_SPEC>;
3#[doc = "Register `avs_cnt_ctl` writer"]
4pub type W = crate::W<AVS_CNT_CTL_SPEC>;
5#[doc = "Field `avs_cnt_en[0-1]` reader - Audio Video Sync Counter Enable"]
6pub type AVS_CNT_EN_R = crate::BitReader<AVS_CNT_EN_A>;
7#[doc = "Audio Video Sync Counter Enable\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum AVS_CNT_EN_A {
10    #[doc = "0: `0`"]
11    DISABLED = 0,
12    #[doc = "1: `1`"]
13    ENABLED = 1,
14}
15impl From<AVS_CNT_EN_A> for bool {
16    #[inline(always)]
17    fn from(variant: AVS_CNT_EN_A) -> Self {
18        variant as u8 != 0
19    }
20}
21impl AVS_CNT_EN_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> AVS_CNT_EN_A {
25        match self.bits {
26            false => AVS_CNT_EN_A::DISABLED,
27            true => AVS_CNT_EN_A::ENABLED,
28        }
29    }
30    #[doc = "`0`"]
31    #[inline(always)]
32    pub fn is_disabled(&self) -> bool {
33        *self == AVS_CNT_EN_A::DISABLED
34    }
35    #[doc = "`1`"]
36    #[inline(always)]
37    pub fn is_enabled(&self) -> bool {
38        *self == AVS_CNT_EN_A::ENABLED
39    }
40}
41#[doc = "Field `avs_cnt_en[0-1]` writer - Audio Video Sync Counter Enable"]
42pub type AVS_CNT_EN_W<'a, REG> = crate::BitWriter<'a, REG, AVS_CNT_EN_A>;
43impl<'a, REG> AVS_CNT_EN_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "`0`"]
48    #[inline(always)]
49    pub fn disabled(self) -> &'a mut crate::W<REG> {
50        self.variant(AVS_CNT_EN_A::DISABLED)
51    }
52    #[doc = "`1`"]
53    #[inline(always)]
54    pub fn enabled(self) -> &'a mut crate::W<REG> {
55        self.variant(AVS_CNT_EN_A::ENABLED)
56    }
57}
58#[doc = "Field `avs_cnt_ps[0-1]` reader - Audio Video Sync Counter Pause Control"]
59pub type AVS_CNT_PS_R = crate::BitReader<AVS_CNT_PS_A>;
60#[doc = "Audio Video Sync Counter Pause Control\n\nValue on reset: 0"]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum AVS_CNT_PS_A {
63    #[doc = "0: `0`"]
64    NOT_PAUSE = 0,
65    #[doc = "1: `1`"]
66    PAUSE = 1,
67}
68impl From<AVS_CNT_PS_A> for bool {
69    #[inline(always)]
70    fn from(variant: AVS_CNT_PS_A) -> Self {
71        variant as u8 != 0
72    }
73}
74impl AVS_CNT_PS_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub const fn variant(&self) -> AVS_CNT_PS_A {
78        match self.bits {
79            false => AVS_CNT_PS_A::NOT_PAUSE,
80            true => AVS_CNT_PS_A::PAUSE,
81        }
82    }
83    #[doc = "`0`"]
84    #[inline(always)]
85    pub fn is_not_pause(&self) -> bool {
86        *self == AVS_CNT_PS_A::NOT_PAUSE
87    }
88    #[doc = "`1`"]
89    #[inline(always)]
90    pub fn is_pause(&self) -> bool {
91        *self == AVS_CNT_PS_A::PAUSE
92    }
93}
94#[doc = "Field `avs_cnt_ps[0-1]` writer - Audio Video Sync Counter Pause Control"]
95pub type AVS_CNT_PS_W<'a, REG> = crate::BitWriter<'a, REG, AVS_CNT_PS_A>;
96impl<'a, REG> AVS_CNT_PS_W<'a, REG>
97where
98    REG: crate::Writable + crate::RegisterSpec,
99{
100    #[doc = "`0`"]
101    #[inline(always)]
102    pub fn not_pause(self) -> &'a mut crate::W<REG> {
103        self.variant(AVS_CNT_PS_A::NOT_PAUSE)
104    }
105    #[doc = "`1`"]
106    #[inline(always)]
107    pub fn pause(self) -> &'a mut crate::W<REG> {
108        self.variant(AVS_CNT_PS_A::PAUSE)
109    }
110}
111impl R {
112    #[doc = "Audio Video Sync Counter Enable\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `avs_cnt0_en` field"]
113    #[inline(always)]
114    pub fn avs_cnt_en(&self, n: u8) -> AVS_CNT_EN_R {
115        #[allow(clippy::no_effect)]
116        [(); 2][n as usize];
117        AVS_CNT_EN_R::new(((self.bits >> n) & 1) != 0)
118    }
119    #[doc = "Bit 0 - Audio Video Sync Counter Enable"]
120    #[inline(always)]
121    pub fn avs_cnt0_en(&self) -> AVS_CNT_EN_R {
122        AVS_CNT_EN_R::new((self.bits & 1) != 0)
123    }
124    #[doc = "Bit 1 - Audio Video Sync Counter Enable"]
125    #[inline(always)]
126    pub fn avs_cnt1_en(&self) -> AVS_CNT_EN_R {
127        AVS_CNT_EN_R::new(((self.bits >> 1) & 1) != 0)
128    }
129    #[doc = "Audio Video Sync Counter Pause Control\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `avs_cnt0_ps` field"]
130    #[inline(always)]
131    pub fn avs_cnt_ps(&self, n: u8) -> AVS_CNT_PS_R {
132        #[allow(clippy::no_effect)]
133        [(); 2][n as usize];
134        AVS_CNT_PS_R::new(((self.bits >> (n + 8)) & 1) != 0)
135    }
136    #[doc = "Bit 8 - Audio Video Sync Counter Pause Control"]
137    #[inline(always)]
138    pub fn avs_cnt0_ps(&self) -> AVS_CNT_PS_R {
139        AVS_CNT_PS_R::new(((self.bits >> 8) & 1) != 0)
140    }
141    #[doc = "Bit 9 - Audio Video Sync Counter Pause Control"]
142    #[inline(always)]
143    pub fn avs_cnt1_ps(&self) -> AVS_CNT_PS_R {
144        AVS_CNT_PS_R::new(((self.bits >> 9) & 1) != 0)
145    }
146}
147impl W {
148    #[doc = "Audio Video Sync Counter Enable\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `avs_cnt0_en` field"]
149    #[inline(always)]
150    #[must_use]
151    pub fn avs_cnt_en(&mut self, n: u8) -> AVS_CNT_EN_W<AVS_CNT_CTL_SPEC> {
152        #[allow(clippy::no_effect)]
153        [(); 2][n as usize];
154        AVS_CNT_EN_W::new(self, n)
155    }
156    #[doc = "Bit 0 - Audio Video Sync Counter Enable"]
157    #[inline(always)]
158    #[must_use]
159    pub fn avs_cnt0_en(&mut self) -> AVS_CNT_EN_W<AVS_CNT_CTL_SPEC> {
160        AVS_CNT_EN_W::new(self, 0)
161    }
162    #[doc = "Bit 1 - Audio Video Sync Counter Enable"]
163    #[inline(always)]
164    #[must_use]
165    pub fn avs_cnt1_en(&mut self) -> AVS_CNT_EN_W<AVS_CNT_CTL_SPEC> {
166        AVS_CNT_EN_W::new(self, 1)
167    }
168    #[doc = "Audio Video Sync Counter Pause Control\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `avs_cnt0_ps` field"]
169    #[inline(always)]
170    #[must_use]
171    pub fn avs_cnt_ps(&mut self, n: u8) -> AVS_CNT_PS_W<AVS_CNT_CTL_SPEC> {
172        #[allow(clippy::no_effect)]
173        [(); 2][n as usize];
174        AVS_CNT_PS_W::new(self, n + 8)
175    }
176    #[doc = "Bit 8 - Audio Video Sync Counter Pause Control"]
177    #[inline(always)]
178    #[must_use]
179    pub fn avs_cnt0_ps(&mut self) -> AVS_CNT_PS_W<AVS_CNT_CTL_SPEC> {
180        AVS_CNT_PS_W::new(self, 8)
181    }
182    #[doc = "Bit 9 - Audio Video Sync Counter Pause Control"]
183    #[inline(always)]
184    #[must_use]
185    pub fn avs_cnt1_ps(&mut self) -> AVS_CNT_PS_W<AVS_CNT_CTL_SPEC> {
186        AVS_CNT_PS_W::new(self, 9)
187    }
188    #[doc = r" Writes raw bits to the register."]
189    #[doc = r""]
190    #[doc = r" # Safety"]
191    #[doc = r""]
192    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
193    #[inline(always)]
194    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
195        self.bits = bits;
196        self
197    }
198}
199#[doc = "AVS Counter Control Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`avs_cnt_ctl::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`avs_cnt_ctl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
200pub struct AVS_CNT_CTL_SPEC;
201impl crate::RegisterSpec for AVS_CNT_CTL_SPEC {
202    type Ux = u32;
203}
204#[doc = "`read()` method returns [`avs_cnt_ctl::R`](R) reader structure"]
205impl crate::Readable for AVS_CNT_CTL_SPEC {}
206#[doc = "`write(|w| ..)` method takes [`avs_cnt_ctl::W`](W) writer structure"]
207impl crate::Writable for AVS_CNT_CTL_SPEC {
208    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
209    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
210}
211#[doc = "`reset()` method sets avs_cnt_ctl to value 0"]
212impl crate::Resettable for AVS_CNT_CTL_SPEC {
213    const RESET_VALUE: Self::Ux = 0;
214}