esp32p4/lp_i2c0/
filter_cfg.rs1#[doc = "Register `FILTER_CFG` reader"]
2pub type R = crate::R<FILTER_CFG_SPEC>;
3#[doc = "Register `FILTER_CFG` writer"]
4pub type W = crate::W<FILTER_CFG_SPEC>;
5#[doc = "Field `SCL_FILTER_THRES` reader - Configures the threshold pulse width to be filtered on SCL. When a pulse on the SCL input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
6pub type SCL_FILTER_THRES_R = crate::FieldReader;
7#[doc = "Field `SCL_FILTER_THRES` writer - Configures the threshold pulse width to be filtered on SCL. When a pulse on the SCL input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
8pub type SCL_FILTER_THRES_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
9#[doc = "Field `SDA_FILTER_THRES` reader - Configures the threshold pulse width to be filtered on SDA. When a pulse on the SDA input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
10pub type SDA_FILTER_THRES_R = crate::FieldReader;
11#[doc = "Field `SDA_FILTER_THRES` writer - Configures the threshold pulse width to be filtered on SDA. When a pulse on the SDA input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
12pub type SDA_FILTER_THRES_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
13#[doc = "Field `SCL_FILTER_EN` reader - Configures to enable the filter function for SCL."]
14pub type SCL_FILTER_EN_R = crate::BitReader;
15#[doc = "Field `SCL_FILTER_EN` writer - Configures to enable the filter function for SCL."]
16pub type SCL_FILTER_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `SDA_FILTER_EN` reader - Configures to enable the filter function for SDA."]
18pub type SDA_FILTER_EN_R = crate::BitReader;
19#[doc = "Field `SDA_FILTER_EN` writer - Configures to enable the filter function for SDA."]
20pub type SDA_FILTER_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
21impl R {
22 #[doc = "Bits 0:3 - Configures the threshold pulse width to be filtered on SCL. When a pulse on the SCL input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
23 #[inline(always)]
24 pub fn scl_filter_thres(&self) -> SCL_FILTER_THRES_R {
25 SCL_FILTER_THRES_R::new((self.bits & 0x0f) as u8)
26 }
27 #[doc = "Bits 4:7 - Configures the threshold pulse width to be filtered on SDA. When a pulse on the SDA input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
28 #[inline(always)]
29 pub fn sda_filter_thres(&self) -> SDA_FILTER_THRES_R {
30 SDA_FILTER_THRES_R::new(((self.bits >> 4) & 0x0f) as u8)
31 }
32 #[doc = "Bit 8 - Configures to enable the filter function for SCL."]
33 #[inline(always)]
34 pub fn scl_filter_en(&self) -> SCL_FILTER_EN_R {
35 SCL_FILTER_EN_R::new(((self.bits >> 8) & 1) != 0)
36 }
37 #[doc = "Bit 9 - Configures to enable the filter function for SDA."]
38 #[inline(always)]
39 pub fn sda_filter_en(&self) -> SDA_FILTER_EN_R {
40 SDA_FILTER_EN_R::new(((self.bits >> 9) & 1) != 0)
41 }
42}
43#[cfg(feature = "impl-register-debug")]
44impl core::fmt::Debug for R {
45 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
46 f.debug_struct("FILTER_CFG")
47 .field(
48 "scl_filter_thres",
49 &format_args!("{}", self.scl_filter_thres().bits()),
50 )
51 .field(
52 "sda_filter_thres",
53 &format_args!("{}", self.sda_filter_thres().bits()),
54 )
55 .field(
56 "scl_filter_en",
57 &format_args!("{}", self.scl_filter_en().bit()),
58 )
59 .field(
60 "sda_filter_en",
61 &format_args!("{}", self.sda_filter_en().bit()),
62 )
63 .finish()
64 }
65}
66#[cfg(feature = "impl-register-debug")]
67impl core::fmt::Debug for crate::generic::Reg<FILTER_CFG_SPEC> {
68 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69 core::fmt::Debug::fmt(&self.read(), f)
70 }
71}
72impl W {
73 #[doc = "Bits 0:3 - Configures the threshold pulse width to be filtered on SCL. When a pulse on the SCL input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
74 #[inline(always)]
75 #[must_use]
76 pub fn scl_filter_thres(&mut self) -> SCL_FILTER_THRES_W<FILTER_CFG_SPEC> {
77 SCL_FILTER_THRES_W::new(self, 0)
78 }
79 #[doc = "Bits 4:7 - Configures the threshold pulse width to be filtered on SDA. When a pulse on the SDA input has smaller width than this register value, the I2C controller will ignore that pulse. Measurement unit: i2c_sclk"]
80 #[inline(always)]
81 #[must_use]
82 pub fn sda_filter_thres(&mut self) -> SDA_FILTER_THRES_W<FILTER_CFG_SPEC> {
83 SDA_FILTER_THRES_W::new(self, 4)
84 }
85 #[doc = "Bit 8 - Configures to enable the filter function for SCL."]
86 #[inline(always)]
87 #[must_use]
88 pub fn scl_filter_en(&mut self) -> SCL_FILTER_EN_W<FILTER_CFG_SPEC> {
89 SCL_FILTER_EN_W::new(self, 8)
90 }
91 #[doc = "Bit 9 - Configures to enable the filter function for SDA."]
92 #[inline(always)]
93 #[must_use]
94 pub fn sda_filter_en(&mut self) -> SDA_FILTER_EN_W<FILTER_CFG_SPEC> {
95 SDA_FILTER_EN_W::new(self, 9)
96 }
97}
98#[doc = "SCL and SDA filter configuration register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`filter_cfg::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 [`filter_cfg::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
99pub struct FILTER_CFG_SPEC;
100impl crate::RegisterSpec for FILTER_CFG_SPEC {
101 type Ux = u32;
102}
103#[doc = "`read()` method returns [`filter_cfg::R`](R) reader structure"]
104impl crate::Readable for FILTER_CFG_SPEC {}
105#[doc = "`write(|w| ..)` method takes [`filter_cfg::W`](W) writer structure"]
106impl crate::Writable for FILTER_CFG_SPEC {
107 type Safety = crate::Unsafe;
108 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
109 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
110}
111#[doc = "`reset()` method sets FILTER_CFG to value 0x0300"]
112impl crate::Resettable for FILTER_CFG_SPEC {
113 const RESET_VALUE: u32 = 0x0300;
114}