Compare commits
No commits in common. "master" and "master" have entirely different histories.
@ -149,7 +149,7 @@
|
||||
"inputs": {
|
||||
"nixpkgs": { "type": "git", "value": "https://github.com/NixOS/nixpkgs.git nixos-24.11", "emailresponsible": false },
|
||||
"nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false },
|
||||
"urukulSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/urukul-pld.git", "emailresponsible": false },
|
||||
"urukulSrc": { "type": "git", "value": "https://github.com/quartiq/urukul.git", "emailresponsible": false },
|
||||
"mirnySrc": { "type": "git", "value": "https://github.com/quartiq/mirny.git", "emailresponsible": false },
|
||||
"fastinoSrc": { "type": "git", "value": "https://github.com/quartiq/fastino.git", "emailresponsible": false },
|
||||
"phaserSrc": { "type": "git", "value": "https://github.com/quartiq/phaser.git", "emailresponsible": false }
|
||||
|
@ -72,10 +72,6 @@ in
|
||||
patch -p1 < ${./pounder-725.diff}
|
||||
'';
|
||||
doCheck = false;
|
||||
outputHashes = {
|
||||
"miniconf-0.18.0" = "sha256-LNlJkQoHK0ukwdekKtt1zg3JLD5CQnq6GQtvw42+FfA=";
|
||||
"idsp-0.17.0" = "sha256-wVROBoWbD1k1bW+C4p0zngbiMkhdPLiLK91ggWivYqs=";
|
||||
};
|
||||
} // value))) {
|
||||
dual-iir = {};
|
||||
dual-iir-pounder_v1_0 = {
|
||||
|
@ -1,11 +1,11 @@
|
||||
diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs
|
||||
index bb66ddc4..f72a36b1 100644
|
||||
index 025f7d4f..59578cce 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 bitbybit::{bitenum, bitfield};
|
||||
use bit_field::BitField;
|
||||
use bitflags::bitflags;
|
||||
+use core::ops::Range;
|
||||
use embedded_hal::{blocking::delay::DelayUs, digital::v2::OutputPin};
|
||||
|
||||
@ -24,19 +24,49 @@ index bb66ddc4..f72a36b1 100644
|
||||
+ end: 160e6,
|
||||
+};
|
||||
+
|
||||
/// 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,
|
||||
/// A device driver for the AD9959 direct digital synthesis (DDS) chip.
|
||||
///
|
||||
/// This chip provides four independently controllable digital-to-analog output sinusoids with
|
||||
@@ -218,23 +234,17 @@ impl<I: Interface> Ad9959<I> {
|
||||
reference_clock_frequency: f32,
|
||||
multiplier: u5,
|
||||
@@ -485,6 +501,109 @@ impl<I: Interface> Ad9959<I> {
|
||||
multiplier: u8,
|
||||
) -> Result<f32, Error> {
|
||||
+ let frequency =
|
||||
+ validate_clocking(reference_clock_frequency, multiplier)?;
|
||||
self.reference_clock_frequency = reference_clock_frequency;
|
||||
|
||||
- if multiplier != 1 && !(4..=20).contains(&multiplier) {
|
||||
- return Err(Error::Bounds);
|
||||
- }
|
||||
-
|
||||
- let frequency = multiplier as f32 * self.reference_clock_frequency;
|
||||
- if frequency > 500_000_000.0f32 {
|
||||
- return Err(Error::Frequency);
|
||||
- }
|
||||
-
|
||||
// TODO: Update / disable any enabled channels?
|
||||
let mut fr1: [u8; 3] = [0, 0, 0];
|
||||
self.read(Register::FR1, &mut fr1)?;
|
||||
fr1[0].set_bits(2..=6, multiplier);
|
||||
|
||||
- let vco_range = frequency > 255e6;
|
||||
+ let vco_range = HIGH_GAIN_VCO_RANGE.contains(&frequency)
|
||||
+ || frequency == HIGH_GAIN_VCO_RANGE.end;
|
||||
fr1[0].set_bit(7, vco_range);
|
||||
|
||||
self.write(Register::FR1, &fr1)?;
|
||||
@@ -365,9 +375,7 @@ impl<I: Interface> Ad9959<I> {
|
||||
channel: Channel,
|
||||
phase_turns: f32,
|
||||
) -> Result<f32, Error> {
|
||||
- let phase_offset: u16 =
|
||||
- (phase_turns * (1 << 14) as f32) as u16 & 0x3FFFu16;
|
||||
-
|
||||
+ let phase_offset = phase_to_pow(phase_turns)?;
|
||||
self.modify_channel(
|
||||
channel,
|
||||
Register::CPOW0,
|
||||
@@ -513,6 +521,108 @@ impl<I: Interface> Ad9959<I> {
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,42 +165,83 @@ index bb66ddc4..f72a36b1 100644
|
||||
+ return Err(Error::Bounds);
|
||||
+ }
|
||||
+
|
||||
+ let asf = (amplitude * (1 << 10) as f32) as u16;
|
||||
+ let acr = match u10::try_new(asf) {
|
||||
+ Ok(asf) => Acr::default().with_multiplier(true).with_asf(asf),
|
||||
+ Err(_) => Acr::default().with_multiplier(false),
|
||||
+ };
|
||||
+ Ok(acr.raw_value().into())
|
||||
+ let acr: u32 = *0u32
|
||||
+ .set_bits(0..=9, ((amplitude * (1 << 10) as f32) as u32) & 0x3FF)
|
||||
+ .set_bit(12, amplitude != 1.0);
|
||||
+
|
||||
+ Ok(acr as u32)
|
||||
+}
|
||||
+
|
||||
/// Represents a means of serializing a DDS profile for writing to a stream.
|
||||
pub struct ProfileSerializer {
|
||||
mode: Mode,
|
||||
// heapless::Vec<u8, 32>, especially its extend_from_slice() is slow
|
||||
@@ -568,6 +678,39 @@ impl ProfileSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
+ /// Update the system clock configuration.
|
||||
+ ///
|
||||
+ /// # Args
|
||||
+ /// * `reference_clock_frequency` - The reference clock frequency provided to the AD9959 core.
|
||||
+ /// * `multiplier` - The frequency multiplier of the system clock. Must be 1 or 4-20.
|
||||
+ ///
|
||||
+ /// # Limitations
|
||||
+ /// The correctness of the FR1 register setting code rely on FR1\[0:17\] staying 0.
|
||||
+ pub fn set_system_clock(
|
||||
+ &mut self,
|
||||
+ reference_clock_frequency: f32,
|
||||
+ multiplier: u8,
|
||||
+ ) -> Result<f32, Error> {
|
||||
+ let frequency = reference_clock_frequency * multiplier as f32;
|
||||
+
|
||||
+ // The enabled channel will be updated after clock reconfig
|
||||
+ let mut fr1 = [0u8; 3];
|
||||
+
|
||||
+ // The ad9959 crate does not modify FR1[0:17]. These bits keep their default value.
|
||||
+ // These bits by default are 0.
|
||||
+ // Reading the register then update is not possible to implement in a serializer, where
|
||||
+ // many QSPI writes are performed in burst. Switching between read and write requires
|
||||
+ // breaking the QSPI indirect write mode and switch into the QSPI indirect read mode.
|
||||
+ fr1[0].set_bits(2..=6, multiplier);
|
||||
+
|
||||
+ // Frequencies within the VCO forbidden range (160e6, 255e6) are already rejected.
|
||||
+ let vco_range = HIGH_GAIN_VCO_RANGE.contains(&frequency);
|
||||
+ fr1[0].set_bit(7, vco_range);
|
||||
+
|
||||
+ self.add_write(Register::FR1, &fr1);
|
||||
+ Ok(frequency)
|
||||
+ }
|
||||
+
|
||||
/// Add a register write to the serialization data.
|
||||
fn add_write(&mut self, register: Register, value: &[u8]) {
|
||||
let data = &mut self.data[self.index..];
|
||||
diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs
|
||||
index e7596341..71eee420 100644
|
||||
index d4146cc2..b9bc99d9 100644
|
||||
--- a/src/bin/dual-iir.rs
|
||||
+++ b/src/bin/dual-iir.rs
|
||||
@@ -28,6 +28,7 @@
|
||||
@@ -28,7 +28,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
-use core::mem::MaybeUninit;
|
||||
+use core::mem::{MaybeUninit, size_of};
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
use miniconf::{Leaf, StrLeaf, Tree};
|
||||
|
||||
@@ -46,6 +47,8 @@ use stabilizer::{
|
||||
use miniconf::{Leaf, Tree};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -48,6 +48,8 @@ use stabilizer::{
|
||||
dac::{Dac0Output, Dac1Output, DacCode},
|
||||
hal,
|
||||
signal_generator::{self, Source},
|
||||
signal_generator::{self, SignalGenerator},
|
||||
+ pounder::{ClockConfig, PounderConfig},
|
||||
+ setup::PounderDevices as Pounder,
|
||||
timers::SamplingTimer,
|
||||
DigitalInput0, DigitalInput1, Pgia, SerialTerminal, SystemTimer,
|
||||
Systick, UsbDevice,
|
||||
@@ -194,6 +197,15 @@ pub struct DualIir {
|
||||
///
|
||||
/// Can be multicast.
|
||||
stream: Leaf<StreamTarget>,
|
||||
DigitalInput0, DigitalInput1, SerialTerminal, SystemTimer, Systick,
|
||||
UsbDevice, AFE0, AFE1,
|
||||
@@ -173,6 +175,16 @@ pub struct DualIir {
|
||||
/// # Value
|
||||
/// See [signal_generator::BasicConfig#miniconf]
|
||||
source: [signal_generator::BasicConfig; 2],
|
||||
+
|
||||
+ /// Specifies the config for pounder DDS clock configuration, DDS channels & attenuations
|
||||
+ ///
|
||||
+ /// # Path
|
||||
@ -182,41 +253,53 @@ index e7596341..71eee420 100644
|
||||
+ pounder: Option<PounderConfig>,
|
||||
}
|
||||
|
||||
impl DualIir {
|
||||
@@ -215,6 +227,7 @@ impl Default for DualIir {
|
||||
_trigger: Leaf(()),
|
||||
impl Default for DualIir {
|
||||
@@ -200,6 +212,8 @@ impl Default for DualIir {
|
||||
source: Default::default(),
|
||||
|
||||
stream: Default::default(),
|
||||
ch: Default::default(),
|
||||
+
|
||||
+ pounder: None.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,6 +251,7 @@ mod app {
|
||||
@@ -211,22 +225,24 @@ mod app {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
usb: UsbDevice,
|
||||
- network: NetworkUsers<DualIir, 3>,
|
||||
+ network: NetworkUsers<DualIir, 6>,
|
||||
settings: Settings,
|
||||
active: [Active; 2],
|
||||
active_settings: DualIir,
|
||||
telemetry: TelemetryBuffer,
|
||||
source: [SignalGenerator; 2],
|
||||
+ pounder: Option<Pounder>,
|
||||
}
|
||||
|
||||
#[local]
|
||||
@@ -248,6 +262,7 @@ mod app {
|
||||
afes: [Pgia; 2],
|
||||
struct Local {
|
||||
- usb_terminal: SerialTerminal<Settings, 4>,
|
||||
+ usb_terminal: SerialTerminal<Settings, 6>,
|
||||
sampling_timer: SamplingTimer,
|
||||
digital_inputs: (DigitalInput0, DigitalInput1),
|
||||
afes: (AFE0, AFE1),
|
||||
adcs: (Adc0Input, Adc1Input),
|
||||
dacs: (Dac0Output, Dac1Output),
|
||||
iir_state: [[[f32; 4]; IIR_CASCADE_LENGTH]; 2],
|
||||
+ dds_clock_state: Option<ClockConfig>,
|
||||
generator: FrameGenerator,
|
||||
cpu_temp_sensor: stabilizer::hardware::cpu_temp_sensor::CpuTempSensor,
|
||||
}
|
||||
@@ -257,7 +272,7 @@ mod app {
|
||||
@@ -236,7 +252,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, _pounder) = hardware::setup::setup::<Settings, 4>(
|
||||
+ let (mut stabilizer, pounder) = hardware::setup::setup::<Settings, 6>(
|
||||
c.core,
|
||||
c.device,
|
||||
clock,
|
||||
@@ -276,6 +291,13 @@ mod app {
|
||||
@@ -255,6 +271,13 @@ mod app {
|
||||
|
||||
let generator = network.configure_streaming(StreamFormat::AdcDacData);
|
||||
|
||||
@ -230,50 +313,50 @@ index e7596341..71eee420 100644
|
||||
let shared = Shared {
|
||||
usb: stabilizer.usb,
|
||||
network,
|
||||
@@ -287,6 +309,7 @@ mod app {
|
||||
.map(|a| a.build().unwrap()),
|
||||
telemetry: TelemetryBuffer::default(),
|
||||
@@ -273,6 +296,7 @@ mod app {
|
||||
),
|
||||
],
|
||||
settings: stabilizer.settings,
|
||||
+ pounder
|
||||
};
|
||||
|
||||
let mut local = Local {
|
||||
@@ -296,6 +319,7 @@ mod app {
|
||||
afes: stabilizer.afes,
|
||||
@@ -283,6 +307,7 @@ mod app {
|
||||
adcs: stabilizer.adcs,
|
||||
dacs: stabilizer.dacs,
|
||||
iir_state: [[[0.; 4]; IIR_CASCADE_LENGTH]; 2],
|
||||
+ dds_clock_state,
|
||||
generator,
|
||||
cpu_temp_sensor: stabilizer.temperature_sensor,
|
||||
};
|
||||
@@ -448,7 +472,7 @@ mod app {
|
||||
@@ -452,7 +477,7 @@ mod app {
|
||||
}
|
||||
}
|
||||
|
||||
- #[task(priority = 1, local=[afes], shared=[network, settings, active])]
|
||||
+ #[task(priority = 1, local=[afes, dds_clock_state], shared=[network, settings, active, pounder])]
|
||||
- #[task(priority = 1, local=[afes], shared=[network, settings, active_settings, source])]
|
||||
+ #[task(priority = 1, local=[afes, dds_clock_state], shared=[network, settings, active_settings, source, 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 {
|
||||
(a.run, a.biquad) = b;
|
||||
c.local.afes.0.set_gain(*settings.dual_iir.afe[0]);
|
||||
@@ -474,6 +499,17 @@ mod app {
|
||||
),
|
||||
}
|
||||
});
|
||||
+ // Update Pounder configurations
|
||||
+ c.shared.pounder.lock(|pounder| {
|
||||
+ if let Some(pounder) = pounder {
|
||||
+ let pounder_settings = settings.dual_iir.pounder.as_ref().unwrap();
|
||||
+ // let mut clocking = c.local.dds_clock_state;
|
||||
+ pounder.update_dds(
|
||||
+ *pounder_settings,
|
||||
+ c.local.dds_clock_state.as_mut().unwrap(),
|
||||
+ );
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
}
|
||||
+ // Update Pounder configurations
|
||||
+ c.shared.pounder.lock(|pounder| {
|
||||
+ if let Some(pounder) = pounder {
|
||||
+ let pounder_settings = settings.dual_iir.pounder.as_ref().unwrap();
|
||||
+ // let mut clocking = c.local.dds_clock_state;
|
||||
+ pounder.update_dds(
|
||||
+ *pounder_settings,
|
||||
+ c.local.dds_clock_state.as_mut().unwrap(),
|
||||
+ );
|
||||
+ }
|
||||
+ });
|
||||
|
||||
c.shared
|
||||
.network
|
||||
.lock(|net| net.direct_stream(*settings.dual_iir.stream));
|
||||
@@ -485,22 +521,31 @@ mod app {
|
||||
});
|
||||
}
|
||||
|
||||
@ -287,11 +370,12 @@ index e7596341..71eee420 100644
|
||||
- let (gains, telemetry_period) =
|
||||
+ 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.afe, *settings.dual_iir.telemetry_period)
|
||||
+ (
|
||||
+ settings.dual_iir.afe,
|
||||
+ *settings.dual_iir.telemetry_period,
|
||||
+ settings.dual_iir.pounder
|
||||
)
|
||||
+ )
|
||||
});
|
||||
|
||||
+ let pounder_telemetry = c.shared.pounder.lock(|pounder| {
|
||||
@ -300,31 +384,27 @@ index e7596341..71eee420 100644
|
||||
+
|
||||
c.shared.network.lock(|net| {
|
||||
net.telemetry.publish(&telemetry.finalize(
|
||||
gains[0],
|
||||
gains[1],
|
||||
*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 d8d193dd..4e5abb28 100644
|
||||
--- a/src/bin/lockin.rs
|
||||
+++ b/src/bin/lockin.rs
|
||||
@@ -28,9 +28,10 @@
|
||||
#![no_main]
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
use core::{
|
||||
- iter,
|
||||
convert::TryFrom,
|
||||
- mem::MaybeUninit,
|
||||
+ convert::TryFrom,
|
||||
+ mem::{MaybeUninit, size_of},
|
||||
sync::atomic::{fence, Ordering},
|
||||
+ iter
|
||||
};
|
||||
|
||||
use miniconf::{Leaf, Tree};
|
||||
@@ -246,7 +247,7 @@ mod app {
|
||||
@@ -248,7 +248,7 @@ mod app {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
usb: UsbDevice,
|
||||
@ -333,7 +413,7 @@ index 064b43d3..fd0c959e 100644
|
||||
settings: Settings,
|
||||
active_settings: Lockin,
|
||||
telemetry: TelemetryBuffer,
|
||||
@@ -254,7 +255,7 @@ mod app {
|
||||
@@ -256,7 +256,7 @@ mod app {
|
||||
|
||||
#[local]
|
||||
struct Local {
|
||||
@ -342,7 +422,7 @@ index 064b43d3..fd0c959e 100644
|
||||
sampling_timer: SamplingTimer,
|
||||
digital_inputs: (DigitalInput0, DigitalInput1),
|
||||
timestamper: InputStamper,
|
||||
@@ -273,7 +274,7 @@ mod app {
|
||||
@@ -275,7 +275,7 @@ mod app {
|
||||
let clock = SystemTimer::new(|| Systick::now().ticks());
|
||||
|
||||
// Configure the microcontroller
|
||||
@ -351,7 +431,7 @@ index 064b43d3..fd0c959e 100644
|
||||
c.core,
|
||||
c.device,
|
||||
clock,
|
||||
@@ -535,6 +536,7 @@ mod app {
|
||||
@@ -543,6 +543,7 @@ mod app {
|
||||
*gains[0],
|
||||
*gains[1],
|
||||
c.local.cpu_temp_sensor.get_temperature().unwrap(),
|
||||
@ -417,81 +497,22 @@ index cfd08b7f..2570f506 100644
|
||||
Ok(attenuation_code as f32 / 2.0)
|
||||
}
|
||||
diff --git a/src/hardware/pounder/dds_output.rs b/src/hardware/pounder/dds_output.rs
|
||||
index 41fb7762..9404894f 100644
|
||||
index 5527a8e1..23435e2e 100644
|
||||
--- a/src/hardware/pounder/dds_output.rs
|
||||
+++ b/src/hardware/pounder/dds_output.rs
|
||||
@@ -55,8 +55,9 @@
|
||||
@@ -55,7 +55,7 @@
|
||||
use log::warn;
|
||||
use stm32h7xx_hal as hal;
|
||||
|
||||
-use super::{hrtimer::HighResTimerE, QspiInterface};
|
||||
-use ad9959::{Mode, ProfileSerializer};
|
||||
+use arbitrary_int::{u14, u24};
|
||||
+use super::{hrtimer::HighResTimerE, Profile, QspiInterface};
|
||||
+use ad9959::{Acr, Channel, Mode, ProfileSerializer};
|
||||
use ad9959::{Channel, Mode, ProfileSerializer};
|
||||
|
||||
/// The DDS profile update stream.
|
||||
pub struct DdsOutput {
|
||||
@@ -91,8 +92,9 @@ impl DdsOutput {
|
||||
@@ -157,6 +157,46 @@ impl ProfileBuilder<'_> {
|
||||
self
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
+ let mode = self.mode;
|
||||
+ ProfileBuilder {dds_output: self, serializer: ProfileSerializer::new(mode)}
|
||||
}
|
||||
|
||||
/// Write a profile to the stream.
|
||||
@@ -105,7 +107,7 @@ impl DdsOutput {
|
||||
/// # Args
|
||||
/// * `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() };
|
||||
@@ -124,3 +126,69 @@ impl DdsOutput {
|
||||
self.io_update_trigger.trigger();
|
||||
}
|
||||
}
|
||||
+
|
||||
+/// A temporary builder for serializing and writing profiles.
|
||||
+pub struct ProfileBuilder<'a> {
|
||||
+ dds_output: &'a mut DdsOutput,
|
||||
+ serializer: ProfileSerializer,
|
||||
+}
|
||||
+
|
||||
+impl ProfileBuilder<'_> {
|
||||
+ /// Update a number of channels with the provided configuration
|
||||
+ ///
|
||||
+ /// # Args
|
||||
+ /// * `channels` - A list of channels to apply the configuration to.
|
||||
+ /// * `ftw` - If provided, indicates a frequency tuning word for the channels.
|
||||
+ /// * `pow` - If provided, indicates a phase offset word for the channels.
|
||||
+ /// * `acr` - If provided, indicates the amplitude control register for the channels. The
|
||||
+ /// 24-bits of the ACR should be stored in the last 3 LSB.
|
||||
+ #[allow(dead_code)]
|
||||
+ #[inline]
|
||||
+ pub fn update_channels(
|
||||
+ &mut self,
|
||||
+ channels: Channel,
|
||||
+ ftw: Option<u32>,
|
||||
+ pow: Option<u16>,
|
||||
+ acr: Option<u32>,
|
||||
+ ) -> &mut Self {
|
||||
+ let pow = if let Some(pow) = pow {
|
||||
+ Some(u14::try_new(pow & 0x3FFF).unwrap())
|
||||
+ } else { None };
|
||||
+ let acr = if let Some(acr) = acr {
|
||||
+ Some(Acr::new_with_raw_value(u24::try_new(acr).unwrap()))
|
||||
+ } else { None };
|
||||
+ self.serializer.push(channels, ftw, pow, acr);
|
||||
+ self
|
||||
+ }
|
||||
+
|
||||
+ /// Update a number of channels with fully defined profile settings.
|
||||
+ ///
|
||||
+ /// # Args
|
||||
@ -507,46 +528,58 @@ index 41fb7762..9404894f 100644
|
||||
+ channels: Channel,
|
||||
+ profile: Profile,
|
||||
+ ) -> &mut Self {
|
||||
+ self.serializer.push(
|
||||
+ self.serializer.update_channels(
|
||||
+ channels,
|
||||
+ Some(profile.frequency_tuning_word),
|
||||
+ Some(u14::try_new(profile.phase_offset & 0x3FFF).unwrap()),
|
||||
+ Some(Acr::new_with_raw_value(u24::try_new(profile.amplitude_control).unwrap())),
|
||||
+ Some(profile.phase_offset),
|
||||
+ Some(profile.amplitude_control),
|
||||
+ );
|
||||
+ self
|
||||
+ }
|
||||
+
|
||||
+ /// Write the profile to the DDS asynchronously.
|
||||
+ #[allow(dead_code)]
|
||||
+ /// Update the system clock configuration.
|
||||
+ ///
|
||||
+ /// # Args
|
||||
+ /// * `reference_clock_frequency` - The reference clock frequency provided to the AD9959 core.
|
||||
+ /// * `multiplier` - The frequency multiplier of the system clock. Must be 1 or 4-20.
|
||||
+ #[inline]
|
||||
+ pub fn write(&mut self) {
|
||||
+ self.dds_output.write(&mut self.serializer);
|
||||
+ pub fn set_system_clock(
|
||||
+ &mut self,
|
||||
+ reference_clock_frequency: f32,
|
||||
+ multiplier: u8,
|
||||
+ ) -> Result<&mut Self, ad9959::Error> {
|
||||
+ self.serializer
|
||||
+ .set_system_clock(reference_clock_frequency, multiplier)?;
|
||||
+ Ok(self)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/// Write the profile to the DDS asynchronously.
|
||||
#[allow(dead_code)]
|
||||
#[inline]
|
||||
diff --git a/src/hardware/pounder/mod.rs b/src/hardware/pounder/mod.rs
|
||||
index 8cf1fb5c..8cc99423 100644
|
||||
index c144db0c..a6831605 100644
|
||||
--- a/src/hardware/pounder/mod.rs
|
||||
+++ b/src/hardware/pounder/mod.rs
|
||||
@@ -1,12 +1,15 @@
|
||||
@@ -1,10 +1,17 @@
|
||||
use self::attenuators::AttenuatorInterface;
|
||||
|
||||
use super::hal;
|
||||
-use crate::hardware::{shared_adc::AdcChannel, I2c1Proxy};
|
||||
-use ad9959::Address;
|
||||
-use bitbybit::bitenum;
|
||||
+use crate::hardware::{setup, shared_adc::AdcChannel, I2c1Proxy};
|
||||
+use crate::net::telemetry::PounderTelemetry;
|
||||
+use ad9959::{Address, frequency_to_ftw, phase_to_pow, amplitude_to_acr, validate_clocking};
|
||||
+use ad9959::{
|
||||
+ amplitude_to_acr, frequency_to_ftw, phase_to_pow, validate_clocking,
|
||||
+};
|
||||
use embedded_hal_02::blocking::spi::Transfer;
|
||||
use enum_iterator::Sequence;
|
||||
+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 {
|
||||
@@ -120,38 +127,97 @@ impl From<Channel> for GpioPin {
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,7 +701,7 @@ index 8cf1fb5c..8cc99423 100644
|
||||
}
|
||||
|
||||
impl From<Channel> for ad9959::Channel {
|
||||
@@ -585,3 +647,79 @@ impl rf_power::PowerMeasurementInterface for PounderDevices {
|
||||
@@ -585,3 +651,78 @@ impl rf_power::PowerMeasurementInterface for PounderDevices {
|
||||
Ok(adc_scale * 2.048)
|
||||
}
|
||||
}
|
||||
@ -689,15 +722,14 @@ index 8cf1fb5c..8cc99423 100644
|
||||
+ .set_ext_clk(*settings.clock.external_clock)
|
||||
+ .unwrap();
|
||||
+
|
||||
+ // skip since ad9959 should already set up the clock
|
||||
+ // self.dds_output
|
||||
+ // .builder()
|
||||
+ // .set_system_clock(
|
||||
+ // *settings.clock.reference_clock,
|
||||
+ // *settings.clock.multiplier,
|
||||
+ // )
|
||||
+ // .unwrap()
|
||||
+ // .write();
|
||||
+ self.dds_output
|
||||
+ .builder()
|
||||
+ .set_system_clock(
|
||||
+ *settings.clock.reference_clock,
|
||||
+ *settings.clock.multiplier,
|
||||
+ )
|
||||
+ .unwrap()
|
||||
+ .write();
|
||||
+
|
||||
+ *clocking = settings.clock;
|
||||
+ }
|
||||
@ -749,15 +781,15 @@ index 8cf1fb5c..8cc99423 100644
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/net/data_stream.rs b/src/net/data_stream.rs
|
||||
index 94b2fb6c..510b9e6a 100644
|
||||
index 714ec57f..d442f197 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 core::{fmt::Write, mem::MaybeUninit};
|
||||
+use core::{fmt::Write, mem::{MaybeUninit, size_of_val}};
|
||||
use heapless::{
|
||||
box_pool,
|
||||
pool::boxed::{Box, BoxBlock},
|
||||
@ -783,10 +815,10 @@ index 8d815e51..5541f8ba 100644
|
||||
}
|
||||
}
|
||||
diff --git a/src/net/telemetry.rs b/src/net/telemetry.rs
|
||||
index a368c014..30dfd0c3 100644
|
||||
index 6b42b97c..48f9828e 100644
|
||||
--- a/src/net/telemetry.rs
|
||||
+++ b/src/net/telemetry.rs
|
||||
@@ -16,7 +16,7 @@ use minimq::Publication;
|
||||
@@ -16,7 +16,7 @@ use minimq::{DeferredPublication, Publication};
|
||||
use serde::Serialize;
|
||||
|
||||
use super::NetworkReference;
|
||||
@ -838,8 +870,8 @@ index a368c014..30dfd0c3 100644
|
||||
+ cpu_temp: f32,
|
||||
+ pounder: Option<PounderTelemetry>,
|
||||
+ ) -> Telemetry {
|
||||
let in0_volts = f32::from(self.adcs[0]) / afe0.gain();
|
||||
let in1_volts = f32::from(self.adcs[1]) / afe1.gain();
|
||||
let in0_volts = Into::<f32>::into(self.adcs[0]) / afe0.as_multiplier();
|
||||
let in1_volts = Into::<f32>::into(self.adcs[1]) / afe1.as_multiplier();
|
||||
|
||||
@@ -89,6 +116,7 @@ impl TelemetryBuffer {
|
||||
adcs: [in0_volts, in1_volts],
|
||||
|
5
web.nix
5
web.nix
@ -11,11 +11,6 @@ in
|
||||
export DOMAINNAME=m-labs-intl.com
|
||||
${pkgs.zola}/bin/zola build -o $out -u https://$DOMAINNAME
|
||||
'';
|
||||
web-ph = pkgs.runCommand "web-ph" {}
|
||||
''
|
||||
cd ${web-src}
|
||||
DOMAINNAME=m-labs.hk ${pkgs.zola}/bin/zola build -o $out -u https://m-labs.ph
|
||||
'';
|
||||
sphinxcontrib-platformpicker = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "sphinxcontrib-platformpicker";
|
||||
version = "1.3";
|
||||
|
Loading…
x
Reference in New Issue
Block a user