diff options
| author | Roy <[email protected]> | 2025-07-02 15:24:01 +0300 |
|---|---|---|
| committer | Roi Bachynskyi <[email protected]> | 2025-07-18 15:22:36 +0300 |
| commit | 6d79c4c81187d5f2704e2d2f72a3deba05ca449a (patch) | |
| tree | 0ec84178e5964300d5836908a1054619debdc131 | |
| parent | 3e1b0e4aec11888d6ea41ef5c62d6d2912d81eae (diff) | |
feat: added log-to-defmt feature
Signed-off-by: Roy <[email protected]>
| -rwxr-xr-x | ci.sh | 1 | ||||
| -rw-r--r-- | embassy-nxp/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-nxp/src/lib.rs | 5 | ||||
| -rw-r--r-- | examples/lpc55s69/Cargo.toml | 4 | ||||
| -rw-r--r-- | examples/lpc55s69/src/bin/log_to_defmt.rs | 18 |
5 files changed, 30 insertions, 2 deletions
| @@ -264,6 +264,7 @@ cargo batch \ | |||
| 264 | --- build --release --manifest-path examples/stm32wba/Cargo.toml --target thumbv8m.main-none-eabihf --artifact-dir out/examples/stm32wba \ | 264 | --- build --release --manifest-path examples/stm32wba/Cargo.toml --target thumbv8m.main-none-eabihf --artifact-dir out/examples/stm32wba \ |
| 265 | --- build --release --manifest-path examples/stm32wl/Cargo.toml --target thumbv7em-none-eabi --artifact-dir out/examples/stm32wl \ | 265 | --- build --release --manifest-path examples/stm32wl/Cargo.toml --target thumbv7em-none-eabi --artifact-dir out/examples/stm32wl \ |
| 266 | --- build --release --manifest-path examples/lpc55s69/Cargo.toml --target thumbv8m.main-none-eabihf --artifact-dir out/examples/lpc55s69 \ | 266 | --- build --release --manifest-path examples/lpc55s69/Cargo.toml --target thumbv8m.main-none-eabihf --artifact-dir out/examples/lpc55s69 \ |
| 267 | --- build --release --manifest-path examples/lpc55s69/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nxp/log-to-defmt --artifact-dir out/examples/lpc55s69 \ | ||
| 267 | --- build --release --manifest-path examples/mspm0g3507/Cargo.toml --target thumbv6m-none-eabi --artifact-dir out/examples/mspm0g3507 \ | 268 | --- build --release --manifest-path examples/mspm0g3507/Cargo.toml --target thumbv6m-none-eabi --artifact-dir out/examples/mspm0g3507 \ |
| 268 | --- build --release --manifest-path examples/mspm0g3519/Cargo.toml --target thumbv6m-none-eabi --artifact-dir out/examples/mspm0g3519 \ | 269 | --- build --release --manifest-path examples/mspm0g3519/Cargo.toml --target thumbv6m-none-eabi --artifact-dir out/examples/mspm0g3519 \ |
| 269 | --- build --release --manifest-path examples/mspm0l1306/Cargo.toml --target thumbv6m-none-eabi --artifact-dir out/examples/mspm0l1306 \ | 270 | --- build --release --manifest-path examples/mspm0l1306/Cargo.toml --target thumbv6m-none-eabi --artifact-dir out/examples/mspm0l1306 \ |
diff --git a/embassy-nxp/Cargo.toml b/embassy-nxp/Cargo.toml index 01f57c4e2..9eb48be17 100644 --- a/embassy-nxp/Cargo.toml +++ b/embassy-nxp/Cargo.toml | |||
| @@ -10,6 +10,8 @@ critical-section = "1.1.2" | |||
| 10 | embassy-hal-internal = { version = "0.3.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-2"] } | 10 | embassy-hal-internal = { version = "0.3.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-2"] } |
| 11 | embassy-sync = { version = "0.7.0", path = "../embassy-sync" } | 11 | embassy-sync = { version = "0.7.0", path = "../embassy-sync" } |
| 12 | defmt = { version = "1", optional = true } | 12 | defmt = { version = "1", optional = true } |
| 13 | log = "0.4.27" | ||
| 14 | log-to-defmt = { version = "0.1.0", optional = true} | ||
| 13 | 15 | ||
| 14 | ## Chip dependencies | 16 | ## Chip dependencies |
| 15 | lpc55-pac = { version = "0.5.0", optional = true } | 17 | lpc55-pac = { version = "0.5.0", optional = true } |
| @@ -30,3 +32,5 @@ unstable-pac = [] | |||
| 30 | 32 | ||
| 31 | #! ### Chip selection features | 33 | #! ### Chip selection features |
| 32 | lpc55 = ["lpc55-pac"] | 34 | lpc55 = ["lpc55-pac"] |
| 35 | ## Enable debug logs | ||
| 36 | log-to-defmt = ["dep:log-to-defmt"] | ||
diff --git a/embassy-nxp/src/lib.rs b/embassy-nxp/src/lib.rs index 433aca9e0..79c66e7f6 100644 --- a/embassy-nxp/src/lib.rs +++ b/embassy-nxp/src/lib.rs | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | pub mod gpio; | 3 | pub mod gpio; |
| 4 | #[cfg(feature = "lpc55")] | 4 | #[cfg(feature = "lpc55")] |
| 5 | pub mod pint; | 5 | pub mod pint; |
| 6 | |||
| 7 | // This mod MUST go last, so that it sees all the `impl_foo!` macros | 6 | // This mod MUST go last, so that it sees all the `impl_foo!` macros |
| 8 | #[cfg_attr(feature = "lpc55", path = "chips/lpc55.rs")] | 7 | #[cfg_attr(feature = "lpc55", path = "chips/lpc55.rs")] |
| 9 | mod chip; | 8 | mod chip; |
| @@ -25,8 +24,10 @@ pub fn init(_config: config::Config) -> Peripherals { | |||
| 25 | { | 24 | { |
| 26 | gpio::init(); | 25 | gpio::init(); |
| 27 | pint::init(); | 26 | pint::init(); |
| 27 | #[cfg(feature = "log-to-defmt")] | ||
| 28 | log_to_defmt::setup(); | ||
| 29 | log::info!("Initialization complete"); | ||
| 28 | } | 30 | } |
| 29 | |||
| 30 | crate::Peripherals::take() | 31 | crate::Peripherals::take() |
| 31 | } | 32 | } |
| 32 | 33 | ||
diff --git a/examples/lpc55s69/Cargo.toml b/examples/lpc55s69/Cargo.toml index 6ec6e51a8..7e3b82432 100644 --- a/examples/lpc55s69/Cargo.toml +++ b/examples/lpc55s69/Cargo.toml | |||
| @@ -18,5 +18,9 @@ defmt-rtt = "1.0.0" | |||
| 18 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } | 18 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } |
| 19 | panic-semihosting = "0.6.0" | 19 | panic-semihosting = "0.6.0" |
| 20 | 20 | ||
| 21 | [features] | ||
| 22 | ## To test all-logs mode | ||
| 23 | log-to-defmt = ["embassy-nxp/log-to-defmt"] | ||
| 24 | |||
| 21 | [profile.release] | 25 | [profile.release] |
| 22 | debug = 2 | 26 | debug = 2 |
diff --git a/examples/lpc55s69/src/bin/log_to_defmt.rs b/examples/lpc55s69/src/bin/log_to_defmt.rs new file mode 100644 index 000000000..7aaab5e54 --- /dev/null +++ b/examples/lpc55s69/src/bin/log_to_defmt.rs | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | /// To test log-to-defmt feature, you have to run the binary file with the corresponding flag | ||
| 2 | /// Example: cargo run --bin <file> --feature log-to-defmt | ||
| 3 | |||
| 4 | |||
| 5 | #![no_std] | ||
| 6 | #![no_main] | ||
| 7 | |||
| 8 | use log::*; | ||
| 9 | use embassy_executor::Spawner; | ||
| 10 | use {defmt_rtt as _, panic_halt as _}; | ||
| 11 | |||
| 12 | #[embassy_executor::main] | ||
| 13 | async fn main(_spawner: Spawner) { | ||
| 14 | info!("Hello World"); | ||
| 15 | loop{ | ||
| 16 | info!("Another test"); | ||
| 17 | } | ||
| 18 | } | ||
