atsamd11d/usb/device/
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}
23impl From<Modeselect> for bool {
24 #[inline(always)]
25 fn from(variant: Modeselect) -> Self {
26 variant as u8 != 0
27 }
28}
29#[doc = "Field `MODE` reader - Operating Mode"]
30pub type ModeR = crate::BitReader<Modeselect>;
31impl ModeR {
32 #[doc = "Get enumerated values variant"]
33 #[inline(always)]
34 pub const fn variant(&self) -> Option<Modeselect> {
35 match self.bits {
36 false => Some(Modeselect::Device),
37 _ => None,
38 }
39 }
40 #[doc = "Device Mode"]
41 #[inline(always)]
42 pub fn is_device(&self) -> bool {
43 *self == Modeselect::Device
44 }
45}
46#[doc = "Field `MODE` writer - Operating Mode"]
47pub type ModeW<'a, REG> = crate::BitWriter<'a, REG, Modeselect>;
48impl<'a, REG> ModeW<'a, REG>
49where
50 REG: crate::Writable + crate::RegisterSpec,
51{
52 #[doc = "Device Mode"]
53 #[inline(always)]
54 pub fn device(self) -> &'a mut crate::W<REG> {
55 self.variant(Modeselect::Device)
56 }
57}
58impl R {
59 #[doc = "Bit 0 - Software Reset"]
60 #[inline(always)]
61 pub fn swrst(&self) -> SwrstR {
62 SwrstR::new((self.bits & 1) != 0)
63 }
64 #[doc = "Bit 1 - Enable"]
65 #[inline(always)]
66 pub fn enable(&self) -> EnableR {
67 EnableR::new(((self.bits >> 1) & 1) != 0)
68 }
69 #[doc = "Bit 2 - Run in Standby Mode"]
70 #[inline(always)]
71 pub fn runstdby(&self) -> RunstdbyR {
72 RunstdbyR::new(((self.bits >> 2) & 1) != 0)
73 }
74 #[doc = "Bit 7 - Operating Mode"]
75 #[inline(always)]
76 pub fn mode(&self) -> ModeR {
77 ModeR::new(((self.bits >> 7) & 1) != 0)
78 }
79}
80impl W {
81 #[doc = "Bit 0 - Software Reset"]
82 #[inline(always)]
83 #[must_use]
84 pub fn swrst(&mut self) -> SwrstW<CtrlaSpec> {
85 SwrstW::new(self, 0)
86 }
87 #[doc = "Bit 1 - Enable"]
88 #[inline(always)]
89 #[must_use]
90 pub fn enable(&mut self) -> EnableW<CtrlaSpec> {
91 EnableW::new(self, 1)
92 }
93 #[doc = "Bit 2 - Run in Standby Mode"]
94 #[inline(always)]
95 #[must_use]
96 pub fn runstdby(&mut self) -> RunstdbyW<CtrlaSpec> {
97 RunstdbyW::new(self, 2)
98 }
99 #[doc = "Bit 7 - Operating Mode"]
100 #[inline(always)]
101 #[must_use]
102 pub fn mode(&mut self) -> ModeW<CtrlaSpec> {
103 ModeW::new(self, 7)
104 }
105}
106#[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)."]
107pub struct CtrlaSpec;
108impl crate::RegisterSpec for CtrlaSpec {
109 type Ux = u8;
110}
111#[doc = "`read()` method returns [`ctrla::R`](R) reader structure"]
112impl crate::Readable for CtrlaSpec {}
113#[doc = "`write(|w| ..)` method takes [`ctrla::W`](W) writer structure"]
114impl crate::Writable for CtrlaSpec {
115 type Safety = crate::Unsafe;
116 const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
117 const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
118}
119#[doc = "`reset()` method sets CTRLA to value 0"]
120impl crate::Resettable for CtrlaSpec {
121 const RESET_VALUE: u8 = 0;
122}