atsamd51g/pdec/
ctrlbclr.rs
1#[doc = "Register `CTRLBCLR` reader"]
2pub type R = crate::R<CtrlbclrSpec>;
3#[doc = "Register `CTRLBCLR` writer"]
4pub type W = crate::W<CtrlbclrSpec>;
5#[doc = "Field `LUPD` reader - Lock Update"]
6pub type LupdR = crate::BitReader;
7#[doc = "Field `LUPD` writer - Lock Update"]
8pub type LupdW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Command\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u8)]
12pub enum Cmdselect {
13 #[doc = "0: No action"]
14 None = 0,
15 #[doc = "1: Force a counter restart or retrigger"]
16 Retrigger = 1,
17 #[doc = "2: Force update of double buffered registers"]
18 Update = 2,
19 #[doc = "3: Force a read synchronization of COUNT"]
20 Readsync = 3,
21 #[doc = "4: Start QDEC/HALL"]
22 Start = 4,
23 #[doc = "5: Stop QDEC/HALL"]
24 Stop = 5,
25}
26impl From<Cmdselect> for u8 {
27 #[inline(always)]
28 fn from(variant: Cmdselect) -> Self {
29 variant as _
30 }
31}
32impl crate::FieldSpec for Cmdselect {
33 type Ux = u8;
34}
35impl crate::IsEnum for Cmdselect {}
36#[doc = "Field `CMD` reader - Command"]
37pub type CmdR = crate::FieldReader<Cmdselect>;
38impl CmdR {
39 #[doc = "Get enumerated values variant"]
40 #[inline(always)]
41 pub const fn variant(&self) -> Option<Cmdselect> {
42 match self.bits {
43 0 => Some(Cmdselect::None),
44 1 => Some(Cmdselect::Retrigger),
45 2 => Some(Cmdselect::Update),
46 3 => Some(Cmdselect::Readsync),
47 4 => Some(Cmdselect::Start),
48 5 => Some(Cmdselect::Stop),
49 _ => None,
50 }
51 }
52 #[doc = "No action"]
53 #[inline(always)]
54 pub fn is_none(&self) -> bool {
55 *self == Cmdselect::None
56 }
57 #[doc = "Force a counter restart or retrigger"]
58 #[inline(always)]
59 pub fn is_retrigger(&self) -> bool {
60 *self == Cmdselect::Retrigger
61 }
62 #[doc = "Force update of double buffered registers"]
63 #[inline(always)]
64 pub fn is_update(&self) -> bool {
65 *self == Cmdselect::Update
66 }
67 #[doc = "Force a read synchronization of COUNT"]
68 #[inline(always)]
69 pub fn is_readsync(&self) -> bool {
70 *self == Cmdselect::Readsync
71 }
72 #[doc = "Start QDEC/HALL"]
73 #[inline(always)]
74 pub fn is_start(&self) -> bool {
75 *self == Cmdselect::Start
76 }
77 #[doc = "Stop QDEC/HALL"]
78 #[inline(always)]
79 pub fn is_stop(&self) -> bool {
80 *self == Cmdselect::Stop
81 }
82}
83#[doc = "Field `CMD` writer - Command"]
84pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 3, Cmdselect>;
85impl<'a, REG> CmdW<'a, REG>
86where
87 REG: crate::Writable + crate::RegisterSpec,
88 REG::Ux: From<u8>,
89{
90 #[doc = "No action"]
91 #[inline(always)]
92 pub fn none(self) -> &'a mut crate::W<REG> {
93 self.variant(Cmdselect::None)
94 }
95 #[doc = "Force a counter restart or retrigger"]
96 #[inline(always)]
97 pub fn retrigger(self) -> &'a mut crate::W<REG> {
98 self.variant(Cmdselect::Retrigger)
99 }
100 #[doc = "Force update of double buffered registers"]
101 #[inline(always)]
102 pub fn update(self) -> &'a mut crate::W<REG> {
103 self.variant(Cmdselect::Update)
104 }
105 #[doc = "Force a read synchronization of COUNT"]
106 #[inline(always)]
107 pub fn readsync(self) -> &'a mut crate::W<REG> {
108 self.variant(Cmdselect::Readsync)
109 }
110 #[doc = "Start QDEC/HALL"]
111 #[inline(always)]
112 pub fn start(self) -> &'a mut crate::W<REG> {
113 self.variant(Cmdselect::Start)
114 }
115 #[doc = "Stop QDEC/HALL"]
116 #[inline(always)]
117 pub fn stop(self) -> &'a mut crate::W<REG> {
118 self.variant(Cmdselect::Stop)
119 }
120}
121impl R {
122 #[doc = "Bit 1 - Lock Update"]
123 #[inline(always)]
124 pub fn lupd(&self) -> LupdR {
125 LupdR::new(((self.bits >> 1) & 1) != 0)
126 }
127 #[doc = "Bits 5:7 - Command"]
128 #[inline(always)]
129 pub fn cmd(&self) -> CmdR {
130 CmdR::new((self.bits >> 5) & 7)
131 }
132}
133impl W {
134 #[doc = "Bit 1 - Lock Update"]
135 #[inline(always)]
136 #[must_use]
137 pub fn lupd(&mut self) -> LupdW<CtrlbclrSpec> {
138 LupdW::new(self, 1)
139 }
140 #[doc = "Bits 5:7 - Command"]
141 #[inline(always)]
142 #[must_use]
143 pub fn cmd(&mut self) -> CmdW<CtrlbclrSpec> {
144 CmdW::new(self, 5)
145 }
146}
147#[doc = "Control B Clear\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlbclr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlbclr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
148pub struct CtrlbclrSpec;
149impl crate::RegisterSpec for CtrlbclrSpec {
150 type Ux = u8;
151}
152#[doc = "`read()` method returns [`ctrlbclr::R`](R) reader structure"]
153impl crate::Readable for CtrlbclrSpec {}
154#[doc = "`write(|w| ..)` method takes [`ctrlbclr::W`](W) writer structure"]
155impl crate::Writable for CtrlbclrSpec {
156 type Safety = crate::Unsafe;
157 const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
158 const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
159}
160#[doc = "`reset()` method sets CTRLBCLR to value 0"]
161impl crate::Resettable for CtrlbclrSpec {
162 const RESET_VALUE: u8 = 0;
163}