avr_device/devices/atmega4809/portc/
pin0ctrl.rs

1#[doc = "Register `PIN0CTRL` reader"]
2pub struct R(crate::R<PIN0CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PIN0CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PIN0CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PIN0CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PIN0CTRL` writer"]
17pub struct W(crate::W<PIN0CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PIN0CTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<PIN0CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PIN0CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ISC` reader - Input/Sense Configuration"]
38pub type ISC_R = crate::FieldReader<u8, ISC_A>;
39#[doc = "Input/Sense Configuration\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum ISC_A {
43    #[doc = "0: Interrupt disabled but input buffer enabled"]
44    INTDISABLE = 0,
45    #[doc = "1: Sense Both Edges"]
46    BOTHEDGES = 1,
47    #[doc = "2: Sense Rising Edge"]
48    RISING = 2,
49    #[doc = "3: Sense Falling Edge"]
50    FALLING = 3,
51    #[doc = "4: Digital Input Buffer disabled"]
52    INPUT_DISABLE = 4,
53    #[doc = "5: Sense low Level"]
54    LEVEL = 5,
55}
56impl From<ISC_A> for u8 {
57    #[inline(always)]
58    fn from(variant: ISC_A) -> Self {
59        variant as _
60    }
61}
62impl ISC_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> Option<ISC_A> {
66        match self.bits {
67            0 => Some(ISC_A::INTDISABLE),
68            1 => Some(ISC_A::BOTHEDGES),
69            2 => Some(ISC_A::RISING),
70            3 => Some(ISC_A::FALLING),
71            4 => Some(ISC_A::INPUT_DISABLE),
72            5 => Some(ISC_A::LEVEL),
73            _ => None,
74        }
75    }
76    #[doc = "Checks if the value of the field is `INTDISABLE`"]
77    #[inline(always)]
78    pub fn is_intdisable(&self) -> bool {
79        *self == ISC_A::INTDISABLE
80    }
81    #[doc = "Checks if the value of the field is `BOTHEDGES`"]
82    #[inline(always)]
83    pub fn is_bothedges(&self) -> bool {
84        *self == ISC_A::BOTHEDGES
85    }
86    #[doc = "Checks if the value of the field is `RISING`"]
87    #[inline(always)]
88    pub fn is_rising(&self) -> bool {
89        *self == ISC_A::RISING
90    }
91    #[doc = "Checks if the value of the field is `FALLING`"]
92    #[inline(always)]
93    pub fn is_falling(&self) -> bool {
94        *self == ISC_A::FALLING
95    }
96    #[doc = "Checks if the value of the field is `INPUT_DISABLE`"]
97    #[inline(always)]
98    pub fn is_input_disable(&self) -> bool {
99        *self == ISC_A::INPUT_DISABLE
100    }
101    #[doc = "Checks if the value of the field is `LEVEL`"]
102    #[inline(always)]
103    pub fn is_level(&self) -> bool {
104        *self == ISC_A::LEVEL
105    }
106}
107#[doc = "Field `ISC` writer - Input/Sense Configuration"]
108pub type ISC_W<'a, const O: u8> = crate::FieldWriter<'a, u8, PIN0CTRL_SPEC, u8, ISC_A, 3, O>;
109impl<'a, const O: u8> ISC_W<'a, O> {
110    #[doc = "Interrupt disabled but input buffer enabled"]
111    #[inline(always)]
112    pub fn intdisable(self) -> &'a mut W {
113        self.variant(ISC_A::INTDISABLE)
114    }
115    #[doc = "Sense Both Edges"]
116    #[inline(always)]
117    pub fn bothedges(self) -> &'a mut W {
118        self.variant(ISC_A::BOTHEDGES)
119    }
120    #[doc = "Sense Rising Edge"]
121    #[inline(always)]
122    pub fn rising(self) -> &'a mut W {
123        self.variant(ISC_A::RISING)
124    }
125    #[doc = "Sense Falling Edge"]
126    #[inline(always)]
127    pub fn falling(self) -> &'a mut W {
128        self.variant(ISC_A::FALLING)
129    }
130    #[doc = "Digital Input Buffer disabled"]
131    #[inline(always)]
132    pub fn input_disable(self) -> &'a mut W {
133        self.variant(ISC_A::INPUT_DISABLE)
134    }
135    #[doc = "Sense low Level"]
136    #[inline(always)]
137    pub fn level(self) -> &'a mut W {
138        self.variant(ISC_A::LEVEL)
139    }
140}
141#[doc = "Field `PULLUPEN` reader - Pullup enable"]
142pub type PULLUPEN_R = crate::BitReader<bool>;
143#[doc = "Field `PULLUPEN` writer - Pullup enable"]
144pub type PULLUPEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, PIN0CTRL_SPEC, bool, O>;
145#[doc = "Field `INVEN` reader - Inverted I/O Enable"]
146pub type INVEN_R = crate::BitReader<bool>;
147#[doc = "Field `INVEN` writer - Inverted I/O Enable"]
148pub type INVEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, PIN0CTRL_SPEC, bool, O>;
149impl R {
150    #[doc = "Bits 0:2 - Input/Sense Configuration"]
151    #[inline(always)]
152    pub fn isc(&self) -> ISC_R {
153        ISC_R::new(self.bits & 7)
154    }
155    #[doc = "Bit 3 - Pullup enable"]
156    #[inline(always)]
157    pub fn pullupen(&self) -> PULLUPEN_R {
158        PULLUPEN_R::new(((self.bits >> 3) & 1) != 0)
159    }
160    #[doc = "Bit 7 - Inverted I/O Enable"]
161    #[inline(always)]
162    pub fn inven(&self) -> INVEN_R {
163        INVEN_R::new(((self.bits >> 7) & 1) != 0)
164    }
165}
166impl W {
167    #[doc = "Bits 0:2 - Input/Sense Configuration"]
168    #[inline(always)]
169    #[must_use]
170    pub fn isc(&mut self) -> ISC_W<0> {
171        ISC_W::new(self)
172    }
173    #[doc = "Bit 3 - Pullup enable"]
174    #[inline(always)]
175    #[must_use]
176    pub fn pullupen(&mut self) -> PULLUPEN_W<3> {
177        PULLUPEN_W::new(self)
178    }
179    #[doc = "Bit 7 - Inverted I/O Enable"]
180    #[inline(always)]
181    #[must_use]
182    pub fn inven(&mut self) -> INVEN_W<7> {
183        INVEN_W::new(self)
184    }
185    #[doc = "Writes raw bits to the register."]
186    #[inline(always)]
187    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
188        self.0.bits(bits);
189        self
190    }
191}
192#[doc = "Pin 0 Control\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 [pin0ctrl](index.html) module"]
193pub struct PIN0CTRL_SPEC;
194impl crate::RegisterSpec for PIN0CTRL_SPEC {
195    type Ux = u8;
196}
197#[doc = "`read()` method returns [pin0ctrl::R](R) reader structure"]
198impl crate::Readable for PIN0CTRL_SPEC {
199    type Reader = R;
200}
201#[doc = "`write(|w| ..)` method takes [pin0ctrl::W](W) writer structure"]
202impl crate::Writable for PIN0CTRL_SPEC {
203    type Writer = W;
204    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
205    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
206}
207#[doc = "`reset()` method sets PIN0CTRL to value 0"]
208impl crate::Resettable for PIN0CTRL_SPEC {
209    const RESET_VALUE: Self::Ux = 0;
210}