commit e0651a723c77e70cc01818bc67477fa2146199ea
Author: Daniel P. <daniel@steew.eu>
Date: Mon Oct 27 13:02:04 2025 +0000
diff --git a/fw/RustFM/.cargo/config.toml b/fw/RustFM/.cargo/config.toml
new file mode 100644
index 0000000..70caeff
--- /dev/null
+++ b/fw/RustFM/.cargo/config.toml
@@ -00 +132 @@
+#[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.lock b/fw/RustFM/Cargo.lock
index b4a96bb..25fbd5c 100644
--- a/fw/RustFM/Cargo.lock
+++ b/fw/RustFM/Cargo.lock
@@ -1121 +116 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "approx"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
-dependencies = [
- "num-traits",
-]
-
-[[package]]
-name = "autocfg"
-version = "1.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
-
[[package]]
name = "bare-metal"
version = "0.2.5"
@@ -18817 +1736 @@ dependencies = [
"embedded-hal-async",
]
-[[package]]
-name = "embedded-hal-compat"
-version = "0.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08ecac72f6be75ad2d4809c9f07d45502e2e5c9a4e9579077f28d7135de81df3"
-dependencies = [
- "embedded-hal 0.2.7",
- "embedded-hal 1.0.0",
- "nb 1.1.0",
-]
-
[[package]]
name = "equivalent"
version = "1.0.2"
@@ -2148 +1887 @@ dependencies = [
"cortex-m-semihosting",
"critical-section",
"embedded-hal 0.2.7",
- "embedded-hal-compat",
- "mpu6050",
+ "mpu6050-dmp",
"nb 1.1.0",
"panic-halt",
"panic-semihosting",
@@ -34828 +32113 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
[[package]]
-name = "mpu6050"
-version = "0.1.6"
+name = "mpu6050-dmp"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abd67852b244bcca82aa14dd89d50795c065fa598e435c0fe2724663f6e3b9f2"
+checksum = "78ad9db142f17e7e850abb7089a683396a7c5e89cb3b51d5512ded0b844551e4"
dependencies = [
"embedded-hal 0.2.7",
"libm",
- "nalgebra",
-]
-
-[[package]]
-name = "nalgebra"
-version = "0.31.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20bd243ab3dbb395b39ee730402d2e5405e448c75133ec49cc977762c4cba3d1"
-dependencies = [
- "approx",
- "num-complex",
- "num-rational",
- "num-traits",
- "simba",
- "typenum",
]
[[package]]
@@ -39643 +3546 @@ dependencies = [
"windows-sys",
]
-[[package]]
-name = "num-complex"
-version = "0.4.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
-dependencies = [
- "num-traits",
-]
-
-[[package]]
-name = "num-integer"
-version = "0.1.46"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
-dependencies = [
- "num-traits",
-]
-
-[[package]]
-name = "num-rational"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
-dependencies = [
- "num-integer",
- "num-traits",
-]
-
-[[package]]
-name = "num-traits"
-version = "0.2.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
-dependencies = [
- "autocfg",
-]
-
[[package]]
name = "once_cell"
version = "1.21.3"
@@ -45512 +3766 @@ dependencies = [
"cortex-m-semihosting",
]
-[[package]]
-name = "paste"
-version = "1.0.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
-
[[package]]
name = "pin-project-lite"
version = "0.2.16"
@@ -66718 +5826 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
-[[package]]
-name = "simba"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2f3fd720c48c53cace224ae62bef1bbff363a70c68c4802a78b5cc6159618176"
-dependencies = [
- "approx",
- "num-complex",
- "num-traits",
- "paste",
-]
-
[[package]]
name = "smallvec"
version = "1.15.1"
@@ -79112 +6946 @@ dependencies = [
"tracing-log",
]
-[[package]]
-name = "typenum"
-version = "1.19.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
-
[[package]]
name = "unicode-ident"
version = "1.0.20"
diff --git a/fw/RustFM/Cargo.toml b/fw/RustFM/Cargo.toml
index cc073b6..5ea3526 100644
--- a/fw/RustFM/Cargo.toml
+++ b/fw/RustFM/Cargo.toml
@@ -614 +614 @@ edition = "2021"
[dependencies]
embedded-hal = "0.2.7"
nb = "1.1.0"
-cortex-m = {git = "https://github.com/rust-embedded/cortex-m", features = ["critical-section-single-core"]}
+cortex-m = {version = "0.7.7", features = ["critical-section-single-core"]}
critical-section = { version = "1.2.0" }
cortex-m-rt ="0.7.5"
panic-halt = "0.2.0"
panic-semihosting = "0.6.0"
cortex-m-semihosting = "0.5.0"
# mpu6050 = "0.1.6"
-mpu6050-dmp = "0.6.1"
+mpu6050-dmp = "0.3.0"
# embedded-hal-compat = "0.13.0"
rtic = {version = "2.2.0", features=["thumbv7-backend"]}
rtic-sync = "1.4.0"
diff --git a/fw/RustFM/src/main.rs b/fw/RustFM/src/main.rs
index cff9f16..041b412 100644
--- a/fw/RustFM/src/main.rs
+++ b/fw/RustFM/src/main.rs
@@ -138 +139 @@ use cortex_m_rt::ExceptionFrame;
mod app {
+ use core::any::Any;
- use embedded_hal_compat::{ForwardCompat, ReverseCompat};
+ // use embedded_hal_compat::{ForwardCompat, ReverseCompat};
@@ -897 +907 @@ mod app {
- mpu: Mpu6050<I2c<I2C1, (PA9<Alternate<OpenDrain, 4>>, PA10<Alternate<OpenDrain, 4>>)>>,
+ mpu: Mpu6050<I2c<I2C1, (PA9<Alternate<OpenDrain, 4>>, PA10<Alternate<OpenDrain, 4>>)>>
@@ -1637 +1647 @@ mod app {
- // let mut timer = Delay::new(c.core.SYST, clocks);
+ let mut timer = Delay::new(c.core.SYST, clocks);
@@ -1766 +17711 @@ mod app {
+ mpu.initialize_dmp(&mut timer).unwrap();
+ mpu.enable_dmp().unwrap();
+ mpu.boot_firmware().unwrap();
+
+ // mpu.disable_dmp
@@ -20618 +21220 @@ mod app {
- #[task(binds = EXTI15_10, priority = 7, local = [imu_int])]
+ #[task(binds = EXTI15_10, priority = 7, local = [mpu, imu_int])]
- let acc = c.local.mpu.get_acc();
+ // let acc = c.local.mpu.get_acc();
+ let acc = c.local.mpu.gyro();
+ c.local.mpu.get_fifo_count().unwrap();
- hprintln!("Read TEMP value: {:?}", c.local.mpu.get_temp().unwrap());
+ // hprintln!("Read TEMP value: {:?}", c.local.mpu.get_temp().unwrap());
- c.local.imu_int.clear_interrupt_pending_bit();
+ // c.local.imu_int.clear_interrupt_pending_bit();
- c.local
- .mpu
- .read_bits(MpuRegs::INT_STATUS.into(), 0, 0)
- .unwrap();
+ // c.local
+ // .mpu
+ // .read_bits(MpuRegs::INT_STATUS.into(), 0, 0)
+ // .unwrap();
@@ -2296 +2377 @@ mod app {
+ // TODO: transmit data and delay
@@ -28671 +2953 @@ mod app {
}
-
-// let mut hstdout = hio::hstdout().unwrap();
-
-// writeln!(hstdout, "Hello, world!").unwrap();
-
-// let cp = cortex_m::Peripherals::take().unwrap();
-// let dp = hal::stm32::Peripherals::take().unwrap();
-
-// let mut flash = dp.FLASH.constrain(); // .constrain();
-// let mut rcc = dp.RCC.constrain();
-// let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1);
-
-// // // Try a different clock configuration
-// // let clocks = rcc.cfgr.hclk(12.MHz()).freeze(&mut flash.acr, &mut pwr);
-// let clocks = rcc.cfgr
-// .hse(12.MHz(), CrystalBypass::Disable, ClockSecuritySystem::Disable)
-// .sysclk(48.MHz())
-// .pclk1(24.MHz())
-// .pclk2(48.MHz())
-// .freeze(&mut flash.acr, &mut pwr);
-
-// // let mut gpioc = dp.GPIOC.split(&mut rcc.ahb2);
-// // let mut led = gpioc.pc14.into_push_pull_output(&mut gpioc.afrh);
-
-// // initialize i2c peripheral
-// let mut gpioa = dp.GPIOA.split(&mut rcc.ahb2);
-// let scl = gpioa
-// .pa9
-// .into_alternate_open_drain::<4>(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
-// let sda = gpioa
-// .pa10
-// .into_alternate_open_drain::<4>(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
-
-// let iic = i2c::I2c::i2c1(dp.I2C1, (scl, sda), i2c::Config::new(400.kHz(), clocks), &mut rcc.apb1r1);
-// let mut gpioc = dp.GPIOC.split(&mut rcc.ahb2);
-// let mut ledg = gpioc
-// .pc14
-// .into_push_pull_output(&mut gpioc.moder, &mut gpioc.otyper);
-// let mut ledr = gpioc
-// .pc15
-// .into_push_pull_output(&mut gpioc.moder, &mut gpioc.otyper);
-// let mut mpu_slave_add_lsb = gpioa
-// .pa11
-// .into_push_pull_output(&mut gpioa.moder, &mut gpioa.otyper);
-
-// // mpu_slave_add_lsb.set_low();
-// let mut mpu = Mpu6050::new(iic);
-// let init_result = mpu.init(&mut timer);
-
-// loop {
-// writeln!(hstdout,"r/p: {:?}", acc);
-
-// // block!(timer.wait()).unwrap();
-// timer.delay_ms(1000_u32);
-// ledg.set_high();
-// ledr.set_low();
-// // block!(timer.wait()).unwrap();
-// timer.delay_ms(1000_u32);
-// ledg.set_low();
-// ledr.set_high();
-
-// }
-// }
-
-#[exception]
-unsafe fn HardFault(ef: &ExceptionFrame) -> ! {
- panic!("{:#?}", ef);
-}