From 13b90e15a570a4ee99b3facddb3134e32725b48a Mon Sep 17 00:00:00 2001 From: Mirabellensaft Date: Tue, 14 Mar 2023 12:07:46 +0100 Subject: [PATCH] move uarte solution to its own folder --- down-the-stack/solutions/.cargo/config.toml | 19 +++++++ down-the-stack/solutions/Cargo.toml | 50 +++++++++++++++++++ down-the-stack/solutions/README.md | 4 ++ .../src/bin/uarte_enable.rs} | 2 +- down-the-stack/solutions/src/lib.rs | 10 ++++ 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 down-the-stack/solutions/.cargo/config.toml create mode 100644 down-the-stack/solutions/Cargo.toml create mode 100644 down-the-stack/solutions/README.md rename down-the-stack/{apps/src/bin/uarte_enable_solution.rs => solutions/src/bin/uarte_enable.rs} (97%) create mode 100644 down-the-stack/solutions/src/lib.rs diff --git a/down-the-stack/solutions/.cargo/config.toml b/down-the-stack/solutions/.cargo/config.toml new file mode 100644 index 0000000..abfd4b6 --- /dev/null +++ b/down-the-stack/solutions/.cargo/config.toml @@ -0,0 +1,19 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# (..) +rustflags = [ + "-C", "linker=flip-link", # adds stack overflow protection + "-C", "link-arg=-Tdefmt.x", # defmt support + # (..) +] + +[target.thumbv7em-none-eabihf] +# set custom cargo runner to flash & run on embedded target when we call `cargo run` +# for more information, check out https://github.com/knurling-rs/probe-run +runner = "probe-run --chip nRF52840_xxAA" +rustflags = [ + "-C", "link-arg=-Tlink.x", +] + +[build] +# cross-compile to this target +target = "thumbv7em-none-eabihf" # = ARM Cortex-M4 \ No newline at end of file diff --git a/down-the-stack/solutions/Cargo.toml b/down-the-stack/solutions/Cargo.toml new file mode 100644 index 0000000..06950f5 --- /dev/null +++ b/down-the-stack/solutions/Cargo.toml @@ -0,0 +1,50 @@ +[package] +authors = ["Tanks Transfeld "] +edition = "2018" +license = "MIT OR Apache-2.0" +name = "uarte_enable_solution" +version = "0.0.0" + +[dependencies] +cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]} +cortex-m-rt = "0.7.2" +dk_bsc = { path = "../dk_bsc" } +dk_pac = { path = "../dk_pac", features = ["critical-section"]} +heapless = "0.7.16" +panic-probe = { version = "0.3.0", features = ["print-defmt"] } +defmt = "0.3.2" +defmt-rtt = "0.3.2" + +# optimize code in both profiles +[profile.dev] +codegen-units = 1 +debug = 2 +debug-assertions = true # ! +incremental = false +lto = "fat" +opt-level = 'z' # ! +overflow-checks = false + +[profile.release] +codegen-units = 1 +debug = 1 +debug-assertions = false +incremental = false +lto = "fat" +opt-level = 3 +overflow-checks = false + +[features] + + +default = [ + "other-feature" +] +other-feature = [] +# do NOT modify these features +defmt-default = [] +defmt-trace = [] +defmt-debug = [] +defmt-info = [] +defmt-warn = [] +defmt-error = [] \ No newline at end of file diff --git a/down-the-stack/solutions/README.md b/down-the-stack/solutions/README.md new file mode 100644 index 0000000..2998083 --- /dev/null +++ b/down-the-stack/solutions/README.md @@ -0,0 +1,4 @@ +# Solutions + +This program does not build if the pac is not generated! +The file is only for reference. \ No newline at end of file diff --git a/down-the-stack/apps/src/bin/uarte_enable_solution.rs b/down-the-stack/solutions/src/bin/uarte_enable.rs similarity index 97% rename from down-the-stack/apps/src/bin/uarte_enable_solution.rs rename to down-the-stack/solutions/src/bin/uarte_enable.rs index ef29275..010d0d4 100644 --- a/down-the-stack/apps/src/bin/uarte_enable_solution.rs +++ b/down-the-stack/solutions/src/bin/uarte_enable.rs @@ -6,7 +6,7 @@ use cortex_m_rt::entry; use dk_pac::UARTE0; // this imports `down-the-stack/apps/lib.rs` to retrieve our global logger + panicking-behavior -use apps as _; +use uarte_enable_solution as _; use defmt; use defmt_rtt as _; // global logger diff --git a/down-the-stack/solutions/src/lib.rs b/down-the-stack/solutions/src/lib.rs new file mode 100644 index 0000000..3446a8d --- /dev/null +++ b/down-the-stack/solutions/src/lib.rs @@ -0,0 +1,10 @@ +#![no_std] + +use panic_probe as _; + +// same panicking *behavior* as `panic-probe` but doesn't print a panic message +// this prevents the panic message being printed *twice* when `defmt::panic` is invoked +#[defmt::panic_handler] +fn panic() -> ! { + cortex_m::asm::udf() +}