Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Twai::enable_rx_interrupt and Twai::disable_rx_interrupt #459

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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