|
15 | 15 |
|
16 | 16 | #include <init.h> |
17 | 17 | #include <drivers/clock_control.h> |
| 18 | +#include <drivers/dma/dma_stm32.h> |
18 | 19 |
|
19 | 20 | #include <logging/log.h> |
20 | 21 | LOG_MODULE_REGISTER(dma_stm32, CONFIG_DMA_LOG_LEVEL); |
@@ -101,14 +102,21 @@ static void dma_stm32_irq_handler(const struct device *dev, uint32_t id) |
101 | 102 | } |
102 | 103 |
|
103 | 104 | /* the dma stream id is in range from STREAM_OFFSET..<dma-requests> */ |
104 | | - if (dma_stm32_is_tc_active(dma, id)) { |
105 | | - dma_stm32_clear_tc(dma, id); |
| 105 | + if (dma_stm32_is_ht_active(dma, id)) { |
| 106 | + /* Let HAL DMA handle flags on its own */ |
| 107 | + if (!stream->hal_override) { |
| 108 | + dma_stm32_clear_ht(dma, id); |
| 109 | + } |
| 110 | + stream->dma_callback(dev, stream->user_data, callback_arg, 0); |
| 111 | + } else if (dma_stm32_is_tc_active(dma, id)) { |
106 | 112 | #ifdef CONFIG_DMAMUX_STM32 |
107 | 113 | stream->busy = false; |
108 | 114 | #endif |
| 115 | + /* Let HAL DMA handle flags on its own */ |
| 116 | + if (!stream->hal_override) { |
| 117 | + dma_stm32_clear_tc(dma, id); |
| 118 | + } |
109 | 119 | stream->dma_callback(dev, stream->user_data, callback_arg, 0); |
110 | | - } else if (dma_stm32_is_ht_active(dma, id)) { |
111 | | - dma_stm32_clear_ht(dma, id); |
112 | 120 | } else if (stm32_dma_is_unexpected_irq_happened(dma, id)) { |
113 | 121 | LOG_ERR("Unexpected irq happened."); |
114 | 122 | stream->dma_callback(dev, stream->user_data, |
@@ -255,6 +263,19 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev, |
255 | 263 | /* give channel from index 0 */ |
256 | 264 | id = id - STREAM_OFFSET; |
257 | 265 |
|
| 266 | + /* Check potential DMA override */ |
| 267 | + if (config->linked_channel == STM32_DMA_HAL_OVERRIDE) { |
| 268 | + /* DMA channel is overridden by HAL DMA |
| 269 | + * Retain that the channel is busy and proceed to the minimal |
| 270 | + * configuration to properly route the IRQ |
| 271 | + */ |
| 272 | + stream->busy = true; |
| 273 | + stream->hal_override = true; |
| 274 | + stream->dma_callback = config->dma_callback; |
| 275 | + stream->user_data = config->user_data; |
| 276 | + return 0; |
| 277 | + } |
| 278 | + |
258 | 279 | if (id >= dev_config->max_streams) { |
259 | 280 | LOG_ERR("cannot configure the dma stream %d.", id); |
260 | 281 | return -EINVAL; |
|
0 commit comments