atsaml21e15b/usb/device/
ctrla.rs

1#[doc = "Register `CTRLA` reader"]
2pub struct R(crate::R<CTRLA_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRLA_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRLA_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRLA_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRLA` writer"]
17pub struct W(crate::W<CTRLA_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRLA_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<CTRLA_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRLA_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SWRST` reader - Software Reset"]
38pub type SWRST_R = crate::BitReader<bool>;
39#[doc = "Field `SWRST` writer - Software Reset"]
40pub type SWRST_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
41#[doc = "Field `ENABLE` reader - Enable"]
42pub type ENABLE_R = crate::BitReader<bool>;
43#[doc = "Field `ENABLE` writer - Enable"]
44pub type ENABLE_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
45#[doc = "Field `RUNSTDBY` reader - Run in Standby Mode"]
46pub type RUNSTDBY_R = crate::BitReader<bool>;
47#[doc = "Field `RUNSTDBY` writer - Run in Standby Mode"]
48pub type RUNSTDBY_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
49#[doc = "Field `MODE` reader - Operating Mode"]
50pub type MODE_R = crate::BitReader<MODESELECT_A>;
51#[doc = "Operating Mode\n\nValue on reset: 0"]
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53pub enum MODESELECT_A {
54    #[doc = "0: Device Mode"]
55    DEVICE = 0,
56    #[doc = "1: Host Mode"]
57    HOST = 1,
58}
59impl From<MODESELECT_A> for bool {
60    #[inline(always)]
61    fn from(variant: MODESELECT_A) -> Self {
62        variant as u8 != 0
63    }
64}
65impl MODE_R {
66    #[doc = "Get enumerated values variant"]
67    #[inline(always)]
68    pub fn variant(&self) -> MODESELECT_A {
69        match self.bits {
70            false => MODESELECT_A::DEVICE,
71            true => MODESELECT_A::HOST,
72        }
73    }
74    #[doc = "Checks if the value of the field is `DEVICE`"]
75    #[inline(always)]
76    pub fn is_device(&self) -> bool {
77        *self == MODESELECT_A::DEVICE
78    }
79    #[doc = "Checks if the value of the field is `HOST`"]
80    #[inline(always)]
81    pub fn is_host(&self) -> bool {
82        *self == MODESELECT_A::HOST
83    }
84}
85#[doc = "Field `MODE` writer - Operating Mode"]
86pub type MODE_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, MODESELECT_A, O>;
87impl<'a, const O: u8> MODE_W<'a, O> {
88    #[doc = "Device Mode"]
89    #[inline(always)]
90    pub fn device(self) -> &'a mut W {
91        self.variant(MODESELECT_A::DEVICE)
92    }
93    #[doc = "Host Mode"]
94    #[inline(always)]
95    pub fn host(self) -> &'a mut W {
96        self.variant(MODESELECT_A::HOST)
97    }
98}
99impl R {
100    #[doc = "Bit 0 - Software Reset"]
101    #[inline(always)]
102    pub fn swrst(&self) -> SWRST_R {
103        SWRST_R::new((self.bits & 1) != 0)
104    }
105    #[doc = "Bit 1 - Enable"]
106    #[inline(always)]
107    pub fn enable(&self) -> ENABLE_R {
108        ENABLE_R::new(((self.bits >> 1) & 1) != 0)
109    }
110    #[doc = "Bit 2 - Run in Standby Mode"]
111    #[inline(always)]
112    pub fn runstdby(&self) -> RUNSTDBY_R {
113        RUNSTDBY_R::new(((self.bits >> 2) & 1) != 0)
114    }
115    #[doc = "Bit 7 - Operating Mode"]
116    #[inline(always)]
117    pub fn mode(&self) -> MODE_R {
118        MODE_R::new(((self.bits >> 7) & 1) != 0)
119    }
120}
121impl W {
122    #[doc = "Bit 0 - Software Reset"]
123    #[inline(always)]
124    #[must_use]
125    pub fn swrst(&mut self) -> SWRST_W<0> {
126        SWRST_W::new(self)
127    }
128    #[doc = "Bit 1 - Enable"]
129    #[inline(always)]
130    #[must_use]
131    pub fn enable(&mut self) -> ENABLE_W<1> {
132        ENABLE_W::new(self)
133    }
134    #[doc = "Bit 2 - Run in Standby Mode"]
135    #[inline(always)]
136    #[must_use]
137    pub fn runstdby(&mut self) -> RUNSTDBY_W<2> {
138        RUNSTDBY_W::new(self)
139    }
140    #[doc = "Bit 7 - Operating Mode"]
141    #[inline(always)]
142    #[must_use]
143    pub fn mode(&mut self) -> MODE_W<7> {
144        MODE_W::new(self)
145    }
146    #[doc = "Writes raw bits to the register."]
147    #[inline(always)]
148    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
149        self.0.bits(bits);
150        self
151    }
152}
153#[doc = "Control A\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 [ctrla](index.html) module"]
154pub struct CTRLA_SPEC;
155impl crate::RegisterSpec for CTRLA_SPEC {
156    type Ux = u8;
157}
158#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
159impl crate::Readable for CTRLA_SPEC {
160    type Reader = R;
161}
162#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
163impl crate::Writable for CTRLA_SPEC {
164    type Writer = W;
165    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
166    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
167}
168#[doc = "`reset()` method sets CTRLA to value 0"]
169impl crate::Resettable for CTRLA_SPEC {
170    const RESET_VALUE: Self::Ux = 0;
171}