pounder patch: for stabilizer commit cb1f145
Needed Rust 1.88+ to compile in stable Rust. Also resolve patch failure.
This commit was merged in pull request #106.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
let
|
||||
pkgs = import <nixpkgs> { overlays = [ rustOverlay ]; };
|
||||
rust = pkgs.rust-bin.stable."1.87.0".default.override {
|
||||
rust = pkgs.rust-bin.stable."1.93.0".default.override {
|
||||
extensions = [ "rust-src" ];
|
||||
targets = [ "thumbv7em-none-eabihf" ];
|
||||
};
|
||||
@@ -53,12 +53,11 @@ in
|
||||
cargoDepsName = "stabilizer";
|
||||
src = <stabilizerSrc>;
|
||||
patchPhase = ''
|
||||
patch -p1 < ${./pounder-39279e2.diff}
|
||||
patch -p1 < ${./pounder-cb1f145.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))) {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs
|
||||
index 59e5137..6c9825a 100644
|
||||
index 552444da..88aadf91 100644
|
||||
--- a/ad9959/src/lib.rs
|
||||
+++ b/ad9959/src/lib.rs
|
||||
@@ -2,8 +2,24 @@
|
||||
|
||||
use arbitrary_int::{traits::Integer, u2, u3, u4, u5, u10, u14, u24};
|
||||
@@ -3,6 +3,22 @@
|
||||
use arbitrary_int::{Number, u2, u3, u4, u5, u10, u14, u24};
|
||||
use bitbybit::{bitenum, bitfield};
|
||||
+use core::ops::Range;
|
||||
use embedded_hal::{blocking::delay::DelayUs, digital::v2::OutputPin};
|
||||
@@ -26,9 +25,7 @@ index 59e5137..6c9825a 100644
|
||||
+
|
||||
/// A trait that allows a HAL to provide a means of communicating with the AD9959.
|
||||
pub trait Interface {
|
||||
type Error;
|
||||
@@ -485,6 +501,109 @@ impl<I: Interface> Ad9959<I> {
|
||||
}
|
||||
@@ -486,4 +502,107 @@ impl<I: Interface> Ad9959<I> {
|
||||
}
|
||||
|
||||
+/// Validate the internal system clock configuration of the chip.
|
||||
@@ -136,13 +133,11 @@ index 59e5137..6c9825a 100644
|
||||
+
|
||||
/// Represents a means of serializing a DDS profile for writing to a stream.
|
||||
pub struct ProfileSerializer {
|
||||
mode: Mode,
|
||||
diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs
|
||||
index c6eb802..9fba6a0 100644
|
||||
index 64ffc19b..1a5429ba 100644
|
||||
--- a/src/bin/dual-iir.rs
|
||||
+++ b/src/bin/dual-iir.rs
|
||||
@@ -35,7 +35,13 @@ use idsp::iir;
|
||||
use platform::{AppSettings, NetSettings};
|
||||
@@ -36,5 +36,11 @@ use platform::{AppSettings, NetSettings};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use signal_generator::{self, Source};
|
||||
-use stabilizer::convert::{AdcCode, DacCode, Gain};
|
||||
@@ -155,9 +150,7 @@ index c6eb802..9fba6a0 100644
|
||||
+};
|
||||
|
||||
// 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.
|
||||
@@ -174,4 +180,13 @@ pub struct DualIir {
|
||||
#[tree(with=miniconf::leaf)]
|
||||
stream: stream::Target,
|
||||
+ /// Specifies the config for pounder DDS clock configuration, DDS channels & attenuations
|
||||
@@ -171,42 +164,32 @@ index c6eb802..9fba6a0 100644
|
||||
+ pounder: Option<PounderConfig>,
|
||||
}
|
||||
|
||||
impl Default for DualIir {
|
||||
@@ -182,6 +197,7 @@ impl Default for DualIir {
|
||||
trigger: false,
|
||||
@@ -183,4 +198,5 @@ impl Default for DualIir {
|
||||
stream: Default::default(),
|
||||
ch: Default::default(),
|
||||
+ pounder: None.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,6 +254,7 @@ mod app {
|
||||
settings: Settings,
|
||||
@@ -239,4 +255,5 @@ mod app {
|
||||
active: [Active; 2],
|
||||
telemetry: TelemetryBuffer,
|
||||
+ pounder: Option<Pounder>,
|
||||
}
|
||||
|
||||
#[local]
|
||||
@@ -248,6 +265,7 @@ mod app {
|
||||
afes: [Pgia; 2],
|
||||
@@ -249,4 +266,5 @@ mod app {
|
||||
adcs: (Adc0Input, Adc1Input),
|
||||
dacs: (Dac0Output, Dac1Output),
|
||||
+ dds_clock_state: Option<ClockConfig>,
|
||||
generator: FrameGenerator,
|
||||
cpu_temp_sensor: stabilizer::hardware::cpu_temp_sensor::CpuTempSensor,
|
||||
}
|
||||
@@ -257,7 +275,7 @@ mod app {
|
||||
let clock = SystemTimer::new(|| Systick::now().ticks());
|
||||
@@ -258,5 +276,5 @@ mod app {
|
||||
|
||||
// Configure the microcontroller
|
||||
- let (stabilizer, _mezzanine, _eem) = hardware::setup::setup::<Settings>(
|
||||
+ let (mut stabilizer, mezzanine, _eem) = hardware::setup::setup::<Settings>(
|
||||
c.core,
|
||||
c.device,
|
||||
clock,
|
||||
@@ -276,6 +294,17 @@ mod app {
|
||||
|
||||
@@ -277,4 +295,15 @@ mod app {
|
||||
let generator = network.configure_streaming(stream::Format::AdcDacData);
|
||||
|
||||
+ let pounder = match mezzanine {
|
||||
@@ -222,34 +205,26 @@ index c6eb802..9fba6a0 100644
|
||||
+
|
||||
let shared = Shared {
|
||||
usb: stabilizer.usb,
|
||||
network,
|
||||
@@ -287,6 +316,7 @@ mod app {
|
||||
.map(|a| a.build().unwrap()),
|
||||
@@ -288,4 +317,5 @@ mod app {
|
||||
telemetry: TelemetryBuffer::default(),
|
||||
settings: stabilizer.settings,
|
||||
+ pounder,
|
||||
};
|
||||
|
||||
let mut local = Local {
|
||||
@@ -296,6 +326,7 @@ mod app {
|
||||
afes: stabilizer.afes,
|
||||
@@ -297,4 +327,5 @@ mod app {
|
||||
adcs: stabilizer.adcs,
|
||||
dacs: stabilizer.dacs,
|
||||
+ dds_clock_state,
|
||||
generator,
|
||||
cpu_temp_sensor: stabilizer.temperature_sensor,
|
||||
};
|
||||
@@ -448,7 +479,7 @@ mod app {
|
||||
}
|
||||
@@ -449,5 +480,5 @@ mod app {
|
||||
}
|
||||
|
||||
- #[task(priority = 1, local=[afes], shared=[network, settings, active])]
|
||||
+ #[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,26 +521,42 @@ mod app {
|
||||
(a.run, a.biquad) = b;
|
||||
@@ -491,4 +522,15 @@ mod app {
|
||||
}
|
||||
});
|
||||
+ // Update Pounder configurations
|
||||
@@ -265,15 +240,14 @@ index c6eb802..9fba6a0 100644
|
||||
+ });
|
||||
c.shared
|
||||
.network
|
||||
.lock(|net| net.direct_stream(settings.dual_iir.stream));
|
||||
});
|
||||
@@ -497,5 +539,5 @@ mod app {
|
||||
}
|
||||
|
||||
- #[task(priority = 1, shared=[network, settings, telemetry], local=[cpu_temp_sensor])]
|
||||
+ #[task(priority = 1, shared=[network, settings, telemetry, pounder], local=[cpu_temp_sensor])]
|
||||
async fn telemetry(mut c: telemetry::Context) {
|
||||
async fn telemetry(mut c: telemetry::Context) -> ! {
|
||||
loop {
|
||||
let telemetry =
|
||||
@@ -503,12 +545,17 @@ mod app {
|
||||
c.shared.telemetry.lock(|telemetry| telemetry.clone());
|
||||
|
||||
- let (gains, telemetry_period) =
|
||||
@@ -292,54 +266,45 @@ index c6eb802..9fba6a0 100644
|
||||
+
|
||||
c.shared.network.lock(|net| {
|
||||
net.telemetry.publish_telemetry(
|
||||
"/telemetry",
|
||||
@@ -517,6 +564,7 @@ mod app {
|
||||
gains[0],
|
||||
@@ -518,4 +565,5 @@ mod app {
|
||||
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 c46c575..bccad0f 100644
|
||||
index 8894ec19..a87ebf2a 100644
|
||||
--- a/src/bin/lockin.rs
|
||||
+++ b/src/bin/lockin.rs
|
||||
@@ -500,6 +500,7 @@ mod app {
|
||||
*gains[0],
|
||||
@@ -501,4 +501,5 @@ mod app {
|
||||
*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
|
||||
index 1edfcca2..50f306d2 100644
|
||||
--- a/src/hardware/net.rs
|
||||
+++ b/src/hardware/net.rs
|
||||
@@ -42,14 +42,14 @@ pub type NetworkManager = smoltcp_nal::shared::NetworkManager<
|
||||
|
||||
@@ -43,5 +43,5 @@ pub type NetworkManager = smoltcp_nal::shared::NetworkManager<
|
||||
struct MqttStorage {
|
||||
telemetry: [u8; 2048],
|
||||
- settings: [u8; 1024],
|
||||
+ settings: [u8; 1536],
|
||||
}
|
||||
|
||||
impl Default for MqttStorage {
|
||||
fn default() -> Self {
|
||||
@@ -50,5 +50,5 @@ impl Default for MqttStorage {
|
||||
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 9e7e743..ab8b4c5 100644
|
||||
index 9e7e743d..ab8b4c52 100644
|
||||
--- a/src/hardware/pounder/dds_output.rs
|
||||
+++ b/src/hardware/pounder/dds_output.rs
|
||||
@@ -54,8 +54,9 @@
|
||||
//! buffer to avoid the software overhead of much of the serialization process.
|
||||
@@ -55,6 +55,7 @@
|
||||
use log::warn;
|
||||
|
||||
-use super::{QspiInterface, hal, hrtimer::HighResTimerE};
|
||||
@@ -349,9 +314,7 @@ index 9e7e743..ab8b4c5 100644
|
||||
+use ad9959::{Acr, Channel, Mode, ProfileSerializer};
|
||||
|
||||
/// The DDS profile update stream.
|
||||
pub struct DdsOutput {
|
||||
@@ -90,8 +91,9 @@ impl DdsOutput {
|
||||
}
|
||||
@@ -91,6 +92,7 @@ impl DdsOutput {
|
||||
|
||||
/// Get a builder for serializing a Pounder DDS profile.
|
||||
- pub fn builder(&mut self) -> ProfileSerializer {
|
||||
@@ -361,18 +324,14 @@ index 9e7e743..ab8b4c5 100644
|
||||
+ ProfileBuilder {dds_output: self, serializer: ProfileSerializer::new(mode)}
|
||||
}
|
||||
|
||||
/// Write a profile to the stream.
|
||||
@@ -104,7 +106,7 @@ impl DdsOutput {
|
||||
/// # Args
|
||||
@@ -105,5 +107,5 @@ impl DdsOutput {
|
||||
/// * `profile` - The serialized DDS profile to write.
|
||||
#[inline]
|
||||
- pub fn write(&mut self, mut profile: ProfileSerializer) {
|
||||
+ pub fn write(&mut self, profile: &mut ProfileSerializer) {
|
||||
// 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() };
|
||||
@@ -123,3 +125,69 @@ impl DdsOutput {
|
||||
self.io_update_trigger.trigger();
|
||||
@@ -124,2 +126,68 @@ impl DdsOutput {
|
||||
}
|
||||
}
|
||||
+
|
||||
@@ -442,10 +401,10 @@ index 9e7e743..ab8b4c5 100644
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/hardware/pounder/mod.rs b/src/hardware/pounder/mod.rs
|
||||
index ea53d1c..38ff6a3 100644
|
||||
index ea53d1cc..38ff6a3d 100644
|
||||
--- a/src/hardware/pounder/mod.rs
|
||||
+++ b/src/hardware/pounder/mod.rs
|
||||
@@ -1,9 +1,12 @@
|
||||
@@ -1,8 +1,11 @@
|
||||
use super::hal;
|
||||
-use crate::hardware::{I2c1Proxy, shared_adc::AdcChannel};
|
||||
-use ad9959::Address;
|
||||
@@ -459,9 +418,7 @@ index ea53d1c..38ff6a3 100644
|
||||
+use stm32h7xx_hal::time::MegaHertz;
|
||||
|
||||
pub mod dds_output;
|
||||
pub mod hrtimer;
|
||||
@@ -117,38 +120,97 @@ impl From<Channel> for GpioPin {
|
||||
}
|
||||
@@ -118,36 +121,95 @@ impl From<Channel> for GpioPin {
|
||||
}
|
||||
|
||||
-#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
@@ -581,9 +538,7 @@ index ea53d1c..38ff6a3 100644
|
||||
+ pub out_channel: [ChannelConfig; 2],
|
||||
}
|
||||
|
||||
impl From<Channel> for ad9959::Channel {
|
||||
@@ -649,3 +711,79 @@ impl PounderDevices {
|
||||
Ok(analog_measurement * (1. / 0.0517) + (-58. + 20.))
|
||||
@@ -650,2 +712,78 @@ impl PounderDevices {
|
||||
}
|
||||
}
|
||||
+
|
||||
@@ -664,18 +619,16 @@ index ea53d1c..38ff6a3 100644
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/telemetry.rs b/src/telemetry.rs
|
||||
index ffbba8d..5900a76 100644
|
||||
index ffbba8dd..5900a76d 100644
|
||||
--- a/src/telemetry.rs
|
||||
+++ b/src/telemetry.rs
|
||||
@@ -1,5 +1,6 @@
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::convert::{AdcCode, DacCode, Gain};
|
||||
use serde::Serialize;
|
||||
+use crate::hardware::{pounder::PounderConfig};
|
||||
|
||||
/// The telemetry buffer is used for storing sample values during execution.
|
||||
///
|
||||
@@ -35,6 +36,26 @@ pub struct Telemetry {
|
||||
|
||||
@@ -36,4 +37,24 @@ pub struct Telemetry {
|
||||
/// The CPU temperature in degrees Celsius.
|
||||
pub cpu_temp: f32,
|
||||
+
|
||||
@@ -700,9 +653,7 @@ index ffbba8d..5900a76 100644
|
||||
+ pub config: PounderConfig,
|
||||
}
|
||||
|
||||
impl TelemetryBuffer {
|
||||
@@ -44,10 +65,17 @@ impl TelemetryBuffer {
|
||||
/// * `afe0` - The current AFE configuration for channel 0.
|
||||
@@ -45,8 +66,15 @@ impl TelemetryBuffer {
|
||||
/// * `afe1` - The current AFE configuration for channel 1.
|
||||
/// * `cpu_temp` - The current CPU temperature.
|
||||
+ /// * `pounder` - The current Pounder telemetry.
|
||||
@@ -719,12 +670,9 @@ index ffbba8d..5900a76 100644
|
||||
+ ) -> Telemetry {
|
||||
let in0_volts = f32::from(self.adcs[0]) / afe0.gain();
|
||||
let in1_volts = f32::from(self.adcs[1]) / afe1.gain();
|
||||
|
||||
@@ -56,6 +84,7 @@ impl TelemetryBuffer {
|
||||
adcs: [in0_volts, in1_volts],
|
||||
@@ -57,4 +85,5 @@ impl TelemetryBuffer {
|
||||
dacs: [self.dacs[0].into(), self.dacs[1].into()],
|
||||
digital_inputs: self.digital_inputs,
|
||||
+ pounder,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user