Skip to content

Commit

Permalink
add Twai::enable_rx_interrupt and Twai::disable_rx_interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpolo committed Mar 29, 2023
1 parent a677abd commit 5b84c88
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions esp-hal-common/src/twai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,42 @@ where
}
}

/// Use in combination with `interrupt::enable`.
/// The interrupt is cleared when all pending messages are received.
#[cfg(any(esp32c3, esp32s3))]
pub fn enable_rx_interrupt(&mut self) {
self.peripheral
.register_block()
.int_ena
.modify(|_, w| w.rx_int_ena().set_bit());
}

/// Use in combination with `interrupt::enable`.
/// The interrupt is cleared when all pending messages are received.
#[cfg(esp32c6)]
pub fn enable_rx_interrupt(&mut self) {
self.peripheral
.register_block()
.interrupt_enable
.modify(|_, w| w.ext_receive_int_ena().set_bit());
}

#[cfg(any(esp32c3, esp32s3))]
pub fn disable_rx_interrupt(&mut self) {
self.peripheral
.register_block()
.int_ena
.modify(|_, w| w.rx_int_ena().clear_bit());
}

#[cfg(esp32c6)]
pub fn disable_rx_interrupt(&mut self) {
self.peripheral
.register_block()
.interrupt_enable
.modify(|_, w| w.ext_receive_int_ena().clear_bit());
}

/// Release the message in the buffer. This will decrement the received
/// message counter and prepare the next message in the FIFO for
/// reading.
Expand Down

0 comments on commit 5b84c88

Please sign in to comment.