@@ -230,8 +230,12 @@ static void dma_stm32_irq_handler(const struct device *dev, uint32_t id)
230
230
__ASSERT_NO_MSG (id < config -> max_streams );
231
231
232
232
stream = & config -> streams [id ];
233
- /* Exit if stream is no more busy */
234
- if (stream -> busy == false) {
233
+ /* The busy channel is pertinent if not overridden by the HAL */
234
+ if ((stream -> hal_override != true) && (stream -> busy == false)) {
235
+ /*
236
+ * When DMA channel is not overridden by HAL,
237
+ * ignore irq if the channel is not busy anymore
238
+ */
235
239
dma_stm32_clear_stream_irq (dev , id );
236
240
return ;
237
241
}
@@ -246,9 +250,6 @@ static void dma_stm32_irq_handler(const struct device *dev, uint32_t id)
246
250
}
247
251
stream -> dma_callback (dev , stream -> user_data , callback_arg , 0 );
248
252
} else if (stm32_dma_is_tc_irq_active (dma , id )) {
249
- #ifdef CONFIG_DMAMUX_STM32
250
- stream -> busy = false;
251
- #endif
252
253
/* Let HAL DMA handle flags on its own */
253
254
if (!stream -> hal_override ) {
254
255
dma_stm32_clear_tc (dma , id );
@@ -540,6 +541,9 @@ static int dma_stm32_reload(const struct device *dev, uint32_t id,
540
541
size / stream -> dst_size );
541
542
}
542
543
544
+ /* When reloading the dma, the stream is busy again before enabling */
545
+ stream -> busy = true;
546
+
543
547
stm32_dma_enable_stream (dma , id );
544
548
545
549
return 0 ;
@@ -549,6 +553,7 @@ static int dma_stm32_start(const struct device *dev, uint32_t id)
549
553
{
550
554
const struct dma_stm32_config * config = dev -> config ;
551
555
DMA_TypeDef * dma = (DMA_TypeDef * )(config -> base );
556
+ struct dma_stm32_stream * stream ;
552
557
553
558
/* Give channel from index 0 */
554
559
id = id - STM32_DMA_STREAM_OFFSET ;
@@ -558,6 +563,10 @@ static int dma_stm32_start(const struct device *dev, uint32_t id)
558
563
return - EINVAL ;
559
564
}
560
565
566
+ /* When starting the dma, the stream is busy before enabling */
567
+ stream = & config -> streams [id ];
568
+ stream -> busy = true;
569
+
561
570
dma_stm32_clear_stream_irq (dev , id );
562
571
563
572
stm32_dma_enable_stream (dma , id );
@@ -578,11 +587,11 @@ static int dma_stm32_stop(const struct device *dev, uint32_t id)
578
587
return - EINVAL ;
579
588
}
580
589
590
+ LL_DMA_DisableIT_TC (dma , dma_stm32_id_to_stream (id ));
591
+
581
592
dma_stm32_clear_stream_irq (dev , id );
582
593
dma_stm32_disable_stream (dma , id );
583
594
584
- LL_DMA_DisableIT_TC (dma , dma_stm32_id_to_stream (id ));
585
-
586
595
/* Finally, flag stream as free */
587
596
stream -> busy = false;
588
597
@@ -715,16 +724,9 @@ static void dma_stm32_config_irq_0(const struct device *dev)
715
724
DMA_STM32_IRQ_CONNECT (0 , 2 );
716
725
DMA_STM32_IRQ_CONNECT (0 , 3 );
717
726
DMA_STM32_IRQ_CONNECT (0 , 4 );
718
- #if DT_INST_IRQ_HAS_IDX (0 , 5 )
719
727
DMA_STM32_IRQ_CONNECT (0 , 5 );
720
- #if DT_INST_IRQ_HAS_IDX (0 , 6 )
721
728
DMA_STM32_IRQ_CONNECT (0 , 6 );
722
- #if DT_INST_IRQ_HAS_IDX (0 , 7 )
723
729
DMA_STM32_IRQ_CONNECT (0 , 7 );
724
- #endif /* DT_INST_IRQ_HAS_IDX(0, 5) */
725
- #endif /* DT_INST_IRQ_HAS_IDX(0, 6) */
726
- #endif /* DT_INST_IRQ_HAS_IDX(0, 7) */
727
- /* Either 5 or 6 or 7 or 8 channels for DMA across all stm32 series. */
728
730
DMA_STM32_IRQ_CONNECT (0 , 8 );
729
731
DMA_STM32_IRQ_CONNECT (0 , 9 );
730
732
DMA_STM32_IRQ_CONNECT (0 , 10 );
0 commit comments