aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/stm32f1/.vscode/launch.json33
-rw-r--r--examples/stm32f1/.vscode/tasks.json21
-rw-r--r--examples/stm32f1/openocd.cfg5
-rw-r--r--examples/stm32f1/openocd.gdb40
-rw-r--r--examples/stm32f1/src/bin/input_capture.rs (renamed from examples/stm32f4/src/bin/pwm_input.rs)8
5 files changed, 103 insertions, 4 deletions
diff --git a/examples/stm32f1/.vscode/launch.json b/examples/stm32f1/.vscode/launch.json
new file mode 100644
index 000000000..7d1504a39
--- /dev/null
+++ b/examples/stm32f1/.vscode/launch.json
@@ -0,0 +1,33 @@
1{
2 /*
3 * Requires the Rust Language Server (rust-analyzer) and Cortex-Debug extensions
4 * https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer
5 * https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug
6 */
7 "version": "0.2.0",
8 "configurations": [
9 {
10 /* Configuration for the STM32F446 Discovery board */
11 "type": "cortex-debug",
12 "request": "launch",
13 "name": "Debug (OpenOCD)",
14 "servertype": "openocd",
15 "cwd": "${workspaceRoot}",
16 "preLaunchTask": "Cargo Build (debug)",
17 "runToEntryPoint": "main",
18 "executable": "./target/thumbv7m-none-eabi/debug/input_capture",
19 /* Run `cargo build --example itm` and uncomment this line to run itm example */
20 // "executable": "./target/thumbv7em-none-eabihf/debug/examples/itm",
21 "device": "STM32F103TB",
22 "configFiles": [
23 "interface/stlink.cfg",
24 "target/stm32f1x.cfg"
25 ],
26 "postLaunchCommands": [
27 "monitor arm semihosting enable"
28 ],
29 "postRestartCommands": [],
30 "postResetCommands": [],
31 }
32 ]
33} \ No newline at end of file
diff --git a/examples/stm32f1/.vscode/tasks.json b/examples/stm32f1/.vscode/tasks.json
new file mode 100644
index 000000000..e153722da
--- /dev/null
+++ b/examples/stm32f1/.vscode/tasks.json
@@ -0,0 +1,21 @@
1{
2 "version": "2.0.0",
3 "tasks": [
4 {
5 "type": "cargo",
6 "command": "build",
7 "problemMatcher": [
8 "$rustc"
9 ],
10 "args": [
11 "--bin",
12 "input_capture"
13 ],
14 "group": {
15 "kind": "build",
16 "isDefault": true
17 },
18 "label": "Cargo Build (debug)",
19 }
20 ]
21} \ No newline at end of file
diff --git a/examples/stm32f1/openocd.cfg b/examples/stm32f1/openocd.cfg
new file mode 100644
index 000000000..0325cd651
--- /dev/null
+++ b/examples/stm32f1/openocd.cfg
@@ -0,0 +1,5 @@
1# Sample OpenOCD configuration for the STM32F3DISCOVERY development board
2
3source [find interface/stlink.cfg]
4
5source [find target/stm32f1x.cfg]
diff --git a/examples/stm32f1/openocd.gdb b/examples/stm32f1/openocd.gdb
new file mode 100644
index 000000000..7795319fb
--- /dev/null
+++ b/examples/stm32f1/openocd.gdb
@@ -0,0 +1,40 @@
1target extended-remote :3333
2
3# print demangled symbols
4set print asm-demangle on
5
6# set backtrace limit to not have infinite backtrace loops
7set backtrace limit 32
8
9# detect unhandled exceptions, hard faults and panics
10break DefaultHandler
11break HardFault
12break rust_begin_unwind
13# # run the next few lines so the panic message is printed immediately
14# # the number needs to be adjusted for your panic handler
15# commands $bpnum
16# next 4
17# end
18
19# *try* to stop at the user entry point (it might be gone due to inlining)
20break main
21
22monitor arm semihosting enable
23
24# # send captured ITM to the file itm.fifo
25# # (the microcontroller SWO pin must be connected to the programmer SWO pin)
26# # 8000000 must match the core clock frequency
27# monitor tpiu config internal itm.txt uart off 8000000
28
29# # OR: make the microcontroller SWO pin output compatible with UART (8N1)
30# # 8000000 must match the core clock frequency
31# # 2000000 is the frequency of the SWO pin
32# monitor tpiu config external uart off 8000000 2000000
33
34# # enable ITM port 0
35# monitor itm port 0 on
36
37load
38
39# start the process but immediately halt the processor
40stepi
diff --git a/examples/stm32f4/src/bin/pwm_input.rs b/examples/stm32f1/src/bin/input_capture.rs
index 49de33d2b..417830231 100644
--- a/examples/stm32f4/src/bin/pwm_input.rs
+++ b/examples/stm32f1/src/bin/input_capture.rs
@@ -11,10 +11,10 @@ use embassy_stm32::{bind_interrupts, peripherals};
11use embassy_time::Timer; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14/// Connect PB2 and PB10 with a 1k Ohm resistor 14/// Connect PA2 and PC13 with a 1k Ohm resistor
15 15
16#[embassy_executor::task] 16#[embassy_executor::task]
17async fn blinky(led: peripherals::PB2) { 17async fn blinky(led: peripherals::PC13) {
18 let mut led = Output::new(led, Level::High, Speed::Low); 18 let mut led = Output::new(led, Level::High, Speed::Low);
19 19
20 loop { 20 loop {
@@ -37,9 +37,9 @@ async fn main(spawner: Spawner) {
37 let p = embassy_stm32::init(Default::default()); 37 let p = embassy_stm32::init(Default::default());
38 info!("Hello World!"); 38 info!("Hello World!");
39 39
40 unwrap!(spawner.spawn(blinky(p.PB2))); 40 unwrap!(spawner.spawn(blinky(p.PC13)));
41 41
42 let ch3 = CapturePin::new_ch3(p.PB10, Pull::None); 42 let ch3 = CapturePin::new_ch3(p.PA2, Pull::None);
43 let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default()); 43 let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default());
44 44
45 loop { 45 loop {