atsam4s16c_pac/acc/
acr.rs

1#[doc = "Register `ACR` reader"]
2pub struct R(crate::R<ACR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ACR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ACR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ACR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ACR` writer"]
17pub struct W(crate::W<ACR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ACR_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<ACR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ACR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ISEL` reader - Current Selection"]
38pub type ISEL_R = crate::BitReader<ISEL_A>;
39#[doc = "Current Selection\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum ISEL_A {
42    #[doc = "0: Low-power option."]
43    LOPW = 0,
44    #[doc = "1: High-speed option."]
45    HISP = 1,
46}
47impl From<ISEL_A> for bool {
48    #[inline(always)]
49    fn from(variant: ISEL_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl ISEL_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> ISEL_A {
57        match self.bits {
58            false => ISEL_A::LOPW,
59            true => ISEL_A::HISP,
60        }
61    }
62    #[doc = "Checks if the value of the field is `LOPW`"]
63    #[inline(always)]
64    pub fn is_lopw(&self) -> bool {
65        *self == ISEL_A::LOPW
66    }
67    #[doc = "Checks if the value of the field is `HISP`"]
68    #[inline(always)]
69    pub fn is_hisp(&self) -> bool {
70        *self == ISEL_A::HISP
71    }
72}
73#[doc = "Field `ISEL` writer - Current Selection"]
74pub type ISEL_W<'a, const O: u8> = crate::BitWriter<'a, u32, ACR_SPEC, ISEL_A, O>;
75impl<'a, const O: u8> ISEL_W<'a, O> {
76    #[doc = "Low-power option."]
77    #[inline(always)]
78    pub fn lopw(self) -> &'a mut W {
79        self.variant(ISEL_A::LOPW)
80    }
81    #[doc = "High-speed option."]
82    #[inline(always)]
83    pub fn hisp(self) -> &'a mut W {
84        self.variant(ISEL_A::HISP)
85    }
86}
87#[doc = "Field `HYST` reader - Hysteresis Selection"]
88pub type HYST_R = crate::FieldReader<u8, u8>;
89#[doc = "Field `HYST` writer - Hysteresis Selection"]
90pub type HYST_W<'a, const O: u8> = crate::FieldWriter<'a, u32, ACR_SPEC, u8, u8, 2, O>;
91impl R {
92    #[doc = "Bit 0 - Current Selection"]
93    #[inline(always)]
94    pub fn isel(&self) -> ISEL_R {
95        ISEL_R::new((self.bits & 1) != 0)
96    }
97    #[doc = "Bits 1:2 - Hysteresis Selection"]
98    #[inline(always)]
99    pub fn hyst(&self) -> HYST_R {
100        HYST_R::new(((self.bits >> 1) & 3) as u8)
101    }
102}
103impl W {
104    #[doc = "Bit 0 - Current Selection"]
105    #[inline(always)]
106    #[must_use]
107    pub fn isel(&mut self) -> ISEL_W<0> {
108        ISEL_W::new(self)
109    }
110    #[doc = "Bits 1:2 - Hysteresis Selection"]
111    #[inline(always)]
112    #[must_use]
113    pub fn hyst(&mut self) -> HYST_W<1> {
114        HYST_W::new(self)
115    }
116    #[doc = "Writes raw bits to the register."]
117    #[inline(always)]
118    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
119        self.0.bits(bits);
120        self
121    }
122}
123#[doc = "Analog Control Register\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 [acr](index.html) module"]
124pub struct ACR_SPEC;
125impl crate::RegisterSpec for ACR_SPEC {
126    type Ux = u32;
127}
128#[doc = "`read()` method returns [acr::R](R) reader structure"]
129impl crate::Readable for ACR_SPEC {
130    type Reader = R;
131}
132#[doc = "`write(|w| ..)` method takes [acr::W](W) writer structure"]
133impl crate::Writable for ACR_SPEC {
134    type Writer = W;
135    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
136    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
137}
138#[doc = "`reset()` method sets ACR to value 0"]
139impl crate::Resettable for ACR_SPEC {
140    const RESET_VALUE: Self::Ux = 0;
141}