From 0b68c00487e460d716045725b51d73a29c7bbb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 20 Sep 2024 21:04:05 +0200 Subject: [PATCH] Fix compile errors --- esp-hal/src/twai/mod.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/esp-hal/src/twai/mod.rs b/esp-hal/src/twai/mod.rs index ea84c1b3b99..3f144c7613e 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -840,7 +840,8 @@ where let mut prescaler = timing.baud_rate_prescaler; - if cfg!(esp32) { + #[cfg(esp32)] + { if timing.baud_rate_prescaler > 128 { // Enable /2 baudrate divider T::register_block() @@ -961,8 +962,14 @@ where .rx_err_cnt() .write(|w| unsafe { w.rx_err_cnt().bits(rec) }); - // Clear any interrupts - _ = T::register_block().int_raw().read(); + // Clear any interrupts by reading the status register + cfg_if::cfg_if! { + if #[cfg(any(esp32, esp32c3, esp32s2, esp32s3))] { + let _ = T::register_block().int_raw().read(); + } else { + let _ = T::register_block().interrupt().read(); + } + } // Put the peripheral into operation mode by clearing the reset mode bit. T::register_block()