diff --git a/hal_adc/Cargo.lock b/hal_adc/Cargo.lock index bbaebed..812182e 100644 --- a/hal_adc/Cargo.lock +++ b/hal_adc/Cargo.lock @@ -2,6 +2,18 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aligned" version = "0.4.2" @@ -26,6 +38,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "az" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" + [[package]] name = "bare-metal" version = "0.2.5" @@ -47,6 +65,12 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" +[[package]] +name = "bitfield" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" + [[package]] name = "bitflags" version = "1.3.2" @@ -87,7 +111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ "bare-metal", - "bitfield", + "bitfield 0.13.2", "critical-section", "embedded-hal 0.2.7", "volatile-register", @@ -110,16 +134,7 @@ checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "cortex-m-semihosting" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23234600452033cc77e4b761e740e02d2c4168e11dbf36ab14a0f58973592b0" -dependencies = [ - "cortex-m", + "syn 2.0.107", ] [[package]] @@ -149,7 +164,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.107", ] [[package]] @@ -160,7 +175,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -192,7 +207,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -214,29 +229,6 @@ dependencies = [ "defmt 1.0.1", ] -[[package]] -name = "defmt-test" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1e67ff0e1c6b1a9540a1a3e04454658faacdd188c91987c444d56e469d7dea" -dependencies = [ - "cortex-m-rt", - "cortex-m-semihosting", - "defmt 0.3.100", - "defmt-test-macros", -] - -[[package]] -name = "defmt-test-macros" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5520fd36862f281c026abeaab153ebbc001717c29a9b8e5ba9704d8f3a879d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "document-features" version = "0.2.11" @@ -273,6 +265,7 @@ checksum = "06070468370195e0e86f241c8e5004356d696590a678d47d6676795b2e439c6b" dependencies = [ "cortex-m", "critical-section", + "defmt 1.0.1", "document-features", "embassy-executor-macros", "embassy-executor-timer-queue", @@ -287,7 +280,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -323,6 +316,17 @@ dependencies = [ "defmt 0.3.100", ] +[[package]] +name = "embassy-net-driver-channel" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b2739fbcf6cd206ae08779c7d709087b16577d255f2ea4a45bc4bbbf305b3f" +dependencies = [ + "embassy-futures", + "embassy-net-driver", + "embassy-sync", +] + [[package]] name = "embassy-stm32" version = "0.4.0" @@ -340,7 +344,6 @@ dependencies = [ "defmt 1.0.1", "document-features", "embassy-embedded-hal", - "embassy-executor", "embassy-futures", "embassy-hal-internal", "embassy-net-driver", @@ -373,6 +376,28 @@ dependencies = [ "volatile-register", ] +[[package]] +name = "embassy-stm32u575zi-examples" +version = "0.1.0" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "defmt 1.0.1", + "defmt-rtt", + "embassy-executor", + "embassy-futures", + "embassy-stm32", + "embassy-sync", + "embassy-time", + "embassy-usb", + "embedded-graphics", + "embedded-hal 1.0.0", + "heapless", + "micromath", + "panic-probe", + "tinybmp", +] + [[package]] name = "embassy-sync" version = "0.7.2" @@ -424,6 +449,23 @@ dependencies = [ "heapless", ] +[[package]] +name = "embassy-usb" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4462e48b19a4f401a11901bdd981aab80c6a826608016a0bdc73cbbab31954" +dependencies = [ + "defmt 1.0.1", + "embassy-futures", + "embassy-net-driver-channel", + "embassy-sync", + "embassy-usb-driver", + "embedded-io-async", + "heapless", + "ssmarshal", + "usbd-hid", +] + [[package]] name = "embassy-usb-driver" version = "0.2.0" @@ -455,6 +497,29 @@ dependencies = [ "nb 1.1.0", ] +[[package]] +name = "embedded-graphics" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0" +dependencies = [ + "az", + "byteorder", + "embedded-graphics-core", + "float-cmp", + "micromath", +] + +[[package]] +name = "embedded-graphics-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044" +dependencies = [ + "az", + "byteorder", +] + [[package]] name = "embedded-hal" version = "0.2.7" @@ -524,6 +589,21 @@ dependencies = [ "embedded-storage", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -569,6 +649,15 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "heapless" version = "0.8.0" @@ -591,6 +680,18 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "micromath" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" + [[package]] name = "nb" version = "0.1.3" @@ -615,6 +716,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + [[package]] name = "panic-probe" version = "1.0.0" @@ -637,6 +744,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -656,7 +769,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -704,12 +817,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b328e2cb950eeccd55b7f55c3a963691455dcd044cfb5354f0c5e68d2c2d6ee2" -[[package]] -name = "semihosting" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e1c7d2b77d80283c750a39c52f1ab4d17234e8f30bca43550f5b2375f41d5f" - [[package]] name = "semver" version = "0.9.0" @@ -725,6 +832,45 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] + +[[package]] +name = "ssmarshal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" +dependencies = [ + "encode_unicode", + "serde", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -757,29 +903,23 @@ dependencies = [ "defmt 0.3.100", ] -[[package]] -name = "stm32u5-blinky" -version = "0.1.0" -dependencies = [ - "cortex-m", - "cortex-m-rt", - "defmt 1.0.1", - "defmt-rtt", - "defmt-test", - "embassy-executor", - "embassy-stm32", - "embassy-time", - "embedded-hal 1.0.0", - "panic-probe", - "semihosting", -] - [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.107" @@ -808,7 +948,16 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.107", +] + +[[package]] +name = "tinybmp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df43af2cb7b369009aa14144959bb4f2720ab62034c9073242f2d3a186c2edb6" +dependencies = [ + "embedded-graphics", ] [[package]] @@ -817,12 +966,65 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "usb-device" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6" +dependencies = [ + "heapless", + "portable-atomic", +] + +[[package]] +name = "usbd-hid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f291ab53d428685cc780f08a2eb9d5d6ff58622db2b36e239a4f715f1e184c" +dependencies = [ + "serde", + "ssmarshal", + "usb-device", + "usbd-hid-macros", +] + +[[package]] +name = "usbd-hid-descriptors" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee54712c5d778d2fb2da43b1ce5a7b5060886ef7b09891baeb4bf36910a3ed" +dependencies = [ + "bitfield 0.14.0", +] + +[[package]] +name = "usbd-hid-macros" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb573c76e7884035ac5e1ab4a81234c187a82b6100140af0ab45757650ccda38" +dependencies = [ + "byteorder", + "hashbrown", + "log", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "usbd-hid-descriptors", +] + [[package]] name = "vcell" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "void" version = "1.0.2" @@ -837,3 +1039,23 @@ checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" dependencies = [ "vcell", ] + +[[package]] +name = "zerocopy" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] diff --git a/hal_adc/Cargo.toml b/hal_adc/Cargo.toml index 6e0cf00..8360bd2 100644 --- a/hal_adc/Cargo.toml +++ b/hal_adc/Cargo.toml @@ -1,43 +1,57 @@ [package] -# TODO(1) fix `authors` and `name` if you didn't use `cargo-generate` -authors = ["Priec "] -name = "stm32u5-blinky" edition = "2024" +name = "embassy-stm32u575zi-examples" version = "0.1.0" - +license = "MIT OR Apache-2.0" +publish = false +authors = ["Priec "] [dependencies] -cortex-m = { version = "0.7", features = ["critical-section-single-core"] } -cortex-m-rt = "0.7" -defmt = "1.0" -defmt-rtt = "1.0" +# Embassy core crates from crates.io (no relative paths) +embassy-stm32 = { version = "0.4.0", features = [ + "defmt", + "stm32u575zi", + "time-driver-any", +] } +embassy-sync = { version = "0.7.2", features = ["defmt"] } +embassy-executor = { version = "0.9.1", features = [ + "arch-cortex-m", + "executor-thread", + "defmt", +] } +embassy-time = { version = "0.5.0", features = [ + "defmt", + "defmt-timestamp-uptime", + "tick-hz-32_768", +] } +embassy-usb = { version = "0.5.1", features = ["defmt"] } +embassy-futures = { version = "0.1.2" } + +# Logging and panic behavior +defmt = "1.0.1" +defmt-rtt = "1.0.0" panic-probe = { version = "1.0", features = ["print-defmt"] } -embassy-stm32 = { version = "0.4.0", features = ["stm32u575zi", "time-driver-tim1", "defmt", "low-power", "memory-x"] } -embassy-time = "0.5.0" -semihosting = "0.1.20" + +# MCU + HAL utilities +cortex-m = { version = "0.7", features = ["inline-asm", "critical-section-single-core"] } +cortex-m-rt = "0.7" embedded-hal = "1.0.0" -embassy-executor = { version = "0.9.1", features = ["arch-cortex-m", "executor-thread"] } +heapless = { version = "0.8", default-features = false } +embedded-graphics = "0.8.1" +tinybmp = "0.6.0" +micromath = "2.0.0" -[dev-dependencies] -defmt-test = "0.3" +[features] +## Allow building secure binaries if TrustZone is enabled +trustzone-secure = ["embassy-stm32/trustzone-secure"] -# cargo build/run -[profile.dev] -# default is opt-level = '0', but that makes very -# verbose machine code -opt-level = 's' -# trade compile speed for slightly better optimisations -codegen-units = 1 - -# cargo build/run --release [profile.release] -# default is opt-level = '3', but that makes quite -# verbose machine code -opt-level = 's' -# trade compile speed for slightly better optimisations -codegen-units = 1 -# Use Link Time Optimisations to further inline things across -# crates -lto = 'fat' -# Leave the debug symbols in (default is no debug info) +lto = "fat" +opt-level = "s" debug = 2 +codegen-units = 1 + +[package.metadata.embassy] +build = [ + { target = "thumbv8m.main-none-eabihf", artifact-dir = "out/examples/stm32u5" } +] diff --git a/hal_adc/Makefile b/hal_adc/Makefile new file mode 100644 index 0000000..dfa5ac1 --- /dev/null +++ b/hal_adc/Makefile @@ -0,0 +1,23 @@ +TARGET = thumbv8m.main-none-eabihf +CHIP = STM32U575ZI +BIN = stm32u5-blinky +MODE ?= release +TARGET_DIR = target/$(TARGET)/$(MODE) +ELF = $(TARGET_DIR)/$(BIN) +PROBE = probe-rs + +.PHONY: all build flash clean empty + +all: build + +build: + cargo build --$(MODE) + +flash: build + $(PROBE) run --chip $(CHIP) $(ELF) + +empty: + $(PROBE) erase --chip $(CHIP) + +clean: + cargo clean diff --git a/hal_adc/openocd-u5.cfg b/hal_adc/openocd-u5.cfg new file mode 100644 index 0000000..5ac6db7 --- /dev/null +++ b/hal_adc/openocd-u5.cfg @@ -0,0 +1,4 @@ +source [find interface/stlink.cfg] +transport select hla_swd +source [find target/stm32u5x.cfg] +reset_config srst_only srst_nogate connect_assert_srst diff --git a/hal_adc/src/lib.rs b/hal_adc/src/lib.rs index deac2a0..f01d8a6 100644 --- a/hal_adc/src/lib.rs +++ b/hal_adc/src/lib.rs @@ -1,11 +1,6 @@ -#![no_main] #![no_std] use defmt_rtt as _; // global logger - -// TODO(5) adjust HAL import -// use some_hal as _; // memory layout - use panic_probe as _; // same panicking *behavior* as `panic-probe` but doesn't print a panic message @@ -15,32 +10,9 @@ fn panic() -> ! { cortex_m::asm::udf() } -/// Terminates the application and makes a semihosting-capable debug tool exit -/// with status code 0. -pub fn exit() -> ! { - semihosting::process::exit(0); -} - -/// Hardfault handler. -/// -/// Terminates the application and makes a semihosting-capable debug tool exit -/// with an error. This seems better than the default, which is to spin in a -/// loop. +/// HardFault exit handler #[cortex_m_rt::exception] unsafe fn HardFault(_frame: &cortex_m_rt::ExceptionFrame) -> ! { - semihosting::process::exit(1); -} - -// defmt-test 0.3.0 has the limitation that this `#[tests]` attribute can only be used -// once within a crate. the module can be in any file but there can only be at most -// one `#[tests]` module in this library crate -#[cfg(test)] -#[defmt_test::tests] -mod unit_tests { - use defmt::assert; - - #[test] - fn it_works() { - assert!(true) - } + cortex_m::asm::bkpt(); // stay under debugger rather than exit semihosting + loop {} } diff --git a/hal_rng/Makefile b/hal_rng/Makefile new file mode 100644 index 0000000..dfa5ac1 --- /dev/null +++ b/hal_rng/Makefile @@ -0,0 +1,23 @@ +TARGET = thumbv8m.main-none-eabihf +CHIP = STM32U575ZI +BIN = stm32u5-blinky +MODE ?= release +TARGET_DIR = target/$(TARGET)/$(MODE) +ELF = $(TARGET_DIR)/$(BIN) +PROBE = probe-rs + +.PHONY: all build flash clean empty + +all: build + +build: + cargo build --$(MODE) + +flash: build + $(PROBE) run --chip $(CHIP) $(ELF) + +empty: + $(PROBE) erase --chip $(CHIP) + +clean: + cargo clean diff --git a/hal_test/.cargo/config.toml b/hal_test/.cargo/config.toml index 793e2c8..c5c1552 100644 --- a/hal_test/.cargo/config.toml +++ b/hal_test/.cargo/config.toml @@ -1,22 +1,11 @@ -[target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = ["probe-rs", "run", "--chip", "STM32U575ZI", "--log-format=oneline"] - -rustflags = [ - "-C", "linker=flip-link", - "-C", "link-arg=-Tlink.x", - "-C", "link-arg=-Tdefmt.x", - "-C", "link-arg=--nmagic", -] - [build] target = "thumbv8m.main-none-eabihf" [target.thumbv8m.main-none-eabihf] -runner = "probe-rs run --chip STM32U575ZI" +runner = "probe-rs run --chip STM32U575ZITxQ" -[alias] -rb = "run --bin" -rrb = "run --release --bin" - -[env] -DEFMT_LOG = "info" +rustflags = [ + "-C", "linker=rust-lld", + "-C", "link-arg=-Tlink.x", # provided by cortex-m-rt + "-C", "link-arg=--nmagic", +] diff --git a/hal_test/Cargo.lock b/hal_test/Cargo.lock index a3c15a8..00eb822 100644 --- a/hal_test/Cargo.lock +++ b/hal_test/Cargo.lock @@ -2,6 +2,18 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aligned" version = "0.4.2" @@ -26,6 +38,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "az" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" + [[package]] name = "bare-metal" version = "0.2.5" @@ -48,16 +66,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bitfield" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "block-device-driver" @@ -87,7 +105,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ "bare-metal", - "bitfield", + "bitfield 0.13.2", "critical-section", "embedded-hal 0.2.7", "volatile-register", @@ -110,16 +128,7 @@ checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "cortex-m-semihosting" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23234600452033cc77e4b761e740e02d2c4168e11dbf36ab14a0f58973592b0" -dependencies = [ - "cortex-m", + "syn 2.0.107", ] [[package]] @@ -149,7 +158,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.107", ] [[package]] @@ -160,81 +169,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn", -] - -[[package]] -name = "defmt" -version = "0.3.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad" -dependencies = [ - "defmt 1.0.1", -] - -[[package]] -name = "defmt" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "548d977b6da32fa1d1fda2876453da1e7df63ad0304c8b3dae4dbe7b96f39b78" -dependencies = [ - "bitflags 1.3.2", - "defmt-macros", -] - -[[package]] -name = "defmt-macros" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e" -dependencies = [ - "defmt-parser", - "proc-macro-error2", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "defmt-parser" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" -dependencies = [ - "thiserror", -] - -[[package]] -name = "defmt-rtt" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2cac3b8a5644a9e02b75085ebad3b6deafdbdbdec04bb25086523828aa4dfd1" -dependencies = [ - "critical-section", - "defmt 1.0.1", -] - -[[package]] -name = "defmt-test" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1e67ff0e1c6b1a9540a1a3e04454658faacdd188c91987c444d56e469d7dea" -dependencies = [ - "cortex-m-rt", - "cortex-m-semihosting", - "defmt 0.3.100", - "defmt-test-macros", -] - -[[package]] -name = "defmt-test-macros" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5520fd36862f281c026abeaab153ebbc001717c29a9b8e5ba9704d8f3a879d" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -252,7 +187,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8" dependencies = [ - "defmt 1.0.1", "embassy-futures", "embassy-hal-internal", "embassy-sync", @@ -287,7 +221,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -310,7 +244,6 @@ checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a" dependencies = [ "cortex-m", "critical-section", - "defmt 1.0.1", "num-traits", ] @@ -319,8 +252,16 @@ name = "embassy-net-driver" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" + +[[package]] +name = "embassy-net-driver-channel" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b2739fbcf6cd206ae08779c7d709087b16577d255f2ea4a45bc4bbbf305b3f" dependencies = [ - "defmt 0.3.100", + "embassy-futures", + "embassy-net-driver", + "embassy-sync", ] [[package]] @@ -331,16 +272,14 @@ checksum = "0d972eab325cc96afee98f80a91ca6b00249b6356dc0fdbff68b70c200df9fae" dependencies = [ "aligned", "bit_field", - "bitflags 2.9.4", + "bitflags", "block-device-driver", "cfg-if", "cortex-m", "cortex-m-rt", "critical-section", - "defmt 1.0.1", "document-features", "embassy-embedded-hal", - "embassy-executor", "embassy-futures", "embassy-hal-internal", "embassy-net-driver", @@ -381,11 +320,10 @@ checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b" dependencies = [ "cfg-if", "critical-section", - "defmt 1.0.1", "embedded-io-async", "futures-core", "futures-sink", - "heapless", + "heapless 0.8.0", ] [[package]] @@ -396,7 +334,6 @@ checksum = "f4fa65b9284d974dad7a23bb72835c4ec85c0b540d86af7fc4098c88cff51d65" dependencies = [ "cfg-if", "critical-section", - "defmt 1.0.1", "document-features", "embassy-time-driver", "embedded-hal 0.2.7", @@ -421,7 +358,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e2ee86063bd028a420a5fb5898c18c87a8898026da1d4c852af2c443d0a454" dependencies = [ "embassy-executor-timer-queue", - "heapless", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-usb" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4462e48b19a4f401a11901bdd981aab80c6a826608016a0bdc73cbbab31954" +dependencies = [ + "embassy-futures", + "embassy-net-driver-channel", + "embassy-sync", + "embassy-usb-driver", + "embedded-io-async", + "heapless 0.8.0", + "ssmarshal", + "usbd-hid", ] [[package]] @@ -430,7 +383,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a" dependencies = [ - "defmt 1.0.1", "embedded-io-async", ] @@ -441,7 +393,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "288751f8eaa44a5cf2613f13cee0ca8e06e6638cb96e897e6834702c79084b23" dependencies = [ "critical-section", - "defmt 1.0.1", "embassy-sync", "embassy-usb-driver", ] @@ -455,6 +406,29 @@ dependencies = [ "nb 1.1.0", ] +[[package]] +name = "embedded-graphics" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0" +dependencies = [ + "az", + "byteorder", + "embedded-graphics-core", + "float-cmp", + "micromath", +] + +[[package]] +name = "embedded-graphics-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044" +dependencies = [ + "az", + "byteorder", +] + [[package]] name = "embedded-hal" version = "0.2.7" @@ -495,9 +469,6 @@ name = "embedded-io" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" -dependencies = [ - "defmt 0.3.100", -] [[package]] name = "embedded-io-async" @@ -505,7 +476,6 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" dependencies = [ - "defmt 0.3.100", "embedded-io", ] @@ -524,6 +494,21 @@ dependencies = [ "embedded-storage", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -560,6 +545,26 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "hal_test" +version = "0.1.0" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "embassy-executor", + "embassy-futures", + "embassy-stm32", + "embassy-sync", + "embassy-time", + "embassy-usb", + "embedded-graphics", + "embedded-hal 1.0.0", + "heapless 0.9.1", + "micromath", + "panic-halt", + "tinybmp", +] + [[package]] name = "hash32" version = "0.3.1" @@ -569,6 +574,15 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "heapless" version = "0.8.0" @@ -579,6 +593,16 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "heapless" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1edcd5a338e64688fbdcb7531a846cfd3476a54784dcb918a0844682bc7ada5" +dependencies = [ + "hash32", + "stable_deref_trait", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -591,6 +615,18 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "micromath" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" + [[package]] name = "nb" version = "0.1.3" @@ -616,14 +652,16 @@ dependencies = [ ] [[package]] -name = "panic-probe" +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "panic-halt" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd402d00b0fb94c5aee000029204a46884b1262e0c443f166d86d2c0747e1a1a" -dependencies = [ - "cortex-m", - "defmt 1.0.1", -] +checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11" [[package]] name = "pin-project-lite" @@ -638,26 +676,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "proc-macro-error-attr2" -version = "2.0.0" +name = "portable-atomic" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" -dependencies = [ - "proc-macro2", - "quote", -] - -[[package]] -name = "proc-macro-error2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" -dependencies = [ - "proc-macro-error-attr2", - "proc-macro2", - "quote", - "syn", -] +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] name = "proc-macro2" @@ -704,12 +726,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b328e2cb950eeccd55b7f55c3a963691455dcd044cfb5354f0c5e68d2c2d6ee2" -[[package]] -name = "semihosting" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e1c7d2b77d80283c750a39c52f1ab4d17234e8f30bca43550f5b2375f41d5f" - [[package]] name = "semver" version = "0.9.0" @@ -725,6 +741,45 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] + +[[package]] +name = "ssmarshal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" +dependencies = [ + "encode_unicode", + "serde", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -754,23 +809,6 @@ checksum = "6fd8ec3a292a0d9fc4798416a61b21da5ae50341b2e7b8d12e662bf305366097" dependencies = [ "cortex-m", "cortex-m-rt", - "defmt 0.3.100", -] - -[[package]] -name = "stm32u5-blinky" -version = "0.1.0" -dependencies = [ - "cortex-m", - "cortex-m-rt", - "defmt 1.0.1", - "defmt-rtt", - "defmt-test", - "embassy-stm32", - "embassy-time", - "embedded-hal 1.0.0", - "panic-probe", - "semihosting", ] [[package]] @@ -781,9 +819,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.106" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -791,23 +829,23 @@ dependencies = [ ] [[package]] -name = "thiserror" -version = "2.0.17" +name = "syn" +version = "2.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b" dependencies = [ "proc-macro2", "quote", - "syn", + "unicode-ident", +] + +[[package]] +name = "tinybmp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df43af2cb7b369009aa14144959bb4f2720ab62034c9073242f2d3a186c2edb6" +dependencies = [ + "embedded-graphics", ] [[package]] @@ -816,12 +854,65 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "usb-device" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6" +dependencies = [ + "heapless 0.8.0", + "portable-atomic", +] + +[[package]] +name = "usbd-hid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f291ab53d428685cc780f08a2eb9d5d6ff58622db2b36e239a4f715f1e184c" +dependencies = [ + "serde", + "ssmarshal", + "usb-device", + "usbd-hid-macros", +] + +[[package]] +name = "usbd-hid-descriptors" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee54712c5d778d2fb2da43b1ce5a7b5060886ef7b09891baeb4bf36910a3ed" +dependencies = [ + "bitfield 0.14.0", +] + +[[package]] +name = "usbd-hid-macros" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb573c76e7884035ac5e1ab4a81234c187a82b6100140af0ab45757650ccda38" +dependencies = [ + "byteorder", + "hashbrown", + "log", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "usbd-hid-descriptors", +] + [[package]] name = "vcell" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "void" version = "1.0.2" @@ -836,3 +927,23 @@ checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" dependencies = [ "vcell", ] + +[[package]] +name = "zerocopy" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] diff --git a/hal_test/Cargo.toml b/hal_test/Cargo.toml index 2962bab..ed1226b 100644 --- a/hal_test/Cargo.toml +++ b/hal_test/Cargo.toml @@ -1,42 +1,24 @@ [package] -# TODO(1) fix `authors` and `name` if you didn't use `cargo-generate` authors = ["Priec "] -name = "stm32u5-blinky" +name = "hal_test" edition = "2024" version = "0.1.0" [dependencies] -cortex-m = { version = "0.7", features = ["critical-section-single-core"] } -cortex-m-rt = "0.7" -defmt = "1.0" -defmt-rtt = "1.0" -panic-probe = { version = "1.0", features = ["print-defmt"] } -embassy-stm32 = { version = "0.4.0", features = ["stm32u575zi", "time-driver-tim1", "defmt", "low-power", "memory-x"] } -embassy-time = "0.5.0" -semihosting = "0.1.20" +cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] } +cortex-m-rt = "0.7.5" +panic-halt = "1.0.0" + +embassy-executor = { version = "0.9.1", features = ["arch-cortex-m", "executor-thread"] } +embassy-futures = "0.1.2" +embassy-stm32 = { version = "0.4.0", features = ["unstable-pac", "stm32u575zi", "time-driver-any", "memory-x"] } +embassy-sync = "0.7.2" +embassy-time = { version = "0.5.0", features = ["tick-hz-32_768"] } +embassy-usb = "0.5.1" + embedded-hal = "1.0.0" - -[dev-dependencies] -defmt-test = "0.3" - -# cargo build/run -[profile.dev] -# default is opt-level = '0', but that makes very -# verbose machine code -opt-level = 's' -# trade compile speed for slightly better optimisations -codegen-units = 1 - -# cargo build/run --release -[profile.release] -# default is opt-level = '3', but that makes quite -# verbose machine code -opt-level = 's' -# trade compile speed for slightly better optimisations -codegen-units = 1 -# Use Link Time Optimisations to further inline things across -# crates -lto = 'fat' -# Leave the debug symbols in (default is no debug info) -debug = 2 +embedded-graphics = "0.8.1" +heapless = { version = "0.9.1", default-features = false } +micromath = "2.1.0" +tinybmp = "0.6.0" diff --git a/hal_test/Makefile b/hal_test/Makefile new file mode 100644 index 0000000..bf6595f --- /dev/null +++ b/hal_test/Makefile @@ -0,0 +1,20 @@ +TARGET = thumbv8m.main-none-eabihf +CHIP = STM32U575ZI +BIN = main +MODE ?= release +ELF = target/$(TARGET)/$(MODE)/$(BIN) +PROBE = probe-rs + +.PHONY: all build flash empty + +all: build flash + +build: + cargo build --target $(TARGET) --$(MODE) + +flash: build + $(PROBE) run --chip $(CHIP) $(ELF) + +empty: + $(PROBE) erase --chip $(CHIP) + diff --git a/hal_test/memory.x b/hal_test/memory.x deleted file mode 100644 index 89f96e1..0000000 --- a/hal_test/memory.x +++ /dev/null @@ -1,13 +0,0 @@ -/* memory.x - STM32U575ZITxQ memory layout */ - -/* Flash: 2 MB starting at 0x08000000 */ -/* SRAM1 + SRAM2 + SRAM3 total 786 KB starting at 0x20000000 */ - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 786K -} - -/* provide stack start symbol (end of RAM) */ -_stack_start = ORIGIN(RAM) + LENGTH(RAM); diff --git a/hal_test/src/bin/main.rs b/hal_test/src/bin/main.rs index f76a673..6e93254 100644 --- a/hal_test/src/bin/main.rs +++ b/hal_test/src/bin/main.rs @@ -1,30 +1,24 @@ -// src/bin/main.rs - #![no_std] #![no_main] -use defmt_rtt as _; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; +use embassy_stm32::init; use embassy_stm32::Config; -use embassy_time::Delay; -use embedded_hal::delay::DelayNs; -use panic_probe as _; +use panic_halt as _; -#[cortex_m_rt::entry] -fn main() -> ! { - defmt::info!("Starting blinky on STM32U575ZI-Q..."); +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = init(Config::default()); - // Initialize peripherals with the default clock tree for STM32U5. - let p = embassy_stm32::init(Config::default()); - - // On‑board LED (PB7 on NUCLEO‑U575ZI‑Q) - let mut led = Output::new(p.PB7, Level::Low, Speed::Low); - let mut delay = Delay; + // The user LED on NUCLEO-U575ZI-Q is typically on port B, pin 0 (verify silkscreen) + let mut led = Output::new(p.PB0, Level::Low, Speed::Low); loop { led.set_high(); - delay.delay_ms(500); // needs embedded_hal::delay::DelayNs in scope + Timer::after(Duration::from_millis(500)).await; led.set_low(); - delay.delay_ms(500); + Timer::after(Duration::from_millis(500)).await; } } diff --git a/hal_test/src/lib.rs b/hal_test/src/lib.rs index deac2a0..0c9ac1a 100644 --- a/hal_test/src/lib.rs +++ b/hal_test/src/lib.rs @@ -1,46 +1 @@ -#![no_main] #![no_std] - -use defmt_rtt as _; // global logger - -// TODO(5) adjust HAL import -// use some_hal as _; // memory layout - -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() -} - -/// Terminates the application and makes a semihosting-capable debug tool exit -/// with status code 0. -pub fn exit() -> ! { - semihosting::process::exit(0); -} - -/// Hardfault handler. -/// -/// Terminates the application and makes a semihosting-capable debug tool exit -/// with an error. This seems better than the default, which is to spin in a -/// loop. -#[cortex_m_rt::exception] -unsafe fn HardFault(_frame: &cortex_m_rt::ExceptionFrame) -> ! { - semihosting::process::exit(1); -} - -// defmt-test 0.3.0 has the limitation that this `#[tests]` attribute can only be used -// once within a crate. the module can be in any file but there can only be at most -// one `#[tests]` module in this library crate -#[cfg(test)] -#[defmt_test::tests] -mod unit_tests { - use defmt::assert; - - #[test] - fn it_works() { - assert!(true) - } -}