From b4491c48abde01ae6bbd41be51a0c4233af36d69 Mon Sep 17 00:00:00 2001 From: irriden Date: Thu, 23 Nov 2023 17:39:06 +0000 Subject: [PATCH] sphinx-key: split button led sd into separate mods fixes tons of warnings when building the clear binary --- .gitignore | 1 - sphinx-key/Cargo.toml | 4 -- sphinx-key/src/btn.rs | 54 --------------------------- sphinx-key/src/{periph => }/button.rs | 0 sphinx-key/src/clear.rs | 14 +------ sphinx-key/src/{periph => }/led.rs | 0 sphinx-key/src/main.rs | 10 +++-- sphinx-key/src/periph/mod.rs | 3 -- sphinx-key/src/{periph => }/sd.rs | 0 9 files changed, 8 insertions(+), 78 deletions(-) delete mode 100644 sphinx-key/src/btn.rs rename sphinx-key/src/{periph => }/button.rs (100%) rename sphinx-key/src/{periph => }/led.rs (100%) delete mode 100644 sphinx-key/src/periph/mod.rs rename sphinx-key/src/{periph => }/sd.rs (100%) diff --git a/.gitignore b/.gitignore index c3c3ce1..7d730e3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,4 @@ teststore2 *.pem *.txt *.bin -*.md *.diff diff --git a/sphinx-key/Cargo.toml b/sphinx-key/Cargo.toml index 57baf35..0bcf094 100644 --- a/sphinx-key/Cargo.toml +++ b/sphinx-key/Cargo.toml @@ -42,10 +42,6 @@ embuild = "0.31.2" name = "clear" path = "src/clear.rs" -[[bin]] -name = "btn" -path = "src/btn.rs" - [profile.release] codegen-units = 1 lto = true diff --git a/sphinx-key/src/btn.rs b/sphinx-key/src/btn.rs deleted file mode 100644 index d9473a2..0000000 --- a/sphinx-key/src/btn.rs +++ /dev/null @@ -1,54 +0,0 @@ -mod conn; -mod core; -mod ota; -mod periph; -mod status; - -pub use crate::core::control::FlashPersister; -use esp_idf_svc::hal::gpio::Gpio0; -use esp_idf_svc::hal::gpio::Gpio9; -use esp_idf_svc::hal::peripheral::Peripheral; -use esp_idf_svc::hal::peripherals::Peripherals; -use esp_idf_svc::nvs::EspDefaultNvsPartition; -use esp_idf_svc::sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported -use status::Status; -use std::sync::mpsc; -use std::sync::{Arc, Mutex}; -use std::thread; -use std::time::Duration; - -const ID_LEN: usize = 16; - -fn main() -> anyhow::Result<()> { - esp_idf_svc::sys::link_patches(); - esp_idf_svc::log::EspLogger::initialize_default(); - thread::sleep(Duration::from_secs(1)); - let mut peripherals = Peripherals::take().unwrap(); - - // LED control thread - let (mut led_tx, mut led_rx) = mpsc::channel::(); - while let Err(e) = periph::led::led_control_loop( - unsafe { Gpio0::new() }, - unsafe { peripherals.rmt.channel0.clone_unchecked() }, - led_rx, - ) { - log::error!("unable to spawn led thread: {:?}", e); - thread::sleep(Duration::from_millis(1000)); - (led_tx, led_rx) = mpsc::channel::(); - } - - // BUTTON thread - let default_nvs = EspDefaultNvsPartition::take()?; - let flash_per = FlashPersister::new(default_nvs); - let flash_arc = Arc::new(Mutex::new(flash_per)); - while let Err(e) = - periph::button::button_loop(unsafe { Gpio9::new() }, led_tx.clone(), flash_arc.clone()) - { - log::error!("unable to spawn button thread: {:?}", e); - thread::sleep(Duration::from_millis(1000)); - } - - loop { - thread::sleep(Duration::from_millis(1000)); - } -} diff --git a/sphinx-key/src/periph/button.rs b/sphinx-key/src/button.rs similarity index 100% rename from sphinx-key/src/periph/button.rs rename to sphinx-key/src/button.rs diff --git a/sphinx-key/src/clear.rs b/sphinx-key/src/clear.rs index bce666f..e63d84b 100644 --- a/sphinx-key/src/clear.rs +++ b/sphinx-key/src/clear.rs @@ -1,17 +1,7 @@ -mod conn; -mod core; -mod ota; -mod periph; -mod status; - -#[allow(unused_imports)] -use crate::periph::sd::mount_sd_card; +mod sd; +use crate::sd::mount_sd_card; use esp_idf_svc as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported - -// use esp_idf_svc::nvs::EspNvs; -// use esp_idf_svc::nvs::*; - use std::fs; use std::path::Path; diff --git a/sphinx-key/src/periph/led.rs b/sphinx-key/src/led.rs similarity index 100% rename from sphinx-key/src/periph/led.rs rename to sphinx-key/src/led.rs diff --git a/sphinx-key/src/main.rs b/sphinx-key/src/main.rs index c17ca38..8ee35d0 100644 --- a/sphinx-key/src/main.rs +++ b/sphinx-key/src/main.rs @@ -1,15 +1,17 @@ +mod button; mod conn; mod core; +mod led; mod ota; -mod periph; +mod sd; mod status; +use crate::button::button_loop; use crate::core::control::controller_from_seed; use crate::core::{config::*, events::*, FlashPersister}; -use crate::periph::button::button_loop; -use crate::periph::led::led_control_loop; +use crate::led::led_control_loop; #[allow(unused_imports)] -use crate::periph::sd::{mount_sd_card, simple_fs_test}; +use crate::sd::{mount_sd_card, simple_fs_test}; use crate::status::Status; use anyhow::Result; use esp_idf_svc::hal::gpio::{Gpio0, Gpio9}; diff --git a/sphinx-key/src/periph/mod.rs b/sphinx-key/src/periph/mod.rs deleted file mode 100644 index 9677bf2..0000000 --- a/sphinx-key/src/periph/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod button; -pub mod led; -pub mod sd; diff --git a/sphinx-key/src/periph/sd.rs b/sphinx-key/src/sd.rs similarity index 100% rename from sphinx-key/src/periph/sd.rs rename to sphinx-key/src/sd.rs