From d2867cf6d1d56f6a1ed7419149a3524668f898eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 29 Oct 2024 17:22:20 +0000 Subject: [PATCH 01/21] sweptsine: POC --- Cargo.lock | 2 - Cargo.toml | 3 + src/bin/dual-iir.rs | 61 +++--- src/hardware/signal_generator.rs | 330 +++++++++++++++++-------------- 4 files changed, 220 insertions(+), 176 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e2e4d7d1..1c49b0c81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -437,8 +437,6 @@ dependencies = [ [[package]] name = "idsp" version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b7ec7ce4a9fa0c4801301dc2dfc836bc98ea06e8e7f04372c86cfcd171a80e" dependencies = [ "num-complex 0.4.6", "num-traits", diff --git a/Cargo.toml b/Cargo.toml index 1891e7025..3f0baf758 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,3 +96,6 @@ opt-level = 3 debug = true lto = true codegen-units = 1 + +[patch.crates-io] +idsp = { path = "../idsp" } diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index bf62fcc0b..a6582add4 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -40,6 +40,7 @@ use mutex_trait::prelude::*; use idsp::iir; +use stabilizer::hardware::signal_generator::SourceConfig; use stabilizer::{ hardware::{ self, @@ -47,7 +48,7 @@ use stabilizer::{ afe::Gain, dac::{Dac0Output, Dac1Output, DacCode}, hal, - signal_generator::{self, SignalGenerator}, + signal_generator::{self, Source}, timers::SamplingTimer, DigitalInput0, DigitalInput1, SerialTerminal, SystemTimer, Systick, UsbDevice, AFE0, AFE1, @@ -172,7 +173,9 @@ pub struct DualIir { /// /// # Value /// See [signal_generator::BasicConfig#miniconf] - source: [signal_generator::BasicConfig; 2], + source: [signal_generator::SourceConfig; 2], + + trigger: Leaf, } impl Default for DualIir { @@ -180,6 +183,9 @@ impl Default for DualIir { let mut i = iir::Biquad::IDENTITY; i.set_min(-SCALE); i.set_max(SCALE); + let mut source = SourceConfig::default(); + source.period = SAMPLE_PERIOD; + source.scale = DacCode::FULL_SCALE; Self { // Analog frontend programmable gain amplifier gains (G1, G2, G5, G10) afe: Default::default(), @@ -197,7 +203,8 @@ impl Default for DualIir { // The default telemetry period in seconds. telemetry_period: 10.into(), - source: Default::default(), + source: [source; 2], + trigger: false.into(), stream: Default::default(), } @@ -215,7 +222,7 @@ mod app { settings: Settings, active_settings: DualIir, telemetry: TelemetryBuffer, - source: [SignalGenerator; 2], + source: [Source; 2], } #[local] @@ -255,23 +262,16 @@ mod app { let generator = network.configure_streaming(StreamFormat::AdcDacData); + let source = + Source::try_from_config(&stabilizer.settings.dual_iir.source[0]) + .unwrap(); + let shared = Shared { usb: stabilizer.usb, network, active_settings: stabilizer.settings.dual_iir.clone(), telemetry: TelemetryBuffer::default(), - source: [ - SignalGenerator::new( - stabilizer.settings.dual_iir.source[0] - .try_into_config(SAMPLE_PERIOD, DacCode::FULL_SCALE) - .unwrap(), - ), - SignalGenerator::new( - stabilizer.settings.dual_iir.source[1] - .try_into_config(SAMPLE_PERIOD, DacCode::FULL_SCALE) - .unwrap(), - ), - ], + source: [source.clone(), source], settings: stabilizer.settings, }; @@ -385,7 +385,7 @@ mod app { // The truncation introduces 1/2 LSB distortion. let y: i16 = unsafe { y.to_int_unchecked() }; - let y = y.saturating_add(signal); + let y = y.saturating_add((signal >> 16) as _); // Convert to DAC code *di = DacCode::from(y).0; @@ -458,20 +458,21 @@ mod app { c.local.afes.0.set_gain(*settings.dual_iir.afe[0]); c.local.afes.1.set_gain(*settings.dual_iir.afe[1]); - // Update the signal generators - for (i, &config) in settings.dual_iir.source.iter().enumerate() { - match config.try_into_config(SAMPLE_PERIOD, DacCode::FULL_SCALE) - { - Ok(config) => { - c.shared.source.lock(|generator| { - generator[i].update_waveform(config) - }); + if *settings.dual_iir.trigger { + settings.dual_iir.trigger = false.into(); + for (i, config) in settings.dual_iir.source.iter().enumerate() { + match Source::try_from_config(config) { + Ok(source) => { + c.shared.source.lock(|s| { + s[i] = source; + }); + } + Err(err) => log::error!( + "Failed to update source on channel {}: {:?}", + i, + err + ), } - Err(err) => log::error!( - "Failed to update signal generation on DAC{}: {:?}", - i, - err - ), } } diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index 45b12a999..f9e1d4b5c 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -1,3 +1,6 @@ +use core::iter::Fuse; + +use idsp::{AccuOsc, SyncExpSweep}; use miniconf::{Leaf, Tree}; use rand_core::{RngCore, SeedableRng}; use rand_xorshift::XorShiftRng; @@ -10,37 +13,65 @@ pub enum Signal { Square, Triangle, WhiteNoise, + SweptSine, +} + +impl Signal { + #[inline] + fn map(&self, x: i32) -> i32 { + match self { + Self::Cosine => idsp::cossin(x).0, + Self::Square => { + if x.is_negative() { + -i32::MAX + } else { + i32::MAX + } + } + Self::Triangle => i32::MIN + (x.saturating_abs() << 1), + _ => unimplemented!(), + } + } } /// Basic configuration for a generated signal. -/// -/// # Miniconf -/// `{"signal": , "frequency", 1000.0, "symmetry": 0.5, "amplitude": 1.0}` -/// -/// Where `` may be any of [Signal] variants, `frequency` specifies the signal frequency -/// in Hertz, `symmetry` specifies the normalized signal symmetry which ranges from 0 - 1.0, and -/// `amplitude` specifies the signal amplitude in Volts. #[derive(Copy, Clone, Debug, Tree, Serialize, Deserialize)] -pub struct BasicConfig { +pub struct SourceConfig { /// The signal type that should be generated. See [Signal] variants. - pub signal: Leaf, + signal: Leaf, /// The frequency of the generated signal in Hertz. - pub frequency: Leaf, + frequency: Leaf, /// The normalized symmetry of the signal. At 0% symmetry, the duration of the first half oscillation is minimal. /// At 25% symmetry, the first half oscillation lasts for 25% of the signal period. For square wave output this /// symmetry is the duty cycle. - pub symmetry: Leaf, + symmetry: Leaf, - /// The amplitude of the output signal in volts. - pub amplitude: Leaf, + /// The amplitude of the output signal + amplitude: Leaf, - /// The phase of the output signal in turns. - pub phase: Leaf, + /// Output offset + offset: Leaf, + + /// The initial phase of the period output signal in turns + phase: Leaf, + + /// Number of half periods (periodic), octaves (sweep), or samples (noise), 0 for infinte + length: Leaf, + + /// Sweep interval in seconds per octave + interval: Leaf, + + /// Sample period + #[tree(skip)] + pub period: f32, + /// Output full scale + #[tree(skip)] + pub scale: f32, } -impl Default for BasicConfig { +impl Default for SourceConfig { fn default() -> Self { Self { frequency: 1.0e3.into(), @@ -48,164 +79,175 @@ impl Default for BasicConfig { signal: Signal::Cosine.into(), amplitude: 0.0.into(), phase: 0.0.into(), + offset: 0.0.into(), + interval: 1.0.into(), + length: 0.into(), + period: 1.0, + scale: 1.0, } } } +#[derive(Clone, Debug)] +pub struct AsymmetricAccu { + ftw2: [i32; 2], + pow: i32, + accu: i32, + count: u32, +} + +impl Iterator for AsymmetricAccu { + type Item = i32; + fn next(&mut self) -> Option { + let sign = self.accu.is_negative(); + self.accu = self.accu.wrapping_add(self.ftw2[sign as usize]); + self.count + .checked_sub(sign as u32 ^ self.accu.is_negative() as u32) + .map(|c| { + self.count = c; + self.accu.wrapping_add(self.pow) + }) + } +} + +#[derive(Clone, Debug)] +pub struct Scaler { + amp: i32, + offset: i32, +} + +impl Scaler { + fn map(&self, x: i32) -> i32 { + ((x as i64 * self.amp as i64) >> 31) as i32 + self.offset + } +} + /// Represents the errors that can occur when attempting to configure the signal generator. #[derive(Copy, Clone, Debug)] pub enum Error { /// The provided amplitude is out-of-range. - InvalidAmplitude, + Amplitude, /// The provided symmetry is out of range. - InvalidSymmetry, + Symmetry, /// The provided frequency is out of range. - InvalidFrequency, + Frequency, + /// Sweep would wrap/invalid + Wrap, +} + +#[derive(Clone, Debug)] +pub enum Source { + SweptSine { + sweep: Fuse>, + amp: Scaler, + }, + Periodic { + accu: AsymmetricAccu, + signal: Signal, + amp: Scaler, + }, + WhiteNoise { + rng: XorShiftRng, + count: u32, + amp: Scaler, + }, } -impl BasicConfig { - /// Convert configuration into signal generator values. - /// - /// # Args - /// * `sample_period` - The time in seconds between samples. - /// * `full_scale` - The full scale output voltage. - pub fn try_into_config( - self, - sample_period: f32, - full_scale: f32, - ) -> Result { - let symmetry_complement = 1.0 - *self.symmetry; - // Validate symmetry - if *self.symmetry < 0.0 || symmetry_complement < 0.0 { - return Err(Error::InvalidSymmetry); +impl Iterator for Source { + type Item = i32; + #[inline] + fn next(&mut self) -> Option { + let (s, a) = match self { + Self::SweptSine { sweep, amp } => (sweep.next().map(|c| c.im), amp), + Self::Periodic { accu, signal, amp } => { + (accu.next().map(|p| signal.map(p)), amp) + } + Self::WhiteNoise { rng, count, amp } => ( + count.checked_sub(1).map(|m| { + *count = m; + rng.next_u32() as i32 + }), + amp, + ), + }; + Some(a.map(s.unwrap_or_default())) + } +} + +impl Source { + /// Convert from SI config + pub fn try_from_config(value: &SourceConfig) -> Result { + if !(0.0..1.0).contains(&*value.symmetry) { + return Err(Error::Symmetry); } const NYQUIST: f32 = (1u32 << 31) as _; - let ftw = *self.frequency * sample_period * NYQUIST; - - // Validate base frequency tuning word to be below Nyquist. - if ftw < 0.0 || 2.0 * ftw > NYQUIST { - return Err(Error::InvalidFrequency); + let ftw = *value.frequency * value.period * NYQUIST; + if !(0.0..2.0 * NYQUIST).contains(&ftw) { + return Err(Error::Frequency); } - // Calculate the frequency tuning words. // Clip both frequency tuning words to within Nyquist before rounding. - let phase_increment = [ - if *self.symmetry * NYQUIST > ftw { - ftw / *self.symmetry + let ftw2 = [ + if *value.symmetry * NYQUIST > ftw { + ftw / *value.symmetry } else { NYQUIST } as i32, - if symmetry_complement * NYQUIST > ftw { - ftw / symmetry_complement + if (1.0 - *value.symmetry) * NYQUIST > ftw { + ftw / (1.0 - *value.symmetry) } else { NYQUIST } as i32, ]; - let amplitude = *self.amplitude * (i16::MIN as f32 / -full_scale); - if !(i16::MIN as f32..=i16::MAX as f32).contains(&litude) { - return Err(Error::InvalidAmplitude); - } - - let phase = *self.phase * (1u64 << 32) as f32; - - Ok(Config { - amplitude: amplitude as i16, - signal: *self.signal, - phase_increment, - phase_offset: phase as i32, - }) - } -} - -#[derive(Copy, Clone, Debug)] -pub struct Config { - /// The type of signal being generated - pub signal: Signal, - - /// The full-scale output code of the signal - pub amplitude: i16, - - /// The frequency tuning word of the signal. Phase is incremented by this amount - pub phase_increment: [i32; 2], - - /// The phase offset - pub phase_offset: i32, -} - -impl Default for Config { - fn default() -> Self { - Self { - signal: Signal::Cosine, - amplitude: 0, - phase_increment: [0, 0], - phase_offset: 0, + let offset = *value.offset / value.scale; + let amplitude = *value.amplitude / value.scale; + fn abs(x: f32) -> f32 { + if x.is_sign_negative() { + -x + } else { + x + } } - } -} - -#[derive(Debug)] -pub struct SignalGenerator { - phase_accumulator: i32, - config: Config, - rng: XorShiftRng, -} - -impl SignalGenerator { - /// Construct a new signal generator with some specific config. - /// - /// # Args - /// * `config` - The config to use for generating signals. - /// - /// # Returns - /// The generator - pub fn new(config: Config) -> Self { - Self { - config, - phase_accumulator: 0, - rng: XorShiftRng::from_seed([0; 16]), // zeros will initialize with XorShiftRng internal seed + if abs(offset) + abs(amplitude) >= 1.0 { + return Err(Error::Amplitude); } - } - - /// Update waveform generation settings. - pub fn update_waveform(&mut self, new_config: Config) { - self.config = new_config; - } - - /// Clear the phase accumulator. - pub fn clear_phase_accumulator(&mut self) { - self.phase_accumulator = 0; - } -} + let amp = Scaler { + amp: (amplitude * NYQUIST) as _, + offset: (offset * NYQUIST) as _, + }; -impl core::iter::Iterator for SignalGenerator { - type Item = i16; - - /// Get the next value in the generator sequence. - fn next(&mut self) -> Option { - let phase = self - .phase_accumulator - .wrapping_add(self.config.phase_offset); - let sign = phase.is_negative(); - self.phase_accumulator = self - .phase_accumulator - .wrapping_add(self.config.phase_increment[sign as usize]); - - let scale = match self.config.signal { - Signal::Cosine => idsp::cossin(phase).0 >> 16, - Signal::Square => { - if sign { - i16::MIN as i32 - } else { - -(i16::MIN as i32) + Ok(match *value.signal { + s @ (Signal::Cosine | Signal::Square | Signal::Triangle) => { + Self::Periodic { + accu: AsymmetricAccu { + ftw2, + pow: (*value.phase * NYQUIST) as i32, + accu: 0, + count: *value.length, + }, + signal: s, + amp, } } - Signal::Triangle => i16::MIN as i32 + (phase >> 15).abs(), - Signal::WhiteNoise => self.rng.next_u32() as i32 >> 16, - }; - - // Calculate the final output result as an i16. - Some(((self.config.amplitude as i32 * scale) >> 15) as _) + Signal::SweptSine => Self::SweptSine { + sweep: AccuOsc::from( + SyncExpSweep::new( + (ftw * 2.0) as _, + *value.length, + (*value.interval / value.period) as u32, + ) + .or(Err(Error::Wrap))?, + ) + .fuse(), + amp, + }, + Signal::WhiteNoise => Self::WhiteNoise { + rng: XorShiftRng::from_seed([0; 16]), + count: *value.length, + amp, + }, + }) } } From 1e222bbbedabd65c729321979477986915d902ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 30 Oct 2024 01:13:23 +0000 Subject: [PATCH 02/21] stream: reduce max frame size --- src/net/data_stream.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/data_stream.rs b/src/net/data_stream.rs index 714ec57fb..d070a61b3 100644 --- a/src/net/data_stream.rs +++ b/src/net/data_stream.rs @@ -52,8 +52,8 @@ const FRAME_COUNT: usize = 4; // The size of each frame in bytes. // Ensure the resulting ethernet frame is within the MTU: -// 1500 MTU - 40 IP6 header - 8 UDP header -const FRAME_SIZE: usize = 1500 - 40 - 8; +// 1500 MTU - 40 IP6 header - 8 UDP header - 32 VPN - 20 IP4 +const FRAME_SIZE: usize = 1500 - 40 - 8 - 32 - 20; // The size of the frame queue must be at least as large as the number of frame buffers. Every // allocated frame buffer should fit in the queue. From 121c96fc2d82a78d814142135295a1461a236f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 30 Oct 2024 01:13:38 +0000 Subject: [PATCH 03/21] stream: refactor --- py/stabilizer/stream.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/py/stabilizer/stream.py b/py/stabilizer/stream.py index 66d423729..387a5bbc2 100644 --- a/py/stabilizer/stream.py +++ b/py/stabilizer/stream.py @@ -76,8 +76,7 @@ def to_traces(self): ] -class StabilizerStream(asyncio.DatagramProtocol): - """Stabilizer streaming receiver protocol""" +class Frame: # The magic header half-word at the start of each packet. magic = 0x057B header_fmt = struct.Struct(" Date: Wed, 30 Oct 2024 01:43:23 +0000 Subject: [PATCH 04/21] simplify stream --- hitl/streaming.py | 2 +- py/stabilizer/stream.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hitl/streaming.py b/hitl/streaming.py index 4d0799163..5ae0fe10c 100644 --- a/hitl/streaming.py +++ b/hitl/streaming.py @@ -63,7 +63,7 @@ async def _main(): try: logger.info("Testing stream reception") _transport, stream = await StabilizerStream.open( - args.ip, args.port, args.broker + args.port, args.ip, args.broker ) loss = await measure(stream, args.duration) if loss > args.max_loss: diff --git a/py/stabilizer/stream.py b/py/stabilizer/stream.py index 387a5bbc2..2992fff95 100644 --- a/py/stabilizer/stream.py +++ b/py/stabilizer/stream.py @@ -101,7 +101,7 @@ class StabilizerStream(asyncio.DatagramProtocol): """Stabilizer streaming receiver protocol""" @classmethod - async def open(cls, addr, port, broker, maxsize=1): + async def open(cls, port=9293, addr="0.0.0.0", broker=None, maxsize=1): """Open a UDP socket and start receiving frames""" loop = asyncio.get_running_loop() sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) @@ -121,7 +121,7 @@ async def open(cls, addr, port, broker, maxsize=1): group = socket.inet_aton(addr) iface = socket.inet_aton(get_local_ip(broker)) sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, group + iface) - sock.bind(('', port)) + sock.bind(("", port)) else: sock.bind((addr, port)) @@ -204,7 +204,7 @@ async def main(): logging.basicConfig(level=logging.INFO) _transport, stream = await StabilizerStream.open( - args.host, args.port, args.broker, args.maxsize) + args.port, args.host, args.broker, args.maxsize) await measure(stream, args.duration) From 46214fb263432f8fadf63a513b44f0a075d785ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 14 Nov 2024 13:09:58 +0000 Subject: [PATCH 05/21] bump cc --- Cargo.lock | 371 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 313 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c49b0c81..1a7caa76d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,9 +95,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.31" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -131,22 +131,22 @@ dependencies = [ [[package]] name = "cortex-m-rt" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1" +checksum = "801d4dec46b34c299ccf6b036717ae0fce602faa4f4fe816d9013b9a7c9f5ba6" dependencies = [ "cortex-m-rt-macros", ] [[package]] name = "cortex-m-rt-macros" -version = "0.7.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" +checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] @@ -176,7 +176,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -187,7 +187,18 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.87", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -287,7 +298,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -383,9 +394,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "heapless" @@ -418,6 +429,124 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -426,12 +555,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -470,9 +610,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libgit2-sys" @@ -488,9 +628,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libz-sys" @@ -504,6 +644,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lm75" version = "0.2.0" @@ -558,15 +704,16 @@ dependencies = [ [[package]] name = "miniconf" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75e453c8c2bdb4367152a3057eeb3dc4cc2346c4d9d7985a76d27b2b070d46c3" +checksum = "04b8f0e5e85b9aba6daeaabb5dd80ae2d97340ccfd54f6eeaf3c3c077301ccfe" dependencies = [ "itoa", "miniconf_derive", "postcard", "serde", "serde-json-core", + "thiserror", ] [[package]] @@ -578,7 +725,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -745,7 +892,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -900,7 +1047,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1018,9 +1165,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.213" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -1038,13 +1185,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1067,7 +1214,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1101,6 +1248,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "smlang" version = "0.6.0" @@ -1298,7 +1451,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1314,9 +1467,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -1335,6 +1488,17 @@ dependencies = [ "vcell", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "tca9539" version = "0.2.1" @@ -1347,31 +1511,40 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.8.0" +name = "thiserror" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" dependencies = [ - "tinyvec_macros", + "thiserror-impl", ] [[package]] -name = "tinyvec_macros" -version = "0.1.1" +name = "thiserror-impl" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] [[package]] -name = "ufmt-write" -version = "0.1.0" +name = "tinystr" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] [[package]] -name = "unicode-bidi" -version = "0.3.17" +name = "ufmt-write" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" +checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" [[package]] name = "unicode-ident" @@ -1379,20 +1552,11 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", @@ -1421,6 +1585,18 @@ dependencies = [ "usb-device", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "varint-rs" version = "2.2.0" @@ -1460,6 +1636,18 @@ dependencies = [ "vcell", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "yafnv" version = "3.0.0" @@ -1468,3 +1656,70 @@ checksum = "a98cd19b5e3fbcda406d58efc9f5cb2d6e82e381708d52f357b3b3cfb19559b1" dependencies = [ "num-traits", ] + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] From cd6fd7a67b3efe046bbd87c077376804f1f5e13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 14 Nov 2024 13:09:58 +0000 Subject: [PATCH 06/21] swept sine signal generator, bump dependencies --- Cargo.lock | 371 ++++++++++++++++++++++++++----- src/bin/dual-iir.rs | 60 +---- src/bin/lockin.rs | 20 +- src/hardware/signal_generator.rs | 14 +- 4 files changed, 343 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c49b0c81..1a7caa76d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,9 +95,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.31" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -131,22 +131,22 @@ dependencies = [ [[package]] name = "cortex-m-rt" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1" +checksum = "801d4dec46b34c299ccf6b036717ae0fce602faa4f4fe816d9013b9a7c9f5ba6" dependencies = [ "cortex-m-rt-macros", ] [[package]] name = "cortex-m-rt-macros" -version = "0.7.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" +checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] @@ -176,7 +176,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -187,7 +187,18 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.87", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -287,7 +298,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -383,9 +394,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "heapless" @@ -418,6 +429,124 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -426,12 +555,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -470,9 +610,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libgit2-sys" @@ -488,9 +628,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libz-sys" @@ -504,6 +644,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lm75" version = "0.2.0" @@ -558,15 +704,16 @@ dependencies = [ [[package]] name = "miniconf" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75e453c8c2bdb4367152a3057eeb3dc4cc2346c4d9d7985a76d27b2b070d46c3" +checksum = "04b8f0e5e85b9aba6daeaabb5dd80ae2d97340ccfd54f6eeaf3c3c077301ccfe" dependencies = [ "itoa", "miniconf_derive", "postcard", "serde", "serde-json-core", + "thiserror", ] [[package]] @@ -578,7 +725,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -745,7 +892,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -900,7 +1047,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1018,9 +1165,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.213" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -1038,13 +1185,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1067,7 +1214,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1101,6 +1248,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "smlang" version = "0.6.0" @@ -1298,7 +1451,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.85", + "syn 2.0.87", ] [[package]] @@ -1314,9 +1467,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -1335,6 +1488,17 @@ dependencies = [ "vcell", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "tca9539" version = "0.2.1" @@ -1347,31 +1511,40 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.8.0" +name = "thiserror" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" dependencies = [ - "tinyvec_macros", + "thiserror-impl", ] [[package]] -name = "tinyvec_macros" -version = "0.1.1" +name = "thiserror-impl" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] [[package]] -name = "ufmt-write" -version = "0.1.0" +name = "tinystr" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] [[package]] -name = "unicode-bidi" -version = "0.3.17" +name = "ufmt-write" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" +checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" [[package]] name = "unicode-ident" @@ -1379,20 +1552,11 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", @@ -1421,6 +1585,18 @@ dependencies = [ "usb-device", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "varint-rs" version = "2.2.0" @@ -1460,6 +1636,18 @@ dependencies = [ "vcell", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "yafnv" version = "3.0.0" @@ -1468,3 +1656,70 @@ checksum = "a98cd19b5e3fbcda406d58efc9f5cb2d6e82e381708d52f357b3b3cfb19559b1" dependencies = [ "num-traits", ] + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index a6582add4..ef51a705d 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -40,7 +40,6 @@ use mutex_trait::prelude::*; use idsp::iir; -use stabilizer::hardware::signal_generator::SourceConfig; use stabilizer::{ hardware::{ self, @@ -107,14 +106,6 @@ impl serial_settings::Settings for Settings { #[derive(Clone, Debug, Tree, Serialize, Deserialize)] pub struct DualIir { /// Configure the Analog Front End (AFE) gain. - /// - /// # Path - /// `afe/` - /// - /// * `` specifies which channel to configure. `` := [0, 1] - /// - /// # Value - /// Any of the variants of [Gain] enclosed in double quotes. afe: [Leaf; 2], /// Configure the IIR filter parameters. @@ -128,52 +119,25 @@ pub struct DualIir { /// See [iir::Biquad] iir_ch: [[Leaf>; IIR_CASCADE_LENGTH]; 2], - /// Specified true if DI1 should be used as a "hold" input. - /// - /// # Path - /// `allow_hold` - /// - /// # Value - /// "true" or "false" + /// Use DI0/1 to HOLD the biquad. allow_hold: Leaf, - /// Specified true if "hold" should be forced regardless of DI1 state and hold allowance. - /// - /// # Path - /// `force_hold` - /// - /// # Value - /// "true" or "false" + /// Force the biquad to HOLD. force_hold: Leaf, - /// Specifies the telemetry output period in seconds. - /// - /// # Path - /// `telemetry_period` - /// - /// # Value - /// Any non-zero value less than 65536. - telemetry_period: Leaf, + /// Telemetry output period in seconds. + telemetry_period: Leaf, - /// Specifies the target for data streaming. - /// - /// # Path - /// `stream` + /// Target IP and port for UDP streaming. + /// + /// Can be multicast. /// /// # Value /// See [StreamTarget#miniconf] stream: Leaf, - /// Specifies the config for signal generators to add on to DAC0/DAC1 outputs. - /// - /// # Path - /// `source/` - /// - /// * `` specifies which channel to configure. `` := [0, 1] - /// - /// # Value - /// See [signal_generator::BasicConfig#miniconf] - source: [signal_generator::SourceConfig; 2], + /// Signal generator configuration to add to the DAC0/DAC1 outputs + source: [signal_generator::Config; 2], trigger: Leaf, } @@ -183,7 +147,7 @@ impl Default for DualIir { let mut i = iir::Biquad::IDENTITY; i.set_min(-SCALE); i.set_max(SCALE); - let mut source = SourceConfig::default(); + let mut source = signal_generator::Config::default(); source.period = SAMPLE_PERIOD; source.scale = DacCode::FULL_SCALE; Self { @@ -201,7 +165,7 @@ impl Default for DualIir { // Force suppress filter output updates. force_hold: false.into(), // The default telemetry period in seconds. - telemetry_period: 10.into(), + telemetry_period: 10.0.into(), source: [source; 2], trigger: false.into(), @@ -504,7 +468,7 @@ mod app { )) }); - Systick::delay((telemetry_period as u32).secs()).await; + Systick::delay(((telemetry_period*1000.0) as u32).millis()).await; } } diff --git a/src/bin/lockin.rs b/src/bin/lockin.rs index db0ebaeb4..9d7d1d233 100644 --- a/src/bin/lockin.rs +++ b/src/bin/lockin.rs @@ -302,14 +302,18 @@ mod app { settings: stabilizer.settings, }; - let signal_config = signal_generator::Config { - // Same frequency as batch size. - phase_increment: [1 << (32 - BATCH_SIZE_LOG2); 2], - // 1V Amplitude - amplitude: DacCode::try_from(1.0).unwrap().into(), - signal: signal_generator::Signal::Cosine, - phase_offset: 0, + let source = signal_generator::AsymmetricAccu { + }; + //::try_from_config(&signal_config).unwrap() + // let signal_config = signal_generator::Config { + // // Same frequency as batch size. + // phase_increment: [1 << (32 - BATCH_SIZE_LOG2); 2], + // // 1V Amplitude + // amplitude: DacCode::try_from(1.0).unwrap().into(), + // signal: signal_generator::Signal::Cosine, + // phase_offset: 0, + // }; let mut local = Local { usb_terminal: stabilizer.usb_serial, @@ -322,7 +326,7 @@ mod app { pll: RPLL::new(SAMPLE_TICKS_LOG2 + BATCH_SIZE_LOG2), lockin: idsp::Lockin::default(), - source: signal_generator::SignalGenerator::new(signal_config), + source, generator, cpu_temp_sensor: stabilizer.temperature_sensor, diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index f9e1d4b5c..4bc9598fc 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -1,5 +1,3 @@ -use core::iter::Fuse; - use idsp::{AccuOsc, SyncExpSweep}; use miniconf::{Leaf, Tree}; use rand_core::{RngCore, SeedableRng}; @@ -36,7 +34,7 @@ impl Signal { /// Basic configuration for a generated signal. #[derive(Copy, Clone, Debug, Tree, Serialize, Deserialize)] -pub struct SourceConfig { +pub struct Config { /// The signal type that should be generated. See [Signal] variants. signal: Leaf, @@ -71,7 +69,7 @@ pub struct SourceConfig { pub scale: f32, } -impl Default for SourceConfig { +impl Default for Config { fn default() -> Self { Self { frequency: 1.0e3.into(), @@ -138,7 +136,7 @@ pub enum Error { #[derive(Clone, Debug)] pub enum Source { SweptSine { - sweep: Fuse>, + sweep: core::iter::Fuse>, amp: Scaler, }, Periodic { @@ -176,7 +174,7 @@ impl Iterator for Source { impl Source { /// Convert from SI config - pub fn try_from_config(value: &SourceConfig) -> Result { + pub fn try_from_config(value: &Config) -> Result { if !(0.0..1.0).contains(&*value.symmetry) { return Err(Error::Symmetry); } @@ -219,7 +217,7 @@ impl Source { }; Ok(match *value.signal { - s @ (Signal::Cosine | Signal::Square | Signal::Triangle) => { + signal @ (Signal::Cosine | Signal::Square | Signal::Triangle) => { Self::Periodic { accu: AsymmetricAccu { ftw2, @@ -227,7 +225,7 @@ impl Source { accu: 0, count: *value.length, }, - signal: s, + signal, amp, } } From 50a07dec5d590ff0a283f358d82af153588edc28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 14 Nov 2024 13:17:01 +0000 Subject: [PATCH 07/21] bump deps --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b8932646d..d314884fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,7 +147,6 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.87", - "syn 2.0.85", ] [[package]] From 6de15396da80aadff0683cf45f74f15b18ce92ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 20 Nov 2024 21:43:21 +0000 Subject: [PATCH 08/21] rename --- src/hardware/signal_generator.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index 4bc9598fc..25863e4a0 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -88,7 +88,7 @@ impl Default for Config { #[derive(Clone, Debug)] pub struct AsymmetricAccu { - ftw2: [i32; 2], + ftw: [i32; 2], pow: i32, accu: i32, count: u32, @@ -98,7 +98,7 @@ impl Iterator for AsymmetricAccu { type Item = i32; fn next(&mut self) -> Option { let sign = self.accu.is_negative(); - self.accu = self.accu.wrapping_add(self.ftw2[sign as usize]); + self.accu = self.accu.wrapping_add(self.ftw[sign as usize]); self.count .checked_sub(sign as u32 ^ self.accu.is_negative() as u32) .map(|c| { @@ -180,20 +180,20 @@ impl Source { } const NYQUIST: f32 = (1u32 << 31) as _; - let ftw = *value.frequency * value.period * NYQUIST; - if !(0.0..2.0 * NYQUIST).contains(&ftw) { + let ftw0 = *value.frequency * value.period * NYQUIST; + if !(0.0..2.0 * NYQUIST).contains(&ftw0) { return Err(Error::Frequency); } // Clip both frequency tuning words to within Nyquist before rounding. - let ftw2 = [ - if *value.symmetry * NYQUIST > ftw { - ftw / *value.symmetry + let ftw = [ + if *value.symmetry * NYQUIST > ftw0 { + ftw0 / *value.symmetry } else { NYQUIST } as i32, - if (1.0 - *value.symmetry) * NYQUIST > ftw { - ftw / (1.0 - *value.symmetry) + if (1.0 - *value.symmetry) * NYQUIST > ftw0 { + ftw0 / (1.0 - *value.symmetry) } else { NYQUIST } as i32, @@ -220,7 +220,7 @@ impl Source { signal @ (Signal::Cosine | Signal::Square | Signal::Triangle) => { Self::Periodic { accu: AsymmetricAccu { - ftw2, + ftw, pow: (*value.phase * NYQUIST) as i32, accu: 0, count: *value.length, @@ -232,7 +232,7 @@ impl Source { Signal::SweptSine => Self::SweptSine { sweep: AccuOsc::from( SyncExpSweep::new( - (ftw * 2.0) as _, + (ftw0 * 2.0) as _, *value.length, (*value.interval / value.period) as u32, ) From 1dd196334703042298922d5d40a552e573abdaeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 21 Nov 2024 10:53:43 +0100 Subject: [PATCH 09/21] deps, miniconf patch --- Cargo.lock | 68 +++++++++++++++++++++++++----------------------------- Cargo.toml | 3 +++ 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a7caa76d..e06514472 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,9 +77,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" [[package]] name = "byteorder" @@ -146,7 +146,7 @@ checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -176,7 +176,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -187,7 +187,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -198,7 +198,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -298,7 +298,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -544,7 +544,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -595,9 +595,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "jobserver" @@ -610,9 +610,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libgit2-sys" @@ -704,9 +704,7 @@ dependencies = [ [[package]] name = "miniconf" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04b8f0e5e85b9aba6daeaabb5dd80ae2d97340ccfd54f6eeaf3c3c077301ccfe" +version = "0.17.2" dependencies = [ "itoa", "miniconf_derive", @@ -718,21 +716,17 @@ dependencies = [ [[package]] name = "miniconf_derive" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86704131b3dad62adfcee4cc7cc314778465976e80a515b64918ee81681424ff" +version = "0.17.2" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "miniconf_mqtt" version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c05e73e94df6dcfce14ac82ff3ed54ce24f77030f9edb355f2b51d42e605d65" dependencies = [ "embedded-io", "heapless 0.8.0", @@ -892,7 +886,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -977,9 +971,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" dependencies = [ "unicode-ident", ] @@ -1047,7 +1041,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1191,7 +1185,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1214,7 +1208,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1451,7 +1445,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1467,9 +1461,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -1496,7 +1490,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1527,7 +1521,7 @@ checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1548,9 +1542,9 @@ checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "url" @@ -1677,7 +1671,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -1698,7 +1692,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -1721,5 +1715,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] diff --git a/Cargo.toml b/Cargo.toml index 3f0baf758..39a6cea66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,3 +99,6 @@ codegen-units = 1 [patch.crates-io] idsp = { path = "../idsp" } +miniconf = {path = "../miniconf/miniconf"} +miniconf_mqtt = {path = "../miniconf/miniconf_mqtt"} +miniconf_derive = {path = "../miniconf/miniconf_derive"} From 3c1dcb8560d2be993b33a77c7f079c54d60ab10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 21 Nov 2024 10:04:29 +0000 Subject: [PATCH 10/21] xorshift: default --- src/hardware/signal_generator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index 25863e4a0..974df6c37 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -242,7 +242,7 @@ impl Source { amp, }, Signal::WhiteNoise => Self::WhiteNoise { - rng: XorShiftRng::from_seed([0; 16]), + rng: XorShiftRng::from_seed(Default::default()), count: *value.length, amp, }, From 14b01ec1e36e92c31600fbe31e06040aa723834d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 22 Nov 2024 14:57:50 +0000 Subject: [PATCH 11/21] bump miniconf --- Cargo.lock | 16 +++++++++++----- Cargo.toml | 7 ++----- serial-settings/Cargo.toml | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e06514472..03e1db3cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -704,7 +704,9 @@ dependencies = [ [[package]] name = "miniconf" -version = "0.17.2" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1503186d3a89d933300e616a919e10b089a8c3379956589d009556ed5ea1b3c4" dependencies = [ "itoa", "miniconf_derive", @@ -716,7 +718,9 @@ dependencies = [ [[package]] name = "miniconf_derive" -version = "0.17.2" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbe8f870567988a09000856955ae194f2dfb1ff73ff615988a44d0fc2385df7b" dependencies = [ "darling", "proc-macro2", @@ -726,7 +730,9 @@ dependencies = [ [[package]] name = "miniconf_mqtt" -version = "0.17.0" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18beed978188ff9ec7ce6f1a10a0d0e6d821fb4742021498662f4ddaa8e02892" dependencies = [ "embedded-io", "heapless 0.8.0", @@ -971,9 +977,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index 39a6cea66..5428685df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,8 +66,8 @@ minimq = "0.9.0" usb-device = "0.3.2" usbd-serial = "0.2" # Keep this synced with the miniconf version in py/setup.py -miniconf = { version = "0.17", features = ["json-core", "derive", "postcard"] } -miniconf_mqtt = { version = "0.17" } +miniconf = { version = "0.18", features = ["json-core", "derive", "postcard"] } +miniconf_mqtt = { version = "0.18" } tca9539 = "0.2" smoltcp-nal = { version = "0.5", features = ["shared-stack"] } postcard = "1" @@ -99,6 +99,3 @@ codegen-units = 1 [patch.crates-io] idsp = { path = "../idsp" } -miniconf = {path = "../miniconf/miniconf"} -miniconf_mqtt = {path = "../miniconf/miniconf_mqtt"} -miniconf_derive = {path = "../miniconf/miniconf_derive"} diff --git a/serial-settings/Cargo.toml b/serial-settings/Cargo.toml index 530efd67c..74657e862 100644 --- a/serial-settings/Cargo.toml +++ b/serial-settings/Cargo.toml @@ -17,7 +17,7 @@ repository = "https://github.com/quartiq/stabilizer" maintenance = { status = "actively-developed" } [dependencies] -miniconf = { version = "0.17", features = ["json-core", "postcard"] } +miniconf = { version = "0.18", features = ["json-core", "postcard"] } menu = { version = "0.6", features = ["echo"], git = "https://github.com/rust-embedded-community/menu.git" } heapless = "0.8" embedded-io = "0.6" From 9c91337f14d3f4913853f991765c8cd79e56984b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Sun, 24 Nov 2024 12:51:48 +0000 Subject: [PATCH 12/21] merge --- Cargo.lock | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41c2d35b6..7c26eb206 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -646,9 +646,9 @@ dependencies = [ [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lm75" @@ -714,7 +714,6 @@ dependencies = [ "serde", "serde-json-core", "thiserror", - "thiserror", ] [[package]] @@ -937,9 +936,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "postcard" @@ -1167,10 +1166,8 @@ dependencies = [ [[package]] name = "serde" version = "1.0.215" -version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -1189,10 +1186,8 @@ dependencies = [ [[package]] name = "serde_derive" version = "1.0.215" -version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -1546,8 +1541,8 @@ dependencies = [ ] [[package]] -name = "thiserror" -version = "2.0.3" +name = "ufmt-write" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" @@ -1559,9 +1554,9 @@ checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -1664,9 +1659,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -1676,9 +1671,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", @@ -1688,18 +1683,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", From 04c04b25a79e8d5863d56f93f376629c2cfb069d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 22 Nov 2024 20:26:00 +0000 Subject: [PATCH 13/21] misc dual iir fmt --- src/bin/dual-iir.rs | 4 ++-- src/bin/lockin.rs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index ef51a705d..fc93c6ec7 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -129,7 +129,7 @@ pub struct DualIir { telemetry_period: Leaf, /// Target IP and port for UDP streaming. - /// + /// /// Can be multicast. /// /// # Value @@ -468,7 +468,7 @@ mod app { )) }); - Systick::delay(((telemetry_period*1000.0) as u32).millis()).await; + Systick::delay(((telemetry_period * 1000.0) as u32).millis()).await; } } diff --git a/src/bin/lockin.rs b/src/bin/lockin.rs index 9d7d1d233..da484a252 100644 --- a/src/bin/lockin.rs +++ b/src/bin/lockin.rs @@ -302,9 +302,7 @@ mod app { settings: stabilizer.settings, }; - let source = signal_generator::AsymmetricAccu { - - }; + let source = signal_generator::AsymmetricAccu {}; //::try_from_config(&signal_config).unwrap() // let signal_config = signal_generator::Config { // // Same frequency as batch size. From 431c0b4b3e4c082f8fd1113d40407b3c89f8a5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 26 Nov 2024 13:19:34 +0000 Subject: [PATCH 14/21] deps: update --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 806ed809f..0496482fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ dependencies = [ "arbitrary-int", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -437,9 +437,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heapless" @@ -638,9 +638,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" @@ -653,9 +653,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.164" +version = "0.2.165" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e" [[package]] name = "libgit2-sys" From cc8dd46e5404a03db2074f98c7bdd8e13ec740b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 26 Dec 2024 20:23:18 +0000 Subject: [PATCH 15/21] lockin: new signal generator --- src/bin/lockin.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/bin/lockin.rs b/src/bin/lockin.rs index 1590b9909..3b9b52b80 100644 --- a/src/bin/lockin.rs +++ b/src/bin/lockin.rs @@ -28,7 +28,6 @@ #![no_main] use core::{ - convert::TryFrom, mem::MaybeUninit, sync::atomic::{fence, Ordering}, }; @@ -49,7 +48,6 @@ use stabilizer::{ dac::{Dac0Output, Dac1Output, DacCode}, hal, input_stamper::InputStamper, - signal_generator, timers::SamplingTimer, DigitalInput0, DigitalInput1, SerialTerminal, SystemTimer, Systick, UsbDevice, AFE0, AFE1, @@ -265,7 +263,7 @@ mod app { dacs: (Dac0Output, Dac1Output), pll: RPLL, lockin: idsp::Lockin>>, - source: signal_generator::SignalGenerator, + source: idsp::AccuOsc>, generator: FrameGenerator, cpu_temp_sensor: stabilizer::hardware::cpu_temp_sensor::CpuTempSensor, } @@ -302,16 +300,10 @@ mod app { settings: stabilizer.settings, }; - let source = signal_generator::AsymmetricAccu {}; - //::try_from_config(&signal_config).unwrap() - // let signal_config = signal_generator::Config { - // // Same frequency as batch size. - // phase_increment: [1 << (32 - BATCH_SIZE_LOG2); 2], - // // 1V Amplitude - // amplitude: DacCode::try_from(1.0).unwrap().into(), - // signal: signal_generator::Signal::Cosine, - // phase_offset: 0, - // }; + let source = idsp::AccuOsc::from(idsp::Accu::new( + 0, + 1 << (64 - BATCH_SIZE_LOG2), + )); let mut local = Local { usb_terminal: stabilizer.usb_serial, @@ -445,7 +437,7 @@ mod app { Conf::InPhase => output.re >> 16, Conf::Quadrature => output.im >> 16, - Conf::Modulation => source.next().unwrap() as i32, + Conf::Modulation => source.next().unwrap().re, }; *sample = DacCode::from(value as i16).0; From 683dadaef70d38cdcf99ad3ee262335044d6201f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 31 Dec 2024 14:59:51 +0000 Subject: [PATCH 16/21] bump idsp/sweptsine --- Cargo.lock | 3 ++- src/bin/lockin.rs | 9 ++++----- src/hardware/signal_generator.rs | 21 ++++++++++----------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f858ba60b..9769ca788 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ad9912" @@ -643,6 +643,7 @@ dependencies = [ "num-complex 0.4.6", "num-traits", "serde", + "thiserror", ] [[package]] diff --git a/src/bin/lockin.rs b/src/bin/lockin.rs index 3b9b52b80..d1c9870ba 100644 --- a/src/bin/lockin.rs +++ b/src/bin/lockin.rs @@ -28,6 +28,7 @@ #![no_main] use core::{ + iter, mem::MaybeUninit, sync::atomic::{fence, Ordering}, }; @@ -263,7 +264,7 @@ mod app { dacs: (Dac0Output, Dac1Output), pll: RPLL, lockin: idsp::Lockin>>, - source: idsp::AccuOsc>, + source: idsp::AccuOsc>, generator: FrameGenerator, cpu_temp_sensor: stabilizer::hardware::cpu_temp_sensor::CpuTempSensor, } @@ -300,10 +301,8 @@ mod app { settings: stabilizer.settings, }; - let source = idsp::AccuOsc::from(idsp::Accu::new( - 0, - 1 << (64 - BATCH_SIZE_LOG2), - )); + let source = + idsp::AccuOsc::new(iter::repeat(1i64 << (64 - BATCH_SIZE_LOG2))); let mut local = Local { usb_terminal: stabilizer.usb_serial, diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index 974df6c37..0f9f62986 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -1,4 +1,4 @@ -use idsp::{AccuOsc, SyncExpSweep}; +use idsp::{AccuOsc, Sweep}; use miniconf::{Leaf, Tree}; use rand_core::{RngCore, SeedableRng}; use rand_xorshift::XorShiftRng; @@ -58,8 +58,8 @@ pub struct Config { /// Number of half periods (periodic), octaves (sweep), or samples (noise), 0 for infinte length: Leaf, - /// Sweep interval in seconds per octave - interval: Leaf, + /// Sweep: cycles for the first octave + cycles: Leaf, /// Sample period #[tree(skip)] @@ -78,7 +78,7 @@ impl Default for Config { amplitude: 0.0.into(), phase: 0.0.into(), offset: 0.0.into(), - interval: 1.0.into(), + cycles: 1.into(), length: 0.into(), period: 1.0, scale: 1.0, @@ -136,7 +136,7 @@ pub enum Error { #[derive(Clone, Debug)] pub enum Source { SweptSine { - sweep: core::iter::Fuse>, + sweep: AccuOsc, amp: Scaler, }, Periodic { @@ -230,15 +230,14 @@ impl Source { } } Signal::SweptSine => Self::SweptSine { - sweep: AccuOsc::from( - SyncExpSweep::new( - (ftw0 * 2.0) as _, + sweep: AccuOsc::new( + Sweep::optimize( + (*value.frequency * value.period) as _, *value.length, - (*value.interval / value.period) as u32, + *value.cycles, ) .or(Err(Error::Wrap))?, - ) - .fuse(), + ), amp, }, Signal::WhiteNoise => Self::WhiteNoise { From 99fce2fc2fd8450b3e974f8c1f86f8cda7749456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 31 Dec 2024 16:25:41 +0000 Subject: [PATCH 17/21] sweptsine: juggle names --- src/hardware/signal_generator.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index 0f9f62986..71bd85532 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -55,11 +55,11 @@ pub struct Config { /// The initial phase of the period output signal in turns phase: Leaf, - /// Number of half periods (periodic), octaves (sweep), or samples (noise), 0 for infinte + /// Number of half periods (periodic), periods in the first octave (sweep), or samples (noise), 0 for infinte length: Leaf, /// Sweep: cycles for the first octave - cycles: Leaf, + octaves: Leaf, /// Sample period #[tree(skip)] @@ -78,7 +78,7 @@ impl Default for Config { amplitude: 0.0.into(), phase: 0.0.into(), offset: 0.0.into(), - cycles: 1.into(), + octaves: 1.into(), length: 0.into(), period: 1.0, scale: 1.0, @@ -233,8 +233,8 @@ impl Source { sweep: AccuOsc::new( Sweep::optimize( (*value.frequency * value.period) as _, + *value.octaves, *value.length, - *value.cycles, ) .or(Err(Error::Wrap))?, ), From 9acc189cedc3321fa4a0c53cd61e0a9c8c89aca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 2 Jan 2025 12:40:36 +0000 Subject: [PATCH 18/21] sweptsine: use machine units --- src/bin/dual-iir.rs | 2 +- src/hardware/signal_generator.rs | 39 ++++++++++++++--------------- src/net/data_stream.rs | 42 ++++++++++++++------------------ 3 files changed, 39 insertions(+), 44 deletions(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index b58d308b9..7a7a9d06f 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -400,7 +400,7 @@ mod app { .lock(|net, settings| net.update(&mut settings.dual_iir)) { NetworkState::SettingsChanged => { - settings_update::spawn().unwrap() + settings_update::spawn().unwrap(); } NetworkState::Updated => {} NetworkState::NoChange => { diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index 71bd85532..3c3353ac3 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -55,11 +55,14 @@ pub struct Config { /// The initial phase of the period output signal in turns phase: Leaf, - /// Number of half periods (periodic), periods in the first octave (sweep), or samples (noise), 0 for infinte + /// Number of half periods (periodic) or samples (sweep and noise), 0 for infinte length: Leaf, - /// Sweep: cycles for the first octave - octaves: Leaf, + /// Sweep: Number of cycles for the first octave + cycles: Leaf, + + /// Sweep: Sweep rate + rate: Leaf, /// Sample period #[tree(skip)] @@ -72,14 +75,15 @@ pub struct Config { impl Default for Config { fn default() -> Self { Self { - frequency: 1.0e3.into(), - symmetry: 0.5.into(), - signal: Signal::Cosine.into(), - amplitude: 0.0.into(), - phase: 0.0.into(), - offset: 0.0.into(), - octaves: 1.into(), - length: 0.into(), + frequency: Leaf(1.0e3), + symmetry: Leaf(0.5), + signal: Leaf(Signal::Cosine), + amplitude: Leaf(0.0), + phase: Leaf(0.0), + offset: Leaf(0.0), + cycles: Leaf(1), + rate: Leaf(0), + length: Leaf(0), period: 1.0, scale: 1.0, } @@ -230,14 +234,11 @@ impl Source { } } Signal::SweptSine => Self::SweptSine { - sweep: AccuOsc::new( - Sweep::optimize( - (*value.frequency * value.period) as _, - *value.octaves, - *value.length, - ) - .or(Err(Error::Wrap))?, - ), + sweep: AccuOsc::new(Sweep::new( + *value.rate, + ((*value.rate * *value.cycles) as i64) << 32, + *value.length as _, + )), amp, }, Signal::WhiteNoise => Self::WhiteNoise { diff --git a/src/net/data_stream.rs b/src/net/data_stream.rs index d070a61b3..fdbc28e4c 100644 --- a/src/net/data_stream.rs +++ b/src/net/data_stream.rs @@ -103,12 +103,6 @@ impl core::str::FromStr for StreamTarget { } } -impl core::fmt::Display for StreamTarget { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - self.0.fmt(f) - } -} - /// Specifies the format of streamed data #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, IntoPrimitive)] @@ -260,31 +254,31 @@ impl FrameGenerator { let sequence_number = self.sequence_number; self.sequence_number = self.sequence_number.wrapping_add(1); - if self.current_frame.is_none() { - if let Ok(buffer) = - FRAME_POOL.alloc([MaybeUninit::uninit(); FRAME_SIZE]) - { - self.current_frame.replace(StreamFrame::new( - buffer, - self.format, - sequence_number, - )); - } else { - return; + let current_frame = match self.current_frame.as_mut() { + None => { + if let Ok(buffer) = + FRAME_POOL.alloc([MaybeUninit::uninit(); FRAME_SIZE]) + { + self.current_frame.insert(StreamFrame::new( + buffer, + self.format, + sequence_number, + )) + } else { + return; + } } - } - - // Note(unwrap): We ensure the frame is present above. - let current_frame = self.current_frame.as_mut().unwrap(); + Some(frame) => frame, + }; let len = current_frame.add_batch(func); if current_frame.is_full(len) { // Note(unwrap): The queue is designed to be at least as large as the frame buffer // count, so this enqueue should always succeed. - self.queue - .enqueue(self.current_frame.take().unwrap()) - .unwrap(); + if let Some(frame) = self.current_frame.take() { + self.queue.enqueue(frame).unwrap(); + } } } } From c788c2c5bc01f2b9cb205454bd6c6e2b45dceb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Mon, 6 Jan 2025 12:57:04 +0000 Subject: [PATCH 19/21] sweptsine: port --- src/hardware/signal_generator.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hardware/signal_generator.rs b/src/hardware/signal_generator.rs index 3c3353ac3..03a78f2bd 100644 --- a/src/hardware/signal_generator.rs +++ b/src/hardware/signal_generator.rs @@ -1,3 +1,5 @@ +use core::iter::Take; + use idsp::{AccuOsc, Sweep}; use miniconf::{Leaf, Tree}; use rand_core::{RngCore, SeedableRng}; @@ -140,7 +142,7 @@ pub enum Error { #[derive(Clone, Debug)] pub enum Source { SweptSine { - sweep: AccuOsc, + sweep: Take>, amp: Scaler, }, Periodic { @@ -237,8 +239,8 @@ impl Source { sweep: AccuOsc::new(Sweep::new( *value.rate, ((*value.rate * *value.cycles) as i64) << 32, - *value.length as _, - )), + )) + .take(*value.length as _), amp, }, Signal::WhiteNoise => Self::WhiteNoise { From 42f9cbacef07d9ab5517662e722a68eff84a7982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 9 Jan 2025 16:20:14 +0000 Subject: [PATCH 20/21] idsp: use released 0.16 --- Cargo.lock | 4 +++- Cargo.toml | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39c673f6c..90ae99a1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -638,7 +638,9 @@ dependencies = [ [[package]] name = "idsp" -version = "0.15.1" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef18d83613898a86a398a5bb7fe15fd4d0b27c7e64fdad5ade81cbc6c19f6729" dependencies = [ "num-complex 0.4.6", "num-traits", diff --git a/Cargo.toml b/Cargo.toml index cd734c536..e7c7116c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ rtic = { version = "2.1", features = ["thumbv7-backend"] } rtic-monotonics = { version = "2.0", features = ["cortex-m-systick"] } num_enum = { version = "0.7.3", default-features = false } paste = "1" -idsp = "0.15.1" +idsp = "0.16.0" ad9959 = { path = "ad9959", version = "0.3.0" } serial-settings = { version = "0.2", path = "serial-settings" } mcp230xx = "1.0" @@ -112,6 +112,3 @@ opt-level = 3 debug = true lto = true codegen-units = 1 - -[patch.crates-io] -idsp = { path = "../idsp" } From 83d47a91708bfdfa7266b943b087bb24f67c5fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 9 Jan 2025 16:27:39 +0000 Subject: [PATCH 21/21] py: lint, docs, formatting --- py/stabilizer/__init__.py | 5 +- py/stabilizer/plot_iir_frequency_response.py | 5 +- py/stabilizer/stream.py | 59 +++++++++++--------- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/py/stabilizer/__init__.py b/py/stabilizer/__init__.py index dd86d1020..bfc9b8bc3 100644 --- a/py/stabilizer/__init__.py +++ b/py/stabilizer/__init__.py @@ -2,13 +2,13 @@ """Stabilizer data conversion and streaming utilities""" # Sample period in seconds, default 100 MHz timer clock and a reload value of 128 -SAMPLE_PERIOD = 10e-9*128 +SAMPLE_PERIOD = 10e-9 * 128 # The number of DAC LSB codes per volt on Stabilizer outputs. DAC_LSB_PER_VOLT = (1 << 16) / (4.096 * 5) # The number of volts per ADC LSB. -ADC_VOLTS_PER_LSB = (5.0 / 2.0 * 4.096) / (1 << 15) +ADC_VOLTS_PER_LSB = (5.0 / 2.0 * 4.096) / (1 << 15) # The number of volts per DAC LSB. DAC_VOLTS_PER_LSB = 1 / DAC_LSB_PER_VOLT @@ -17,6 +17,7 @@ # DAC. DAC_FULL_SCALE = float(0x7FFF / DAC_LSB_PER_VOLT) + def voltage_to_machine_units(voltage): """Convert a voltage to machine units.""" code = int(round(voltage * DAC_LSB_PER_VOLT)) diff --git a/py/stabilizer/plot_iir_frequency_response.py b/py/stabilizer/plot_iir_frequency_response.py index 6f2899c37..cc844c091 100644 --- a/py/stabilizer/plot_iir_frequency_response.py +++ b/py/stabilizer/plot_iir_frequency_response.py @@ -11,8 +11,7 @@ from stabilizer.iir_coefficients import get_filters # disable warnings about short variable names and similar code -#pylint: disable=invalid-name, duplicate-code, redefined-builtin - +# pylint: disable=invalid-name, duplicate-code, redefined-builtin def _main(): @@ -52,7 +51,7 @@ def _main(): if forward_gain == 0 and args.x_offset != 0: print("Filter has no DC gain but x_offset is non-zero") - f = np.logspace(-8.5, 0, 1024, endpoint=False)*(.5/args.sample_period) + f = np.logspace(-8.5, 0, 1024, endpoint=False) * (0.5 / args.sample_period) f, h = signal.freqz( coefficients[:3], np.r_[1, [-c for c in coefficients[3:]]], diff --git a/py/stabilizer/stream.py b/py/stabilizer/stream.py index 2992fff95..7cdd9582c 100644 --- a/py/stabilizer/stream.py +++ b/py/stabilizer/stream.py @@ -1,4 +1,6 @@ #!/usr/bin/python3 +# pylint: disable=too-few-public-methods + """Stabilizer streaming receiver and parsers""" import argparse @@ -21,7 +23,7 @@ def wrap(wide): """Wrap to 32 bit integer""" - return wide & 0xffffffff + return wide & 0xFFFFFFFF def get_local_ip(remote): @@ -37,6 +39,7 @@ def get_local_ip(remote): class AdcDac: """Stabilizer default striming data format""" + format_id = 1 def __init__(self, header, body): @@ -69,14 +72,16 @@ def to_traces(self): """Convert the raw data to labelled Trace instances""" data = self.to_mu() return [ - Trace(data[0], scale=DAC_VOLTS_PER_LSB, label='ADC0'), - Trace(data[1], scale=DAC_VOLTS_PER_LSB, label='ADC1'), - Trace(data[2], scale=DAC_VOLTS_PER_LSB, label='DAC0'), - Trace(data[3], scale=DAC_VOLTS_PER_LSB, label='DAC1') + Trace(data[0], scale=DAC_VOLTS_PER_LSB, label="ADC0"), + Trace(data[1], scale=DAC_VOLTS_PER_LSB, label="ADC1"), + Trace(data[2], scale=DAC_VOLTS_PER_LSB, label="DAC0"), + Trace(data[3], scale=DAC_VOLTS_PER_LSB, label="DAC1"), ] class Frame: + """Stream frame constisting of a header and multiple data batches""" + # The magic header half-word at the start of each packet. magic = 0x057B header_fmt = struct.Struct("