lockin: make order generic

master
Robert Jördens 2021-02-23 16:46:16 +01:00
parent 1f19b65584
commit 6c6c2e64a7
5 changed files with 11 additions and 10 deletions

1
Cargo.lock generated
View File

@ -724,6 +724,7 @@ dependencies = [
"dsp", "dsp",
"embedded-hal", "embedded-hal",
"enum-iterator", "enum-iterator",
"generic-array 0.14.4",
"heapless", "heapless",
"log", "log",
"mcp23017", "mcp23017",

View File

@ -46,6 +46,7 @@ dsp = { path = "dsp" }
ad9959 = { path = "ad9959" } ad9959 = { path = "ad9959" }
smoltcp-nal = "0.1.0" smoltcp-nal = "0.1.0"
miniconf = "0.1" miniconf = "0.1"
generic-array = "0.14"
[patch.crates-io.miniconf] [patch.crates-io.miniconf]
git = "https://github.com/quartiq/miniconf.git" git = "https://github.com/quartiq/miniconf.git"

View File

@ -1,12 +1,12 @@
use super::{Complex, ComplexExt, Lowpass, MulScaled}; use super::{Complex, ComplexExt, Lowpass, MulScaled};
use generic_array::typenum::U2; use generic_array::ArrayLength;
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct Lockin { pub struct Lockin<N: ArrayLength<i32>> {
state: [Lowpass<U2>; 2], state: [Lowpass<N>; 2],
} }
impl Lockin { impl<N: ArrayLength<i32>> Lockin<N> {
/// Update the lockin with a sample taken at a given phase. /// Update the lockin with a sample taken at a given phase.
pub fn update(&mut self, sample: i32, phase: i32, k: u8) -> Complex<i32> { pub fn update(&mut self, sample: i32, phase: i32, k: u8) -> Complex<i32> {
// Get the LO signal for demodulation and mix the sample; // Get the LO signal for demodulation and mix the sample;

View File

@ -2,10 +2,8 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use stm32h7xx_hal as hal; use generic_array::typenum::U4;
use stabilizer::{hardware, hardware::design_parameters}; use stabilizer::{hardware, hardware::design_parameters};
use dsp::{Accu, Complex, ComplexExt, Lockin, RPLL}; use dsp::{Accu, Complex, ComplexExt, Lockin, RPLL};
use hardware::{ use hardware::{
Adc0Input, Adc1Input, Dac0Output, Dac1Output, InputStamper, AFE0, AFE1, Adc0Input, Adc1Input, Dac0Output, Dac1Output, InputStamper, AFE0, AFE1,
@ -20,7 +18,7 @@ const APP: () = {
timestamper: InputStamper, timestamper: InputStamper,
pll: RPLL, pll: RPLL,
lockin: Lockin, lockin: Lockin<U4>,
} }
#[init] #[init]
@ -156,7 +154,7 @@ const APP: () = {
#[task(binds = ETH, priority = 1)] #[task(binds = ETH, priority = 1)]
fn eth(_: eth::Context) { fn eth(_: eth::Context) {
unsafe { hal::ethernet::interrupt_handler() } unsafe { stm32h7xx_hal::ethernet::interrupt_handler() }
} }
#[task(binds = SPI2, priority = 3)] #[task(binds = SPI2, priority = 3)]

View File

@ -2,6 +2,7 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use generic_array::typenum::U2;
use dsp::{Accu, Complex, ComplexExt, Lockin}; use dsp::{Accu, Complex, ComplexExt, Lockin};
use hardware::{Adc1Input, Dac0Output, Dac1Output, AFE0, AFE1}; use hardware::{Adc1Input, Dac0Output, Dac1Output, AFE0, AFE1};
use stabilizer::{hardware, hardware::design_parameters}; use stabilizer::{hardware, hardware::design_parameters};
@ -20,7 +21,7 @@ const APP: () = {
adc: Adc1Input, adc: Adc1Input,
dacs: (Dac0Output, Dac1Output), dacs: (Dac0Output, Dac1Output),
lockin: Lockin, lockin: Lockin<U2>,
} }
#[init] #[init]