From f704058005210e10d2abf844838093eeefb63654 Mon Sep 17 00:00:00 2001 From: Kesavan Yogeswaran Date: Sat, 1 Jun 2024 12:07:44 -0400 Subject: [PATCH] Fix clippy lints --- hangman/.cargo/{config => config.toml} | 2 +- hangman/src/button.rs | 7 +++++++ hangman/src/util.rs | 6 ++++++ hangman/src/weight/mod.rs | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) rename hangman/.cargo/{config => config.toml} (94%) diff --git a/hangman/.cargo/config b/hangman/.cargo/config.toml similarity index 94% rename from hangman/.cargo/config rename to hangman/.cargo/config.toml index 2678ff5..667c31f 100644 --- a/hangman/.cargo/config +++ b/hangman/.cargo/config.toml @@ -19,7 +19,7 @@ runner = "probe-rs run --chip nRF52832_xxAA" target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) [env] -ADVERTISED_NAME = "Progressor_1719" +ADVERTISED_NAME = "Progressor_1234" DEVICE_ID = "42" DEVICE_VERSION_NUMBER = "1.2.3.4" CALIBRATION_CURVE = "FFFFFFFFFFFFFFFF00000000" diff --git a/hangman/src/button.rs b/hangman/src/button.rs index 790c268..265a252 100644 --- a/hangman/src/button.rs +++ b/hangman/src/button.rs @@ -72,6 +72,13 @@ impl Button { &port.pin_cnf[usize::from(self.pin_number)] } + /// Enable pin sensing mechanism (SENSE) for button's pin. Useful for allowing button to wake + /// MCU from sleep modes. + /// + /// # Safety + /// + /// This breaks invariants in the embassy hal's GPIO driver. One should disable the sense line + /// before using the embassy hal's GPIO driver, including pin re-initialization after wakeup. pub unsafe fn enable_sense(&mut self) { let cfg = unsafe { self.steal_pin_cnf() }; match self.polarity { diff --git a/hangman/src/util.rs b/hangman/src/util.rs index 628826c..721fbff 100644 --- a/hangman/src/util.rs +++ b/hangman/src/util.rs @@ -14,6 +14,12 @@ use crate::pac; +/// Disable pin sensing mechanism (SENSE) for all GPIO pins, matching the default on-reset state. +/// +/// # Safety +/// +/// This may break invariants in the embassy hal's GPIO driver. Recommended to only use this before +/// system off or at wakeup before performing any GPIO initialization. pub unsafe fn disable_all_gpio_sense() { #[cfg(feature = "nrf52840")] { diff --git a/hangman/src/weight/mod.rs b/hangman/src/weight/mod.rs index f0767af..dd6dc73 100644 --- a/hangman/src/weight/mod.rs +++ b/hangman/src/weight/mod.rs @@ -37,7 +37,7 @@ pub use task::task_function; static SAMPLING_INTERVAL_HZ: OnceCell = OnceCell::new(); // Temporary defaults for test load cell // TODO: provide better defaults for Hangman P1_0 -pub const DEFAULT_CALIBRATION_M: f32 = 4.6750380809321235e-06; +pub const DEFAULT_CALIBRATION_M: f32 = 4.675_038e-6; pub const DEFAULT_CALIBRATION_B: i32 = -100598; type RawReading = i32;