msp430g2231/timer_a2/
tactl.rs

1#[doc = "Register `TACTL` reader"]
2pub type R = crate::R<TACTL_SPEC>;
3#[doc = "Register `TACTL` writer"]
4pub type W = crate::W<TACTL_SPEC>;
5#[doc = "Field `TAIFG` reader - Timer A counter interrupt flag"]
6pub type TAIFG_R = crate::BitReader;
7#[doc = "Field `TAIFG` writer - Timer A counter interrupt flag"]
8pub type TAIFG_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
9#[doc = "Field `TAIE` reader - Timer A counter interrupt enable"]
10pub type TAIE_R = crate::BitReader;
11#[doc = "Field `TAIE` writer - Timer A counter interrupt enable"]
12pub type TAIE_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
13#[doc = "Field `TACLR` reader - Timer A counter clear"]
14pub type TACLR_R = crate::BitReader;
15#[doc = "Field `TACLR` writer - Timer A counter clear"]
16pub type TACLR_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
17#[doc = "Field `MC` reader - Timer A mode control 1"]
18pub type MC_R = crate::FieldReader<MC_A>;
19#[doc = "Timer A mode control 1\n\nValue on reset: 0"]
20#[derive(Clone, Copy, Debug, PartialEq, Eq)]
21#[repr(u8)]
22pub enum MC_A {
23    #[doc = "0: Timer A mode control: 0 - Stop"]
24    MC_0 = 0,
25    #[doc = "1: Timer A mode control: 1 - Up to CCR0"]
26    MC_1 = 1,
27    #[doc = "2: Timer A mode control: 2 - Continous up"]
28    MC_2 = 2,
29    #[doc = "3: Timer A mode control: 3 - Up/Down"]
30    MC_3 = 3,
31}
32impl From<MC_A> for u8 {
33    #[inline(always)]
34    fn from(variant: MC_A) -> Self {
35        variant as _
36    }
37}
38impl crate::FieldSpec for MC_A {
39    type Ux = u8;
40}
41impl MC_R {
42    #[doc = "Get enumerated values variant"]
43    #[inline(always)]
44    pub const fn variant(&self) -> MC_A {
45        match self.bits {
46            0 => MC_A::MC_0,
47            1 => MC_A::MC_1,
48            2 => MC_A::MC_2,
49            3 => MC_A::MC_3,
50            _ => unreachable!(),
51        }
52    }
53    #[doc = "Timer A mode control: 0 - Stop"]
54    #[inline(always)]
55    pub fn is_mc_0(&self) -> bool {
56        *self == MC_A::MC_0
57    }
58    #[doc = "Timer A mode control: 1 - Up to CCR0"]
59    #[inline(always)]
60    pub fn is_mc_1(&self) -> bool {
61        *self == MC_A::MC_1
62    }
63    #[doc = "Timer A mode control: 2 - Continous up"]
64    #[inline(always)]
65    pub fn is_mc_2(&self) -> bool {
66        *self == MC_A::MC_2
67    }
68    #[doc = "Timer A mode control: 3 - Up/Down"]
69    #[inline(always)]
70    pub fn is_mc_3(&self) -> bool {
71        *self == MC_A::MC_3
72    }
73}
74#[doc = "Field `MC` writer - Timer A mode control 1"]
75pub type MC_W<'a, REG, const O: u8> = crate::FieldWriterSafe<'a, REG, 2, O, MC_A>;
76impl<'a, REG, const O: u8> MC_W<'a, REG, O>
77where
78    REG: crate::Writable + crate::RegisterSpec,
79    REG::Ux: From<u8>,
80{
81    #[doc = "Timer A mode control: 0 - Stop"]
82    #[inline(always)]
83    pub fn mc_0(self) -> &'a mut crate::W<REG> {
84        self.variant(MC_A::MC_0)
85    }
86    #[doc = "Timer A mode control: 1 - Up to CCR0"]
87    #[inline(always)]
88    pub fn mc_1(self) -> &'a mut crate::W<REG> {
89        self.variant(MC_A::MC_1)
90    }
91    #[doc = "Timer A mode control: 2 - Continous up"]
92    #[inline(always)]
93    pub fn mc_2(self) -> &'a mut crate::W<REG> {
94        self.variant(MC_A::MC_2)
95    }
96    #[doc = "Timer A mode control: 3 - Up/Down"]
97    #[inline(always)]
98    pub fn mc_3(self) -> &'a mut crate::W<REG> {
99        self.variant(MC_A::MC_3)
100    }
101}
102#[doc = "Field `ID` reader - Timer A clock input divider 1"]
103pub type ID_R = crate::FieldReader<ID_A>;
104#[doc = "Timer A clock input divider 1\n\nValue on reset: 0"]
105#[derive(Clone, Copy, Debug, PartialEq, Eq)]
106#[repr(u8)]
107pub enum ID_A {
108    #[doc = "0: Timer A input divider: 0 - /1"]
109    ID_0 = 0,
110    #[doc = "1: Timer A input divider: 1 - /2"]
111    ID_1 = 1,
112    #[doc = "2: Timer A input divider: 2 - /4"]
113    ID_2 = 2,
114    #[doc = "3: Timer A input divider: 3 - /8"]
115    ID_3 = 3,
116}
117impl From<ID_A> for u8 {
118    #[inline(always)]
119    fn from(variant: ID_A) -> Self {
120        variant as _
121    }
122}
123impl crate::FieldSpec for ID_A {
124    type Ux = u8;
125}
126impl ID_R {
127    #[doc = "Get enumerated values variant"]
128    #[inline(always)]
129    pub const fn variant(&self) -> ID_A {
130        match self.bits {
131            0 => ID_A::ID_0,
132            1 => ID_A::ID_1,
133            2 => ID_A::ID_2,
134            3 => ID_A::ID_3,
135            _ => unreachable!(),
136        }
137    }
138    #[doc = "Timer A input divider: 0 - /1"]
139    #[inline(always)]
140    pub fn is_id_0(&self) -> bool {
141        *self == ID_A::ID_0
142    }
143    #[doc = "Timer A input divider: 1 - /2"]
144    #[inline(always)]
145    pub fn is_id_1(&self) -> bool {
146        *self == ID_A::ID_1
147    }
148    #[doc = "Timer A input divider: 2 - /4"]
149    #[inline(always)]
150    pub fn is_id_2(&self) -> bool {
151        *self == ID_A::ID_2
152    }
153    #[doc = "Timer A input divider: 3 - /8"]
154    #[inline(always)]
155    pub fn is_id_3(&self) -> bool {
156        *self == ID_A::ID_3
157    }
158}
159#[doc = "Field `ID` writer - Timer A clock input divider 1"]
160pub type ID_W<'a, REG, const O: u8> = crate::FieldWriterSafe<'a, REG, 2, O, ID_A>;
161impl<'a, REG, const O: u8> ID_W<'a, REG, O>
162where
163    REG: crate::Writable + crate::RegisterSpec,
164    REG::Ux: From<u8>,
165{
166    #[doc = "Timer A input divider: 0 - /1"]
167    #[inline(always)]
168    pub fn id_0(self) -> &'a mut crate::W<REG> {
169        self.variant(ID_A::ID_0)
170    }
171    #[doc = "Timer A input divider: 1 - /2"]
172    #[inline(always)]
173    pub fn id_1(self) -> &'a mut crate::W<REG> {
174        self.variant(ID_A::ID_1)
175    }
176    #[doc = "Timer A input divider: 2 - /4"]
177    #[inline(always)]
178    pub fn id_2(self) -> &'a mut crate::W<REG> {
179        self.variant(ID_A::ID_2)
180    }
181    #[doc = "Timer A input divider: 3 - /8"]
182    #[inline(always)]
183    pub fn id_3(self) -> &'a mut crate::W<REG> {
184        self.variant(ID_A::ID_3)
185    }
186}
187#[doc = "Field `TASSEL` reader - Timer A clock source select 1"]
188pub type TASSEL_R = crate::FieldReader<TASSEL_A>;
189#[doc = "Timer A clock source select 1\n\nValue on reset: 0"]
190#[derive(Clone, Copy, Debug, PartialEq, Eq)]
191#[repr(u8)]
192pub enum TASSEL_A {
193    #[doc = "0: Timer A clock source select: 0 - TACLK"]
194    TASSEL_0 = 0,
195    #[doc = "1: Timer A clock source select: 1 - ACLK"]
196    TASSEL_1 = 1,
197    #[doc = "2: Timer A clock source select: 2 - SMCLK"]
198    TASSEL_2 = 2,
199    #[doc = "3: Timer A clock source select: 3 - INCLK"]
200    TASSEL_3 = 3,
201}
202impl From<TASSEL_A> for u8 {
203    #[inline(always)]
204    fn from(variant: TASSEL_A) -> Self {
205        variant as _
206    }
207}
208impl crate::FieldSpec for TASSEL_A {
209    type Ux = u8;
210}
211impl TASSEL_R {
212    #[doc = "Get enumerated values variant"]
213    #[inline(always)]
214    pub const fn variant(&self) -> TASSEL_A {
215        match self.bits {
216            0 => TASSEL_A::TASSEL_0,
217            1 => TASSEL_A::TASSEL_1,
218            2 => TASSEL_A::TASSEL_2,
219            3 => TASSEL_A::TASSEL_3,
220            _ => unreachable!(),
221        }
222    }
223    #[doc = "Timer A clock source select: 0 - TACLK"]
224    #[inline(always)]
225    pub fn is_tassel_0(&self) -> bool {
226        *self == TASSEL_A::TASSEL_0
227    }
228    #[doc = "Timer A clock source select: 1 - ACLK"]
229    #[inline(always)]
230    pub fn is_tassel_1(&self) -> bool {
231        *self == TASSEL_A::TASSEL_1
232    }
233    #[doc = "Timer A clock source select: 2 - SMCLK"]
234    #[inline(always)]
235    pub fn is_tassel_2(&self) -> bool {
236        *self == TASSEL_A::TASSEL_2
237    }
238    #[doc = "Timer A clock source select: 3 - INCLK"]
239    #[inline(always)]
240    pub fn is_tassel_3(&self) -> bool {
241        *self == TASSEL_A::TASSEL_3
242    }
243}
244#[doc = "Field `TASSEL` writer - Timer A clock source select 1"]
245pub type TASSEL_W<'a, REG, const O: u8> = crate::FieldWriterSafe<'a, REG, 2, O, TASSEL_A>;
246impl<'a, REG, const O: u8> TASSEL_W<'a, REG, O>
247where
248    REG: crate::Writable + crate::RegisterSpec,
249    REG::Ux: From<u8>,
250{
251    #[doc = "Timer A clock source select: 0 - TACLK"]
252    #[inline(always)]
253    pub fn tassel_0(self) -> &'a mut crate::W<REG> {
254        self.variant(TASSEL_A::TASSEL_0)
255    }
256    #[doc = "Timer A clock source select: 1 - ACLK"]
257    #[inline(always)]
258    pub fn tassel_1(self) -> &'a mut crate::W<REG> {
259        self.variant(TASSEL_A::TASSEL_1)
260    }
261    #[doc = "Timer A clock source select: 2 - SMCLK"]
262    #[inline(always)]
263    pub fn tassel_2(self) -> &'a mut crate::W<REG> {
264        self.variant(TASSEL_A::TASSEL_2)
265    }
266    #[doc = "Timer A clock source select: 3 - INCLK"]
267    #[inline(always)]
268    pub fn tassel_3(self) -> &'a mut crate::W<REG> {
269        self.variant(TASSEL_A::TASSEL_3)
270    }
271}
272impl R {
273    #[doc = "Bit 0 - Timer A counter interrupt flag"]
274    #[inline(always)]
275    pub fn taifg(&self) -> TAIFG_R {
276        TAIFG_R::new((self.bits & 1) != 0)
277    }
278    #[doc = "Bit 1 - Timer A counter interrupt enable"]
279    #[inline(always)]
280    pub fn taie(&self) -> TAIE_R {
281        TAIE_R::new(((self.bits >> 1) & 1) != 0)
282    }
283    #[doc = "Bit 2 - Timer A counter clear"]
284    #[inline(always)]
285    pub fn taclr(&self) -> TACLR_R {
286        TACLR_R::new(((self.bits >> 2) & 1) != 0)
287    }
288    #[doc = "Bits 4:5 - Timer A mode control 1"]
289    #[inline(always)]
290    pub fn mc(&self) -> MC_R {
291        MC_R::new(((self.bits >> 4) & 3) as u8)
292    }
293    #[doc = "Bits 6:7 - Timer A clock input divider 1"]
294    #[inline(always)]
295    pub fn id(&self) -> ID_R {
296        ID_R::new(((self.bits >> 6) & 3) as u8)
297    }
298    #[doc = "Bits 8:9 - Timer A clock source select 1"]
299    #[inline(always)]
300    pub fn tassel(&self) -> TASSEL_R {
301        TASSEL_R::new(((self.bits >> 8) & 3) as u8)
302    }
303}
304impl W {
305    #[doc = "Bit 0 - Timer A counter interrupt flag"]
306    #[inline(always)]
307    #[must_use]
308    pub fn taifg(&mut self) -> TAIFG_W<TACTL_SPEC, 0> {
309        TAIFG_W::new(self)
310    }
311    #[doc = "Bit 1 - Timer A counter interrupt enable"]
312    #[inline(always)]
313    #[must_use]
314    pub fn taie(&mut self) -> TAIE_W<TACTL_SPEC, 1> {
315        TAIE_W::new(self)
316    }
317    #[doc = "Bit 2 - Timer A counter clear"]
318    #[inline(always)]
319    #[must_use]
320    pub fn taclr(&mut self) -> TACLR_W<TACTL_SPEC, 2> {
321        TACLR_W::new(self)
322    }
323    #[doc = "Bits 4:5 - Timer A mode control 1"]
324    #[inline(always)]
325    #[must_use]
326    pub fn mc(&mut self) -> MC_W<TACTL_SPEC, 4> {
327        MC_W::new(self)
328    }
329    #[doc = "Bits 6:7 - Timer A clock input divider 1"]
330    #[inline(always)]
331    #[must_use]
332    pub fn id(&mut self) -> ID_W<TACTL_SPEC, 6> {
333        ID_W::new(self)
334    }
335    #[doc = "Bits 8:9 - Timer A clock source select 1"]
336    #[inline(always)]
337    #[must_use]
338    pub fn tassel(&mut self) -> TASSEL_W<TACTL_SPEC, 8> {
339        TASSEL_W::new(self)
340    }
341    #[doc = r" Writes raw bits to the register."]
342    #[doc = r""]
343    #[doc = r" # Safety"]
344    #[doc = r""]
345    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
346    #[inline(always)]
347    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
348        self.bits = bits;
349        self
350    }
351}
352#[doc = "Timer A Control\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`tactl::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 [`tactl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
353pub struct TACTL_SPEC;
354impl crate::RegisterSpec for TACTL_SPEC {
355    type Ux = u16;
356}
357#[doc = "`read()` method returns [`tactl::R`](R) reader structure"]
358impl crate::Readable for TACTL_SPEC {}
359#[doc = "`write(|w| ..)` method takes [`tactl::W`](W) writer structure"]
360impl crate::Writable for TACTL_SPEC {
361    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
362    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
363}
364#[doc = "`reset()` method sets TACTL to value 0"]
365impl crate::Resettable for TACTL_SPEC {
366    const RESET_VALUE: Self::Ux = 0;
367}