diff --git a/Cargo.lock b/Cargo.lock index d074b02..f7c8e17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -757,6 +757,7 @@ dependencies = [ "embassy-nrf", "embassy-sync 0.7.2", "embassy-time", + "embedded-storage-async", "futures", "nrf-softdevice", "panic-halt", diff --git a/Cargo.toml b/Cargo.toml index ca28661..ff991ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ panic-halt = "1.0.0" panic-probe = { version = "1.0.0", features = ["print-defmt"], optional = true } nrf-softdevice = { version = "0.1.0", features = ["s140", "ble-peripheral", "nrf52840", "nrf-softdevice-s140", "critical-section-impl", "defmt", "nrf52840-pac", "critical-section", "ble-gatt-server"] } futures = { version = "0.3", default-features = false, features = [] } +embedded-storage-async = "0.4.1" [[bin]] name = "odesa" diff --git a/src/main.rs b/src/main.rs index 6e0597b..1eb56da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,9 +27,10 @@ use embassy_sync::signal::Signal; use embassy_time::{with_timeout, Duration, Timer}; use futures::future::{select, Either}; use futures::pin_mut; -use nrf_softdevice::{raw, Softdevice}; +use nrf_softdevice::{raw, Flash, Softdevice}; use nrf_softdevice::ble::advertisement_builder::{Flag, LegacyAdvertisementBuilder, LegacyAdvertisementPayload, ServiceList, ServiceUuid16}; use nrf_softdevice::ble::{peripheral, gatt_server, Connection}; +use embedded_storage_async::nor_flash::ReadNorFlash; #[derive(Copy, Clone, Eq, PartialEq, Format)] enum SysAction { @@ -152,6 +153,13 @@ async fn main(spawner: Spawner) { channel_config.reference = Reference::INTERNAL; let saadc = Saadc::new(p.SAADC, AdcIrqs, saadc::Config::default(), [channel_config]); saadc.calibrate().await; + let flash = Flash::take(sd); + pin_mut!(flash); + let mut data = [0u8; 16]; + if let Err(e) = flash.as_mut().read(0x000F9800 - 4096, &mut data).await { + error!("Error reading from flash: {}", e); + } + info!("Data in flash: {:?}", data); let pwm_text = SimplePwm::new_3ch(p.PWM0, p.P1_00, p.P1_04, p.P1_06, &Default::default()); let pwm_heart = SimplePwm::new_3ch(p.PWM2, p.P0_17, p.P0_20, p.P0_22, &Default::default()); @@ -486,11 +494,11 @@ async fn light_task(mut pwm: SimplePwm<'static>) { match action { SysAction::PresentenceOn if intensity < 100 => { intensity.add_assign(1); - info!("Increase intensity to {}", intensity); + // info!("Increase intensity to {}", intensity); }, SysAction::PresentenceOff if intensity > 0 => { intensity.sub_assign(1); - info!("Decrease intensity to {}", intensity); + // info!("Decrease intensity to {}", intensity); }, _ => { // ignore