Skip to content

Commit 5b84c88

Browse files
committed
add Twai::enable_rx_interrupt and Twai::disable_rx_interrupt
1 parent a677abd commit 5b84c88

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

esp-hal-common/src/twai/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,42 @@ where
403403
}
404404
}
405405

406+
/// Use in combination with `interrupt::enable`.
407+
/// The interrupt is cleared when all pending messages are received.
408+
#[cfg(any(esp32c3, esp32s3))]
409+
pub fn enable_rx_interrupt(&mut self) {
410+
self.peripheral
411+
.register_block()
412+
.int_ena
413+
.modify(|_, w| w.rx_int_ena().set_bit());
414+
}
415+
416+
/// Use in combination with `interrupt::enable`.
417+
/// The interrupt is cleared when all pending messages are received.
418+
#[cfg(esp32c6)]
419+
pub fn enable_rx_interrupt(&mut self) {
420+
self.peripheral
421+
.register_block()
422+
.interrupt_enable
423+
.modify(|_, w| w.ext_receive_int_ena().set_bit());
424+
}
425+
426+
#[cfg(any(esp32c3, esp32s3))]
427+
pub fn disable_rx_interrupt(&mut self) {
428+
self.peripheral
429+
.register_block()
430+
.int_ena
431+
.modify(|_, w| w.rx_int_ena().clear_bit());
432+
}
433+
434+
#[cfg(esp32c6)]
435+
pub fn disable_rx_interrupt(&mut self) {
436+
self.peripheral
437+
.register_block()
438+
.interrupt_enable
439+
.modify(|_, w| w.ext_receive_int_ena().clear_bit());
440+
}
441+
406442
/// Release the message in the buffer. This will decrement the received
407443
/// message counter and prepare the next message in the FIFO for
408444
/// reading.

0 commit comments

Comments
 (0)