atsamd51g/usb/host/
ctrla.rs

1#[doc = "Register `CTRLA` reader"]
2pub type R = crate::R<CtrlaSpec>;
3#[doc = "Register `CTRLA` writer"]
4pub type W = crate::W<CtrlaSpec>;
5#[doc = "Field `SWRST` reader - Software Reset"]
6pub type SwrstR = crate::BitReader;
7#[doc = "Field `SWRST` writer - Software Reset"]
8pub type SwrstW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `ENABLE` reader - Enable"]
10pub type EnableR = crate::BitReader;
11#[doc = "Field `ENABLE` writer - Enable"]
12pub type EnableW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `RUNSTDBY` reader - Run in Standby Mode"]
14pub type RunstdbyR = crate::BitReader;
15#[doc = "Field `RUNSTDBY` writer - Run in Standby Mode"]
16pub type RunstdbyW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Operating Mode\n\nValue on reset: 0"]
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19pub enum Modeselect {
20    #[doc = "0: Device Mode"]
21    Device = 0,
22    #[doc = "1: Host Mode"]
23    Host = 1,
24}
25impl From<Modeselect> for bool {
26    #[inline(always)]
27    fn from(variant: Modeselect) -> Self {
28        variant as u8 != 0
29    }
30}
31#[doc = "Field `MODE` reader - Operating Mode"]
32pub type ModeR = crate::BitReader<Modeselect>;
33impl ModeR {
34    #[doc = "Get enumerated values variant"]
35    #[inline(always)]
36    pub const fn variant(&self) -> Modeselect {
37        match self.bits {
38            false => Modeselect::Device,
39            true => Modeselect::Host,
40        }
41    }
42    #[doc = "Device Mode"]
43    #[inline(always)]
44    pub fn is_device(&self) -> bool {
45        *self == Modeselect::Device
46    }
47    #[doc = "Host Mode"]
48    #[inline(always)]
49    pub fn is_host(&self) -> bool {
50        *self == Modeselect::Host
51    }
52}
53#[doc = "Field `MODE` writer - Operating Mode"]
54pub type ModeW<'a, REG> = crate::BitWriter<'a, REG, Modeselect>;
55impl<'a, REG> ModeW<'a, REG>
56where
57    REG: crate::Writable + crate::RegisterSpec,
58{
59    #[doc = "Device Mode"]
60    #[inline(always)]
61    pub fn device(self) -> &'a mut crate::W<REG> {
62        self.variant(Modeselect::Device)
63    }
64    #[doc = "Host Mode"]
65    #[inline(always)]
66    pub fn host(self) -> &'a mut crate::W<REG> {
67        self.variant(Modeselect::Host)
68    }
69}
70impl R {
71    #[doc = "Bit 0 - Software Reset"]
72    #[inline(always)]
73    pub fn swrst(&self) -> SwrstR {
74        SwrstR::new((self.bits & 1) != 0)
75    }
76    #[doc = "Bit 1 - Enable"]
77    #[inline(always)]
78    pub fn enable(&self) -> EnableR {
79        EnableR::new(((self.bits >> 1) & 1) != 0)
80    }
81    #[doc = "Bit 2 - Run in Standby Mode"]
82    #[inline(always)]
83    pub fn runstdby(&self) -> RunstdbyR {
84        RunstdbyR::new(((self.bits >> 2) & 1) != 0)
85    }
86    #[doc = "Bit 7 - Operating Mode"]
87    #[inline(always)]
88    pub fn mode(&self) -> ModeR {
89        ModeR::new(((self.bits >> 7) & 1) != 0)
90    }
91}
92impl W {
93    #[doc = "Bit 0 - Software Reset"]
94    #[inline(always)]
95    #[must_use]
96    pub fn swrst(&mut self) -> SwrstW<CtrlaSpec> {
97        SwrstW::new(self, 0)
98    }
99    #[doc = "Bit 1 - Enable"]
100    #[inline(always)]
101    #[must_use]
102    pub fn enable(&mut self) -> EnableW<CtrlaSpec> {
103        EnableW::new(self, 1)
104    }
105    #[doc = "Bit 2 - Run in Standby Mode"]
106    #[inline(always)]
107    #[must_use]
108    pub fn runstdby(&mut self) -> RunstdbyW<CtrlaSpec> {
109        RunstdbyW::new(self, 2)
110    }
111    #[doc = "Bit 7 - Operating Mode"]
112    #[inline(always)]
113    #[must_use]
114    pub fn mode(&mut self) -> ModeW<CtrlaSpec> {
115        ModeW::new(self, 7)
116    }
117}
118#[doc = "Control A\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrla::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrla::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
119pub struct CtrlaSpec;
120impl crate::RegisterSpec for CtrlaSpec {
121    type Ux = u8;
122}
123#[doc = "`read()` method returns [`ctrla::R`](R) reader structure"]
124impl crate::Readable for CtrlaSpec {}
125#[doc = "`write(|w| ..)` method takes [`ctrla::W`](W) writer structure"]
126impl crate::Writable for CtrlaSpec {
127    type Safety = crate::Unsafe;
128    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
129    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
130}
131#[doc = "`reset()` method sets CTRLA to value 0"]
132impl crate::Resettable for CtrlaSpec {
133    const RESET_VALUE: u8 = 0;
134}