avr_device/devices/atmega4809/slpctrl/
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 `SEN` reader - Sleep enable"]
38pub type SEN_R = crate::BitReader<bool>;
39#[doc = "Field `SEN` writer - Sleep enable"]
40pub type SEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
41#[doc = "Field `SMODE` reader - Sleep mode"]
42pub type SMODE_R = crate::FieldReader<u8, SMODE_A>;
43#[doc = "Sleep mode\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum SMODE_A {
47    #[doc = "0: Idle mode"]
48    IDLE = 0,
49    #[doc = "1: Standby Mode"]
50    STDBY = 1,
51    #[doc = "2: Power-down Mode"]
52    PDOWN = 2,
53}
54impl From<SMODE_A> for u8 {
55    #[inline(always)]
56    fn from(variant: SMODE_A) -> Self {
57        variant as _
58    }
59}
60impl SMODE_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<SMODE_A> {
64        match self.bits {
65            0 => Some(SMODE_A::IDLE),
66            1 => Some(SMODE_A::STDBY),
67            2 => Some(SMODE_A::PDOWN),
68            _ => None,
69        }
70    }
71    #[doc = "Checks if the value of the field is `IDLE`"]
72    #[inline(always)]
73    pub fn is_idle(&self) -> bool {
74        *self == SMODE_A::IDLE
75    }
76    #[doc = "Checks if the value of the field is `STDBY`"]
77    #[inline(always)]
78    pub fn is_stdby(&self) -> bool {
79        *self == SMODE_A::STDBY
80    }
81    #[doc = "Checks if the value of the field is `PDOWN`"]
82    #[inline(always)]
83    pub fn is_pdown(&self) -> bool {
84        *self == SMODE_A::PDOWN
85    }
86}
87#[doc = "Field `SMODE` writer - Sleep mode"]
88pub type SMODE_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CTRLA_SPEC, u8, SMODE_A, 2, O>;
89impl<'a, const O: u8> SMODE_W<'a, O> {
90    #[doc = "Idle mode"]
91    #[inline(always)]
92    pub fn idle(self) -> &'a mut W {
93        self.variant(SMODE_A::IDLE)
94    }
95    #[doc = "Standby Mode"]
96    #[inline(always)]
97    pub fn stdby(self) -> &'a mut W {
98        self.variant(SMODE_A::STDBY)
99    }
100    #[doc = "Power-down Mode"]
101    #[inline(always)]
102    pub fn pdown(self) -> &'a mut W {
103        self.variant(SMODE_A::PDOWN)
104    }
105}
106impl R {
107    #[doc = "Bit 0 - Sleep enable"]
108    #[inline(always)]
109    pub fn sen(&self) -> SEN_R {
110        SEN_R::new((self.bits & 1) != 0)
111    }
112    #[doc = "Bits 1:2 - Sleep mode"]
113    #[inline(always)]
114    pub fn smode(&self) -> SMODE_R {
115        SMODE_R::new((self.bits >> 1) & 3)
116    }
117}
118impl W {
119    #[doc = "Bit 0 - Sleep enable"]
120    #[inline(always)]
121    #[must_use]
122    pub fn sen(&mut self) -> SEN_W<0> {
123        SEN_W::new(self)
124    }
125    #[doc = "Bits 1:2 - Sleep mode"]
126    #[inline(always)]
127    #[must_use]
128    pub fn smode(&mut self) -> SMODE_W<1> {
129        SMODE_W::new(self)
130    }
131    #[doc = "Writes raw bits to the register."]
132    #[inline(always)]
133    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
134        self.0.bits(bits);
135        self
136    }
137}
138#[doc = "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 [ctrla](index.html) module"]
139pub struct CTRLA_SPEC;
140impl crate::RegisterSpec for CTRLA_SPEC {
141    type Ux = u8;
142}
143#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
144impl crate::Readable for CTRLA_SPEC {
145    type Reader = R;
146}
147#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
148impl crate::Writable for CTRLA_SPEC {
149    type Writer = W;
150    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
151    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
152}
153#[doc = "`reset()` method sets CTRLA to value 0"]
154impl crate::Resettable for CTRLA_SPEC {
155    const RESET_VALUE: Self::Ux = 0;
156}