Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
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
16 changes: 13 additions & 3 deletions sfy-buoy/Cargo.lock

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

5 changes: 3 additions & 2 deletions sfy-buoy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ serde-json-core = { version = "0.4", optional = true }
serde_json = { version = "1", optional = true }
embedded-hal = "0.2.6"
cortex-m = "*"
ism330dhcx = "0.4.0"
ism330dhcx = { git = "https://github.com/stianvikanes/ism330dhcx", branch = "CTRL10-register-trying" }
#ism330dhcx = "0.4.0"
static_assertions = "1"
chrono = { version = "0.4.19", default-features = false }
micromath = { version = "2", features = [ "quaternion", "vector" ] }
Expand Down Expand Up @@ -54,7 +55,7 @@ build-bin = [ "fir", "storage", "raw", "anyhow", "argh", "serde-json-core/std",


[patch.crates-io]
ism330dhcx = { git = "https://github.com/gauteh/ism330dhcx", branch = "52hz" }
ism330dhcx = { git = "https://github.com/stianvikanes/ism330dhcx", branch = "CTRL10-register-trying" }
# ism330dhcx = { path = "../../../../dev/embedded/imu/ism330dhcx" }
cmsis_dsp = { git = "https://github.com/samcrow/cmsis_dsp.rs" }
# embedded-sdmmc = { git = "https://github.com/rust-embedded-community/embedded-sdmmc-rs", branch = "develop" }
Expand Down
2 changes: 1 addition & 1 deletion sfy-buoy/sfy-artemis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use embedded_hal::blocking::{
};

#[cfg(feature = "storage")]
use embedded_hal::spi::MODE_0;
use embedded_hal::spi::MODE_0;
#[cfg(feature = "storage")]
use hal::spi::{Freq, Spi};

Expand Down
2 changes: 1 addition & 1 deletion sfy-buoy/src/fir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::simd::{f32x4, SimdFloat};
use heapless::Deque;

/// Sample rate.
pub const FREQ: f32 = 208.0;
pub const FREQ: f32 = 104.0;

pub mod hz50 {
/// Filter order, length or number of taps.
Expand Down
258 changes: 129 additions & 129 deletions sfy-buoy/src/firwin.10_52_coeff

Large diffs are not rendered by default.

258 changes: 129 additions & 129 deletions sfy-buoy/src/firwin.25_52_coeff

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sfy-buoy/src/make_firwin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import scipy as sc

FREQ = 208. # Input frequency
FREQ = 104. # Input frequency

# 50 Hz
NTAP = 129 # Length of filter
Expand Down
11 changes: 8 additions & 3 deletions sfy-buoy/src/waves/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use embedded_hal::blocking::{
delay::DelayMs,
i2c::{Write, WriteRead},
};
use ism330dhcx::{ctrl1xl, ctrl2g, fifo, fifoctrl, Ism330Dhcx};
use ism330dhcx::{ctrl10c, ctrl1xl, ctrl2g, fifo, fifoctrl, freqfine, Ism330Dhcx};

#[cfg(feature = "fir")]
use static_assertions as sa;
Expand All @@ -28,7 +28,7 @@ pub type AxlPacketT = (AxlPacket, VecRawAxl);
#[cfg(not(feature = "raw"))]
pub type AxlPacketT = (AxlPacket,);

pub const FREQ: Freq = Freq::Hz208;
pub const FREQ: Freq = Freq::Hz104;

#[cfg(all(feature = "20Hz", not(feature = "fir")))]
compile_error!("Feature 20Hz requires feature fir");
Expand Down Expand Up @@ -161,7 +161,7 @@ impl<E: Debug> From<E> for ImuError<E> {
}
}

impl<E: Debug, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
impl<E: Debug + defmt::Format, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
pub fn new(mut i2c: I2C) -> Result<Waves<I2C>, E> {
defmt::debug!("setting up imu driver..");
let imu = Ism330Dhcx::new_with_address(&mut i2c, 0x6a)?;
Expand Down Expand Up @@ -270,6 +270,9 @@ impl<E: Debug, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
// Gyro: LPF2 at 66.8 Hz when ODR = 208 Hz (not configurable)
// Accel: default is ODR/2 => 104 Hz.

//CTRL10_C
sensor.ctrl10c.enable_timestamp(i2c, true)?; // Enable timestamp (for the ODR_actual)

Ok(())
}

Expand Down Expand Up @@ -298,6 +301,8 @@ impl<E: Debug, I2C: WriteRead<Error = E> + Write<Error = E>> Waves<I2C> {
// Start FIFO. The FIFO will fill up and stop if it is not emptied fast enough.
self.imu.fifoctrl.mode(i2c, fifoctrl::FifoMode::FifoMode)?;

let actual: f32 = self.imu.freqfine.read_freq(i2c)?.into();
defmt::debug!("actual frequency: {}", actual);
Ok(())
}

Expand Down