Fixing math

This commit is contained in:
Ryan Summers 2021-07-19 14:37:34 +02:00
parent e2d2ce0752
commit 1c32695a49
2 changed files with 15 additions and 16 deletions

View File

@ -345,14 +345,13 @@ const APP: () = {
c.resources.afes.1.set_gain(settings.afe[1]); c.resources.afes.1.set_gain(settings.afe[1]);
// Update the signal generators // Update the signal generators
c.resources.signal_generator.lock(|generator| { for (i, &config) in settings.signal_generator.iter().enumerate() {
for (i, (ref mut generator, &config)) in generator
.iter_mut()
.zip(settings.signal_generator.iter())
.enumerate()
{
match config.try_into() { match config.try_into() {
Ok(config) => generator.update_waveform(config), Ok(config) => {
c.resources
.signal_generator
.lock(|generator| generator[i].update_waveform(config));
}
Err(err) => log::error!( Err(err) => log::error!(
"Failed to update signal generation on DAC{}: {:?}", "Failed to update signal generation on DAC{}: {:?}",
i, i,
@ -360,7 +359,6 @@ const APP: () = {
), ),
} }
} }
});
let target = settings.stream_target.into(); let target = settings.stream_target.into();
c.resources.network.direct_stream(target); c.resources.network.direct_stream(target);

View File

@ -1,4 +1,4 @@
use crate::hardware::{dac::DacCode, design_parameters::ADC_SAMPLE_TICKS}; use crate::{configuration::ADC_SAMPLE_TICKS_LOG2, hardware::dac::DacCode};
use core::convert::{TryFrom, TryInto}; use core::convert::{TryFrom, TryInto};
use miniconf::Miniconf; use miniconf::Miniconf;
use serde::Deserialize; use serde::Deserialize;
@ -60,7 +60,8 @@ impl TryFrom<BasicConfig> for Config {
fn try_from(config: BasicConfig) -> Result<Config, Error> { fn try_from(config: BasicConfig) -> Result<Config, Error> {
// Calculate the frequency tuning words // Calculate the frequency tuning words
let frequency_tuning_word: [u32; 2] = { let frequency_tuning_word: [u32; 2] = {
const LSB_PER_HERTZ: f32 = ((1u64 + ADC_SAMPLE_TICKS_LOG2) << 32) as f32 / 100.0e6; const LSB_PER_HERTZ: f32 =
(1u64 << (31 + ADC_SAMPLE_TICKS_LOG2)) as f32 / 100.0e6;
let ftw = config.frequency * LSB_PER_HERTZ; let ftw = config.frequency * LSB_PER_HERTZ;
if config.symmetry <= 0.0 { if config.symmetry <= 0.0 {