stm32f4xx-hal
stm32f4xx-hal copied to clipboard
No way to access DMA interrupt source
When configuring a DMA request, there are 5 different interrupts we can enable.
However, inside the interrupt
enum fo the crate, there is only one variant for each DMA-Stream combo.
There seems to be no way to retrieve what caused the interrupt.
Example
fn dma_init() {
let config = DmaConfig::default()
.transfer_complete_interrupt(true)
.half_transfer_interrupt(true)
.transfer_error_interrupt(true)
.fifo_error_interrupt(true)
.direct_mode_error_interrupt(true);
let transfer = ... // Initialize Transfer for DMA2, Stream 1
// Hand off transfer ownership to interrupt
cortex_m::interrupt::free(|cs| *DCMI_TRANSFER.borrow(&cs).borrow_mut() = Some(transfer));
// Enable interrupt for the dma stream combo
unsafe { NVIC::unmask(interrupt::DMA2_STREAM1) }
}
#[interrupt]
fn DMA2_STREAM1() {
static mut TRANSFER: Option<DcmiTranfer> = None;
// <- even though we have access to the `Transfer` struct,
// there is no API for retrieving which event triggered the interrupt
}
This looks like something similar to #42, where access to the Status register is needed, but for the DMA case.
Currently, you can get both the transfer complete flag and half transfer complete flag through the Stream
trait, we should probably add methods to get at least the transfer error flag and the direct mode error flag too.