From 643b84e97895b94a8bc2347c639bdc9c810b1b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 7 Oct 2024 13:43:02 +0200 Subject: [PATCH] CI, more defmt impls --- esp-hal/src/twai/mod.rs | 14 +++++++++----- examples/src/bin/embassy_twai.rs | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs index ebe9c121fdb..a46db828a0d 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -244,6 +244,7 @@ impl embedded_can::Error for ErrorKind { /// Specifies in which mode the TWAI controller will operate. #[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum TwaiMode { /// Normal operating mode Normal, @@ -256,6 +257,7 @@ pub enum TwaiMode { /// Standard 11-bit TWAI Identifier (`0..=0x7FF`). #[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct StandardId(u16); impl StandardId { @@ -321,6 +323,7 @@ impl From for StandardId { /// Extended 29-bit TWAI Identifier (`0..=1FFF_FFFF`). #[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct ExtendedId(u32); impl ExtendedId { @@ -392,6 +395,7 @@ impl From for ExtendedId { /// A TWAI Identifier (standard or extended). #[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Id { /// Standard 11-bit Identifier (`0..=0x7FF`). Standard(StandardId), @@ -451,6 +455,7 @@ impl From for Id { /// Structure backing the embedded_hal_02::can::Frame/embedded_can::Frame trait. #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct EspTwaiFrame { id: Id, dlc: usize, @@ -776,15 +781,14 @@ where .modify(|r, w| unsafe { w.bits(r.bits() | 0x80) }); } - let rx_pull; - if no_transceiver { + let rx_pull = if no_transceiver { tx_pin.set_to_open_drain_output(crate::private::Internal); tx_pin.pull_direction(Pull::Up, crate::private::Internal); - rx_pull = Pull::Up; + Pull::Up } else { tx_pin.set_to_push_pull_output(crate::private::Internal); - rx_pull = Pull::None; - } + Pull::None + }; tx_pin.connect_peripheral_to_output(T::OUTPUT_SIGNAL, crate::private::Internal); // Setting up RX pin later allows us to use a single pin in tests. diff --git a/examples/src/bin/embassy_twai.rs b/examples/src/bin/embassy_twai.rs index 86ac5f74bf3..bbd77a08fe3 100644 --- a/examples/src/bin/embassy_twai.rs +++ b/examples/src/bin/embassy_twai.rs @@ -60,7 +60,8 @@ async fn receiver( print_frame(&frame); // Send a response - let frame = EspTwaiFrame::new(StandardId::new(1).unwrap(), &[4, 5, 6, 7, 8]).unwrap(); + let frame = + EspTwaiFrame::new(StandardId::new(1).unwrap(), &[4, 5, 6, 7, 8]).unwrap(); channel.send(frame).await; } Err(e) => {