esp32p4/uart0/
sleep_conf2.rs

1#[doc = "Register `SLEEP_CONF2` reader"]
2pub type R = crate::R<SLEEP_CONF2_SPEC>;
3#[doc = "Register `SLEEP_CONF2` writer"]
4pub type W = crate::W<SLEEP_CONF2_SPEC>;
5#[doc = "Field `ACTIVE_THRESHOLD` reader - The uart is activated from light sleeping mode when the input rxd edge changes more times than this register value."]
6pub type ACTIVE_THRESHOLD_R = crate::FieldReader<u16>;
7#[doc = "Field `ACTIVE_THRESHOLD` writer - The uart is activated from light sleeping mode when the input rxd edge changes more times than this register value."]
8pub type ACTIVE_THRESHOLD_W<'a, REG> = crate::FieldWriter<'a, REG, 10, u16>;
9#[doc = "Field `RX_WAKE_UP_THRHD` reader - In wake up mode 1 this field is used to set the received data number threshold to wake up chip."]
10pub type RX_WAKE_UP_THRHD_R = crate::FieldReader;
11#[doc = "Field `RX_WAKE_UP_THRHD` writer - In wake up mode 1 this field is used to set the received data number threshold to wake up chip."]
12pub type RX_WAKE_UP_THRHD_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
13#[doc = "Field `WK_CHAR_NUM` reader - This register is used to select number of wake up char."]
14pub type WK_CHAR_NUM_R = crate::FieldReader;
15#[doc = "Field `WK_CHAR_NUM` writer - This register is used to select number of wake up char."]
16pub type WK_CHAR_NUM_W<'a, REG> = crate::FieldWriter<'a, REG, 3>;
17#[doc = "Field `WK_CHAR_MASK` reader - This register is used to mask wake up char."]
18pub type WK_CHAR_MASK_R = crate::FieldReader;
19#[doc = "Field `WK_CHAR_MASK` writer - This register is used to mask wake up char."]
20pub type WK_CHAR_MASK_W<'a, REG> = crate::FieldWriter<'a, REG, 5>;
21#[doc = "Field `WK_MODE_SEL` reader - This register is used to select wake up mode. 0: RXD toggling to wake up. 1: received data number larger than"]
22pub type WK_MODE_SEL_R = crate::FieldReader;
23#[doc = "Field `WK_MODE_SEL` writer - This register is used to select wake up mode. 0: RXD toggling to wake up. 1: received data number larger than"]
24pub type WK_MODE_SEL_W<'a, REG> = crate::FieldWriter<'a, REG, 2>;
25impl R {
26    #[doc = "Bits 0:9 - The uart is activated from light sleeping mode when the input rxd edge changes more times than this register value."]
27    #[inline(always)]
28    pub fn active_threshold(&self) -> ACTIVE_THRESHOLD_R {
29        ACTIVE_THRESHOLD_R::new((self.bits & 0x03ff) as u16)
30    }
31    #[doc = "Bits 10:17 - In wake up mode 1 this field is used to set the received data number threshold to wake up chip."]
32    #[inline(always)]
33    pub fn rx_wake_up_thrhd(&self) -> RX_WAKE_UP_THRHD_R {
34        RX_WAKE_UP_THRHD_R::new(((self.bits >> 10) & 0xff) as u8)
35    }
36    #[doc = "Bits 18:20 - This register is used to select number of wake up char."]
37    #[inline(always)]
38    pub fn wk_char_num(&self) -> WK_CHAR_NUM_R {
39        WK_CHAR_NUM_R::new(((self.bits >> 18) & 7) as u8)
40    }
41    #[doc = "Bits 21:25 - This register is used to mask wake up char."]
42    #[inline(always)]
43    pub fn wk_char_mask(&self) -> WK_CHAR_MASK_R {
44        WK_CHAR_MASK_R::new(((self.bits >> 21) & 0x1f) as u8)
45    }
46    #[doc = "Bits 26:27 - This register is used to select wake up mode. 0: RXD toggling to wake up. 1: received data number larger than"]
47    #[inline(always)]
48    pub fn wk_mode_sel(&self) -> WK_MODE_SEL_R {
49        WK_MODE_SEL_R::new(((self.bits >> 26) & 3) as u8)
50    }
51}
52#[cfg(feature = "impl-register-debug")]
53impl core::fmt::Debug for R {
54    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
55        f.debug_struct("SLEEP_CONF2")
56            .field(
57                "active_threshold",
58                &format_args!("{}", self.active_threshold().bits()),
59            )
60            .field(
61                "rx_wake_up_thrhd",
62                &format_args!("{}", self.rx_wake_up_thrhd().bits()),
63            )
64            .field(
65                "wk_char_num",
66                &format_args!("{}", self.wk_char_num().bits()),
67            )
68            .field(
69                "wk_char_mask",
70                &format_args!("{}", self.wk_char_mask().bits()),
71            )
72            .field(
73                "wk_mode_sel",
74                &format_args!("{}", self.wk_mode_sel().bits()),
75            )
76            .finish()
77    }
78}
79#[cfg(feature = "impl-register-debug")]
80impl core::fmt::Debug for crate::generic::Reg<SLEEP_CONF2_SPEC> {
81    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
82        core::fmt::Debug::fmt(&self.read(), f)
83    }
84}
85impl W {
86    #[doc = "Bits 0:9 - The uart is activated from light sleeping mode when the input rxd edge changes more times than this register value."]
87    #[inline(always)]
88    #[must_use]
89    pub fn active_threshold(&mut self) -> ACTIVE_THRESHOLD_W<SLEEP_CONF2_SPEC> {
90        ACTIVE_THRESHOLD_W::new(self, 0)
91    }
92    #[doc = "Bits 10:17 - In wake up mode 1 this field is used to set the received data number threshold to wake up chip."]
93    #[inline(always)]
94    #[must_use]
95    pub fn rx_wake_up_thrhd(&mut self) -> RX_WAKE_UP_THRHD_W<SLEEP_CONF2_SPEC> {
96        RX_WAKE_UP_THRHD_W::new(self, 10)
97    }
98    #[doc = "Bits 18:20 - This register is used to select number of wake up char."]
99    #[inline(always)]
100    #[must_use]
101    pub fn wk_char_num(&mut self) -> WK_CHAR_NUM_W<SLEEP_CONF2_SPEC> {
102        WK_CHAR_NUM_W::new(self, 18)
103    }
104    #[doc = "Bits 21:25 - This register is used to mask wake up char."]
105    #[inline(always)]
106    #[must_use]
107    pub fn wk_char_mask(&mut self) -> WK_CHAR_MASK_W<SLEEP_CONF2_SPEC> {
108        WK_CHAR_MASK_W::new(self, 21)
109    }
110    #[doc = "Bits 26:27 - This register is used to select wake up mode. 0: RXD toggling to wake up. 1: received data number larger than"]
111    #[inline(always)]
112    #[must_use]
113    pub fn wk_mode_sel(&mut self) -> WK_MODE_SEL_W<SLEEP_CONF2_SPEC> {
114        WK_MODE_SEL_W::new(self, 26)
115    }
116}
117#[doc = "UART sleep configure register 2\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`sleep_conf2::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 [`sleep_conf2::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
118pub struct SLEEP_CONF2_SPEC;
119impl crate::RegisterSpec for SLEEP_CONF2_SPEC {
120    type Ux = u32;
121}
122#[doc = "`read()` method returns [`sleep_conf2::R`](R) reader structure"]
123impl crate::Readable for SLEEP_CONF2_SPEC {}
124#[doc = "`write(|w| ..)` method takes [`sleep_conf2::W`](W) writer structure"]
125impl crate::Writable for SLEEP_CONF2_SPEC {
126    type Safety = crate::Unsafe;
127    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
128    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
129}
130#[doc = "`reset()` method sets SLEEP_CONF2 to value 0x0014_04f0"]
131impl crate::Resettable for SLEEP_CONF2_SPEC {
132    const RESET_VALUE: u32 = 0x0014_04f0;
133}