esp32p4/lp_adc/
wakeup2.rs1#[doc = "Register `WAKEUP2` reader"]
2pub type R = crate::R<WAKEUP2_SPEC>;
3#[doc = "Register `WAKEUP2` writer"]
4pub type W = crate::W<WAKEUP2_SPEC>;
5#[doc = "Field `SAR2_WAKEUP_TH_LOW` reader - Lower threshold."]
6pub type SAR2_WAKEUP_TH_LOW_R = crate::FieldReader<u16>;
7#[doc = "Field `SAR2_WAKEUP_TH_LOW` writer - Lower threshold."]
8pub type SAR2_WAKEUP_TH_LOW_W<'a, REG> = crate::FieldWriter<'a, REG, 12, u16>;
9#[doc = "Field `SAR2_WAKEUP_TH_HIGH` reader - Upper threshold."]
10pub type SAR2_WAKEUP_TH_HIGH_R = crate::FieldReader<u16>;
11#[doc = "Field `SAR2_WAKEUP_TH_HIGH` writer - Upper threshold."]
12pub type SAR2_WAKEUP_TH_HIGH_W<'a, REG> = crate::FieldWriter<'a, REG, 12, u16>;
13#[doc = "Field `SAR2_WAKEUP_OVER_UPPER_TH` reader - Indicates that this wakeup event arose from exceeding upper threshold."]
14pub type SAR2_WAKEUP_OVER_UPPER_TH_R = crate::BitReader;
15#[doc = "Field `SAR2_WAKEUP_EN` reader - Wakeup function enable."]
16pub type SAR2_WAKEUP_EN_R = crate::BitReader;
17#[doc = "Field `SAR2_WAKEUP_EN` writer - Wakeup function enable."]
18pub type SAR2_WAKEUP_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
19#[doc = "Field `SAR2_WAKEUP_MODE` reader - 0:absolute value comparison mode. 1: relative value comparison mode."]
20pub type SAR2_WAKEUP_MODE_R = crate::BitReader;
21#[doc = "Field `SAR2_WAKEUP_MODE` writer - 0:absolute value comparison mode. 1: relative value comparison mode."]
22pub type SAR2_WAKEUP_MODE_W<'a, REG> = crate::BitWriter<'a, REG>;
23impl R {
24 #[doc = "Bits 0:11 - Lower threshold."]
25 #[inline(always)]
26 pub fn sar2_wakeup_th_low(&self) -> SAR2_WAKEUP_TH_LOW_R {
27 SAR2_WAKEUP_TH_LOW_R::new((self.bits & 0x0fff) as u16)
28 }
29 #[doc = "Bits 14:25 - Upper threshold."]
30 #[inline(always)]
31 pub fn sar2_wakeup_th_high(&self) -> SAR2_WAKEUP_TH_HIGH_R {
32 SAR2_WAKEUP_TH_HIGH_R::new(((self.bits >> 14) & 0x0fff) as u16)
33 }
34 #[doc = "Bit 29 - Indicates that this wakeup event arose from exceeding upper threshold."]
35 #[inline(always)]
36 pub fn sar2_wakeup_over_upper_th(&self) -> SAR2_WAKEUP_OVER_UPPER_TH_R {
37 SAR2_WAKEUP_OVER_UPPER_TH_R::new(((self.bits >> 29) & 1) != 0)
38 }
39 #[doc = "Bit 30 - Wakeup function enable."]
40 #[inline(always)]
41 pub fn sar2_wakeup_en(&self) -> SAR2_WAKEUP_EN_R {
42 SAR2_WAKEUP_EN_R::new(((self.bits >> 30) & 1) != 0)
43 }
44 #[doc = "Bit 31 - 0:absolute value comparison mode. 1: relative value comparison mode."]
45 #[inline(always)]
46 pub fn sar2_wakeup_mode(&self) -> SAR2_WAKEUP_MODE_R {
47 SAR2_WAKEUP_MODE_R::new(((self.bits >> 31) & 1) != 0)
48 }
49}
50#[cfg(feature = "impl-register-debug")]
51impl core::fmt::Debug for R {
52 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
53 f.debug_struct("WAKEUP2")
54 .field(
55 "sar2_wakeup_th_low",
56 &format_args!("{}", self.sar2_wakeup_th_low().bits()),
57 )
58 .field(
59 "sar2_wakeup_th_high",
60 &format_args!("{}", self.sar2_wakeup_th_high().bits()),
61 )
62 .field(
63 "sar2_wakeup_over_upper_th",
64 &format_args!("{}", self.sar2_wakeup_over_upper_th().bit()),
65 )
66 .field(
67 "sar2_wakeup_en",
68 &format_args!("{}", self.sar2_wakeup_en().bit()),
69 )
70 .field(
71 "sar2_wakeup_mode",
72 &format_args!("{}", self.sar2_wakeup_mode().bit()),
73 )
74 .finish()
75 }
76}
77#[cfg(feature = "impl-register-debug")]
78impl core::fmt::Debug for crate::generic::Reg<WAKEUP2_SPEC> {
79 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
80 core::fmt::Debug::fmt(&self.read(), f)
81 }
82}
83impl W {
84 #[doc = "Bits 0:11 - Lower threshold."]
85 #[inline(always)]
86 #[must_use]
87 pub fn sar2_wakeup_th_low(&mut self) -> SAR2_WAKEUP_TH_LOW_W<WAKEUP2_SPEC> {
88 SAR2_WAKEUP_TH_LOW_W::new(self, 0)
89 }
90 #[doc = "Bits 14:25 - Upper threshold."]
91 #[inline(always)]
92 #[must_use]
93 pub fn sar2_wakeup_th_high(&mut self) -> SAR2_WAKEUP_TH_HIGH_W<WAKEUP2_SPEC> {
94 SAR2_WAKEUP_TH_HIGH_W::new(self, 14)
95 }
96 #[doc = "Bit 30 - Wakeup function enable."]
97 #[inline(always)]
98 #[must_use]
99 pub fn sar2_wakeup_en(&mut self) -> SAR2_WAKEUP_EN_W<WAKEUP2_SPEC> {
100 SAR2_WAKEUP_EN_W::new(self, 30)
101 }
102 #[doc = "Bit 31 - 0:absolute value comparison mode. 1: relative value comparison mode."]
103 #[inline(always)]
104 #[must_use]
105 pub fn sar2_wakeup_mode(&mut self) -> SAR2_WAKEUP_MODE_W<WAKEUP2_SPEC> {
106 SAR2_WAKEUP_MODE_W::new(self, 31)
107 }
108}
109#[doc = "ADC2 wakeup configuration registers.\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`wakeup2::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`wakeup2::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
110pub struct WAKEUP2_SPEC;
111impl crate::RegisterSpec for WAKEUP2_SPEC {
112 type Ux = u32;
113}
114#[doc = "`read()` method returns [`wakeup2::R`](R) reader structure"]
115impl crate::Readable for WAKEUP2_SPEC {}
116#[doc = "`write(|w| ..)` method takes [`wakeup2::W`](W) writer structure"]
117impl crate::Writable for WAKEUP2_SPEC {
118 type Safety = crate::Unsafe;
119 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
120 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
121}
122#[doc = "`reset()` method sets WAKEUP2 to value 0x03ff_c000"]
123impl crate::Resettable for WAKEUP2_SPEC {
124 const RESET_VALUE: u32 = 0x03ff_c000;
125}