corstone300_pac/fpgaio/
button.rs1#[doc = "Register `BUTTON` reader"]
6pub struct R(crate::R<BUTTON_SPEC>);
7impl core::ops::Deref for R {
8 type Target = crate::R<BUTTON_SPEC>;
9 #[inline(always)]
10 fn deref(&self) -> &Self::Target {
11 &self.0
12 }
13}
14impl From<crate::R<BUTTON_SPEC>> for R {
15 #[inline(always)]
16 fn from(reader: crate::R<BUTTON_SPEC>) -> Self {
17 R(reader)
18 }
19}
20#[doc = "Register `BUTTON` writer"]
21pub struct W(crate::W<BUTTON_SPEC>);
22impl core::ops::Deref for W {
23 type Target = crate::W<BUTTON_SPEC>;
24 #[inline(always)]
25 fn deref(&self) -> &Self::Target {
26 &self.0
27 }
28}
29impl core::ops::DerefMut for W {
30 #[inline(always)]
31 fn deref_mut(&mut self) -> &mut Self::Target {
32 &mut self.0
33 }
34}
35impl From<crate::W<BUTTON_SPEC>> for W {
36 #[inline(always)]
37 fn from(writer: crate::W<BUTTON_SPEC>) -> Self {
38 W(writer)
39 }
40}
41#[doc = "Field `BUTTON0` reader - "]
42pub type BUTTON0_R = crate::BitReader<BUTTON0_A>;
43#[doc = "\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum BUTTON0_A {
46 #[doc = "0: BUTTON is off"]
47 OFF = 0,
48 #[doc = "1: BUTTON is on"]
49 ON = 1,
50}
51impl From<BUTTON0_A> for bool {
52 #[inline(always)]
53 fn from(variant: BUTTON0_A) -> Self {
54 variant as u8 != 0
55 }
56}
57impl BUTTON0_R {
58 #[doc = "Get enumerated values variant"]
59 #[inline(always)]
60 pub fn variant(&self) -> BUTTON0_A {
61 match self.bits {
62 false => BUTTON0_A::OFF,
63 true => BUTTON0_A::ON,
64 }
65 }
66 #[doc = "Checks if the value of the field is `OFF`"]
67 #[inline(always)]
68 pub fn is_off(&self) -> bool {
69 *self == BUTTON0_A::OFF
70 }
71 #[doc = "Checks if the value of the field is `ON`"]
72 #[inline(always)]
73 pub fn is_on(&self) -> bool {
74 *self == BUTTON0_A::ON
75 }
76}
77#[doc = "Field `BUTTON0` writer - "]
78pub type BUTTON0_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUTTON_SPEC, BUTTON0_A, O>;
79impl<'a, const O: u8> BUTTON0_W<'a, O> {
80 #[doc = "BUTTON is off"]
81 #[inline(always)]
82 pub fn off(self) -> &'a mut W {
83 self.variant(BUTTON0_A::OFF)
84 }
85 #[doc = "BUTTON is on"]
86 #[inline(always)]
87 pub fn on(self) -> &'a mut W {
88 self.variant(BUTTON0_A::ON)
89 }
90}
91#[doc = "Field `BUTTON1` reader - "]
92pub type BUTTON1_R = crate::BitReader<BUTTON1_A>;
93#[doc = "\n\nValue on reset: 0"]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95pub enum BUTTON1_A {
96 #[doc = "0: BUTTON is off"]
97 OFF = 0,
98 #[doc = "1: BUTTON is on"]
99 ON = 1,
100}
101impl From<BUTTON1_A> for bool {
102 #[inline(always)]
103 fn from(variant: BUTTON1_A) -> Self {
104 variant as u8 != 0
105 }
106}
107impl BUTTON1_R {
108 #[doc = "Get enumerated values variant"]
109 #[inline(always)]
110 pub fn variant(&self) -> BUTTON1_A {
111 match self.bits {
112 false => BUTTON1_A::OFF,
113 true => BUTTON1_A::ON,
114 }
115 }
116 #[doc = "Checks if the value of the field is `OFF`"]
117 #[inline(always)]
118 pub fn is_off(&self) -> bool {
119 *self == BUTTON1_A::OFF
120 }
121 #[doc = "Checks if the value of the field is `ON`"]
122 #[inline(always)]
123 pub fn is_on(&self) -> bool {
124 *self == BUTTON1_A::ON
125 }
126}
127#[doc = "Field `BUTTON1` writer - "]
128pub type BUTTON1_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUTTON_SPEC, BUTTON1_A, O>;
129impl<'a, const O: u8> BUTTON1_W<'a, O> {
130 #[doc = "BUTTON is off"]
131 #[inline(always)]
132 pub fn off(self) -> &'a mut W {
133 self.variant(BUTTON1_A::OFF)
134 }
135 #[doc = "BUTTON is on"]
136 #[inline(always)]
137 pub fn on(self) -> &'a mut W {
138 self.variant(BUTTON1_A::ON)
139 }
140}
141impl R {
142 #[doc = "Bit 0"]
143 #[inline(always)]
144 pub fn button0(&self) -> BUTTON0_R {
145 BUTTON0_R::new((self.bits & 1) != 0)
146 }
147 #[doc = "Bit 1"]
148 #[inline(always)]
149 pub fn button1(&self) -> BUTTON1_R {
150 BUTTON1_R::new(((self.bits >> 1) & 1) != 0)
151 }
152}
153impl W {
154 #[doc = "Bit 0"]
155 #[inline(always)]
156 pub fn button0(&mut self) -> BUTTON0_W<0> {
157 BUTTON0_W::new(self)
158 }
159 #[doc = "Bit 1"]
160 #[inline(always)]
161 pub fn button1(&mut self) -> BUTTON1_W<1> {
162 BUTTON1_W::new(self)
163 }
164 #[doc = "Writes raw bits to the register."]
165 #[inline(always)]
166 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
167 self.0.bits(bits);
168 self
169 }
170}
171#[doc = "Button Connections\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [button](index.html) module"]
172pub struct BUTTON_SPEC;
173impl crate::RegisterSpec for BUTTON_SPEC {
174 type Ux = u32;
175}
176#[doc = "`read()` method returns [button::R](R) reader structure"]
177impl crate::Readable for BUTTON_SPEC {
178 type Reader = R;
179}
180#[doc = "`write(|w| ..)` method takes [button::W](W) writer structure"]
181impl crate::Writable for BUTTON_SPEC {
182 type Writer = W;
183}
184#[doc = "`reset()` method sets BUTTON to value 0"]
185impl crate::Resettable for BUTTON_SPEC {
186 #[inline(always)]
187 fn reset_value() -> Self::Ux {
188 0
189 }
190}