diff --git a/cpu/stm32/include/periph/cpu_dma.h b/cpu/stm32/include/periph/cpu_dma.h index 74dd58e8cd..bcdfc1ce95 100644 --- a/cpu/stm32/include/periph/cpu_dma.h +++ b/cpu/stm32/include/periph/cpu_dma.h @@ -38,7 +38,7 @@ typedef struct { * - 8: DAM2 / Stream0 * - ... * - 15: DMA2 / Stream7 - * STM32F0/1/L0/1/4: + * STM32F0/1/3/L0/1/4: * - 0: DMA1 / Channel1 * - ... * - 4: DMA1 / Channel5 diff --git a/cpu/stm32/periph/dma.c b/cpu/stm32/periph/dma.c index c61106f6b8..8f4d7b9f43 100644 --- a/cpu/stm32/periph/dma.c +++ b/cpu/stm32/periph/dma.c @@ -193,22 +193,28 @@ static IRQn_Type dma_get_irqn(int stream) return ((IRQn_Type)((int)DMA1_Channel1_IRQn + stream)); } #if defined(DMA2_BASE) + /* stream 7 is invalid for these CPU families */ + else if (stream == 7) { + return -1; + } #if defined(CPU_FAM_STM32F1) else if (stream < 11) { #else else if (stream < 13 ) { #endif - return ((IRQn_Type)((int)DMA2_Channel1_IRQn + stream)); + /* magic number 8 is first DMA2 stream */ + return ((IRQn_Type)((int)DMA2_Channel1_IRQn + stream - 8)); } -#if !defined(CPU_FAM_STM32L1) +#if !defined(CPU_FAM_STM32L1) && !defined(CPU_FAM_STM32F3) else { #if defined(CPU_FAM_STM32F1) return (DMA2_Channel4_5_IRQn); #else - return ((IRQn_Type)((int)DMA2_Channel6_IRQn + stream)); + /* magic number 13 is 8 (first DMA2 stream) + 5 (Channel6) */ + return ((IRQn_Type)((int)DMA2_Channel6_IRQn + stream - 13)); #endif } -#endif /* !defined(CPU_FAM_STM32L1) */ +#endif /* !defined(CPU_FAM_STM32L1) && !defined(CPU_FAM_STM32F3) */ #endif /* defined(DMA2_BASE) */ #endif