atsamd11c/pm/
apbbsel.rs
1#[doc = "Register `APBBSEL` reader"]
2pub type R = crate::R<ApbbselSpec>;
3#[doc = "Register `APBBSEL` writer"]
4pub type W = crate::W<ApbbselSpec>;
5#[doc = "APBB Prescaler Selection\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Apbbdivselect {
9 #[doc = "0: Divide by 1"]
10 Div1 = 0,
11 #[doc = "1: Divide by 2"]
12 Div2 = 1,
13 #[doc = "2: Divide by 4"]
14 Div4 = 2,
15 #[doc = "3: Divide by 8"]
16 Div8 = 3,
17 #[doc = "4: Divide by 16"]
18 Div16 = 4,
19 #[doc = "5: Divide by 32"]
20 Div32 = 5,
21 #[doc = "6: Divide by 64"]
22 Div64 = 6,
23 #[doc = "7: Divide by 128"]
24 Div128 = 7,
25}
26impl From<Apbbdivselect> for u8 {
27 #[inline(always)]
28 fn from(variant: Apbbdivselect) -> Self {
29 variant as _
30 }
31}
32impl crate::FieldSpec for Apbbdivselect {
33 type Ux = u8;
34}
35impl crate::IsEnum for Apbbdivselect {}
36#[doc = "Field `APBBDIV` reader - APBB Prescaler Selection"]
37pub type ApbbdivR = crate::FieldReader<Apbbdivselect>;
38impl ApbbdivR {
39 #[doc = "Get enumerated values variant"]
40 #[inline(always)]
41 pub const fn variant(&self) -> Apbbdivselect {
42 match self.bits {
43 0 => Apbbdivselect::Div1,
44 1 => Apbbdivselect::Div2,
45 2 => Apbbdivselect::Div4,
46 3 => Apbbdivselect::Div8,
47 4 => Apbbdivselect::Div16,
48 5 => Apbbdivselect::Div32,
49 6 => Apbbdivselect::Div64,
50 7 => Apbbdivselect::Div128,
51 _ => unreachable!(),
52 }
53 }
54 #[doc = "Divide by 1"]
55 #[inline(always)]
56 pub fn is_div1(&self) -> bool {
57 *self == Apbbdivselect::Div1
58 }
59 #[doc = "Divide by 2"]
60 #[inline(always)]
61 pub fn is_div2(&self) -> bool {
62 *self == Apbbdivselect::Div2
63 }
64 #[doc = "Divide by 4"]
65 #[inline(always)]
66 pub fn is_div4(&self) -> bool {
67 *self == Apbbdivselect::Div4
68 }
69 #[doc = "Divide by 8"]
70 #[inline(always)]
71 pub fn is_div8(&self) -> bool {
72 *self == Apbbdivselect::Div8
73 }
74 #[doc = "Divide by 16"]
75 #[inline(always)]
76 pub fn is_div16(&self) -> bool {
77 *self == Apbbdivselect::Div16
78 }
79 #[doc = "Divide by 32"]
80 #[inline(always)]
81 pub fn is_div32(&self) -> bool {
82 *self == Apbbdivselect::Div32
83 }
84 #[doc = "Divide by 64"]
85 #[inline(always)]
86 pub fn is_div64(&self) -> bool {
87 *self == Apbbdivselect::Div64
88 }
89 #[doc = "Divide by 128"]
90 #[inline(always)]
91 pub fn is_div128(&self) -> bool {
92 *self == Apbbdivselect::Div128
93 }
94}
95#[doc = "Field `APBBDIV` writer - APBB Prescaler Selection"]
96pub type ApbbdivW<'a, REG> = crate::FieldWriter<'a, REG, 3, Apbbdivselect, crate::Safe>;
97impl<'a, REG> ApbbdivW<'a, REG>
98where
99 REG: crate::Writable + crate::RegisterSpec,
100 REG::Ux: From<u8>,
101{
102 #[doc = "Divide by 1"]
103 #[inline(always)]
104 pub fn div1(self) -> &'a mut crate::W<REG> {
105 self.variant(Apbbdivselect::Div1)
106 }
107 #[doc = "Divide by 2"]
108 #[inline(always)]
109 pub fn div2(self) -> &'a mut crate::W<REG> {
110 self.variant(Apbbdivselect::Div2)
111 }
112 #[doc = "Divide by 4"]
113 #[inline(always)]
114 pub fn div4(self) -> &'a mut crate::W<REG> {
115 self.variant(Apbbdivselect::Div4)
116 }
117 #[doc = "Divide by 8"]
118 #[inline(always)]
119 pub fn div8(self) -> &'a mut crate::W<REG> {
120 self.variant(Apbbdivselect::Div8)
121 }
122 #[doc = "Divide by 16"]
123 #[inline(always)]
124 pub fn div16(self) -> &'a mut crate::W<REG> {
125 self.variant(Apbbdivselect::Div16)
126 }
127 #[doc = "Divide by 32"]
128 #[inline(always)]
129 pub fn div32(self) -> &'a mut crate::W<REG> {
130 self.variant(Apbbdivselect::Div32)
131 }
132 #[doc = "Divide by 64"]
133 #[inline(always)]
134 pub fn div64(self) -> &'a mut crate::W<REG> {
135 self.variant(Apbbdivselect::Div64)
136 }
137 #[doc = "Divide by 128"]
138 #[inline(always)]
139 pub fn div128(self) -> &'a mut crate::W<REG> {
140 self.variant(Apbbdivselect::Div128)
141 }
142}
143impl R {
144 #[doc = "Bits 0:2 - APBB Prescaler Selection"]
145 #[inline(always)]
146 pub fn apbbdiv(&self) -> ApbbdivR {
147 ApbbdivR::new(self.bits & 7)
148 }
149}
150impl W {
151 #[doc = "Bits 0:2 - APBB Prescaler Selection"]
152 #[inline(always)]
153 #[must_use]
154 pub fn apbbdiv(&mut self) -> ApbbdivW<ApbbselSpec> {
155 ApbbdivW::new(self, 0)
156 }
157}
158#[doc = "APBB Clock Select\n\nYou can [`read`](crate::Reg::read) this register and get [`apbbsel::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`apbbsel::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
159pub struct ApbbselSpec;
160impl crate::RegisterSpec for ApbbselSpec {
161 type Ux = u8;
162}
163#[doc = "`read()` method returns [`apbbsel::R`](R) reader structure"]
164impl crate::Readable for ApbbselSpec {}
165#[doc = "`write(|w| ..)` method takes [`apbbsel::W`](W) writer structure"]
166impl crate::Writable for ApbbselSpec {
167 type Safety = crate::Unsafe;
168 const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
169 const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
170}
171#[doc = "`reset()` method sets APBBSEL to value 0"]
172impl crate::Resettable for ApbbselSpec {
173 const RESET_VALUE: u8 = 0;
174}