From 40c9ee7c73e4d96a8a6d26d0e55d044252e6588b Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 29 Sep 2019 10:05:14 +0000 Subject: [PATCH] Introduced shared handlers for DMAv1. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13043 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- .../ports/STM32/LLD/DMAv1/stm32_dma1_ch23.inc | 78 +++++++++++++++++ .../STM32/LLD/DMAv1/stm32_dma1_ch4567.inc | 84 +++++++++++++++++++ os/hal/ports/STM32/STM32G0xx/stm32_isr.c | 49 +---------- 3 files changed, 165 insertions(+), 46 deletions(-) create mode 100644 os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch23.inc create mode 100644 os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch4567.inc diff --git a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch23.inc b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch23.inc new file mode 100644 index 000000000..c67f5b470 --- /dev/null +++ b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch23.inc @@ -0,0 +1,78 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file DMAv1/stm32_dma1_ch23.inc + * @brief Shared DMA1 Channels 2 and 3 handler. + * + * @addtogroup STM32_DMA1_CH23_HANDLER + * @{ + */ + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/* Other checks.*/ +#if !defined(STM32_DMA1_CH23_HANDLER) +#error "STM32_DMA1_CH23_HANDLER not defined in stm32_isr.h" +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +#if defined(STM32_DMA_REQUIRED) || defined(__DOXYGEN__) +/** + * @brief DMA1 streams 2 and 3 shared ISR. + * + * @isr + */ +OSAL_IRQ_HANDLER(STM32_DMA1_CH23_HANDLER) { + + OSAL_IRQ_PROLOGUE(); + + /* Check on channel 2.*/ + dmaServeInterrupt(STM32_DMA1_STREAM2); + + /* Check on channel 3.*/ + dmaServeInterrupt(STM32_DMA1_STREAM3); + + OSAL_IRQ_EPILOGUE(); +} +#endif + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/** @} */ diff --git a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch4567.inc b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch4567.inc new file mode 100644 index 000000000..1de459746 --- /dev/null +++ b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma1_ch4567.inc @@ -0,0 +1,84 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file DMAv1/stm32_dma1_ch4567.inc + * @brief Shared DMA1 Channels 4, 5, 6 and 7 handler. + * + * @addtogroup STM32_DMA1_CH4567_HANDLER + * @{ + */ + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/* Other checks.*/ +#if !defined(STM32_DMA1_CH4567_HANDLER) +#error "STM32_DMA1_CH4567_HANDLER not defined in stm32_isr.h" +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +#if defined(STM32_DMA_REQUIRED) || defined(__DOXYGEN__) +/** + * @brief DMA1 streams 4, 5, 6 and 7 shared ISR. + * + * @isr + */ +OSAL_IRQ_HANDLER(STM32_DMA1_CH4567_HANDLER) { + + OSAL_IRQ_PROLOGUE(); + + /* Check on channel 4.*/ + dmaServeInterrupt(STM32_DMA1_STREAM4); + + /* Check on channel 5.*/ + dmaServeInterrupt(STM32_DMA1_STREAM5); + + /* Check on channel 6.*/ + dmaServeInterrupt(STM32_DMA1_STREAM6); + + /* Check on channel 7.*/ + dmaServeInterrupt(STM32_DMA1_STREAM7); + + OSAL_IRQ_EPILOGUE(); +} +#endif + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/** @} */ diff --git a/os/hal/ports/STM32/STM32G0xx/stm32_isr.c b/os/hal/ports/STM32/STM32G0xx/stm32_isr.c index 05ea9b784..b924e9be4 100644 --- a/os/hal/ports/STM32/STM32G0xx/stm32_isr.c +++ b/os/hal/ports/STM32/STM32G0xx/stm32_isr.c @@ -51,6 +51,9 @@ /* Driver interrupt handlers. */ /*===========================================================================*/ +#include "stm32_dma1_ch23.inc" +#include "stm32_dma1_ch4567.inc" + #include "stm32_exti0_1.inc" #include "stm32_exti2_3.inc" #include "stm32_exti4_15.inc" @@ -73,52 +76,6 @@ #include "stm32_tim16.inc" #include "stm32_tim17.inc" -#if defined(STM32_DMA_REQUIRED) || defined(__DOXYGEN__) -/** - * @brief DMA1 streams 2 and 3 shared ISR. - * @note It is declared here because this device has a non-standard - * DMA shared IRQ handler. - * - * @isr - */ -OSAL_IRQ_HANDLER(STM32_DMA1_CH23_HANDLER) { - - OSAL_IRQ_PROLOGUE(); - - /* Check on channel 2.*/ - dmaServeInterrupt(STM32_DMA1_STREAM2); - - /* Check on channel 3.*/ - dmaServeInterrupt(STM32_DMA1_STREAM3); - - OSAL_IRQ_EPILOGUE(); -} - -/** - * @brief DMA1 streams 4, 5, 6 and 7 shared ISR. - * - * @isr - */ -OSAL_IRQ_HANDLER(STM32_DMA1_CH4567_HANDLER) { - - OSAL_IRQ_PROLOGUE(); - - /* Check on channel 4.*/ - dmaServeInterrupt(STM32_DMA1_STREAM4); - - /* Check on channel 5.*/ - dmaServeInterrupt(STM32_DMA1_STREAM5); - - /* Check on channel 6.*/ - dmaServeInterrupt(STM32_DMA1_STREAM6); - - /* Check on channel 7.*/ - dmaServeInterrupt(STM32_DMA1_STREAM7); - - OSAL_IRQ_EPILOGUE(); -} -#endif - /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/