pounder patch: for stabilizer commit 39279e2
This commit is contained in:
parent
22dd4d1dc6
commit
2d71b794ff
@ -8,8 +8,8 @@ let
|
||||
"thumbv7em-none-eabihf"
|
||||
];
|
||||
rustManifest = pkgs.fetchurl {
|
||||
url = "https://static.rust-lang.org/dist/2024-11-28/channel-rust-stable.toml";
|
||||
sha256 = "b3544fb72bc3189697fc18ac2d3fa27d57ee8434f59d9919d4d70af2c6f010b3";
|
||||
url = "https://static.rust-lang.org/dist/2025-05-15/channel-rust-stable.toml";
|
||||
sha256 = "sha256-KUm16pHj+cRedf8vxs/Hd2YWxpOrWZ7UOrwhILdSJBU=";
|
||||
};
|
||||
rustChannelOfTargets = _channel: _date: targets:
|
||||
(pkgs.lib.rustLib.fromManifestFile rustManifest {
|
||||
@ -69,9 +69,14 @@ in
|
||||
cargoDepsName = "stabilizer";
|
||||
src = <stabilizerSrc>;
|
||||
patchPhase = ''
|
||||
patch -p1 < ${./pounder-725.diff}
|
||||
patch -p1 < ${./pounder-39279e2.diff}
|
||||
'';
|
||||
doCheck = false;
|
||||
outputHashes = {
|
||||
"serde-reflection-0.5.0" = "sha256-87vME2qufkuJV29hKQa+2ALbzI+oGFogsPACYBZWO/g=";
|
||||
"smoltcp-nal-0.6.0" = "sha256-hQhReEqbQcKxUe07jqNRL27AbaCKyy+OGH4XKn0gUjU=";
|
||||
"stm32h7xx-hal-0.16.0" = "sha256-DMEZzNooOY1NJpziPkuZJXY+LyrTkUWibyhM9Azu/ks=";
|
||||
};
|
||||
} // value))) {
|
||||
dual-iir = {};
|
||||
dual-iir-pounder_v1_0 = {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs
|
||||
index bb66ddc4..f72a36b1 100644
|
||||
index 59e5137..6c9825a 100644
|
||||
--- a/ad9959/src/lib.rs
|
||||
+++ b/ad9959/src/lib.rs
|
||||
@@ -2,8 +2,24 @@
|
||||
|
||||
use arbitrary_int::{u10, u14, u2, u24, u3, u4, u5, Number};
|
||||
use arbitrary_int::{traits::Integer, u2, u3, u4, u5, u10, u14, u24};
|
||||
use bitbybit::{bitenum, bitfield};
|
||||
+use core::ops::Range;
|
||||
use embedded_hal::{blocking::delay::DelayUs, digital::v2::OutputPin};
|
||||
@ -27,15 +27,6 @@ index bb66ddc4..f72a36b1 100644
|
||||
/// A trait that allows a HAL to provide a means of communicating with the AD9959.
|
||||
pub trait Interface {
|
||||
type Error;
|
||||
@@ -234,7 +250,7 @@ impl<I: Interface> Ad9959<I> {
|
||||
///
|
||||
/// Returns:
|
||||
/// The actual frequency configured for the internal system clock.
|
||||
- fn set_system_clock(
|
||||
+ pub fn set_system_clock(
|
||||
&mut self,
|
||||
reference_clock_frequency: f32,
|
||||
multiplier: u5,
|
||||
@@ -485,6 +501,109 @@ impl<I: Interface> Ad9959<I> {
|
||||
}
|
||||
}
|
||||
@ -147,30 +138,28 @@ index bb66ddc4..f72a36b1 100644
|
||||
pub struct ProfileSerializer {
|
||||
mode: Mode,
|
||||
diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs
|
||||
index e7596341..71eee420 100644
|
||||
index c6eb802..9fba6a0 100644
|
||||
--- a/src/bin/dual-iir.rs
|
||||
+++ b/src/bin/dual-iir.rs
|
||||
@@ -28,6 +28,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
+use core::mem::{MaybeUninit, size_of};
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
use miniconf::{Leaf, StrLeaf, Tree};
|
||||
|
||||
@@ -46,6 +47,8 @@ use stabilizer::{
|
||||
dac::{Dac0Output, Dac1Output, DacCode},
|
||||
hal,
|
||||
signal_generator::{self, Source},
|
||||
@@ -35,7 +35,13 @@ use idsp::iir;
|
||||
use platform::{AppSettings, NetSettings};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use signal_generator::{self, Source};
|
||||
-use stabilizer::convert::{AdcCode, DacCode, Gain};
|
||||
+use stabilizer::{
|
||||
+ convert::{AdcCode, DacCode, Gain},
|
||||
+ hardware:: {
|
||||
+ pounder::{ClockConfig, PounderConfig},
|
||||
+ setup::PounderDevices as Pounder,
|
||||
timers::SamplingTimer,
|
||||
DigitalInput0, DigitalInput1, Pgia, SerialTerminal, SystemTimer,
|
||||
Systick, UsbDevice,
|
||||
@@ -194,6 +197,15 @@ pub struct DualIir {
|
||||
///
|
||||
+ setup::{Mezzanine, Pounder},
|
||||
+ }
|
||||
+};
|
||||
|
||||
// The number of cascaded IIR biquads per channel. Select 1 or 2!
|
||||
const IIR_CASCADE_LENGTH: usize = 1;
|
||||
@@ -173,6 +179,15 @@ pub struct DualIir {
|
||||
/// Can be multicast.
|
||||
stream: Leaf<StreamTarget>,
|
||||
#[tree(with=miniconf::leaf)]
|
||||
stream: stream::Target,
|
||||
+ /// Specifies the config for pounder DDS clock configuration, DDS channels & attenuations
|
||||
+ ///
|
||||
+ /// # Path
|
||||
@ -182,16 +171,16 @@ index e7596341..71eee420 100644
|
||||
+ pounder: Option<PounderConfig>,
|
||||
}
|
||||
|
||||
impl DualIir {
|
||||
@@ -215,6 +227,7 @@ impl Default for DualIir {
|
||||
_trigger: Leaf(()),
|
||||
impl Default for DualIir {
|
||||
@@ -182,6 +197,7 @@ impl Default for DualIir {
|
||||
trigger: false,
|
||||
stream: Default::default(),
|
||||
ch: Default::default(),
|
||||
+ pounder: None.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,6 +251,7 @@ mod app {
|
||||
@@ -238,6 +254,7 @@ mod app {
|
||||
settings: Settings,
|
||||
active: [Active; 2],
|
||||
telemetry: TelemetryBuffer,
|
||||
@ -199,7 +188,7 @@ index e7596341..71eee420 100644
|
||||
}
|
||||
|
||||
#[local]
|
||||
@@ -248,6 +262,7 @@ mod app {
|
||||
@@ -248,6 +265,7 @@ mod app {
|
||||
afes: [Pgia; 2],
|
||||
adcs: (Adc0Input, Adc1Input),
|
||||
dacs: (Dac0Output, Dac1Output),
|
||||
@ -207,19 +196,23 @@ index e7596341..71eee420 100644
|
||||
generator: FrameGenerator,
|
||||
cpu_temp_sensor: stabilizer::hardware::cpu_temp_sensor::CpuTempSensor,
|
||||
}
|
||||
@@ -257,7 +272,7 @@ mod app {
|
||||
@@ -257,7 +275,7 @@ mod app {
|
||||
let clock = SystemTimer::new(|| Systick::now().ticks());
|
||||
|
||||
// Configure the microcontroller
|
||||
- let (stabilizer, _pounder) = hardware::setup::setup::<Settings, 9>(
|
||||
+ let (mut stabilizer, pounder) = hardware::setup::setup::<Settings, 9>(
|
||||
- let (stabilizer, _mezzanine, _eem) = hardware::setup::setup::<Settings>(
|
||||
+ let (mut stabilizer, mezzanine, _eem) = hardware::setup::setup::<Settings>(
|
||||
c.core,
|
||||
c.device,
|
||||
clock,
|
||||
@@ -276,6 +291,13 @@ mod app {
|
||||
@@ -276,6 +294,17 @@ mod app {
|
||||
|
||||
let generator = network.configure_streaming(StreamFormat::AdcDacData);
|
||||
let generator = network.configure_streaming(stream::Format::AdcDacData);
|
||||
|
||||
+ let pounder = match mezzanine {
|
||||
+ Mezzanine::Pounder(pounder) => Some(pounder),
|
||||
+ Mezzanine::None => None,
|
||||
+ };
|
||||
+ let dds_clock_state = pounder.as_ref().map(|_| ClockConfig::default());
|
||||
+ if pounder.is_some() {
|
||||
+ stabilizer.settings.dual_iir
|
||||
@ -230,15 +223,15 @@ index e7596341..71eee420 100644
|
||||
let shared = Shared {
|
||||
usb: stabilizer.usb,
|
||||
network,
|
||||
@@ -287,6 +309,7 @@ mod app {
|
||||
@@ -287,6 +316,7 @@ mod app {
|
||||
.map(|a| a.build().unwrap()),
|
||||
telemetry: TelemetryBuffer::default(),
|
||||
settings: stabilizer.settings,
|
||||
+ pounder
|
||||
+ pounder,
|
||||
};
|
||||
|
||||
let mut local = Local {
|
||||
@@ -296,6 +319,7 @@ mod app {
|
||||
@@ -296,6 +326,7 @@ mod app {
|
||||
afes: stabilizer.afes,
|
||||
adcs: stabilizer.adcs,
|
||||
dacs: stabilizer.dacs,
|
||||
@ -246,7 +239,7 @@ index e7596341..71eee420 100644
|
||||
generator,
|
||||
cpu_temp_sensor: stabilizer.temperature_sensor,
|
||||
};
|
||||
@@ -448,7 +472,7 @@ mod app {
|
||||
@@ -448,7 +479,7 @@ mod app {
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,8 +247,8 @@ index e7596341..71eee420 100644
|
||||
+ #[task(priority = 1, local=[afes, dds_clock_state], shared=[network, settings, active, pounder])]
|
||||
async fn settings_update(mut c: settings_update::Context) {
|
||||
c.shared.settings.lock(|settings| {
|
||||
c.local.afes[0].set_gain(*settings.dual_iir.ch[0].gain);
|
||||
@@ -490,31 +514,49 @@ mod app {
|
||||
c.local.afes[0].set_gain(settings.dual_iir.ch[0].gain);
|
||||
@@ -490,26 +521,42 @@ mod app {
|
||||
(a.run, a.biquad) = b;
|
||||
}
|
||||
});
|
||||
@ -270,10 +263,9 @@ index e7596341..71eee420 100644
|
||||
+ );
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
c.shared
|
||||
.network
|
||||
.lock(|net| net.direct_stream(*settings.dual_iir.stream));
|
||||
.lock(|net| net.direct_stream(settings.dual_iir.stream));
|
||||
});
|
||||
}
|
||||
|
||||
@ -288,163 +280,89 @@ index e7596341..71eee420 100644
|
||||
+ let (gains, telemetry_period, pounder_config) =
|
||||
c.shared.settings.lock(|settings| {
|
||||
(
|
||||
settings.dual_iir.ch.each_ref().map(|ch| *ch.gain),
|
||||
*settings.dual_iir.telemetry_period,
|
||||
+ settings.dual_iir.pounder
|
||||
settings.dual_iir.ch.each_ref().map(|ch| ch.gain),
|
||||
settings.dual_iir.telemetry_period,
|
||||
+ settings.dual_iir.pounder,
|
||||
)
|
||||
});
|
||||
|
||||
+ let pounder_telemetry = c.shared.pounder.lock(|pounder| {
|
||||
+ pounder.as_mut().map(|pdr| pdr.get_telemetry(pounder_config.unwrap()))
|
||||
+ });
|
||||
+ });
|
||||
+
|
||||
c.shared.network.lock(|net| {
|
||||
net.telemetry.publish(&telemetry.finalize(
|
||||
gains[0],
|
||||
gains[1],
|
||||
c.local.cpu_temp_sensor.get_temperature().unwrap(),
|
||||
+ pounder_telemetry,
|
||||
))
|
||||
net.telemetry.publish_telemetry(
|
||||
"/telemetry",
|
||||
@@ -517,6 +564,7 @@ mod app {
|
||||
gains[0],
|
||||
gains[1],
|
||||
c.local.cpu_temp_sensor.get_temperature().unwrap(),
|
||||
+ pounder_telemetry,
|
||||
),
|
||||
)
|
||||
});
|
||||
|
||||
diff --git a/src/bin/lockin.rs b/src/bin/lockin.rs
|
||||
index 064b43d3..fd0c959e 100644
|
||||
index c46c575..bccad0f 100644
|
||||
--- a/src/bin/lockin.rs
|
||||
+++ b/src/bin/lockin.rs
|
||||
@@ -28,9 +28,10 @@
|
||||
#![no_main]
|
||||
|
||||
use core::{
|
||||
- iter,
|
||||
- mem::MaybeUninit,
|
||||
+ convert::TryFrom,
|
||||
+ mem::{MaybeUninit, size_of},
|
||||
sync::atomic::{fence, Ordering},
|
||||
+ iter
|
||||
};
|
||||
|
||||
use miniconf::{Leaf, Tree};
|
||||
@@ -246,7 +247,7 @@ mod app {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
usb: UsbDevice,
|
||||
- network: NetworkUsers<Lockin, 2>,
|
||||
+ network: NetworkUsers<Lockin, 6>,
|
||||
settings: Settings,
|
||||
active_settings: Lockin,
|
||||
telemetry: TelemetryBuffer,
|
||||
@@ -254,7 +255,7 @@ mod app {
|
||||
|
||||
#[local]
|
||||
struct Local {
|
||||
- usb_terminal: SerialTerminal<Settings, 3>,
|
||||
+ usb_terminal: SerialTerminal<Settings, 6>,
|
||||
sampling_timer: SamplingTimer,
|
||||
digital_inputs: (DigitalInput0, DigitalInput1),
|
||||
timestamper: InputStamper,
|
||||
@@ -273,7 +274,7 @@ mod app {
|
||||
let clock = SystemTimer::new(|| Systick::now().ticks());
|
||||
|
||||
// Configure the microcontroller
|
||||
- let (mut stabilizer, _pounder) = hardware::setup::setup::<Settings, 3>(
|
||||
+ let (mut stabilizer, _pounder) = hardware::setup::setup::<Settings, 6>(
|
||||
c.core,
|
||||
c.device,
|
||||
clock,
|
||||
@@ -535,6 +536,7 @@ mod app {
|
||||
*gains[0],
|
||||
*gains[1],
|
||||
c.local.cpu_temp_sensor.get_temperature().unwrap(),
|
||||
+ None,
|
||||
))
|
||||
@@ -500,6 +500,7 @@ mod app {
|
||||
*gains[0],
|
||||
*gains[1],
|
||||
c.local.cpu_temp_sensor.get_temperature().unwrap(),
|
||||
+ None,
|
||||
),
|
||||
)
|
||||
});
|
||||
diff --git a/src/hardware/net.rs b/src/hardware/net.rs
|
||||
index 1edfcca..50f306d 100644
|
||||
--- a/src/hardware/net.rs
|
||||
+++ b/src/hardware/net.rs
|
||||
@@ -42,14 +42,14 @@ pub type NetworkManager = smoltcp_nal::shared::NetworkManager<
|
||||
|
||||
diff --git a/src/bin/urukul.rs b/src/bin/urukul.rs
|
||||
index fc7faf40..10ff9016 100644
|
||||
--- a/src/bin/urukul.rs
|
||||
+++ b/src/bin/urukul.rs
|
||||
@@ -104,21 +104,21 @@ mod app {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
usb: UsbDevice,
|
||||
- network: NetworkUsers<App, 3>,
|
||||
+ network: NetworkUsers<App, 6>,
|
||||
settings: Settings,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {
|
||||
urukul: Urukul,
|
||||
- usb_terminal: SerialTerminal<Settings, 4>,
|
||||
+ usb_terminal: SerialTerminal<Settings, 6>,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(c: init::Context) -> (Shared, Local) {
|
||||
let clock = SystemTimer::new(|| Systick::now().ticks());
|
||||
|
||||
- let (stabilizer, _pounder) = hardware::setup::setup::<Settings, 4>(
|
||||
+ let (stabilizer, _pounder) = hardware::setup::setup::<Settings, 6>(
|
||||
c.core,
|
||||
c.device,
|
||||
clock,
|
||||
diff --git a/src/hardware/pounder/attenuators.rs b/src/hardware/pounder/attenuators.rs
|
||||
index cfd08b7f..2570f506 100644
|
||||
--- a/src/hardware/pounder/attenuators.rs
|
||||
+++ b/src/hardware/pounder/attenuators.rs
|
||||
@@ -52,10 +52,9 @@ pub trait AttenuatorInterface {
|
||||
fn get_attenuation(&mut self, channel: Channel) -> Result<f32, Error> {
|
||||
let mut channels = [0_u8; 4];
|
||||
|
||||
- // Reading the data always shifts data out of the staging registers, so we perform a
|
||||
- // duplicate write-back to ensure the staging register is always equal to the output
|
||||
- // register.
|
||||
- self.transfer_attenuators(&mut channels)?;
|
||||
+ // Reading the data always shifts data out of the staging registers, so a duplicate
|
||||
+ // write-back will be performed to ensure the staging register is always equal to the
|
||||
+ // output register.
|
||||
self.transfer_attenuators(&mut channels)?;
|
||||
|
||||
// The attenuation code is stored in the upper 6 bits of the register, where each LSB
|
||||
@@ -66,6 +65,9 @@ pub trait AttenuatorInterface {
|
||||
// care) would contain erroneous data.
|
||||
let attenuation_code = (!channels[channel as usize]) >> 2;
|
||||
|
||||
+ // The write-back transfer is performed. Staging register is now restored.
|
||||
+ self.transfer_attenuators(&mut channels)?;
|
||||
+
|
||||
// Convert the desired channel code into dB of attenuation.
|
||||
Ok(attenuation_code as f32 / 2.0)
|
||||
struct MqttStorage {
|
||||
telemetry: [u8; 2048],
|
||||
- settings: [u8; 1024],
|
||||
+ settings: [u8; 1536],
|
||||
}
|
||||
|
||||
impl Default for MqttStorage {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
telemetry: [0u8; 2048],
|
||||
- settings: [0u8; 1024],
|
||||
+ settings: [0u8; 1536],
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/hardware/pounder/dds_output.rs b/src/hardware/pounder/dds_output.rs
|
||||
index 41fb7762..9404894f 100644
|
||||
index 9e7e743..ab8b4c5 100644
|
||||
--- a/src/hardware/pounder/dds_output.rs
|
||||
+++ b/src/hardware/pounder/dds_output.rs
|
||||
@@ -55,8 +55,9 @@
|
||||
@@ -54,8 +54,9 @@
|
||||
//! buffer to avoid the software overhead of much of the serialization process.
|
||||
use log::warn;
|
||||
use stm32h7xx_hal as hal;
|
||||
|
||||
-use super::{hrtimer::HighResTimerE, QspiInterface};
|
||||
-use super::{QspiInterface, hal, hrtimer::HighResTimerE};
|
||||
-use ad9959::{Mode, ProfileSerializer};
|
||||
+use arbitrary_int::{u14, u24};
|
||||
+use super::{hrtimer::HighResTimerE, Profile, QspiInterface};
|
||||
+use super::{Profile, QspiInterface, hal, hrtimer::HighResTimerE};
|
||||
+use ad9959::{Acr, Channel, Mode, ProfileSerializer};
|
||||
|
||||
/// The DDS profile update stream.
|
||||
pub struct DdsOutput {
|
||||
@@ -91,8 +92,9 @@ impl DdsOutput {
|
||||
@@ -90,8 +91,9 @@ impl DdsOutput {
|
||||
}
|
||||
|
||||
/// Get a builder for serializing a Pounder DDS profile.
|
||||
- pub fn builder(&mut self) -> ProfileSerializer {
|
||||
- ProfileSerializer::new(self.mode)
|
||||
+ pub fn builder(&mut self) -> ProfileBuilder {
|
||||
+ pub fn builder(&mut self) -> ProfileBuilder<'_> {
|
||||
+ let mode = self.mode;
|
||||
+ ProfileBuilder {dds_output: self, serializer: ProfileSerializer::new(mode)}
|
||||
}
|
||||
|
||||
/// Write a profile to the stream.
|
||||
@@ -105,7 +107,7 @@ impl DdsOutput {
|
||||
@@ -104,7 +106,7 @@ impl DdsOutput {
|
||||
/// # Args
|
||||
/// * `profile` - The serialized DDS profile to write.
|
||||
#[inline]
|
||||
@ -453,7 +371,7 @@ index 41fb7762..9404894f 100644
|
||||
// Note(unsafe): We own the QSPI interface, so it is safe to access the registers in a raw
|
||||
// fashion.
|
||||
let regs = unsafe { &*hal::stm32::QUADSPI::ptr() };
|
||||
@@ -124,3 +126,69 @@ impl DdsOutput {
|
||||
@@ -123,3 +125,69 @@ impl DdsOutput {
|
||||
self.io_update_trigger.trigger();
|
||||
}
|
||||
}
|
||||
@ -524,29 +442,25 @@ index 41fb7762..9404894f 100644
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/hardware/pounder/mod.rs b/src/hardware/pounder/mod.rs
|
||||
index 8cf1fb5c..8cc99423 100644
|
||||
index ea53d1c..38ff6a3 100644
|
||||
--- a/src/hardware/pounder/mod.rs
|
||||
+++ b/src/hardware/pounder/mod.rs
|
||||
@@ -1,12 +1,15 @@
|
||||
use self::attenuators::AttenuatorInterface;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
use super::hal;
|
||||
-use crate::hardware::{shared_adc::AdcChannel, I2c1Proxy};
|
||||
-use crate::hardware::{I2c1Proxy, shared_adc::AdcChannel};
|
||||
-use ad9959::Address;
|
||||
-use bitbybit::bitenum;
|
||||
+use crate::hardware::{setup, shared_adc::AdcChannel, I2c1Proxy};
|
||||
+use crate::net::telemetry::PounderTelemetry;
|
||||
+use crate::hardware::{setup, I2c1Proxy, shared_adc::AdcChannel};
|
||||
+use crate::telemetry::PounderTelemetry;
|
||||
+use ad9959::{Address, frequency_to_ftw, phase_to_pow, amplitude_to_acr, validate_clocking};
|
||||
use embedded_hal_02::blocking::spi::Transfer;
|
||||
+use miniconf::{Leaf, Tree};
|
||||
+use rf_power::PowerMeasurementInterface;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::IntoEnumIterator;
|
||||
+use stm32h7xx_hal::time::MegaHertz;
|
||||
|
||||
pub mod attenuators;
|
||||
pub mod dds_output;
|
||||
@@ -122,38 +125,97 @@ impl From<Channel> for GpioPin {
|
||||
pub mod hrtimer;
|
||||
@@ -117,38 +120,97 @@ impl From<Channel> for GpioPin {
|
||||
}
|
||||
}
|
||||
|
||||
@ -570,18 +484,13 @@ index 8cf1fb5c..8cc99423 100644
|
||||
+impl Default for DdsChannelConfig {
|
||||
+ fn default() -> Self {
|
||||
+ Self {
|
||||
+ frequency: 0.0.into(),
|
||||
+ phase_offset: 0.0.into(),
|
||||
+ amplitude: 0.0.into(),
|
||||
+ frequency: Leaf(0.0),
|
||||
+ phase_offset: Leaf(0.0),
|
||||
+ amplitude: Leaf(0.0),
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
-#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
-pub struct InputChannelState {
|
||||
- pub attenuation: f32,
|
||||
- pub power: f32,
|
||||
- pub mixer: DdsChannelState,
|
||||
+}
|
||||
+
|
||||
+/// Represents a fully defined DDS profile, with parameters expressed in machine units
|
||||
+pub struct Profile {
|
||||
+ /// A 32-bits representation of DDS frequency in relation to the system clock frequency.
|
||||
@ -594,12 +503,8 @@ index 8cf1fb5c..8cc99423 100644
|
||||
+ /// Control amplitudes of DDS channels. It corresponds to the AD9959 ACR register, which
|
||||
+ /// controls the amplitude scaling factor of DDS channels.
|
||||
+ pub amplitude_control: u32,
|
||||
}
|
||||
|
||||
-#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
-pub struct OutputChannelState {
|
||||
- pub attenuation: f32,
|
||||
- pub channel: DdsChannelState,
|
||||
+}
|
||||
+
|
||||
+impl TryFrom<(ClockConfig, ChannelConfig)> for Profile {
|
||||
+ type Error = ad9959::Error;
|
||||
+
|
||||
@ -620,22 +525,26 @@ index 8cf1fb5c..8cc99423 100644
|
||||
}
|
||||
|
||||
-#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
-pub struct DdsClockConfig {
|
||||
- pub multiplier: u8,
|
||||
- pub reference_clock: f32,
|
||||
- pub external_clock: bool,
|
||||
-pub struct InputChannelState {
|
||||
- pub attenuation: f32,
|
||||
- pub power: f32,
|
||||
- pub mixer: DdsChannelState,
|
||||
+#[derive(Serialize, Deserialize, Copy, Clone, Debug, Tree)]
|
||||
+pub struct ChannelConfig {
|
||||
+ #[tree]
|
||||
+ pub dds: DdsChannelConfig,
|
||||
+ pub attenuation: Leaf<f32>,
|
||||
+}
|
||||
+
|
||||
}
|
||||
|
||||
-#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
-pub struct OutputChannelState {
|
||||
- pub attenuation: f32,
|
||||
- pub channel: DdsChannelState,
|
||||
+impl Default for ChannelConfig {
|
||||
+ fn default() -> Self {
|
||||
+ ChannelConfig {
|
||||
+ dds: DdsChannelConfig::default(),
|
||||
+ attenuation: 31.5.into(),
|
||||
+ attenuation: Leaf(31.5),
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@ -650,13 +559,18 @@ index 8cf1fb5c..8cc99423 100644
|
||||
+impl Default for ClockConfig {
|
||||
+ fn default() -> Self {
|
||||
+ Self {
|
||||
+ multiplier: 5.into(),
|
||||
+ reference_clock: (MegaHertz::MHz(100).to_Hz() as f32).into(),
|
||||
+ external_clock: false.into(),
|
||||
+ multiplier: Leaf(5),
|
||||
+ reference_clock: Leaf(MegaHertz::MHz(100).to_Hz() as f32),
|
||||
+ external_clock: Leaf(false),
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
}
|
||||
|
||||
-#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
-pub struct DdsClockConfig {
|
||||
- pub multiplier: u8,
|
||||
- pub reference_clock: f32,
|
||||
- pub external_clock: bool,
|
||||
+#[derive(Copy, Clone, Debug, Default, Deserialize, Serialize, Tree)]
|
||||
+pub struct PounderConfig {
|
||||
+ #[tree]
|
||||
@ -668,12 +582,12 @@ index 8cf1fb5c..8cc99423 100644
|
||||
}
|
||||
|
||||
impl From<Channel> for ad9959::Channel {
|
||||
@@ -585,3 +647,79 @@ impl rf_power::PowerMeasurementInterface for PounderDevices {
|
||||
Ok(adc_scale * 2.048)
|
||||
@@ -649,3 +711,79 @@ impl PounderDevices {
|
||||
Ok(analog_measurement * (1. / 0.0517) + (-58. + 20.))
|
||||
}
|
||||
}
|
||||
+
|
||||
+impl setup::PounderDevices {
|
||||
+impl setup::Pounder {
|
||||
+ pub fn update_dds(
|
||||
+ &mut self,
|
||||
+ settings: PounderConfig,
|
||||
@ -748,54 +662,19 @@ index 8cf1fb5c..8cc99423 100644
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/net/data_stream.rs b/src/net/data_stream.rs
|
||||
index 94b2fb6c..510b9e6a 100644
|
||||
--- a/src/net/data_stream.rs
|
||||
+++ b/src/net/data_stream.rs
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#![allow(non_camel_case_types)] // https://github.com/rust-embedded/heapless/issues/411
|
||||
|
||||
-use core::{fmt::Write, mem::MaybeUninit, net::SocketAddr};
|
||||
+use core::{fmt::Write, mem::{MaybeUninit, size_of_val}, net::SocketAddr};
|
||||
use heapless::{
|
||||
box_pool,
|
||||
pool::boxed::{Box, BoxBlock},
|
||||
diff --git a/src/net/mod.rs b/src/net/mod.rs
|
||||
index 8d815e51..5541f8ba 100644
|
||||
--- a/src/net/mod.rs
|
||||
+++ b/src/net/mod.rs
|
||||
@@ -32,14 +32,14 @@ pub type NetworkReference =
|
||||
|
||||
pub struct MqttStorage {
|
||||
telemetry: [u8; 2048],
|
||||
- settings: [u8; 1024],
|
||||
+ settings: [u8; 1536],
|
||||
}
|
||||
|
||||
impl Default for MqttStorage {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
telemetry: [0u8; 2048],
|
||||
- settings: [0u8; 1024],
|
||||
+ settings: [0u8; 1536],
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/net/telemetry.rs b/src/net/telemetry.rs
|
||||
index a368c014..30dfd0c3 100644
|
||||
--- a/src/net/telemetry.rs
|
||||
+++ b/src/net/telemetry.rs
|
||||
@@ -16,7 +16,7 @@ use minimq::Publication;
|
||||
\ No newline at end of file
|
||||
diff --git a/src/telemetry.rs b/src/telemetry.rs
|
||||
index ffbba8d..5900a76 100644
|
||||
--- a/src/telemetry.rs
|
||||
+++ b/src/telemetry.rs
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::convert::{AdcCode, DacCode, Gain};
|
||||
use serde::Serialize;
|
||||
+use crate::hardware::{pounder::PounderConfig};
|
||||
|
||||
use super::NetworkReference;
|
||||
-use crate::hardware::{adc::AdcCode, afe::Gain, dac::DacCode, SystemTimer};
|
||||
+use crate::hardware::{adc::AdcCode, afe::Gain, dac::DacCode, SystemTimer, pounder::PounderConfig};
|
||||
|
||||
/// Default metadata message if formatting errors occur.
|
||||
const DEFAULT_METADATA: &str = "{\"message\":\"Truncated: See USB terminal\"}";
|
||||
@@ -68,6 +68,26 @@ pub struct Telemetry {
|
||||
/// The telemetry buffer is used for storing sample values during execution.
|
||||
///
|
||||
@@ -35,6 +36,26 @@ pub struct Telemetry {
|
||||
|
||||
/// The CPU temperature in degrees Celsius.
|
||||
pub cpu_temp: f32,
|
||||
@ -822,7 +701,7 @@ index a368c014..30dfd0c3 100644
|
||||
}
|
||||
|
||||
impl TelemetryBuffer {
|
||||
@@ -77,10 +97,17 @@ impl TelemetryBuffer {
|
||||
@@ -44,10 +65,17 @@ impl TelemetryBuffer {
|
||||
/// * `afe0` - The current AFE configuration for channel 0.
|
||||
/// * `afe1` - The current AFE configuration for channel 1.
|
||||
/// * `cpu_temp` - The current CPU temperature.
|
||||
@ -841,7 +720,7 @@ index a368c014..30dfd0c3 100644
|
||||
let in0_volts = f32::from(self.adcs[0]) / afe0.gain();
|
||||
let in1_volts = f32::from(self.adcs[1]) / afe1.gain();
|
||||
|
||||
@@ -89,6 +116,7 @@ impl TelemetryBuffer {
|
||||
@@ -56,6 +84,7 @@ impl TelemetryBuffer {
|
||||
adcs: [in0_volts, in1_volts],
|
||||
dacs: [self.dacs[0].into(), self.dacs[1].into()],
|
||||
digital_inputs: self.digital_inputs,
|
||||
Loading…
x
Reference in New Issue
Block a user