esp32p4/lp_adc/
meas2_ctrl2.rs

1#[doc = "Register `MEAS2_CTRL2` reader"]
2pub type R = crate::R<MEAS2_CTRL2_SPEC>;
3#[doc = "Register `MEAS2_CTRL2` writer"]
4pub type W = crate::W<MEAS2_CTRL2_SPEC>;
5#[doc = "Field `MEAS2_DATA_SAR` reader - SAR ADC2 data."]
6pub type MEAS2_DATA_SAR_R = crate::FieldReader<u16>;
7#[doc = "Field `MEAS2_DONE_SAR` reader - SAR ADC2 conversion done indication."]
8pub type MEAS2_DONE_SAR_R = crate::BitReader;
9#[doc = "Field `MEAS2_START_SAR` reader - SAR ADC2 controller (in RTC) starts conversion."]
10pub type MEAS2_START_SAR_R = crate::BitReader;
11#[doc = "Field `MEAS2_START_SAR` writer - SAR ADC2 controller (in RTC) starts conversion."]
12pub type MEAS2_START_SAR_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `MEAS2_START_FORCE` reader - 1: SAR ADC2 controller (in RTC) is started by SW."]
14pub type MEAS2_START_FORCE_R = crate::BitReader;
15#[doc = "Field `MEAS2_START_FORCE` writer - 1: SAR ADC2 controller (in RTC) is started by SW."]
16pub type MEAS2_START_FORCE_W<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `SAR2_EN_PAD` reader - SAR ADC2 pad enable bitmap."]
18pub type SAR2_EN_PAD_R = crate::FieldReader<u16>;
19#[doc = "Field `SAR2_EN_PAD` writer - SAR ADC2 pad enable bitmap."]
20pub type SAR2_EN_PAD_W<'a, REG> = crate::FieldWriter<'a, REG, 12, u16>;
21#[doc = "Field `SAR2_EN_PAD_FORCE` reader - 1: SAR ADC2 pad enable bitmap is controlled by SW."]
22pub type SAR2_EN_PAD_FORCE_R = crate::BitReader;
23#[doc = "Field `SAR2_EN_PAD_FORCE` writer - 1: SAR ADC2 pad enable bitmap is controlled by SW."]
24pub type SAR2_EN_PAD_FORCE_W<'a, REG> = crate::BitWriter<'a, REG>;
25impl R {
26    #[doc = "Bits 0:15 - SAR ADC2 data."]
27    #[inline(always)]
28    pub fn meas2_data_sar(&self) -> MEAS2_DATA_SAR_R {
29        MEAS2_DATA_SAR_R::new((self.bits & 0xffff) as u16)
30    }
31    #[doc = "Bit 16 - SAR ADC2 conversion done indication."]
32    #[inline(always)]
33    pub fn meas2_done_sar(&self) -> MEAS2_DONE_SAR_R {
34        MEAS2_DONE_SAR_R::new(((self.bits >> 16) & 1) != 0)
35    }
36    #[doc = "Bit 17 - SAR ADC2 controller (in RTC) starts conversion."]
37    #[inline(always)]
38    pub fn meas2_start_sar(&self) -> MEAS2_START_SAR_R {
39        MEAS2_START_SAR_R::new(((self.bits >> 17) & 1) != 0)
40    }
41    #[doc = "Bit 18 - 1: SAR ADC2 controller (in RTC) is started by SW."]
42    #[inline(always)]
43    pub fn meas2_start_force(&self) -> MEAS2_START_FORCE_R {
44        MEAS2_START_FORCE_R::new(((self.bits >> 18) & 1) != 0)
45    }
46    #[doc = "Bits 19:30 - SAR ADC2 pad enable bitmap."]
47    #[inline(always)]
48    pub fn sar2_en_pad(&self) -> SAR2_EN_PAD_R {
49        SAR2_EN_PAD_R::new(((self.bits >> 19) & 0x0fff) as u16)
50    }
51    #[doc = "Bit 31 - 1: SAR ADC2 pad enable bitmap is controlled by SW."]
52    #[inline(always)]
53    pub fn sar2_en_pad_force(&self) -> SAR2_EN_PAD_FORCE_R {
54        SAR2_EN_PAD_FORCE_R::new(((self.bits >> 31) & 1) != 0)
55    }
56}
57#[cfg(feature = "impl-register-debug")]
58impl core::fmt::Debug for R {
59    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
60        f.debug_struct("MEAS2_CTRL2")
61            .field(
62                "meas2_data_sar",
63                &format_args!("{}", self.meas2_data_sar().bits()),
64            )
65            .field(
66                "meas2_done_sar",
67                &format_args!("{}", self.meas2_done_sar().bit()),
68            )
69            .field(
70                "meas2_start_sar",
71                &format_args!("{}", self.meas2_start_sar().bit()),
72            )
73            .field(
74                "meas2_start_force",
75                &format_args!("{}", self.meas2_start_force().bit()),
76            )
77            .field(
78                "sar2_en_pad",
79                &format_args!("{}", self.sar2_en_pad().bits()),
80            )
81            .field(
82                "sar2_en_pad_force",
83                &format_args!("{}", self.sar2_en_pad_force().bit()),
84            )
85            .finish()
86    }
87}
88#[cfg(feature = "impl-register-debug")]
89impl core::fmt::Debug for crate::generic::Reg<MEAS2_CTRL2_SPEC> {
90    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
91        core::fmt::Debug::fmt(&self.read(), f)
92    }
93}
94impl W {
95    #[doc = "Bit 17 - SAR ADC2 controller (in RTC) starts conversion."]
96    #[inline(always)]
97    #[must_use]
98    pub fn meas2_start_sar(&mut self) -> MEAS2_START_SAR_W<MEAS2_CTRL2_SPEC> {
99        MEAS2_START_SAR_W::new(self, 17)
100    }
101    #[doc = "Bit 18 - 1: SAR ADC2 controller (in RTC) is started by SW."]
102    #[inline(always)]
103    #[must_use]
104    pub fn meas2_start_force(&mut self) -> MEAS2_START_FORCE_W<MEAS2_CTRL2_SPEC> {
105        MEAS2_START_FORCE_W::new(self, 18)
106    }
107    #[doc = "Bits 19:30 - SAR ADC2 pad enable bitmap."]
108    #[inline(always)]
109    #[must_use]
110    pub fn sar2_en_pad(&mut self) -> SAR2_EN_PAD_W<MEAS2_CTRL2_SPEC> {
111        SAR2_EN_PAD_W::new(self, 19)
112    }
113    #[doc = "Bit 31 - 1: SAR ADC2 pad enable bitmap is controlled by SW."]
114    #[inline(always)]
115    #[must_use]
116    pub fn sar2_en_pad_force(&mut self) -> SAR2_EN_PAD_FORCE_W<MEAS2_CTRL2_SPEC> {
117        SAR2_EN_PAD_FORCE_W::new(self, 31)
118    }
119}
120#[doc = "ADC2 configuration registers.\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`meas2_ctrl2::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 [`meas2_ctrl2::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
121pub struct MEAS2_CTRL2_SPEC;
122impl crate::RegisterSpec for MEAS2_CTRL2_SPEC {
123    type Ux = u32;
124}
125#[doc = "`read()` method returns [`meas2_ctrl2::R`](R) reader structure"]
126impl crate::Readable for MEAS2_CTRL2_SPEC {}
127#[doc = "`write(|w| ..)` method takes [`meas2_ctrl2::W`](W) writer structure"]
128impl crate::Writable for MEAS2_CTRL2_SPEC {
129    type Safety = crate::Unsafe;
130    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
131    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
132}
133#[doc = "`reset()` method sets MEAS2_CTRL2 to value 0"]
134impl crate::Resettable for MEAS2_CTRL2_SPEC {
135    const RESET_VALUE: u32 = 0;
136}