diff options
| author | Tyler <[email protected]> | 2023-09-29 20:02:24 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-29 20:02:24 -0600 |
| commit | 2f9b59c5cf21f1e2761a9ccefdfd86f0edea829c (patch) | |
| tree | 8964744b4fb753cf98f6f413464106c4d2a72976 /embassy-boot/boot | |
| parent | ce91fb2bfc846570ef543a09396c428d70675245 (diff) | |
| parent | 95b3d9eb3b3657de3d7bc9c04f8fb83eae901640 (diff) | |
Merge branch 'main' into issue-1974-add-sai-driver
Diffstat (limited to 'embassy-boot/boot')
| -rw-r--r-- | embassy-boot/boot/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy-boot/boot/src/fmt.rs | 45 |
2 files changed, 40 insertions, 7 deletions
diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml index 415d7960f..6a334f01a 100644 --- a/embassy-boot/boot/Cargo.toml +++ b/embassy-boot/boot/Cargo.toml | |||
| @@ -28,7 +28,7 @@ digest = "0.10" | |||
| 28 | log = { version = "0.4", optional = true } | 28 | log = { version = "0.4", optional = true } |
| 29 | ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true } | 29 | ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true } |
| 30 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | 30 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } |
| 31 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync" } | 31 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync" } |
| 32 | embedded-storage = "0.3.0" | 32 | embedded-storage = "0.3.0" |
| 33 | embedded-storage-async = { version = "0.4.0", optional = true } | 33 | embedded-storage-async = { version = "0.4.0", optional = true } |
| 34 | salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true } | 34 | salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true } |
diff --git a/embassy-boot/boot/src/fmt.rs b/embassy-boot/boot/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-boot/boot/src/fmt.rs +++ b/embassy-boot/boot/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
