fix!: don't require defmt always

This commit is contained in:
cscherr 2025-05-14 17:26:38 +02:00
parent 69d2c65076
commit d24370dd03
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7
3 changed files with 34 additions and 5 deletions

View file

@ -4,8 +4,6 @@ target = "thumbv6m-none-eabi"
[target.thumbv6m-none-eabi]
runner = 'probe-rs run --chip STM32L053R8'
rustflags = ["-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tdefmt.x"]
[alias]
cflash = "flash --chip STM32L053R8"

View file

@ -14,6 +14,29 @@ cortex-m-rt = "0.7.5"
panic-halt = "1.0.0"
hd44780-driver = "0.4.0"
heapless = "0.8.0"
defmt = "1.0.1"
defmt-rtt = "1.0.0"
panic-probe = { version = "0.3", features = ["print-defmt"] }
defmt = {version="1.0.1", optional= true}
defmt-rtt = {version="1.0.0", optional=true}
panic-probe = { version = "0.3", features = ["print-defmt"], optional=true }
[features]
logging = ["dep:defmt", "dep:defmt-rtt", "dep:panic-probe"]
[[example]]
name = "logging"
path = "examples/logging.rs"
required-features = ["logging"]
[[example]]
name = "rtc-log"
path = "examples/rtc-log.rs"
required-features = ["logging"]
[[example]]
name = "temperature"
path = "examples/temperature.rs"
required-features = ["logging"]
[[example]]
name = "aes_ecb"
path = "examples/aes_ecb.rs"
required-features = ["logging"]

8
build.rs Executable file
View file

@ -0,0 +1,8 @@
fn main() {
println!("cargo::rerun-if-changed=Cargo.toml");
println!("cargo::rustc-link-arg=-Tlink.x");
#[cfg(feature = "logging")]
{
println!("cargo::rustc-link-arg=-Tdefmt.x");
}
}