From a4b1b930616de4d72fbadd964518faf85d42789b Mon Sep 17 00:00:00 2001 From: Akhil Velagapudi <4@4khil.com> Date: Thu, 28 Nov 2024 21:20:19 -0800 Subject: [PATCH] Implement defmt::Format for all error types Signed-off-by: Akhil Velagapudi <4@4khil.com> --- src/clocks/mod.rs | 2 +- src/crc.rs | 2 +- src/flash/non_trustzone.rs | 2 +- src/flash/trustzone.rs | 2 +- src/i2c.rs | 2 +- src/i2c_f4.rs | 2 +- src/qspi.rs | 2 +- src/rtc.rs | 2 +- src/spi/mod.rs | 2 +- src/timer.rs | 2 +- src/usart.rs | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/clocks/mod.rs b/src/clocks/mod.rs index 420add3..7b4c5e0 100644 --- a/src/clocks/mod.rs +++ b/src/clocks/mod.rs @@ -36,7 +36,7 @@ cfg_if::cfg_if! { // todo: Continue working through DRY between the clock modules. /// Speed out of limits. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, defmt::Format)] pub enum RccError { Speed, Hardware, diff --git a/src/crc.rs b/src/crc.rs index 6cac30c..664893e 100644 --- a/src/crc.rs +++ b/src/crc.rs @@ -313,7 +313,7 @@ impl Default for Polynomial { } /// Errors generated when trying to create invalid polynomials. -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, defmt::Format)] pub enum PolynomialError { /// Tried to create an even polynomial. /// The hardware CRC unit only supports odd polynomials. diff --git a/src/flash/non_trustzone.rs b/src/flash/non_trustzone.rs index 5481bc2..61bda6e 100644 --- a/src/flash/non_trustzone.rs +++ b/src/flash/non_trustzone.rs @@ -32,7 +32,7 @@ pub enum Bank { B2 = 1, } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, defmt::Format)] /// Possible error states for flash operations. pub enum Error { /// Flash controller is not done yet diff --git a/src/flash/trustzone.rs b/src/flash/trustzone.rs index 7ebba4e..4baa3fb 100644 --- a/src/flash/trustzone.rs +++ b/src/flash/trustzone.rs @@ -32,7 +32,7 @@ pub enum Bank { B2 = 1, } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, defmt::Format)] /// Possible error states for flash operations. pub enum Error { /// Flash controller is not done yet diff --git a/src/i2c.rs b/src/i2c.rs index c3ea631..92ec5af 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -63,7 +63,7 @@ macro_rules! busy_wait { /// I2C error #[non_exhaustive] -#[derive(Debug)] +#[derive(Debug, defmt::Format)] pub enum Error { /// Bus error Bus, diff --git a/src/i2c_f4.rs b/src/i2c_f4.rs index a1c72fd..01f2e1b 100644 --- a/src/i2c_f4.rs +++ b/src/i2c_f4.rs @@ -25,7 +25,7 @@ pub enum I2cDevice { Three, } -#[derive(Debug)] +#[derive(Debug, defmt::Format)] pub enum Error { OVERRUN, NACK, diff --git a/src/qspi.rs b/src/qspi.rs index 9743c59..ebfa90b 100644 --- a/src/qspi.rs +++ b/src/qspi.rs @@ -89,7 +89,7 @@ pub enum SamplingEdge { } /// Indicates an error with the QSPI peripheral. -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, defmt::Format)] pub enum QspiError { Busy, Underflow, diff --git a/src/rtc.rs b/src/rtc.rs index 484d19b..25abe08 100644 --- a/src/rtc.rs +++ b/src/rtc.rs @@ -26,7 +26,7 @@ pub enum RtcClockSource { } /// RTC error type -#[derive(Debug)] +#[derive(Debug, defmt::Format)] pub enum Error { /// Invalid input error InvalidInputData, diff --git a/src/spi/mod.rs b/src/spi/mod.rs index 8e8e11b..78135c7 100644 --- a/src/spi/mod.rs +++ b/src/spi/mod.rs @@ -53,7 +53,7 @@ macro_rules! check_errors { /// SPI error #[non_exhaustive] -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, defmt::Format)] pub enum SpiError { /// Overrun occurred Overrun, diff --git a/src/timer.rs b/src/timer.rs index c9d7a24..4156e47 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -53,7 +53,7 @@ pub static TICK_OVERFLOW_COUNT: AtomicU32 = AtomicU32::new(0); // todo: Low power timer enabling etc. eg on L4, RCC_APB1ENR1.LPTIM1EN -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, defmt::Format)] /// Used for when attempting to set a timer period that is out of range. pub struct ValueError {} diff --git a/src/usart.rs b/src/usart.rs index a6bef21..1e28083 100644 --- a/src/usart.rs +++ b/src/usart.rs @@ -93,7 +93,7 @@ pub enum IrdaMode { /// Serial error #[non_exhaustive] -#[derive(Debug)] +#[derive(Debug, defmt::Format)] pub enum UartError { /// Framing error Framing,