From 0991b1a8c8f1d26e8a969360601fbe729c39a3c7 Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Tue, 28 Nov 2023 19:53:49 +0000 Subject: [PATCH 01/11] Initial impl for raw reads --- src/lib.rs | 2 ++ src/touch.rs | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 src/touch.rs diff --git a/src/lib.rs b/src/lib.rs index 3b3b69d5285..bdc70f16516 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,6 +82,8 @@ pub mod task; #[cfg(not(feature = "riscv-ulp-hal"))] pub mod timer; #[cfg(not(feature = "riscv-ulp-hal"))] +pub mod touch; +#[cfg(not(feature = "riscv-ulp-hal"))] pub mod uart; #[cfg(all( any(esp32, esp32s2, esp32s3, esp32c6, esp32p4), diff --git a/src/touch.rs b/src/touch.rs new file mode 100644 index 00000000000..068e087029d --- /dev/null +++ b/src/touch.rs @@ -0,0 +1,96 @@ +use esp_idf_sys::{ + esp, touch_fsm_mode_t, touch_fsm_mode_t_TOUCH_FSM_MODE_MAX, touch_fsm_mode_t_TOUCH_FSM_MODE_SW, + touch_fsm_mode_t_TOUCH_FSM_MODE_TIMER, touch_pad_config, touch_pad_fsm_start, touch_pad_init, + touch_pad_read_raw_data, touch_pad_set_fsm_mode, touch_pad_t, touch_pad_t_TOUCH_PAD_NUM0, + touch_pad_t_TOUCH_PAD_NUM1, touch_pad_t_TOUCH_PAD_NUM10, touch_pad_t_TOUCH_PAD_NUM11, + touch_pad_t_TOUCH_PAD_NUM12, touch_pad_t_TOUCH_PAD_NUM13, touch_pad_t_TOUCH_PAD_NUM14, + touch_pad_t_TOUCH_PAD_NUM2, touch_pad_t_TOUCH_PAD_NUM3, touch_pad_t_TOUCH_PAD_NUM4, + touch_pad_t_TOUCH_PAD_NUM5, touch_pad_t_TOUCH_PAD_NUM6, touch_pad_t_TOUCH_PAD_NUM7, + touch_pad_t_TOUCH_PAD_NUM8, touch_pad_t_TOUCH_PAD_NUM9, EspError, +}; + +pub enum FsmMode { + Timer, + SW, + Max, +} + +impl From for touch_fsm_mode_t { + fn from(value: FsmMode) -> Self { + match value { + FsmMode::Timer => touch_fsm_mode_t_TOUCH_FSM_MODE_TIMER, + FsmMode::SW => touch_fsm_mode_t_TOUCH_FSM_MODE_SW, + FsmMode::Max => touch_fsm_mode_t_TOUCH_FSM_MODE_MAX, + } + } +} + +pub enum TouchPad { + Pad0, + Pad1, + Pad2, + Pad3, + Pad4, + Pad5, + Pad6, + Pad7, + Pad8, + Pad9, + Pad10, + Pad11, + Pad12, + Pad13, + Pad14, +} + +impl From for touch_pad_t { + fn from(value: TouchPad) -> Self { + match value { + TouchPad::Pad0 => touch_pad_t_TOUCH_PAD_NUM0, + TouchPad::Pad1 => touch_pad_t_TOUCH_PAD_NUM1, + TouchPad::Pad2 => touch_pad_t_TOUCH_PAD_NUM2, + TouchPad::Pad3 => touch_pad_t_TOUCH_PAD_NUM3, + TouchPad::Pad4 => touch_pad_t_TOUCH_PAD_NUM4, + TouchPad::Pad5 => touch_pad_t_TOUCH_PAD_NUM5, + TouchPad::Pad6 => touch_pad_t_TOUCH_PAD_NUM6, + TouchPad::Pad7 => touch_pad_t_TOUCH_PAD_NUM7, + TouchPad::Pad8 => touch_pad_t_TOUCH_PAD_NUM8, + TouchPad::Pad9 => touch_pad_t_TOUCH_PAD_NUM9, + TouchPad::Pad10 => touch_pad_t_TOUCH_PAD_NUM10, + TouchPad::Pad11 => touch_pad_t_TOUCH_PAD_NUM11, + TouchPad::Pad12 => touch_pad_t_TOUCH_PAD_NUM12, + TouchPad::Pad13 => touch_pad_t_TOUCH_PAD_NUM13, + TouchPad::Pad14 => touch_pad_t_TOUCH_PAD_NUM14, + } + } +} + +pub struct TouchDriver {} + +impl TouchDriver { + pub fn new() -> Result { + Ok(TouchDriver {}) + } + + pub fn init(&mut self) -> Result<(), EspError> { + esp!(unsafe { touch_pad_init() }) + } + + pub fn config(&mut self, pad: TouchPad) -> Result<(), EspError> { + esp!(unsafe { touch_pad_config(pad.into()) }) + } + + pub fn set_fsm_mode(&mut self, mode: FsmMode) -> Result<(), EspError> { + esp!(unsafe { touch_pad_set_fsm_mode(mode.into()) }) + } + + pub fn start_fsm(&mut self) -> Result<(), EspError> { + esp!(unsafe { touch_pad_fsm_start() }) + } + + pub fn read_raw_data(&mut self, pad: TouchPad) -> Result { + let mut raw: u32 = 0; + let result = esp!(unsafe { touch_pad_read_raw_data(pad.into(), &mut raw) }); + result.map(|_| raw) + } +} From cba54d1aa70e956ebcebca4937db79e69211516e Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Tue, 28 Nov 2023 20:03:34 +0000 Subject: [PATCH 02/11] Only enable on relevant controllers --- src/touch.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/touch.rs b/src/touch.rs index 068e087029d..89aaeabdb4e 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -9,12 +9,14 @@ use esp_idf_sys::{ touch_pad_t_TOUCH_PAD_NUM8, touch_pad_t_TOUCH_PAD_NUM9, EspError, }; +#[cfg(any(esp32, esp32s2, esp32s3))] pub enum FsmMode { Timer, SW, Max, } +#[cfg(any(esp32, esp32s2, esp32s3))] impl From for touch_fsm_mode_t { fn from(value: FsmMode) -> Self { match value { @@ -25,6 +27,7 @@ impl From for touch_fsm_mode_t { } } +#[cfg(any(esp32, esp32s2, esp32s3))] pub enum TouchPad { Pad0, Pad1, @@ -43,6 +46,7 @@ pub enum TouchPad { Pad14, } +#[cfg(any(esp32, esp32s2, esp32s3))] impl From for touch_pad_t { fn from(value: TouchPad) -> Self { match value { @@ -65,8 +69,10 @@ impl From for touch_pad_t { } } +#[cfg(any(esp32, esp32s2, esp32s3))] pub struct TouchDriver {} +#[cfg(any(esp32, esp32s2, esp32s3))] impl TouchDriver { pub fn new() -> Result { Ok(TouchDriver {}) From 6c61beef855a2fa7d3cdbaeeda8b129ed12f24f7 Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Tue, 28 Nov 2023 20:34:16 +0000 Subject: [PATCH 03/11] Gate module on correct controllers --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index bdc70f16516..4ca364f741f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,7 +81,7 @@ pub mod sys; pub mod task; #[cfg(not(feature = "riscv-ulp-hal"))] pub mod timer; -#[cfg(not(feature = "riscv-ulp-hal"))] +#[cfg(all(any(esp32, esp32s2, esp32s3), not(feature = "riscv-ulp-hal")))] pub mod touch; #[cfg(not(feature = "riscv-ulp-hal"))] pub mod uart; From 5d988a3e54ff1d8d72d7e5a840fbe81967db4f9b Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Tue, 28 Nov 2023 20:44:58 +0000 Subject: [PATCH 04/11] consolidate initialisation --- src/touch.rs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/touch.rs b/src/touch.rs index 89aaeabdb4e..0d85be6ff95 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -6,7 +6,7 @@ use esp_idf_sys::{ touch_pad_t_TOUCH_PAD_NUM12, touch_pad_t_TOUCH_PAD_NUM13, touch_pad_t_TOUCH_PAD_NUM14, touch_pad_t_TOUCH_PAD_NUM2, touch_pad_t_TOUCH_PAD_NUM3, touch_pad_t_TOUCH_PAD_NUM4, touch_pad_t_TOUCH_PAD_NUM5, touch_pad_t_TOUCH_PAD_NUM6, touch_pad_t_TOUCH_PAD_NUM7, - touch_pad_t_TOUCH_PAD_NUM8, touch_pad_t_TOUCH_PAD_NUM9, EspError, + touch_pad_t_TOUCH_PAD_NUM8, touch_pad_t_TOUCH_PAD_NUM9, EspError, CONFIG_CONSOLE_UART, }; #[cfg(any(esp32, esp32s2, esp32s3))] @@ -69,29 +69,27 @@ impl From for touch_pad_t { } } +pub struct TouchConfig { + fsm_mode: FsmMode, + configured_pads: Vec, +} + #[cfg(any(esp32, esp32s2, esp32s3))] pub struct TouchDriver {} #[cfg(any(esp32, esp32s2, esp32s3))] impl TouchDriver { - pub fn new() -> Result { - Ok(TouchDriver {}) - } - - pub fn init(&mut self) -> Result<(), EspError> { - esp!(unsafe { touch_pad_init() }) - } - - pub fn config(&mut self, pad: TouchPad) -> Result<(), EspError> { - esp!(unsafe { touch_pad_config(pad.into()) }) - } - - pub fn set_fsm_mode(&mut self, mode: FsmMode) -> Result<(), EspError> { - esp!(unsafe { touch_pad_set_fsm_mode(mode.into()) }) - } + pub fn new(config: TouchConfig) -> Result { + unsafe { + esp!(touch_pad_init())?; + for pad in config.configured_pads { + esp!(touch_pad_config(pad.into()))?; + } + esp!(touch_pad_set_fsm_mode(config.fsm_mode.into()))?; + esp!(touch_pad_fsm_start())?; + } - pub fn start_fsm(&mut self) -> Result<(), EspError> { - esp!(unsafe { touch_pad_fsm_start() }) + Ok(TouchDriver {}) } pub fn read_raw_data(&mut self, pad: TouchPad) -> Result { From 2a5a5e58f43912a2160e933f7fbe608546aecdeb Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Tue, 28 Nov 2023 20:49:38 +0000 Subject: [PATCH 05/11] remove stray import --- src/touch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/touch.rs b/src/touch.rs index 0d85be6ff95..9239c09e385 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -6,7 +6,7 @@ use esp_idf_sys::{ touch_pad_t_TOUCH_PAD_NUM12, touch_pad_t_TOUCH_PAD_NUM13, touch_pad_t_TOUCH_PAD_NUM14, touch_pad_t_TOUCH_PAD_NUM2, touch_pad_t_TOUCH_PAD_NUM3, touch_pad_t_TOUCH_PAD_NUM4, touch_pad_t_TOUCH_PAD_NUM5, touch_pad_t_TOUCH_PAD_NUM6, touch_pad_t_TOUCH_PAD_NUM7, - touch_pad_t_TOUCH_PAD_NUM8, touch_pad_t_TOUCH_PAD_NUM9, EspError, CONFIG_CONSOLE_UART, + touch_pad_t_TOUCH_PAD_NUM8, touch_pad_t_TOUCH_PAD_NUM9, EspError, }; #[cfg(any(esp32, esp32s2, esp32s3))] From 4aea49c5c63e615592116611d90177c404b0e0a8 Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Sat, 2 Dec 2023 19:17:29 +0000 Subject: [PATCH 06/11] refactor to mimic SpiDriver --- src/touch.rs | 55 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/touch.rs b/src/touch.rs index 9239c09e385..ab734965507 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -1,3 +1,5 @@ +use core::borrow::Borrow; + use esp_idf_sys::{ esp, touch_fsm_mode_t, touch_fsm_mode_t_TOUCH_FSM_MODE_MAX, touch_fsm_mode_t_TOUCH_FSM_MODE_SW, touch_fsm_mode_t_TOUCH_FSM_MODE_TIMER, touch_pad_config, touch_pad_fsm_start, touch_pad_init, @@ -10,6 +12,7 @@ use esp_idf_sys::{ }; #[cfg(any(esp32, esp32s2, esp32s3))] +#[derive(Copy, Clone)] pub enum FsmMode { Timer, SW, @@ -28,6 +31,7 @@ impl From for touch_fsm_mode_t { } #[cfg(any(esp32, esp32s2, esp32s3))] +#[derive(Copy, Clone)] pub enum TouchPad { Pad0, Pad1, @@ -71,30 +75,57 @@ impl From for touch_pad_t { pub struct TouchConfig { fsm_mode: FsmMode, - configured_pads: Vec, } #[cfg(any(esp32, esp32s2, esp32s3))] -pub struct TouchDriver {} +pub struct TouchDriver { + config: TouchConfig, +} + +pub struct TouchPadDriver +where + T: Borrow, +{ + touch: T, + pad: TouchPad, +} + +impl TouchPadDriver { + pub fn new_single_started(pad: TouchPad, config: TouchConfig) -> Result { + let mut touch = TouchDriver::new(config)?; + esp!(unsafe { touch_pad_config(pad.into()) })?; + touch.start()?; + Ok(Self { touch, pad }) + } +} + +impl TouchPadDriver +where + T: Borrow, +{ + pub fn read_raw_data(&self) -> Result { + let mut raw: u32 = 0; + let result = esp!(unsafe { touch_pad_read_raw_data(self.borrow().pad.into(), &mut raw) }); + result.map(|_| raw) + } +} #[cfg(any(esp32, esp32s2, esp32s3))] impl TouchDriver { pub fn new(config: TouchConfig) -> Result { unsafe { esp!(touch_pad_init())?; - for pad in config.configured_pads { - esp!(touch_pad_config(pad.into()))?; - } - esp!(touch_pad_set_fsm_mode(config.fsm_mode.into()))?; - esp!(touch_pad_fsm_start())?; } - Ok(TouchDriver {}) + Ok(TouchDriver { config }) } - pub fn read_raw_data(&mut self, pad: TouchPad) -> Result { - let mut raw: u32 = 0; - let result = esp!(unsafe { touch_pad_read_raw_data(pad.into(), &mut raw) }); - result.map(|_| raw) + pub fn start(&mut self) -> Result<(), EspError> { + unsafe { + esp!(touch_pad_set_fsm_mode(self.config.borrow().fsm_mode.into()))?; + esp!(touch_pad_fsm_start())?; + } + + Ok(()) } } From 2625c012bd2205dbf95b61d06361a5e3b6cea06f Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Sun, 3 Dec 2023 10:58:14 +0000 Subject: [PATCH 07/11] Add stop fn --- src/touch.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/touch.rs b/src/touch.rs index ab734965507..88cf0cfa165 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -1,14 +1,15 @@ -use core::borrow::Borrow; +use core::borrow::{Borrow, BorrowMut}; use esp_idf_sys::{ esp, touch_fsm_mode_t, touch_fsm_mode_t_TOUCH_FSM_MODE_MAX, touch_fsm_mode_t_TOUCH_FSM_MODE_SW, - touch_fsm_mode_t_TOUCH_FSM_MODE_TIMER, touch_pad_config, touch_pad_fsm_start, touch_pad_init, - touch_pad_read_raw_data, touch_pad_set_fsm_mode, touch_pad_t, touch_pad_t_TOUCH_PAD_NUM0, - touch_pad_t_TOUCH_PAD_NUM1, touch_pad_t_TOUCH_PAD_NUM10, touch_pad_t_TOUCH_PAD_NUM11, - touch_pad_t_TOUCH_PAD_NUM12, touch_pad_t_TOUCH_PAD_NUM13, touch_pad_t_TOUCH_PAD_NUM14, - touch_pad_t_TOUCH_PAD_NUM2, touch_pad_t_TOUCH_PAD_NUM3, touch_pad_t_TOUCH_PAD_NUM4, - touch_pad_t_TOUCH_PAD_NUM5, touch_pad_t_TOUCH_PAD_NUM6, touch_pad_t_TOUCH_PAD_NUM7, - touch_pad_t_TOUCH_PAD_NUM8, touch_pad_t_TOUCH_PAD_NUM9, EspError, + touch_fsm_mode_t_TOUCH_FSM_MODE_TIMER, touch_pad_config, touch_pad_fsm_start, + touch_pad_fsm_stop, touch_pad_init, touch_pad_read_raw_data, touch_pad_set_fsm_mode, + touch_pad_t, touch_pad_t_TOUCH_PAD_NUM0, touch_pad_t_TOUCH_PAD_NUM1, + touch_pad_t_TOUCH_PAD_NUM10, touch_pad_t_TOUCH_PAD_NUM11, touch_pad_t_TOUCH_PAD_NUM12, + touch_pad_t_TOUCH_PAD_NUM13, touch_pad_t_TOUCH_PAD_NUM14, touch_pad_t_TOUCH_PAD_NUM2, + touch_pad_t_TOUCH_PAD_NUM3, touch_pad_t_TOUCH_PAD_NUM4, touch_pad_t_TOUCH_PAD_NUM5, + touch_pad_t_TOUCH_PAD_NUM6, touch_pad_t_TOUCH_PAD_NUM7, touch_pad_t_TOUCH_PAD_NUM8, + touch_pad_t_TOUCH_PAD_NUM9, EspError, }; #[cfg(any(esp32, esp32s2, esp32s3))] @@ -84,7 +85,7 @@ pub struct TouchDriver { pub struct TouchPadDriver where - T: Borrow, + T: BorrowMut, { touch: T, pad: TouchPad, @@ -101,13 +102,17 @@ impl TouchPadDriver { impl TouchPadDriver where - T: Borrow, + T: BorrowMut, { pub fn read_raw_data(&self) -> Result { let mut raw: u32 = 0; let result = esp!(unsafe { touch_pad_read_raw_data(self.borrow().pad.into(), &mut raw) }); result.map(|_| raw) } + + pub fn stop(&mut self) -> Result<(), EspError> { + self.touch.borrow_mut().stop() + } } #[cfg(any(esp32, esp32s2, esp32s3))] @@ -128,4 +133,9 @@ impl TouchDriver { Ok(()) } + + pub fn stop(&mut self) -> Result<(), EspError> { + esp!(unsafe { touch_pad_fsm_stop() })?; + Ok(()) + } } From 2934ed3e792d099db86a486aab43d7e7b76f713b Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Sun, 3 Dec 2023 11:19:16 +0000 Subject: [PATCH 08/11] Remove explicit stop in favour of drop --- src/touch.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/touch.rs b/src/touch.rs index 88cf0cfa165..3a2f776a6fc 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -109,10 +109,6 @@ where let result = esp!(unsafe { touch_pad_read_raw_data(self.borrow().pad.into(), &mut raw) }); result.map(|_| raw) } - - pub fn stop(&mut self) -> Result<(), EspError> { - self.touch.borrow_mut().stop() - } } #[cfg(any(esp32, esp32s2, esp32s3))] @@ -133,9 +129,11 @@ impl TouchDriver { Ok(()) } +} - pub fn stop(&mut self) -> Result<(), EspError> { - esp!(unsafe { touch_pad_fsm_stop() })?; - Ok(()) +#[cfg(any(esp32, esp32s2, esp32s3))] +impl Drop for TouchDriver { + fn drop(&mut self) { + unsafe { touch_pad_fsm_stop() }; } } From 3e6c0b1a910229d094e4c49961bbd5aa8cf17501 Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Sun, 3 Dec 2023 11:23:06 +0000 Subject: [PATCH 09/11] Unwrap errors on drop, prevent clippy warning --- src/touch.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/touch.rs b/src/touch.rs index 3a2f776a6fc..3d32caaf15d 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -87,7 +87,7 @@ pub struct TouchPadDriver where T: BorrowMut, { - touch: T, + _touch: T, pad: TouchPad, } @@ -96,7 +96,7 @@ impl TouchPadDriver { let mut touch = TouchDriver::new(config)?; esp!(unsafe { touch_pad_config(pad.into()) })?; touch.start()?; - Ok(Self { touch, pad }) + Ok(Self { _touch: touch, pad }) } } @@ -134,6 +134,6 @@ impl TouchDriver { #[cfg(any(esp32, esp32s2, esp32s3))] impl Drop for TouchDriver { fn drop(&mut self) { - unsafe { touch_pad_fsm_stop() }; + esp!(unsafe { touch_pad_fsm_stop() }).unwrap() } } From b9e972750ed9450bf7f6727a2af9286815d99e5e Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Sun, 3 Dec 2023 11:40:29 +0000 Subject: [PATCH 10/11] Fix clippy issue --- src/touch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/touch.rs b/src/touch.rs index 3d32caaf15d..07c959ee25a 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -123,7 +123,7 @@ impl TouchDriver { pub fn start(&mut self) -> Result<(), EspError> { unsafe { - esp!(touch_pad_set_fsm_mode(self.config.borrow().fsm_mode.into()))?; + esp!(touch_pad_set_fsm_mode(self.config.fsm_mode.into()))?; esp!(touch_pad_fsm_start())?; } From d5d79c76f680aa3ffa695a6b9790ed1b87e517ce Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Mon, 4 Dec 2023 16:11:26 +0000 Subject: [PATCH 11/11] Remove redundant build conditions --- src/lib.rs | 2 +- src/touch.rs | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4ca364f741f..3eee4fba16e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,7 +81,7 @@ pub mod sys; pub mod task; #[cfg(not(feature = "riscv-ulp-hal"))] pub mod timer; -#[cfg(all(any(esp32, esp32s2, esp32s3), not(feature = "riscv-ulp-hal")))] +#[cfg(all(any(esp32s2, esp32s3), not(feature = "riscv-ulp-hal")))] pub mod touch; #[cfg(not(feature = "riscv-ulp-hal"))] pub mod uart; diff --git a/src/touch.rs b/src/touch.rs index 07c959ee25a..ddb00c59bb2 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -12,7 +12,6 @@ use esp_idf_sys::{ touch_pad_t_TOUCH_PAD_NUM9, EspError, }; -#[cfg(any(esp32, esp32s2, esp32s3))] #[derive(Copy, Clone)] pub enum FsmMode { Timer, @@ -20,7 +19,6 @@ pub enum FsmMode { Max, } -#[cfg(any(esp32, esp32s2, esp32s3))] impl From for touch_fsm_mode_t { fn from(value: FsmMode) -> Self { match value { @@ -31,7 +29,6 @@ impl From for touch_fsm_mode_t { } } -#[cfg(any(esp32, esp32s2, esp32s3))] #[derive(Copy, Clone)] pub enum TouchPad { Pad0, @@ -51,7 +48,6 @@ pub enum TouchPad { Pad14, } -#[cfg(any(esp32, esp32s2, esp32s3))] impl From for touch_pad_t { fn from(value: TouchPad) -> Self { match value { @@ -78,7 +74,6 @@ pub struct TouchConfig { fsm_mode: FsmMode, } -#[cfg(any(esp32, esp32s2, esp32s3))] pub struct TouchDriver { config: TouchConfig, } @@ -111,7 +106,6 @@ where } } -#[cfg(any(esp32, esp32s2, esp32s3))] impl TouchDriver { pub fn new(config: TouchConfig) -> Result { unsafe { @@ -131,7 +125,6 @@ impl TouchDriver { } } -#[cfg(any(esp32, esp32s2, esp32s3))] impl Drop for TouchDriver { fn drop(&mut self) { esp!(unsafe { touch_pad_fsm_stop() }).unwrap()