commit 46dcede5e2ea61bfed8e2576476c19c423479606
Author: Daniel P. <daniel@steew.eu>
Date: Wed Oct 29 22:38:09 2025 +0000
diff --git a/fw/RustFM/.cargo/config b/fw/RustFM/.cargo/config
deleted file mode 100644
index 70caeff..0000000
--- a/fw/RustFM/.cargo/config
+++ /dev/null
@@ -132 +00 @@
-#[target.thumbv7m-none-eabi]
-# uncomment this to make `cargo run` execute programs on QEMU
-# runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
-
-[target.'cfg(all(target_arch = "arm", target_os = "none"))']
-# uncomment ONE of these three option to make `cargo run` start a GDB session
-# which option to pick depends on your system
-# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
-# runner = "gdb-multiarch -q -x openocd.gdb"
-# runner = "gdb -q -x openocd.gdb"
-runner = "probe-rs run --chip STM32L431RCTx"
-
-rustflags = [
- # LLD (shipped with the Rust toolchain) is used as the default linker
- "-C", "link-arg=-Tlink.x",
-
- # if you run into problems with LLD switch to the GNU linker by commenting out
- # this line
- # "-C", "linker=arm-none-eabi-ld",
-
- # if you need to link to pre-compiled C libraries provided by a C toolchain
- # use GCC as the linker by commenting out both lines above and then
- # uncommenting the three lines below
- # "-C", "linker=arm-none-eabi-gcc",
- # "-C", "link-arg=-Wl,-Tlink.x",
- # "-C", "link-arg=-nostartfiles",
-]
-
-[build]
-# Pick ONE of these compilation targets
-# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
-target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
\ No newline at end of file
diff --git a/fw/RustFM/Cargo.toml b/fw/RustFM/Cargo.toml
index 5ea3526..bda5274 100644
--- a/fw/RustFM/Cargo.toml
+++ b/fw/RustFM/Cargo.toml
@@ -177 +177 @@ mpu6050-dmp = "0.3.0"
# embedded-hal-compat = "0.13.0"
rtic = {version = "2.2.0", features=["thumbv7-backend"]}
rtic-sync = "1.4.0"
-# rtic-monotonics = {version = "2.1.0", features = ["stm32_tim3", "stm32l431rc"]}
+rtic-monotonics = {version = "2.1.0", features = ["stm32_tim2", "stm32l431rc"]}
[dependencies.stm32l4xx-hal]
version = "0.7.1"
diff --git a/fw/RustFM/memory.x b/fw/RustFM/memory.x
index 33e05f4..3ec49df 100644
--- a/fw/RustFM/memory.x
+++ b/fw/RustFM/memory.x
@@ -27 +28 @@ MEMORY
{
/* NOTE K = KiBi = 1024 bytes */
/* TODO Adjust these memory regions to match your device memory layout */
- FLASH : ORIGIN = 0x08000000, LENGTH = 256K
+ /* FLASH : ORIGIN = 0x08000000, LENGTH = 256K */
+ FLASH : ORIGIN = 0x08000000, LENGTH = 256K
RAM : ORIGIN = 0x20000000, LENGTH = 64K
}
diff --git a/fw/RustFM/rustfmt.toml b/fw/RustFM/rustfmt.toml
new file mode 100644
index 0000000..c51666e
--- /dev/null
+++ b/fw/RustFM/rustfmt.toml
@@ -00 +1 @@
+edition = "2018"
\ No newline at end of file
diff --git a/fw/RustFM/src/main.rs b/fw/RustFM/src/main.rs
index 041b412..5c50a94 100644
--- a/fw/RustFM/src/main.rs
+++ b/fw/RustFM/src/main.rs
@@ -322 +321 @@
use panic_halt as _;
extern crate cortex_m;
-#[macro_use]
+// #[macro_use]
extern crate cortex_m_rt as rt;
extern crate cortex_m_semihosting as sh;
-use cortex_m_rt::ExceptionFrame;
-
#[rtic::app(device = stm32l4xx_hal::pac, peripherals = true, dispatchers = [SAI1, ADC1_2, SPI1])]
mod app {
-
- use core::any::Any;
+ use rtic_monotonics::{stm32::prelude::*, stm32_tim2_monotonic};
+ stm32_tim2_monotonic!(Mono, 100);
+
@@ -278 +268 @@ mod app {
- Alternate, Input, OpenDrain, Output, PullDown, PushPull, PA10, PA12, PA6, PA9,
- PC14, PC15,
+ Alternate, Input, OpenDrain, Output, PullDown, PushPull, PA10, PA12, PA6, PA9, PC14,
+ PC15,
@@ -647 +638 @@ mod app {
- SLOW = 1, MEDIUM = 3,
+ SLOW = 1,
+ MEDIUM = 3,
@@ -908 +907 @@ mod app {
- mpu: Mpu6050<I2c<I2C1, (PA9<Alternate<OpenDrain, 4>>, PA10<Alternate<OpenDrain, 4>>)>>
- // mpu: Mpu6050<I2c>,
+ mpu: Mpu6050<I2c<I2C1, (PA9<Alternate<OpenDrain, 4>>, PA10<Alternate<OpenDrain, 4>>)>>, // mpu: Mpu6050<I2c>,
@@ -11915 +11827 @@ mod app {
+ let mut gpiob = dp.GPIOB.split(&mut rcc.ahb2);
+
- let txpin = gpioa
+ let mut txpin = gpioa
+ let mut rxen = gpiob
+ .pb0
+ .into_push_pull_output(&mut gpiob.moder, &mut gpiob.otyper);
+ let mut txen = gpiob
+ .pb1
+ .into_push_pull_output(&mut gpiob.moder, &mut gpiob.otyper);
+
+ // setup for transmission
+ rxen.set_high();
+ txen.set_low();
@@ -1629 +17316 @@ mod app {
- // mpu_slave_add_lsb.set_low();
+ mpu_slave_add_lsb.set_low();
- let mut timer = Delay::new(c.core.SYST, clocks);
+ let mut delay = Delay::new(c.core.SYST, clocks);
+
+ // init sequence for max7044
+ txpin.set_low();
+ delay.delay_ms(1_u32);
+ txpin.set_high();
+ delay.delay_ms(1_u32);
+ txpin.set_low();
@@ -17716 +19521 @@ mod app {
- mpu.initialize_dmp(&mut timer).unwrap();
+ mpu.initialize_dmp(&mut delay).unwrap();
+ mpu.set_clock_source(mpu6050_dmp::clock_source::ClockSource::Xgyro)
+ .unwrap();
+
+ Mono::start(12_000_000);
-
+
+ #[allow(unused_variables)]
- sender1::spawn(send).unwrap();
-
+ // sender1::spawn(send).unwrap();
+
@@ -2079 +23012 @@ mod app {
- async fn sender1(_c: sender1::Context, mut sender: Sender<'static, usize, CAPACITY>) {
- hprintln!("Sender 1 sending: 1");
- sender.send(1).await.unwrap();
+ async fn sender1(_: sender1::Context, mut sender: Sender<'static, usize, CAPACITY>) {
+ loop {
+ // hprintln!("Sender 1 sending: 1");
+ sender.send(1).await.unwrap();
+ Mono::delay(50_u64.millis()).await
+ }
@@ -23513 +26114 @@ mod app {
- while let Ok(data) = receiver.recv().await {
- hprintln!("Got data to transmit: {}", data);
- // TODO: transmit data and delay
+ while let Ok(_data) = receiver.recv().await {
+ // hprintln!("Got data to transmit: {}", data);
+ ctx.local.txpin.toggle();
+ hprintln!("No more data received.");