Potential DMA IRQ problem.
Posted: Sat May 31, 2014 10:36 pm
I've run into something disturbing in DMA driver. STM32F1 XL and HD devices have shared DMA2 4th and 5th channel. At dmaStreamRelease there is no check whether when disabling 4th channel, 5th is allocated, or opposite.
Here you have fix proposal (2.6.x):
Here you have fix proposal (2.6.x):
Code: Select all
void dmaStreamRelease(const stm32_dma_stream_t *dmastp) {
chDbgCheck(dmastp != NULL, "dmaStreamRelease");
/* Check if the streams is not taken.*/
chDbgAssert((dma_streams_mask & (1 << dmastp->selfindex)) != 0,
"dmaStreamRelease(), #1", "not allocated");
/* Marks the stream as not allocated.*/
dma_streams_mask &= ~(1 << dmastp->selfindex);
/* Disables the associated IRQ vector.*/
#if !(STM32_HAS_DMA2 && !defined(STM32F10X_CL)) || defined(__DOXYGEN__)
nvicDisableVector(dmastp->vector);
#else
/* Check unless it is 10 or 11 stream. If yes, make additional check before
disabling IRQ.*/
if (dmastp->selfindex < 10) {
nvicDisableVector(dmastp->vector);
}
else {
if (dma_streams_mask & (3 << 10) == 0)
nvicDisableVector(dmastp->vector);
}
#endif/* STM32_HAS_DMA2 && !STM32F10X_CL */
/* Shutting down clocks that are no more required, if any.*/
if ((dma_streams_mask & STM32_DMA1_STREAMS_MASK) == 0)
rccDisableDMA1(FALSE);
#if STM32_HAS_DMA2
if ((dma_streams_mask & STM32_DMA2_STREAMS_MASK) == 0)
rccDisableDMA2(FALSE);
#endif
}