d1_pac/tpadc/
tp_ctrl2.rs

1#[doc = "Register `tp_ctrl2` reader"]
2pub type R = crate::R<TP_CTRL2_SPEC>;
3#[doc = "Register `tp_ctrl2` writer"]
4pub type W = crate::W<TP_CTRL2_SPEC>;
5#[doc = "Field `pre_mea_thre_cnt` reader - TP Pressure Measurement Threshold Control"]
6pub type PRE_MEA_THRE_CNT_R = crate::FieldReader<u32>;
7#[doc = "Field `pre_mea_thre_cnt` writer - TP Pressure Measurement Threshold Control"]
8pub type PRE_MEA_THRE_CNT_W<'a, REG> = crate::FieldWriter<'a, REG, 24, u32>;
9#[doc = "Field `pre_mea_en` reader - TP Pressure Measurement Enable Control"]
10pub type PRE_MEA_EN_R = crate::BitReader<PRE_MEA_EN_A>;
11#[doc = "TP Pressure Measurement Enable Control\n\nValue on reset: 0"]
12#[derive(Clone, Copy, Debug, PartialEq, Eq)]
13pub enum PRE_MEA_EN_A {
14    #[doc = "0: `0`"]
15    DISABLE = 0,
16    #[doc = "1: `1`"]
17    ENABLE = 1,
18}
19impl From<PRE_MEA_EN_A> for bool {
20    #[inline(always)]
21    fn from(variant: PRE_MEA_EN_A) -> Self {
22        variant as u8 != 0
23    }
24}
25impl PRE_MEA_EN_R {
26    #[doc = "Get enumerated values variant"]
27    #[inline(always)]
28    pub const fn variant(&self) -> PRE_MEA_EN_A {
29        match self.bits {
30            false => PRE_MEA_EN_A::DISABLE,
31            true => PRE_MEA_EN_A::ENABLE,
32        }
33    }
34    #[doc = "`0`"]
35    #[inline(always)]
36    pub fn is_disable(&self) -> bool {
37        *self == PRE_MEA_EN_A::DISABLE
38    }
39    #[doc = "`1`"]
40    #[inline(always)]
41    pub fn is_enable(&self) -> bool {
42        *self == PRE_MEA_EN_A::ENABLE
43    }
44}
45#[doc = "Field `pre_mea_en` writer - TP Pressure Measurement Enable Control"]
46pub type PRE_MEA_EN_W<'a, REG> = crate::BitWriter<'a, REG, PRE_MEA_EN_A>;
47impl<'a, REG> PRE_MEA_EN_W<'a, REG>
48where
49    REG: crate::Writable + crate::RegisterSpec,
50{
51    #[doc = "`0`"]
52    #[inline(always)]
53    pub fn disable(self) -> &'a mut crate::W<REG> {
54        self.variant(PRE_MEA_EN_A::DISABLE)
55    }
56    #[doc = "`1`"]
57    #[inline(always)]
58    pub fn enable(self) -> &'a mut crate::W<REG> {
59        self.variant(PRE_MEA_EN_A::ENABLE)
60    }
61}
62#[doc = "Field `tp_fifo_mode_select` reader - TP Access Data Mode Select"]
63pub type TP_FIFO_MODE_SELECT_R = crate::FieldReader<TP_FIFO_MODE_SELECT_A>;
64#[doc = "TP Access Data Mode Select\n\nValue on reset: 0"]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66#[repr(u8)]
67pub enum TP_FIFO_MODE_SELECT_A {
68    #[doc = "0: FIFO store X1 Y1 data for single touch no pressure mode"]
69    X1Y1 = 0,
70    #[doc = "1: FIFO store X1 Y1 ΔX ΔY data for dual touch no pressure mode"]
71    X1Y1D_XD_Y = 1,
72    #[doc = "2: FIFO store X1 Y1 X2 Y2 data for dual touch no pressure mode"]
73    X1Y1X2Y2 = 2,
74    #[doc = "3: FIFO store X1 Y1 X2 Y2 Z1 Z2 data for dual touch and pressure mode"]
75    X1Y1X2Y2Z1Z2 = 3,
76}
77impl From<TP_FIFO_MODE_SELECT_A> for u8 {
78    #[inline(always)]
79    fn from(variant: TP_FIFO_MODE_SELECT_A) -> Self {
80        variant as _
81    }
82}
83impl crate::FieldSpec for TP_FIFO_MODE_SELECT_A {
84    type Ux = u8;
85}
86impl TP_FIFO_MODE_SELECT_R {
87    #[doc = "Get enumerated values variant"]
88    #[inline(always)]
89    pub const fn variant(&self) -> TP_FIFO_MODE_SELECT_A {
90        match self.bits {
91            0 => TP_FIFO_MODE_SELECT_A::X1Y1,
92            1 => TP_FIFO_MODE_SELECT_A::X1Y1D_XD_Y,
93            2 => TP_FIFO_MODE_SELECT_A::X1Y1X2Y2,
94            3 => TP_FIFO_MODE_SELECT_A::X1Y1X2Y2Z1Z2,
95            _ => unreachable!(),
96        }
97    }
98    #[doc = "FIFO store X1 Y1 data for single touch no pressure mode"]
99    #[inline(always)]
100    pub fn is_x1y1(&self) -> bool {
101        *self == TP_FIFO_MODE_SELECT_A::X1Y1
102    }
103    #[doc = "FIFO store X1 Y1 ΔX ΔY data for dual touch no pressure mode"]
104    #[inline(always)]
105    pub fn is_x1y1d_xd_y(&self) -> bool {
106        *self == TP_FIFO_MODE_SELECT_A::X1Y1D_XD_Y
107    }
108    #[doc = "FIFO store X1 Y1 X2 Y2 data for dual touch no pressure mode"]
109    #[inline(always)]
110    pub fn is_x1y1x2y2(&self) -> bool {
111        *self == TP_FIFO_MODE_SELECT_A::X1Y1X2Y2
112    }
113    #[doc = "FIFO store X1 Y1 X2 Y2 Z1 Z2 data for dual touch and pressure mode"]
114    #[inline(always)]
115    pub fn is_x1y1x2y2z1z2(&self) -> bool {
116        *self == TP_FIFO_MODE_SELECT_A::X1Y1X2Y2Z1Z2
117    }
118}
119#[doc = "Field `tp_fifo_mode_select` writer - TP Access Data Mode Select"]
120pub type TP_FIFO_MODE_SELECT_W<'a, REG> = crate::FieldWriterSafe<'a, REG, 2, TP_FIFO_MODE_SELECT_A>;
121impl<'a, REG> TP_FIFO_MODE_SELECT_W<'a, REG>
122where
123    REG: crate::Writable + crate::RegisterSpec,
124    REG::Ux: From<u8>,
125{
126    #[doc = "FIFO store X1 Y1 data for single touch no pressure mode"]
127    #[inline(always)]
128    pub fn x1y1(self) -> &'a mut crate::W<REG> {
129        self.variant(TP_FIFO_MODE_SELECT_A::X1Y1)
130    }
131    #[doc = "FIFO store X1 Y1 ΔX ΔY data for dual touch no pressure mode"]
132    #[inline(always)]
133    pub fn x1y1d_xd_y(self) -> &'a mut crate::W<REG> {
134        self.variant(TP_FIFO_MODE_SELECT_A::X1Y1D_XD_Y)
135    }
136    #[doc = "FIFO store X1 Y1 X2 Y2 data for dual touch no pressure mode"]
137    #[inline(always)]
138    pub fn x1y1x2y2(self) -> &'a mut crate::W<REG> {
139        self.variant(TP_FIFO_MODE_SELECT_A::X1Y1X2Y2)
140    }
141    #[doc = "FIFO store X1 Y1 X2 Y2 Z1 Z2 data for dual touch and pressure mode"]
142    #[inline(always)]
143    pub fn x1y1x2y2z1z2(self) -> &'a mut crate::W<REG> {
144        self.variant(TP_FIFO_MODE_SELECT_A::X1Y1X2Y2Z1Z2)
145    }
146}
147#[doc = "Field `tp_sensitive_adjust` reader - Internal Pull-up Resistor Control"]
148pub type TP_SENSITIVE_ADJUST_R = crate::FieldReader;
149#[doc = "Field `tp_sensitive_adjust` writer - Internal Pull-up Resistor Control"]
150pub type TP_SENSITIVE_ADJUST_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
151impl R {
152    #[doc = "Bits 0:23 - TP Pressure Measurement Threshold Control"]
153    #[inline(always)]
154    pub fn pre_mea_thre_cnt(&self) -> PRE_MEA_THRE_CNT_R {
155        PRE_MEA_THRE_CNT_R::new(self.bits & 0x00ff_ffff)
156    }
157    #[doc = "Bit 24 - TP Pressure Measurement Enable Control"]
158    #[inline(always)]
159    pub fn pre_mea_en(&self) -> PRE_MEA_EN_R {
160        PRE_MEA_EN_R::new(((self.bits >> 24) & 1) != 0)
161    }
162    #[doc = "Bits 26:27 - TP Access Data Mode Select"]
163    #[inline(always)]
164    pub fn tp_fifo_mode_select(&self) -> TP_FIFO_MODE_SELECT_R {
165        TP_FIFO_MODE_SELECT_R::new(((self.bits >> 26) & 3) as u8)
166    }
167    #[doc = "Bits 28:31 - Internal Pull-up Resistor Control"]
168    #[inline(always)]
169    pub fn tp_sensitive_adjust(&self) -> TP_SENSITIVE_ADJUST_R {
170        TP_SENSITIVE_ADJUST_R::new(((self.bits >> 28) & 0x0f) as u8)
171    }
172}
173impl W {
174    #[doc = "Bits 0:23 - TP Pressure Measurement Threshold Control"]
175    #[inline(always)]
176    #[must_use]
177    pub fn pre_mea_thre_cnt(&mut self) -> PRE_MEA_THRE_CNT_W<TP_CTRL2_SPEC> {
178        PRE_MEA_THRE_CNT_W::new(self, 0)
179    }
180    #[doc = "Bit 24 - TP Pressure Measurement Enable Control"]
181    #[inline(always)]
182    #[must_use]
183    pub fn pre_mea_en(&mut self) -> PRE_MEA_EN_W<TP_CTRL2_SPEC> {
184        PRE_MEA_EN_W::new(self, 24)
185    }
186    #[doc = "Bits 26:27 - TP Access Data Mode Select"]
187    #[inline(always)]
188    #[must_use]
189    pub fn tp_fifo_mode_select(&mut self) -> TP_FIFO_MODE_SELECT_W<TP_CTRL2_SPEC> {
190        TP_FIFO_MODE_SELECT_W::new(self, 26)
191    }
192    #[doc = "Bits 28:31 - Internal Pull-up Resistor Control"]
193    #[inline(always)]
194    #[must_use]
195    pub fn tp_sensitive_adjust(&mut self) -> TP_SENSITIVE_ADJUST_W<TP_CTRL2_SPEC> {
196        TP_SENSITIVE_ADJUST_W::new(self, 28)
197    }
198    #[doc = r" Writes raw bits to the register."]
199    #[doc = r""]
200    #[doc = r" # Safety"]
201    #[doc = r""]
202    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
203    #[inline(always)]
204    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
205        self.bits = bits;
206        self
207    }
208}
209#[doc = "TP Control Register 2\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`tp_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 [`tp_ctrl2::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
210pub struct TP_CTRL2_SPEC;
211impl crate::RegisterSpec for TP_CTRL2_SPEC {
212    type Ux = u32;
213}
214#[doc = "`read()` method returns [`tp_ctrl2::R`](R) reader structure"]
215impl crate::Readable for TP_CTRL2_SPEC {}
216#[doc = "`write(|w| ..)` method takes [`tp_ctrl2::W`](W) writer structure"]
217impl crate::Writable for TP_CTRL2_SPEC {
218    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
219    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
220}
221#[doc = "`reset()` method sets tp_ctrl2 to value 0"]
222impl crate::Resettable for TP_CTRL2_SPEC {
223    const RESET_VALUE: Self::Ux = 0;
224}