commit 023680192bb7146ecd6366744d6ed2124225a89b
Author: Daniel P. <daniel@steew.eu>
Date: Sun Nov 02 00:26:15 2025 +0000
diff --git a/fw/RustFM/Cargo.toml b/fw/RustFM/Cargo.toml
index b509328..1930c59 100644
--- a/fw/RustFM/Cargo.toml
+++ b/fw/RustFM/Cargo.toml
@@ -412 +48 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-# panic-halt = "0.2.0"
-# panic-semihosting = "0.6.0"
-# cortex-m-semihosting = "0.5.0"
# mpu6050 = "0.1.6"
-# mpu6050-dmp = "0.3.0"
-# embedded-hal-compat = "0.13.0"
+mpu6050-dmp = "0.6.1"
embassy-executor = { version = "0.9.0", features = ["defmt", "arch-cortex-m", "executor-thread"] }
embassy-time = { version = "0.5.0", features = ["defmt"] }
embassy-sync = { version = "0.7.2", features = [ "defmt" ] }
@@ -295 +254 @@ defmt = "1.0.1"
[dependencies.embassy-stm32]
version = "0.4.0"
features = ["stm32l431rc", "unstable-pac", "memory-x", "time-driver-any", "exti", "chrono"]
-# features = ["stm32l431rc", "unstable-pac", "time-driver-any", "exti", "chrono"]
diff --git a/fw/RustFM/src/main.rs b/fw/RustFM/src/main.rs
index 4a070f9..954f462 100644
--- a/fw/RustFM/src/main.rs
+++ b/fw/RustFM/src/main.rs
@@ -116 +116 @@
#![no_std]
#![no_main]
-use core::{any::Any, ops::Deref};
-
-use defmt::*;
+use defmt::{trace};
use embassy_executor::Spawner;
use embassy_stm32::{
- gpio::{AnyPin, Level, Output, Speed}, rcc::{self}, time::hz, timer::simple_pwm::{PwmPin, SimplePwm}, Config, Peri
+ exti::ExtiInput, gpio::{AnyPin, Level, Output, Speed}, i2c::{self, I2c, Master}, mode::Blocking, rcc::{self}, Config, Peri
};
-use embassy_time::{Timer, WithTimeout};
+use embassy_time::{Timer, Delay};
use {defmt_rtt as _, panic_probe as _};
+use mpu6050_dmp::{sensor::Mpu6050};
+
#[embassy_executor::main]
async fn main(spawner: Spawner) {
@@ -2120 +2129 @@ async fn main(spawner: Spawner) {
+ let iic = I2c::new_blocking(p.I2C1, p.PA9, p.PA10, i2c::Config::default());
+ let _lsb_pin = Output::new(p.PA11, Level::Low, Speed::Low);
+
+
+ let _rxen = Output::new(p.PB0, Level::High, Speed::Low);
+ let _txen = Output::new(p.PB1, Level::Low, Speed::Low);
+
+ core::mem::forget(_rxen);
+ core::mem::forget(_txen);
+ core::mem::forget(_lsb_pin);
- let rxen = Output::new(p.PB0, Level::High, Speed::Low);
- let txen = Output::new(p.PB1, Level::Low, Speed::Low);
+ let imu_int = ExtiInput::new(p.PA12, p.EXTI12, embassy_stm32::gpio::Pull::Down);
+ spawner.spawn(transmit(txpin.into())).unwrap();
+ spawner.spawn(read_mpu(iic, imu_int.into())).unwrap();
+
- spawner.spawn(transmit(txpin.into())).unwrap();
-
- // loop {
- // }
+
}
#[embassy_executor::task(pool_size = 2)]
@@ -5115 +6040 @@ async fn status_leds(p: Peri<'static, AnyPin>) {
#[embassy_executor::task]
async fn transmit(p: Peri<'static, AnyPin>) {
- let mut txpin = Output::new(p, Level::Low, Speed::Medium);
+ let mut txpin = Output::new(p, Level::Low, Speed::VeryHigh);
-
+
- Timer::after_millis(1).await;
+ Timer::after_millis(4).await;
+ }
+}
+
+
+#[embassy_executor::task]
+async fn read_mpu(iic: I2c<'static, Blocking, Master>, mut ext: ExtiInput<'static>) {
+ let mpu = Mpu6050::new(iic, mpu6050_dmp::address::Address::default());
+ let mut mpu = mpu.unwrap();
+ mpu.initialize_dmp(&mut Delay).unwrap();
+ mpu.enable_dmp().unwrap();
+ mpu.set_clock_source(mpu6050_dmp::clock_source::ClockSource::Xgyro).unwrap();
+ let mut fifo : [u8; 6] = [0; 6];
+ mpu.interrupt_fifo_oflow_en().unwrap();
+ mpu.enable_fifo().unwrap();
+ mpu.interrupt_read_clear().unwrap();
+
+ loop {
+ ext.wait_for_rising_edge().await;
+ trace!("Received new data");
+ mpu.read_fifo(&mut fifo).unwrap();
+ // let accel = mpu.gyro().unwrap();
+ // trace!("X: {}, Y: {}, Z: {}" , accel.x(), accel.y(), accel.z());
+ trace!("{}", fifo);
+ mpu.interrupt_read_clear().unwrap();
}
+