From 91c2ce97bb37d33369eace79dd1642d3f667b943 Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 16 Apr 2024 21:04:25 +0200 Subject: [PATCH 01/10] enable presence feature --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 00aee3d..1163a9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ version = "0.1.2" rust-version = "1.75" [dependencies] -a121-sys = { version = "0.2", features = ["distance"] } +a121-sys = { version = "0.2", features = ["distance", "presence"] } defmt = "0.3.5" defmt-rtt = "0.4.0" From 8c3512dd2abc9cedce0ed101a5a0559e54a33e15 Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 16 Apr 2024 21:04:52 +0200 Subject: [PATCH 02/10] Implement conversion traits for ProcessingResult and AccComplex --- src/num.rs | 14 ++++++++++---- src/processing.rs | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/num.rs b/src/num.rs index 6b5f671..862c3db 100644 --- a/src/num.rs +++ b/src/num.rs @@ -4,11 +4,21 @@ use a121_sys::{ acc_int16_complex_t, acc_processing_meter_to_points, acc_processing_points_to_meter, }; +pub struct AccComplex { + inner: acc_int16_complex_t, +} + impl AccComplex { pub fn new() -> Self { Self::default() } + pub fn from_ptr(ptr: *const acc_int16_complex_t) -> Self { + Self { + inner: unsafe { *ptr }, + } + } + /// Returns a mutable pointer to the inner `acc_int16_complex_t` struct. /// # Safety /// This function is unsafe because it returns a raw pointer. @@ -21,10 +31,6 @@ impl AccComplex { } } -pub struct AccComplex { - inner: acc_int16_complex_t, -} - impl Default for AccComplex { fn default() -> Self { Self { diff --git a/src/processing.rs b/src/processing.rs index 320d8af..6e3e8d6 100644 --- a/src/processing.rs +++ b/src/processing.rs @@ -83,3 +83,19 @@ impl Drop for Processing { } } } + +impl From for ProcessingResult { + fn from(result: acc_processing_result_t) -> Self { + let frame = unsafe { AccComplex::from_ptr(result.frame) }; + Self { + inner: result, + frame, + } + } +} + +impl From for acc_processing_result_t { + fn from(result: ProcessingResult) -> Self { + result.inner + } +} From d205be381f7ef2a6c33654363ec4d62636006c5a Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 16 Apr 2024 21:05:28 +0200 Subject: [PATCH 03/10] wip presence implementation --- src/detector/presence.rs | 140 +++++++++++++++++++++++++++++++ src/detector/presence/config.rs | 97 +++++++++++++++++++++ src/detector/presence/results.rs | 137 ++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+) create mode 100644 src/detector/presence/config.rs create mode 100644 src/detector/presence/results.rs diff --git a/src/detector/presence.rs b/src/detector/presence.rs index 8b13789..09fd116 100644 --- a/src/detector/presence.rs +++ b/src/detector/presence.rs @@ -1 +1,141 @@ +pub mod config; +pub mod results; +use crate::detector::presence::config::PresenceConfig; +use crate::detector::presence::results::{PresenceMetadata, PresenceResult, ProcessDataError}; +use crate::radar::{Radar, Ready}; +use crate::sensor::calibration::CalibrationResult; +use crate::sensor::error::SensorError; +use a121_sys::*; +use core::ffi::c_void; +use embedded_hal::digital::OutputPin; +use embedded_hal_async::delay::DelayNs; +use embedded_hal_async::digital::Wait; + +struct InnerPresenceDetector { + presence_metadata: PresenceMetadata, + inner: *mut acc_detector_presence_handle, +} + +impl InnerPresenceDetector { + fn new(config: &PresenceConfig) -> Self { + let mut presence_metadata = PresenceMetadata::default(); + Self { + inner: unsafe { + acc_detector_presence_create(config.inner, presence_metadata.mut_ptr()) + }, + presence_metadata, + } + } + + fn inner(&self) -> *const acc_detector_presence_handle { + self.inner + } + + fn inner_mut(&mut self) -> *mut acc_detector_presence_handle { + self.inner + } +} + +impl Drop for InnerPresenceDetector { + fn drop(&mut self) { + unsafe { acc_detector_presence_destroy(self.inner) } + } +} + +pub struct PresenceDetector<'radar, SINT, ENABLE, DLY> +where + SINT: Wait, + ENABLE: OutputPin, + DLY: DelayNs, +{ + pub radar: &'radar mut Radar, + inner: InnerPresenceDetector, + pub config: PresenceConfig, +} + +impl<'radar, SINT, ENABLE, DLY> PresenceDetector<'radar, SINT, ENABLE, DLY> +where + SINT: Wait, + ENABLE: OutputPin, + DLY: DelayNs, +{ + pub fn new(radar: &'radar mut Radar) -> Self { + let config = PresenceConfig::default(); + let inner = InnerPresenceDetector::new(&config); + Self { + radar, + inner, + config, + } + } + + pub fn with_config( + radar: &'radar mut Radar, + config: PresenceConfig, + ) -> Self { + let inner = InnerPresenceDetector::new(&config); + Self { + radar, + inner, + config, + } + } + + pub async fn prepare_detector( + &mut self, + sensor_cal_result: &CalibrationResult, + buffer: &mut [u8], + ) -> Result<(), SensorError> { + let buffer_size = self.get_buffer_size(); + + if buffer.len() < buffer_size { + return Err(SensorError::BufferTooSmall); + } + + let prepare_success = unsafe { + acc_detector_presence_prepare( + self.inner.inner_mut(), + self.config.inner, + self.radar.inner_sensor(), + sensor_cal_result.ptr(), + buffer.as_mut_ptr() as *mut c_void, + buffer.len() as u32, + ) + }; + + if prepare_success { + Ok(()) + } else { + Err(SensorError::PrepareFailed) + } + } + + pub fn get_buffer_size(&self) -> usize { + let mut buffer_size: u32 = 0; + unsafe { + acc_detector_presence_get_buffer_size(self.inner.inner(), &mut buffer_size as *mut u32); + } + buffer_size as usize + } + + pub async fn detect_presence( + &mut self, + buffer: &mut [u8], + ) -> Result { + let mut result = PresenceResult::default(); + let detection_success = unsafe { + acc_detector_presence_process( + self.inner.inner_mut(), + buffer.as_mut_ptr() as *mut c_void, + &mut result.inner() as *mut acc_detector_presence_result_t, + ) + }; + + if detection_success { + Ok(result) + } else { + Err(ProcessDataError::ProcessingFailed) + } + } +} diff --git a/src/detector/presence/config.rs b/src/detector/presence/config.rs new file mode 100644 index 0000000..ba2df53 --- /dev/null +++ b/src/detector/presence/config.rs @@ -0,0 +1,97 @@ +//! Presence Detection Module +//! +//! Provides an API for presence detection using radar technology. This module includes +//! functionality to create and configure presence detectors, prepare for +//! measurements, detect presence, and more. +//! +//! For a detailed description of the algorithm and its parameters, see the Acconeer documentation. + +#![warn(missing_docs)] + +use crate::config::profile::RadarProfile; +use a121_sys::*; +use core::ops::RangeInclusive; + +/// Type alias for the signal quality +pub type SignalQuality = f32; + +/// Configuration for the radar presence detection. +pub struct PresenceConfig { + pub inner: *mut acc_detector_presence_config, +} + +impl Drop for PresenceConfig { + fn drop(&mut self) { + unsafe { acc_detector_presence_config_destroy(self.inner) } + } +} + +impl Default for PresenceConfig { + fn default() -> Self { + Self { + inner: unsafe { acc_detector_presence_config_create() }, + } + } +} + +impl PresenceConfig { + /// Sets the measurement range in meters. + pub fn set_range(&mut self, range: RangeInclusive) { + unsafe { + acc_detector_presence_config_start_set(self.inner, *range.start()); + acc_detector_presence_config_end_set(self.inner, *range.end()); + } + } + + /// Sets the step length based on profile or manually. + pub fn set_step_length(&mut self, step_length: Option) { + match step_length { + Some(length) => unsafe { + acc_detector_presence_config_step_length_set(self.inner, length); + acc_detector_presence_config_auto_step_length_set(self.inner, false); + }, + None => unsafe { acc_detector_presence_config_auto_step_length_set(self.inner, true) }, + } + } + + /// Sets the sensor ID. + pub fn sensor_set(&mut self, sensor_id: u32) { + unsafe { acc_detector_presence_config_sensor_set(self.inner, sensor_id) } + } + + /// Enables or disables automatic profile selection. + pub fn auto_profile_set(&mut self, enable: bool) { + unsafe { acc_detector_presence_config_auto_profile_set(self.inner, enable) } + } + + /// Sets the profile for presence detection. + pub fn profile_set(&mut self, profile: RadarProfile) { + unsafe { acc_detector_presence_config_profile_set(self.inner, profile as u32) } + } + + /// Configures frame rate for presence detection. + pub fn frame_rate_set(&mut self, frame_rate: f32) { + unsafe { acc_detector_presence_config_frame_rate_set(self.inner, frame_rate) } + } + + /// Enables or disables filter reset on prepare. + pub fn reset_filters_on_prepare_set(&mut self, enable: bool) { + unsafe { acc_detector_presence_config_reset_filters_on_prepare_set(self.inner, enable) } + } + + /// Configures detection thresholds for fast and slow movements. + pub fn detection_thresholds_set(&mut self, intra: f32, inter: f32) { + unsafe { + acc_detector_presence_config_intra_detection_threshold_set(self.inner, intra); + acc_detector_presence_config_inter_detection_threshold_set(self.inner, inter); + } + } + + /// Enables or disables intra-frame and inter-frame detection. + pub fn detection_enable(&mut self, intra_enable: bool, inter_enable: bool) { + unsafe { + acc_detector_presence_config_intra_detection_set(self.inner, intra_enable); + acc_detector_presence_config_inter_detection_set(self.inner, inter_enable); + } + } +} diff --git a/src/detector/presence/results.rs b/src/detector/presence/results.rs new file mode 100644 index 0000000..6c7aa68 --- /dev/null +++ b/src/detector/presence/results.rs @@ -0,0 +1,137 @@ +use crate::config::prf::PulseRepetitionFrequency; +use crate::config::profile::RadarProfile; +use crate::config::RadarConfig; +use crate::processing::ProcessingResult; +use a121_sys::{ + acc_config_profile_t, acc_config_profile_t_ACC_CONFIG_PROFILE_5, + acc_detector_presence_metadata_t, acc_detector_presence_result_t, +}; + +/// Represents the results from a presence detection operation. +pub struct PresenceResult<'r> { + pub presence_detected: bool, + pub intra_presence_score: f32, + pub inter_presence_score: f32, + pub presence_distance: f32, + pub depthwise_intra_presence_scores: &'r [f32], + pub depthwise_inter_presence_scores: &'r [f32], + pub depthwise_presence_scores_length: u32, + pub processing_result: ProcessingResult, +} + +impl PresenceResult<'_> { + /// Updates the presence result with data from the detector. + /// This function should be called after `acc_detector_presence_process`. + pub fn update_from_detector_result(&mut self, result: &acc_detector_presence_result_t) { + self.presence_detected = result.presence_detected; + self.intra_presence_score = result.intra_presence_score; + self.inter_presence_score = result.inter_presence_score; + self.presence_distance = result.presence_distance; + + // Assuming buffer contains depthwise scores after calling acc_detector_presence_process + // and the lengths are correctly populated. + self.depthwise_presence_scores_length = result.depthwise_presence_scores_length; + self.depthwise_intra_presence_scores = unsafe { + core::slice::from_raw_parts( + result.depthwise_intra_presence_scores as *const f32, + result.depthwise_presence_scores_length as usize, + ) + }; + self.depthwise_inter_presence_scores = unsafe { + core::slice::from_raw_parts( + result.depthwise_inter_presence_scores as *const f32, + result.depthwise_presence_scores_length as usize, + ) + }; + + // Processing result is directly assigned for simplicity, might require processing based on use-case + self.processing_result = ProcessingResult::from(result.processing_result); + } + + pub(super) fn inner(&mut self) -> acc_detector_presence_result_t { + acc_detector_presence_result_t { + presence_detected: self.presence_detected, + intra_presence_score: self.intra_presence_score, + inter_presence_score: self.inter_presence_score, + presence_distance: self.presence_distance, + depthwise_intra_presence_scores: self.depthwise_intra_presence_scores.as_ptr() + as *mut _, + depthwise_inter_presence_scores: self.depthwise_inter_presence_scores.as_ptr() + as *mut _, + depthwise_presence_scores_length: self.depthwise_presence_scores_length, + processing_result: self.processing_result.into(), + } + } +} + +impl Default for PresenceResult<'_> { + fn default() -> Self { + Self { + presence_detected: false, + intra_presence_score: 0.0, + inter_presence_score: 0.0, + presence_distance: 0.0, + depthwise_intra_presence_scores: &[], + depthwise_inter_presence_scores: &[], + depthwise_presence_scores_length: 0, + processing_result: ProcessingResult::default(), + } + } +} + +/// Enumerates possible errors that can occur during the processing of radar data for presence detection. +#[derive(Debug, Copy, Clone, defmt::Format)] +pub enum ProcessDataError { + CalibrationNeeded, + ProcessingFailed, + Unavailable, +} + +pub struct PresenceMetadata { + inner: acc_detector_presence_metadata_t, +} + +impl PresenceMetadata { + pub fn start_m(&self) -> f32 { + self.inner.start_m + } + + pub fn step_length_m(&self) -> f32 { + self.inner.step_length_m + } + + pub fn num_points(&self) -> u16 { + self.inner.num_points + } + + pub fn profile(&self) -> RadarProfile { + (self.inner.profile as u32).into() + } + + pub(super) fn inner(&self) -> &acc_detector_presence_metadata_t { + &self.inner + } + + pub(super) fn mut_ptr(&mut self) -> *mut acc_detector_presence_metadata_t { + &mut self.inner + } +} + +impl Default for PresenceMetadata { + fn default() -> Self { + Self { + inner: acc_detector_presence_metadata_t { + start_m: 0.0, + step_length_m: 0.0, + num_points: 0, + profile: acc_config_profile_t_ACC_CONFIG_PROFILE_5, + }, + } + } +} + +impl From for PresenceMetadata { + fn from(metadata: acc_detector_presence_metadata_t) -> Self { + Self { inner: metadata } + } +} From df8445cd011606c5ff79f8d85f4bdb11c008b83b Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 23 Apr 2024 21:49:15 +0200 Subject: [PATCH 04/10] doc --- src/detector/presence/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detector/presence/config.rs b/src/detector/presence/config.rs index ba2df53..bee992f 100644 --- a/src/detector/presence/config.rs +++ b/src/detector/presence/config.rs @@ -17,6 +17,7 @@ pub type SignalQuality = f32; /// Configuration for the radar presence detection. pub struct PresenceConfig { + /// Pointer to the inner presence detector configuration. pub inner: *mut acc_detector_presence_config, } From 4ada350e397275296cdee11022e571110d8fc7d1 Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 23 Apr 2024 21:49:58 +0200 Subject: [PATCH 05/10] Refactor presence detection code and remove unused imports --- src/detector/presence.rs | 8 ++++++++ src/detector/presence/results.rs | 15 +++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/detector/presence.rs b/src/detector/presence.rs index 09fd116..c341349 100644 --- a/src/detector/presence.rs +++ b/src/detector/presence.rs @@ -28,6 +28,10 @@ impl InnerPresenceDetector { } } + pub fn presence_metadata(&self) -> &PresenceMetadata { + &self.presence_metadata + } + fn inner(&self) -> *const acc_detector_presence_handle { self.inner } @@ -82,6 +86,10 @@ where } } + pub fn presence_metadata(&self) -> &PresenceMetadata { + self.inner.presence_metadata() + } + pub async fn prepare_detector( &mut self, sensor_cal_result: &CalibrationResult, diff --git a/src/detector/presence/results.rs b/src/detector/presence/results.rs index 6c7aa68..630136d 100644 --- a/src/detector/presence/results.rs +++ b/src/detector/presence/results.rs @@ -1,10 +1,8 @@ -use crate::config::prf::PulseRepetitionFrequency; use crate::config::profile::RadarProfile; -use crate::config::RadarConfig; use crate::processing::ProcessingResult; use a121_sys::{ - acc_config_profile_t, acc_config_profile_t_ACC_CONFIG_PROFILE_5, - acc_detector_presence_metadata_t, acc_detector_presence_result_t, + acc_config_profile_t_ACC_CONFIG_PROFILE_5, acc_detector_presence_metadata_t, + acc_detector_presence_result_t, }; /// Represents the results from a presence detection operation. @@ -49,6 +47,7 @@ impl PresenceResult<'_> { } pub(super) fn inner(&mut self) -> acc_detector_presence_result_t { + let processing_result = self.processing_result.clone(); acc_detector_presence_result_t { presence_detected: self.presence_detected, intra_presence_score: self.intra_presence_score, @@ -59,7 +58,7 @@ impl PresenceResult<'_> { depthwise_inter_presence_scores: self.depthwise_inter_presence_scores.as_ptr() as *mut _, depthwise_presence_scores_length: self.depthwise_presence_scores_length, - processing_result: self.processing_result.into(), + processing_result: processing_result.into(), } } } @@ -105,11 +104,7 @@ impl PresenceMetadata { } pub fn profile(&self) -> RadarProfile { - (self.inner.profile as u32).into() - } - - pub(super) fn inner(&self) -> &acc_detector_presence_metadata_t { - &self.inner + self.inner.profile.into() } pub(super) fn mut_ptr(&mut self) -> *mut acc_detector_presence_metadata_t { From fca563de2847b397e54db377a4fd4652f3967ec2 Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 23 Apr 2024 21:50:11 +0200 Subject: [PATCH 06/10] Refactor presence detection code and remove unused imports --- src/num.rs | 1 + src/processing.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/num.rs b/src/num.rs index 862c3db..2a68f20 100644 --- a/src/num.rs +++ b/src/num.rs @@ -4,6 +4,7 @@ use a121_sys::{ acc_int16_complex_t, acc_processing_meter_to_points, acc_processing_points_to_meter, }; +#[derive(Debug, Clone)] pub struct AccComplex { inner: acc_int16_complex_t, } diff --git a/src/processing.rs b/src/processing.rs index 6e3e8d6..5a663a9 100644 --- a/src/processing.rs +++ b/src/processing.rs @@ -11,6 +11,7 @@ use a121_sys::{ pub mod metadata; +#[derive(Debug, Clone)] pub struct ProcessingResult { inner: acc_processing_result_t, pub frame: AccComplex, @@ -86,7 +87,7 @@ impl Drop for Processing { impl From for ProcessingResult { fn from(result: acc_processing_result_t) -> Self { - let frame = unsafe { AccComplex::from_ptr(result.frame) }; + let frame = AccComplex::from_ptr(result.frame); Self { inner: result, frame, From 8b6b3701380acd463d2e6bfcff16736ec9d6ae1d Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 23 Apr 2024 21:50:35 +0200 Subject: [PATCH 07/10] Integrate RadarDistanceConfig for custom parameters --- examples/xe125-nightly/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/xe125-nightly/src/main.rs b/examples/xe125-nightly/src/main.rs index 4b17c03..118abe5 100644 --- a/examples/xe125-nightly/src/main.rs +++ b/examples/xe125-nightly/src/main.rs @@ -6,6 +6,7 @@ extern crate alloc; use alloc::vec; use core::cell::RefCell; +use a121_rs::detector::distance::config::RadarDistanceConfig; use a121_rs::detector::distance::RadarDistanceDetector; use a121_rs::radar; use a121_rs::radar::Radar; @@ -77,7 +78,9 @@ async fn main(_spawner: Spawner) { let mut calibration = radar.calibrate().await.unwrap(); info!("Calibration complete."); let mut radar = radar.prepare_sensor(&mut calibration).unwrap(); - let mut distance = RadarDistanceDetector::new(&mut radar); + let mut dist_config = RadarDistanceConfig::balanced(); + dist_config.set_interval(4.0..=5.5); + let mut distance = RadarDistanceDetector::with_config(&mut radar, dist_config); let mut buffer = vec![0u8; distance.get_distance_buffer_size()]; let mut static_cal_result = vec![0u8; distance.get_static_result_buffer_size()]; trace!("Calibrating detector..."); From 147312b93895513216527780864f1f88d9b39e51 Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Tue, 23 Apr 2024 22:06:49 +0200 Subject: [PATCH 08/10] Update crate versions in Cargo.toml --- examples/xe125-nightly/Cargo.lock | 152 ++++++++++++++++-------------- examples/xe125-nightly/Cargo.toml | 14 +-- 2 files changed, 87 insertions(+), 79 deletions(-) diff --git a/examples/xe125-nightly/Cargo.lock b/examples/xe125-nightly/Cargo.lock index b3d8914..aa9faef 100644 --- a/examples/xe125-nightly/Cargo.lock +++ b/examples/xe125-nightly/Cargo.lock @@ -19,9 +19,9 @@ dependencies = [ [[package]] name = "a121-sys" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3fa639196480856e3e9d8889ede7a3b5d728ec61cced764569f09f4a607f25" +checksum = "94ef22a929b92c5b269a993532b01fa24dd809fb795e1a8858471b7bc49bdc80" dependencies = [ "bindgen", "cc", @@ -29,18 +29,18 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "bare-metal" @@ -57,7 +57,7 @@ version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cexpr", "clang-sys", "itertools", @@ -70,7 +70,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.52", + "syn 2.0.60", "which", ] @@ -94,9 +94,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bxcan" @@ -119,9 +119,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.89" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" [[package]] name = "cexpr" @@ -140,9 +140,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "num-traits", ] @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "cortex-m-rt" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1" +checksum = "2722f5b7d6ea8583cffa4d247044e280ccbb9fe501bed56552e2ba48b02d5f3d" dependencies = [ "cortex-m-rt-macros", ] @@ -218,7 +218,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -229,7 +229,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -252,7 +252,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -285,9 +285,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "embassy-embedded-hal" @@ -331,7 +331,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -605,7 +605,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -703,9 +703,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2caa5afb8bf9f3a2652760ce7d4f62d21c4d5a423e68466fca30df82f2330164" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", "windows-targets", @@ -747,9 +747,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "minimal-lexical" @@ -784,9 +784,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" dependencies = [ "num-complex", "num-integer", @@ -863,9 +863,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -881,12 +881,12 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "prettyplease" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -915,18 +915,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -939,9 +939,9 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -962,9 +962,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rustc-hash" @@ -983,11 +983,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -1089,9 +1089,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1100,37 +1100,38 @@ dependencies = [ [[package]] name = "talc" -version = "4.3.1" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5244db9f91c0b033fa05c16e349ccdb0a3225198a5a71dbeacd36696e08d940b" +checksum = "04be12ec299aadd63a0bf781d893e4b6139d33cdca6dcd6f6be31f849cedcac8" dependencies = [ "lock_api", ] [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] name = "tinyrlibc" -version = "0.3.0" -source = "git+https://github.com/rust-embedded-community/tinyrlibc.git#a62f24c7a586d8c4c742132a8cf4a85a81920064" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27aacb7ad7ad37d08dbe479ddad04f555273fe025c0c486587a7dd6b93b6531b" dependencies = [ "cc", ] @@ -1191,13 +1192,14 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1206,45 +1208,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "xe125-nightly" diff --git a/examples/xe125-nightly/Cargo.toml b/examples/xe125-nightly/Cargo.toml index de3b74d..fee3b31 100644 --- a/examples/xe125-nightly/Cargo.toml +++ b/examples/xe125-nightly/Cargo.toml @@ -8,11 +8,11 @@ a121-rs = { path = "../../", features = ["distance", "nightly-logger"] } panic-probe = { version = "0.3", features = ["print-defmt"] } -cortex-m = { version = "0.7.7", features = ["critical-section-single-core", "inline-asm"] } -cortex-m-rt = "0.7.0" +cortex-m = { version = "0.7", features = ["critical-section-single-core", "inline-asm"] } +cortex-m-rt = "0.7" -defmt = "0.3.5" -defmt-rtt = "0.4.0" +defmt = "0.3" +defmt-rtt = "0.4" embedded-hal = "1.0.0" embassy-executor = { version = "0.5.0", features = [ "task-arena-size-20480", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers" ] } @@ -23,10 +23,10 @@ embassy-embedded-hal = { version = "0.1", features = ["defmt"] } embedded-hal-bus = { version = "0.1.0", features = ["defmt-03"] } libc = { version = "0.2", default-features = false } -talc = { version = "4.2", default-features = false, features = ["lock_api"] } -spin = "0.9.8" +talc = { version = "4.4", default-features = false, features = ["lock_api"] } +spin = "0.9" num = { version = "0.4", default-features = false, features = ["libm"]} -tinyrlibc = { git = "https://github.com/rust-embedded-community/tinyrlibc.git", version = "0.3.0" } +tinyrlibc = { version = "0.4", features = ["alloc"] } static_cell = "2.0.0" From 699fc6e93f7be8cae9922e09fe1118ddfa4ef7ac Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Thu, 25 Apr 2024 22:48:19 +0200 Subject: [PATCH 09/10] Move example to bin folder, to prepare for a presence example in the future --- examples/xe125-nightly/Cargo.toml | 9 +++ .../src/{main.rs => bin/distance.rs} | 74 +++---------------- examples/xe125-nightly/src/lib.rs | 68 +++++++++++++++++ 3 files changed, 86 insertions(+), 65 deletions(-) rename examples/xe125-nightly/src/{main.rs => bin/distance.rs} (66%) create mode 100644 examples/xe125-nightly/src/lib.rs diff --git a/examples/xe125-nightly/Cargo.toml b/examples/xe125-nightly/Cargo.toml index fee3b31..ccbabbb 100644 --- a/examples/xe125-nightly/Cargo.toml +++ b/examples/xe125-nightly/Cargo.toml @@ -3,6 +3,10 @@ name = "xe125-nightly" version = "0.1.0" edition = "2021" +[lib] +bench = false +test = false + [dependencies] a121-rs = { path = "../../", features = ["distance", "nightly-logger"] } @@ -39,3 +43,8 @@ debug = 2 lto = true codegen-units = 1 opt-level = "s" + +[[bin]] +name = "distance" +bench = false +test = false diff --git a/examples/xe125-nightly/src/main.rs b/examples/xe125-nightly/src/bin/distance.rs similarity index 66% rename from examples/xe125-nightly/src/main.rs rename to examples/xe125-nightly/src/bin/distance.rs index 118abe5..af1907f 100644 --- a/examples/xe125-nightly/src/main.rs +++ b/examples/xe125-nightly/src/bin/distance.rs @@ -6,48 +6,24 @@ extern crate alloc; use alloc::vec; use core::cell::RefCell; -use a121_rs::detector::distance::config::RadarDistanceConfig; -use a121_rs::detector::distance::RadarDistanceDetector; -use a121_rs::radar; -use a121_rs::radar::Radar; use defmt::{info, trace, warn}; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::peripherals::{DMA2_CH2, DMA2_CH3, PB0, SPI1}; -use embassy_stm32::rcc::{ - ClockSrc, LsConfig, Pll, PllMul, PllPDiv, PllPreDiv, PllQDiv, PllRDiv, PllSource, -}; -use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; +use embassy_stm32::spi::Spi; use embassy_time::{Delay, Instant}; use embedded_hal_bus::spi::ExclusiveDevice; -use radar::rss_version; -use talc::{ClaimOnOom, Span, Talc, Talck}; -use tinyrlibc as _; -use {defmt_rtt as _, panic_probe as _}; -use crate::adapter::SpiAdapter; - -mod adapter; - -static mut ARENA: [u8; 16000] = [0u8; 16000]; - -#[global_allocator] -static ALLOCATOR: Talck, ClaimOnOom> = Talc::new(unsafe { - // if we're in a hosted environment, the Rust runtime may allocate before - // main() is called, so we need to initialize the arena automatically - ClaimOnOom::new(Span::from_const_array(core::ptr::addr_of!(ARENA))) -}) -.lock(); - -type SpiDeviceMutex = - ExclusiveDevice, Output<'static, PB0>, Delay>; -static mut SPI_DEVICE: Option>> = None; +use a121_rs::detector::distance::config::RadarDistanceConfig; +use a121_rs::detector::distance::RadarDistanceDetector; +use a121_rs::radar; +use a121_rs::radar::Radar; +use radar::rss_version; +use xe125_nightly::adapter::SpiAdapter; +use xe125_nightly::*; #[embassy_executor::main] async fn main(_spawner: Spawner) { - info!("Starting..."); let p = embassy_stm32::init(xm125_clock_config()); let enable = Output::new(p.PB12, Level::Low, Speed::VeryHigh); // ENABLE on PB12 @@ -66,7 +42,6 @@ async fn main(_spawner: Spawner) { xm125_spi_config(), ); let exclusive_device = ExclusiveDevice::new(spi, cs_pin, Delay); - info!("SPI initialized."); unsafe { SPI_DEVICE = Some(RefCell::new(SpiAdapter::new(exclusive_device))) }; let spi_mut_ref = unsafe { SPI_DEVICE.as_mut().unwrap() }; @@ -78,6 +53,7 @@ async fn main(_spawner: Spawner) { let mut calibration = radar.calibrate().await.unwrap(); info!("Calibration complete."); let mut radar = radar.prepare_sensor(&mut calibration).unwrap(); + let mut dist_config = RadarDistanceConfig::balanced(); dist_config.set_interval(4.0..=5.5); let mut distance = RadarDistanceDetector::with_config(&mut radar, dist_config); @@ -136,35 +112,3 @@ async fn main(_spawner: Spawner) { } } } - -fn xm125_spi_config() -> Config { - let mut spi_config = Config::default(); - spi_config.frequency = Hertz(1_000_000); - spi_config -} - -fn xm125_clock_config() -> embassy_stm32::Config { - let mut config = embassy_stm32::Config::default(); - config.rcc.hsi = true; - config.rcc.hse = None; - config.rcc.msi = None; - config.rcc.mux = ClockSrc::PLL1_R; - config.rcc.pll = Some(Pll { - source: PllSource::HSI, - prediv: PllPreDiv::DIV1, - mul: PllMul::MUL10, - divp: Some(PllPDiv::DIV7), - divq: Some(PllQDiv::DIV2), - divr: Some(PllRDiv::DIV2), - }); - config.rcc.pllsai1 = Some(Pll { - source: PllSource::HSI, - prediv: PllPreDiv::DIV1, - mul: PllMul::MUL8, - divp: Some(PllPDiv::DIV7), - divq: Some(PllQDiv::DIV2), - divr: Some(PllRDiv::DIV2), - }); - config.rcc.ls = LsConfig::default_lsi(); - config -} diff --git a/examples/xe125-nightly/src/lib.rs b/examples/xe125-nightly/src/lib.rs new file mode 100644 index 0000000..0779470 --- /dev/null +++ b/examples/xe125-nightly/src/lib.rs @@ -0,0 +1,68 @@ +#![no_std] + +extern crate alloc; + +use core::cell::RefCell; + +use embassy_stm32::gpio::Output; +use embassy_stm32::peripherals::{DMA2_CH2, DMA2_CH3, PB0, SPI1}; +use embassy_stm32::rcc::{ + ClockSrc, LsConfig, Pll, PllMul, PllPDiv, PllPreDiv, PllQDiv, PllRDiv, PllSource, +}; +use embassy_stm32::spi::{Config, Spi}; +use embassy_stm32::time::Hertz; +use embassy_time::Delay; +use embedded_hal_bus::spi::ExclusiveDevice; +use talc::{ClaimOnOom, Span, Talc, Talck}; +use tinyrlibc as _; +use {defmt_rtt as _, panic_probe as _}; + +use crate::adapter::SpiAdapter; + +pub mod adapter; + +static mut ARENA: [u8; 16000] = [0u8; 16000]; + +#[global_allocator] +static ALLOCATOR: Talck, ClaimOnOom> = Talc::new(unsafe { + // if we're in a hosted environment, the Rust runtime may allocate before + // main() is called, so we need to initialize the arena automatically + ClaimOnOom::new(Span::from_const_array(core::ptr::addr_of!(ARENA))) +}) +.lock(); + +pub type SpiDeviceMutex = + ExclusiveDevice, Output<'static, PB0>, Delay>; +pub static mut SPI_DEVICE: Option>> = None; + +pub fn xm125_spi_config() -> Config { + let mut spi_config = Config::default(); + spi_config.frequency = Hertz(1_000_000); + spi_config +} + +pub fn xm125_clock_config() -> embassy_stm32::Config { + let mut config = embassy_stm32::Config::default(); + config.rcc.hsi = true; + config.rcc.hse = None; + config.rcc.msi = None; + config.rcc.mux = ClockSrc::PLL1_R; + config.rcc.pll = Some(Pll { + source: PllSource::HSI, + prediv: PllPreDiv::DIV1, + mul: PllMul::MUL10, + divp: Some(PllPDiv::DIV7), + divq: Some(PllQDiv::DIV2), + divr: Some(PllRDiv::DIV2), + }); + config.rcc.pllsai1 = Some(Pll { + source: PllSource::HSI, + prediv: PllPreDiv::DIV1, + mul: PllMul::MUL8, + divp: Some(PllPDiv::DIV7), + divq: Some(PllQDiv::DIV2), + divr: Some(PllRDiv::DIV2), + }); + config.rcc.ls = LsConfig::default_lsi(); + config +} From e67e85ec6b12ce03c9ba9e51ba675245bc93c798 Mon Sep 17 00:00:00 2001 From: ragarnoy Date: Sun, 28 Apr 2024 23:47:32 +0200 Subject: [PATCH 10/10] details --- examples/xe125-nightly/src/bin/distance.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/xe125-nightly/src/bin/distance.rs b/examples/xe125-nightly/src/bin/distance.rs index af1907f..7b7ee26 100644 --- a/examples/xe125-nightly/src/bin/distance.rs +++ b/examples/xe125-nightly/src/bin/distance.rs @@ -6,7 +6,7 @@ extern crate alloc; use alloc::vec; use core::cell::RefCell; -use defmt::{info, trace, warn}; +use defmt::{debug, info, trace, warn}; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; @@ -46,7 +46,7 @@ async fn main(_spawner: Spawner) { unsafe { SPI_DEVICE = Some(RefCell::new(SpiAdapter::new(exclusive_device))) }; let spi_mut_ref = unsafe { SPI_DEVICE.as_mut().unwrap() }; - info!("RSS Version: {}", rss_version()); + debug!("RSS Version: {}", rss_version()); let mut radar = Radar::new(1, spi_mut_ref.get_mut(), interrupt, enable, Delay).await; info!("Radar enabled.");