Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

* Telemetry

### Changed

* Const generics bumping the MSRV to 1.51.0

### Fixed

## [v0.5.0] - 2021-04-21
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ to implement different use cases. Several applications are provides by default
* Get [rustup](https://rustup.rs/)
* `rustup target add thumbv7em-none-eabihf`
* `cargo build --release`
* Minimum supported Rust version (MSRV) is 1.51.0
* When using debug (non `--release`) mode, increase the sample interval significantly.
The added error checking code and missing optimizations may lead to the code
missing deadlines and panicing.
Expand Down
1 change: 0 additions & 1 deletion dsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2018"
[dependencies]
libm = "0.2.1"
serde = { version = "1.0", features = ["derive"], default-features = false }
generic-array = "0.14"
num = { version = "0.4.0", default-features = false }
miniconf = "0.1"

Expand Down
7 changes: 3 additions & 4 deletions dsp/benches/micro.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::f32::consts::PI;

use easybench::bench_env;
use generic_array::typenum::U4;

use dsp::{atan2, cossin, iir, iir_int, Lowpass, PLL, RPLL};

Expand Down Expand Up @@ -72,13 +71,13 @@ fn iir_bench() {
}

fn lowpass_bench() {
let mut dut = Lowpass::<U4>::default();
let mut dut = Lowpass::<4>::default();
println!(
"Lowpass::<U4>::update(x, k): {}",
"Lowpass::<4>::update(x, k): {}",
bench_env((0x32421, 14), |(x, k)| dut.update(*x, *k))
);
println!(
"Lowpass::<U4>::update(x, 14): {}",
"Lowpass::<4>::update(x, 14): {}",
bench_env(0x32421, |x| dut.update(*x, 14))
);
}
Expand Down
5 changes: 2 additions & 3 deletions dsp/src/lockin.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use super::{Complex, ComplexExt, Lowpass, MulScaled};
use generic_array::ArrayLength;

#[derive(Clone, Default)]
pub struct Lockin<N: ArrayLength<i32>> {
pub struct Lockin<const N: usize> {
state: [Lowpass<N>; 2],
}

impl<N: ArrayLength<i32>> Lockin<N> {
impl<const N: usize> Lockin<N> {
/// Update the lockin with a sample taken at a given phase.
pub fn update(&mut self, sample: i32, phase: i32, k: u8) -> Complex<i32> {
// Get the LO signal for demodulation and mix the sample;
Expand Down
16 changes: 10 additions & 6 deletions dsp/src/lowpass.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
use generic_array::{ArrayLength, GenericArray};

/// Arbitrary order, high dynamic range, wide coefficient range,
/// lowpass filter implementation. DC gain is 1.
///
/// Type argument N is the filter order.
#[derive(Clone, Default)]
pub struct Lowpass<N: ArrayLength<i32>> {
#[derive(Clone)]
pub struct Lowpass<const N: usize> {
// IIR state storage
y: GenericArray<i32, N>,
y: [i32; N],
}

impl<const N: usize> Default for Lowpass<N> {
fn default() -> Self {
Lowpass { y: [0i32; N] }
}
}

impl<N: ArrayLength<i32>> Lowpass<N> {
impl<const N: usize> Lowpass<N> {
/// Update the filter with a new sample.
///
/// # Args
Expand Down
3 changes: 1 addition & 2 deletions src/bin/lockin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![no_main]

use embedded_hal::digital::v2::InputPin;
use generic_array::typenum::U4;

use serde::Deserialize;

Expand Down Expand Up @@ -92,7 +91,7 @@ const APP: () = {

timestamper: InputStamper,
pll: RPLL,
lockin: Lockin<U4>,
lockin: Lockin<4>,
}

#[init(spawn=[settings_update, telemetry])]
Expand Down