summaryrefslogtreecommitdiff
path: root/examples/stm32u5
diff options
context:
space:
mode:
authorBob McWhirter <bmcwhirt@redhat.com>2021-11-02 14:43:42 -0400
committerBob McWhirter <bmcwhirt@redhat.com>2021-11-02 14:43:42 -0400
commit3ab17758203cefa3da5df534ba1e1d2da7670f22 (patch)
treecc475d35ecf0a146f84acf2d1931c0c5d055c4a7 /examples/stm32u5
parent705523d0eaf6ae30901e04a1fb51ab47425cd2a4 (diff)
downloadembassy-3ab17758203cefa3da5df534ba1e1d2da7670f22.zip
Add STM32U5 example.
Diffstat (limited to 'examples/stm32u5')
-rw-r--r--examples/stm32u5/.cargo/config.toml18
-rw-r--r--examples/stm32u5/Cargo.toml37
-rw-r--r--examples/stm32u5/src/bin/boot.rs28
-rw-r--r--examples/stm32u5/src/example_common.rs17
4 files changed, 100 insertions, 0 deletions
diff --git a/examples/stm32u5/.cargo/config.toml b/examples/stm32u5/.cargo/config.toml
new file mode 100644
index 00000000..7f488700
--- /dev/null
+++ b/examples/stm32u5/.cargo/config.toml
@@ -0,0 +1,18 @@
+[target.'cfg(all(target_arch = "arm", target_os = "none"))']
+# replace STM32F429ZITx with your chip as listed in `probe-run --list-chips`
+runner = "probe-run --chip STM32U585AIIx"
+
+rustflags = [
+ # LLD (shipped with the Rust toolchain) is used as the default linker
+ "-C", "link-arg=--nmagic",
+ "-C", "link-arg=-Tlink.x",
+ "-C", "link-arg=-Tdefmt.x",
+
+ # Code-size optimizations.
+ "-Z", "trap-unreachable=no",
+ "-C", "inline-threshold=5",
+ "-C", "no-vectorize-loops",
+]
+
+[build]
+target = "thumbv7em-none-eabi"
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml
new file mode 100644
index 00000000..b3c3c970
--- /dev/null
+++ b/examples/stm32u5/Cargo.toml
@@ -0,0 +1,37 @@
+[package]
+authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
+edition = "2018"
+name = "embassy-stm32u5-examples"
+version = "0.1.0"
+resolver = "2"
+
+[features]
+default = [
+ "defmt-default",
+]
+defmt-default = []
+defmt-trace = []
+defmt-debug = []
+defmt-info = []
+defmt-warn = []
+defmt-error = []
+
+[dependencies]
+embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-trace"] }
+embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
+embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "defmt-trace", "unstable-pac", "stm32u585ai", "memory-x" ] }
+embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" }
+
+defmt = "0.2.3"
+defmt-rtt = "0.2.0"
+
+cortex-m = "0.7.3"
+cortex-m-rt = "0.7.0"
+embedded-hal = "0.2.6"
+panic-probe = { version = "0.2.0", features = ["print-defmt"] }
+futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
+rtt-target = { version = "0.3.1", features = ["cortex-m"] }
+heapless = { version = "0.7.5", default-features = false }
+
+micromath = "2.0.0"
+
diff --git a/examples/stm32u5/src/bin/boot.rs b/examples/stm32u5/src/bin/boot.rs
new file mode 100644
index 00000000..b1e71fbe
--- /dev/null
+++ b/examples/stm32u5/src/bin/boot.rs
@@ -0,0 +1,28 @@
+#![no_std]
+#![no_main]
+#![feature(type_alias_impl_trait)]
+
+#[path = "../example_common.rs"]
+mod example_common;
+use embassy_stm32::gpio::{Input, Pull};
+use embedded_hal::digital::v2::InputPin;
+use example_common::*;
+
+#[cortex_m_rt::entry]
+fn main() -> ! {
+ info!("Hello World!");
+
+ loop {}
+
+ //let p = embassy_stm32::init(Default::default());
+
+ //let button = Input::new(p.PC13, Pull::Up);
+
+ //loop {
+ //if unwrap!(button.is_high()) {
+ //info!("high");
+ //} else {
+ //info!("low");
+ //}
+ //}
+}
diff --git a/examples/stm32u5/src/example_common.rs b/examples/stm32u5/src/example_common.rs
new file mode 100644
index 00000000..54d63383
--- /dev/null
+++ b/examples/stm32u5/src/example_common.rs
@@ -0,0 +1,17 @@
+#![macro_use]
+
+use defmt_rtt as _; // global logger
+use panic_probe as _;
+
+pub use defmt::*;
+
+use core::sync::atomic::{AtomicUsize, Ordering};
+
+defmt::timestamp! {"{=u64}", {
+ static COUNT: AtomicUsize = AtomicUsize::new(0);
+ // NOTE(no-CAS) `timestamps` runs with interrupts disabled
+ let n = COUNT.load(Ordering::Relaxed);
+ COUNT.store(n + 1, Ordering::Relaxed);
+ n as u64
+ }
+}