Skip to content

Commit

Permalink
CI, more defmt impls
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 7, 2024
1 parent 24853bc commit 643b84e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions esp-hal/src/twai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -321,6 +323,7 @@ impl From<embedded_can::StandardId> 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 {
Expand Down Expand Up @@ -392,6 +395,7 @@ impl From<embedded_can::ExtendedId> 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),
Expand Down Expand Up @@ -451,6 +455,7 @@ impl From<embedded_can::Id> 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,
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion examples/src/bin/embassy_twai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 643b84e

Please sign in to comment.