esp32p4/lp_tsens/
wakeup_ctrl.rs

1#[doc = "Register `WAKEUP_CTRL` reader"]
2pub type R = crate::R<WAKEUP_CTRL_SPEC>;
3#[doc = "Register `WAKEUP_CTRL` writer"]
4pub type W = crate::W<WAKEUP_CTRL_SPEC>;
5#[doc = "Field `WAKEUP_TH_LOW` reader - Lower threshold."]
6pub type WAKEUP_TH_LOW_R = crate::FieldReader;
7#[doc = "Field `WAKEUP_TH_LOW` writer - Lower threshold."]
8pub type WAKEUP_TH_LOW_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
9#[doc = "Field `WAKEUP_TH_HIGH` reader - Upper threshold."]
10pub type WAKEUP_TH_HIGH_R = crate::FieldReader;
11#[doc = "Field `WAKEUP_TH_HIGH` writer - Upper threshold."]
12pub type WAKEUP_TH_HIGH_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
13#[doc = "Field `WAKEUP_OVER_UPPER_TH` reader - Indicates that this wakeup event arose from exceeding upper threshold."]
14pub type WAKEUP_OVER_UPPER_TH_R = crate::BitReader;
15#[doc = "Field `WAKEUP_EN` reader - Tsens wakeup enable."]
16pub type WAKEUP_EN_R = crate::BitReader;
17#[doc = "Field `WAKEUP_EN` writer - Tsens wakeup enable."]
18pub type WAKEUP_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
19#[doc = "Field `WAKEUP_MODE` reader - 0:absolute value comparison mode. 1: relative value comparison mode."]
20pub type WAKEUP_MODE_R = crate::BitReader;
21#[doc = "Field `WAKEUP_MODE` writer - 0:absolute value comparison mode. 1: relative value comparison mode."]
22pub type WAKEUP_MODE_W<'a, REG> = crate::BitWriter<'a, REG>;
23impl R {
24    #[doc = "Bits 0:7 - Lower threshold."]
25    #[inline(always)]
26    pub fn wakeup_th_low(&self) -> WAKEUP_TH_LOW_R {
27        WAKEUP_TH_LOW_R::new((self.bits & 0xff) as u8)
28    }
29    #[doc = "Bits 14:21 - Upper threshold."]
30    #[inline(always)]
31    pub fn wakeup_th_high(&self) -> WAKEUP_TH_HIGH_R {
32        WAKEUP_TH_HIGH_R::new(((self.bits >> 14) & 0xff) as u8)
33    }
34    #[doc = "Bit 29 - Indicates that this wakeup event arose from exceeding upper threshold."]
35    #[inline(always)]
36    pub fn wakeup_over_upper_th(&self) -> WAKEUP_OVER_UPPER_TH_R {
37        WAKEUP_OVER_UPPER_TH_R::new(((self.bits >> 29) & 1) != 0)
38    }
39    #[doc = "Bit 30 - Tsens wakeup enable."]
40    #[inline(always)]
41    pub fn wakeup_en(&self) -> WAKEUP_EN_R {
42        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 wakeup_mode(&self) -> WAKEUP_MODE_R {
47        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("WAKEUP_CTRL")
54            .field(
55                "wakeup_th_low",
56                &format_args!("{}", self.wakeup_th_low().bits()),
57            )
58            .field(
59                "wakeup_th_high",
60                &format_args!("{}", self.wakeup_th_high().bits()),
61            )
62            .field(
63                "wakeup_over_upper_th",
64                &format_args!("{}", self.wakeup_over_upper_th().bit()),
65            )
66            .field("wakeup_en", &format_args!("{}", self.wakeup_en().bit()))
67            .field("wakeup_mode", &format_args!("{}", self.wakeup_mode().bit()))
68            .finish()
69    }
70}
71#[cfg(feature = "impl-register-debug")]
72impl core::fmt::Debug for crate::generic::Reg<WAKEUP_CTRL_SPEC> {
73    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
74        core::fmt::Debug::fmt(&self.read(), f)
75    }
76}
77impl W {
78    #[doc = "Bits 0:7 - Lower threshold."]
79    #[inline(always)]
80    #[must_use]
81    pub fn wakeup_th_low(&mut self) -> WAKEUP_TH_LOW_W<WAKEUP_CTRL_SPEC> {
82        WAKEUP_TH_LOW_W::new(self, 0)
83    }
84    #[doc = "Bits 14:21 - Upper threshold."]
85    #[inline(always)]
86    #[must_use]
87    pub fn wakeup_th_high(&mut self) -> WAKEUP_TH_HIGH_W<WAKEUP_CTRL_SPEC> {
88        WAKEUP_TH_HIGH_W::new(self, 14)
89    }
90    #[doc = "Bit 30 - Tsens wakeup enable."]
91    #[inline(always)]
92    #[must_use]
93    pub fn wakeup_en(&mut self) -> WAKEUP_EN_W<WAKEUP_CTRL_SPEC> {
94        WAKEUP_EN_W::new(self, 30)
95    }
96    #[doc = "Bit 31 - 0:absolute value comparison mode. 1: relative value comparison mode."]
97    #[inline(always)]
98    #[must_use]
99    pub fn wakeup_mode(&mut self) -> WAKEUP_MODE_W<WAKEUP_CTRL_SPEC> {
100        WAKEUP_MODE_W::new(self, 31)
101    }
102}
103#[doc = "Tsens wakeup control registers.\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`wakeup_ctrl::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 [`wakeup_ctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
104pub struct WAKEUP_CTRL_SPEC;
105impl crate::RegisterSpec for WAKEUP_CTRL_SPEC {
106    type Ux = u32;
107}
108#[doc = "`read()` method returns [`wakeup_ctrl::R`](R) reader structure"]
109impl crate::Readable for WAKEUP_CTRL_SPEC {}
110#[doc = "`write(|w| ..)` method takes [`wakeup_ctrl::W`](W) writer structure"]
111impl crate::Writable for WAKEUP_CTRL_SPEC {
112    type Safety = crate::Unsafe;
113    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
114    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
115}
116#[doc = "`reset()` method sets WAKEUP_CTRL to value 0x003f_c000"]
117impl crate::Resettable for WAKEUP_CTRL_SPEC {
118    const RESET_VALUE: u32 = 0x003f_c000;
119}