+++ /dev/null
-/**\r
- ******************************************************************************\r
- * @file stm32l4xx_hal_dma_ex.c\r
- * @author MCD Application Team\r
- * @brief DMA Extension HAL module driver\r
- * This file provides firmware functions to manage the following\r
- * functionalities of the DMA Extension peripheral:\r
- * + Extended features functions\r
- *\r
- @verbatim\r
- ==============================================================================\r
- ##### How to use this driver #####\r
- ==============================================================================\r
- [..]\r
- The DMA Extension HAL driver can be used as follows:\r
-\r
- (+) Configure the DMA_MUX Synchronization Block using HAL_DMAEx_ConfigMuxSync function.\r
- (+) Configure the DMA_MUX Request Generator Block using HAL_DMAEx_ConfigMuxRequestGenerator function.\r
- Functions HAL_DMAEx_EnableMuxRequestGenerator and HAL_DMAEx_DisableMuxRequestGenerator can then be used\r
- to respectively enable/disable the request generator.\r
-\r
- (+) To handle the DMAMUX Interrupts, the function HAL_DMAEx_MUX_IRQHandler should be called from\r
- the DMAMUX IRQ handler i.e DMAMUX1_OVR_IRQHandler.\r
- As only one interrupt line is available for all DMAMUX channels and request generators , HAL_DMAEx_MUX_IRQHandler should be\r
- called with, as parameter, the appropriate DMA handle as many as used DMAs in the user project\r
- (exception done if a given DMA is not using the DMAMUX SYNC block neither a request generator)\r
-\r
- -@- In Memory-to-Memory transfer mode, Multi (Double) Buffer mode is not allowed.\r
- -@- When Multi (Double) Buffer mode is enabled, the transfer is circular by default.\r
- -@- In Multi (Double) buffer mode, it is possible to update the base address for\r
- the AHB memory port on the fly (DMA_CM0ARx or DMA_CM1ARx) when the channel is enabled.\r
-\r
-\r
- @endverbatim\r
- ******************************************************************************\r
- * @attention\r
- *\r
- * <h2><center>© Copyright (c) 2017 STMicroelectronics.\r
- * All rights reserved.</center></h2>\r
- *\r
- * This software component is licensed by ST under BSD 3-Clause license,\r
- * the "License"; You may not use this file except in compliance with the\r
- * License. You may obtain a copy of the License at:\r
- * opensource.org/licenses/BSD-3-Clause\r
- *\r
- ******************************************************************************\r
- */\r
-\r
-/* Includes ------------------------------------------------------------------*/\r
-#include "stm32l4xx_hal.h"\r
-\r
-#if defined(DMAMUX1)\r
-\r
-/** @addtogroup STM32L4xx_HAL_Driver\r
- * @{\r
- */\r
-\r
-/** @defgroup DMAEx DMAEx\r
- * @brief DMA Extended HAL module driver\r
- * @{\r
- */\r
-\r
-#ifdef HAL_DMA_MODULE_ENABLED\r
-\r
-/* Private typedef -----------------------------------------------------------*/\r
-/* Private define ------------------------------------------------------------*/\r
-/* Private macro -------------------------------------------------------------*/\r
-/* Private variables ---------------------------------------------------------*/\r
-/* Private Constants ---------------------------------------------------------*/\r
-/* Private function prototypes -----------------------------------------------*/\r
-/* Private functions ---------------------------------------------------------*/\r
-\r
-\r
-/** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions\r
- * @{\r
- */\r
-\r
-/** @defgroup DMAEx_Exported_Functions_Group1 DMAEx Extended features functions\r
- * @brief Extended features functions\r
- *\r
-@verbatim\r
- ===============================================================================\r
- ##### Extended features functions #####\r
- ===============================================================================\r
- [..] This section provides functions allowing to:\r
-\r
- (+) Configure the DMAMUX Synchronization Block using HAL_DMAEx_ConfigMuxSync function.\r
- (+) Configure the DMAMUX Request Generator Block using HAL_DMAEx_ConfigMuxRequestGenerator function.\r
- Functions HAL_DMAEx_EnableMuxRequestGenerator and HAL_DMAEx_DisableMuxRequestGenerator can then be used\r
- to respectively enable/disable the request generator.\r
-\r
-@endverbatim\r
- * @{\r
- */\r
-\r
-\r
-/**\r
- * @brief Configure the DMAMUX synchronization parameters for a given DMA channel (instance).\r
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains\r
- * the configuration information for the specified DMA channel.\r
- * @param pSyncConfig : pointer to HAL_DMA_MuxSyncConfigTypeDef : contains the DMAMUX synchronization parameters\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DMAEx_ConfigMuxSync(DMA_HandleTypeDef *hdma, HAL_DMA_MuxSyncConfigTypeDef *pSyncConfig)\r
-{\r
- /* Check the parameters */\r
- assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));\r
-\r
- assert_param(IS_DMAMUX_SYNC_SIGNAL_ID(pSyncConfig->SyncSignalID));\r
-\r
- assert_param(IS_DMAMUX_SYNC_POLARITY(pSyncConfig-> SyncPolarity));\r
- assert_param(IS_DMAMUX_SYNC_STATE(pSyncConfig->SyncEnable));\r
- assert_param(IS_DMAMUX_SYNC_EVENT(pSyncConfig->EventEnable));\r
- assert_param(IS_DMAMUX_SYNC_REQUEST_NUMBER(pSyncConfig->RequestNumber));\r
-\r
- /*Check if the DMA state is ready */\r
- if(hdma->State == HAL_DMA_STATE_READY)\r
- {\r
- /* Process Locked */\r
- __HAL_LOCK(hdma);\r
-\r
- /* Set the new synchronization parameters (and keep the request ID filled during the Init)*/\r
- MODIFY_REG( hdma->DMAmuxChannel->CCR, \\r
- (~DMAMUX_CxCR_DMAREQ_ID) , \\r
- ((pSyncConfig->SyncSignalID) << DMAMUX_CxCR_SYNC_ID_Pos) | ((pSyncConfig->RequestNumber - 1U) << DMAMUX_CxCR_NBREQ_Pos) | \\r
- pSyncConfig->SyncPolarity | ((uint32_t)pSyncConfig->SyncEnable << DMAMUX_CxCR_SE_Pos) | \\r
- ((uint32_t)pSyncConfig->EventEnable << DMAMUX_CxCR_EGE_Pos));\r
-\r
- /* Process UnLocked */\r
- __HAL_UNLOCK(hdma);\r
-\r
- return HAL_OK;\r
- }\r
- else\r
- {\r
- /*DMA State not Ready*/\r
- return HAL_ERROR;\r
- }\r
-}\r
-\r
-/**\r
- * @brief Configure the DMAMUX request generator block used by the given DMA channel (instance).\r
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains\r
- * the configuration information for the specified DMA channel.\r
- * @param pRequestGeneratorConfig : pointer to HAL_DMA_MuxRequestGeneratorConfigTypeDef :\r
- * contains the request generator parameters.\r
- *\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator (DMA_HandleTypeDef *hdma, HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig)\r
-{\r
- /* Check the parameters */\r
- assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));\r
-\r
- assert_param(IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(pRequestGeneratorConfig->SignalID));\r
-\r
- assert_param(IS_DMAMUX_REQUEST_GEN_POLARITY(pRequestGeneratorConfig->Polarity));\r
- assert_param(IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(pRequestGeneratorConfig->RequestNumber));\r
-\r
- /* check if the DMA state is ready\r
- and DMA is using a DMAMUX request generator block\r
- */\r
- if((hdma->State == HAL_DMA_STATE_READY) && (hdma->DMAmuxRequestGen != 0U))\r
- {\r
- /* Process Locked */\r
- __HAL_LOCK(hdma);\r
-\r
- /* Set the request generator new parameters */\r
- hdma->DMAmuxRequestGen->RGCR = pRequestGeneratorConfig->SignalID | \\r
- ((pRequestGeneratorConfig->RequestNumber - 1U) << DMAMUX_RGxCR_GNBREQ_Pos)| \\r
- pRequestGeneratorConfig->Polarity;\r
- /* Process UnLocked */\r
- __HAL_UNLOCK(hdma);\r
-\r
- return HAL_OK;\r
- }\r
- else\r
- {\r
- return HAL_ERROR;\r
- }\r
-}\r
-\r
-/**\r
- * @brief Enable the DMAMUX request generator block used by the given DMA channel (instance).\r
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains\r
- * the configuration information for the specified DMA channel.\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DMAEx_EnableMuxRequestGenerator (DMA_HandleTypeDef *hdma)\r
-{\r
- /* Check the parameters */\r
- assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));\r
-\r
- /* check if the DMA state is ready\r
- and DMA is using a DMAMUX request generator block\r
- */\r
- if((hdma->State != HAL_DMA_STATE_RESET) && (hdma->DMAmuxRequestGen != 0))\r
- {\r
-\r
- /* Enable the request generator*/\r
- hdma->DMAmuxRequestGen->RGCR |= DMAMUX_RGxCR_GE;\r
-\r
- return HAL_OK;\r
- }\r
- else\r
- {\r
- return HAL_ERROR;\r
- }\r
-}\r
-\r
-/**\r
- * @brief Disable the DMAMUX request generator block used by the given DMA channel (instance).\r
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains\r
- * the configuration information for the specified DMA channel.\r
- * @retval HAL status\r
- */\r
-HAL_StatusTypeDef HAL_DMAEx_DisableMuxRequestGenerator (DMA_HandleTypeDef *hdma)\r
-{\r
- /* Check the parameters */\r
- assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));\r
-\r
- /* check if the DMA state is ready\r
- and DMA is using a DMAMUX request generator block\r
- */\r
- if((hdma->State != HAL_DMA_STATE_RESET) && (hdma->DMAmuxRequestGen != 0))\r
- {\r
-\r
- /* Disable the request generator*/\r
- hdma->DMAmuxRequestGen->RGCR &= ~DMAMUX_RGxCR_GE;\r
-\r
- return HAL_OK;\r
- }\r
- else\r
- {\r
- return HAL_ERROR;\r
- }\r
-}\r
-\r
-/**\r
- * @brief Handles DMAMUX interrupt request.\r
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains\r
- * the configuration information for the specified DMA channel.\r
- * @retval None\r
- */\r
-void HAL_DMAEx_MUX_IRQHandler(DMA_HandleTypeDef *hdma)\r
-{\r
- /* Check for DMAMUX Synchronization overrun */\r
- if((hdma->DMAmuxChannelStatus->CSR & hdma->DMAmuxChannelStatusMask) != 0U)\r
- {\r
- /* Disable the synchro overrun interrupt */\r
- hdma->DMAmuxChannel->CCR &= ~DMAMUX_CxCR_SOIE;\r
-\r
- /* Clear the DMAMUX synchro overrun flag */\r
- hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;\r
-\r
- /* Update error code */\r
- hdma->ErrorCode |= HAL_DMA_ERROR_SYNC;\r
-\r
- if(hdma->XferErrorCallback != NULL)\r
- {\r
- /* Transfer error callback */\r
- hdma->XferErrorCallback(hdma);\r
- }\r
- }\r
-\r
- if(hdma->DMAmuxRequestGen != 0)\r
- {\r
- /* if using a DMAMUX request generator block Check for DMAMUX request generator overrun */\r
- if((hdma->DMAmuxRequestGenStatus->RGSR & hdma->DMAmuxRequestGenStatusMask) != 0U)\r
- {\r
- /* Disable the request gen overrun interrupt */\r
- hdma->DMAmuxRequestGen->RGCR &= ~DMAMUX_RGxCR_OIE;\r
-\r
- /* Clear the DMAMUX request generator overrun flag */\r
- hdma->DMAmuxRequestGenStatus->RGCFR = hdma->DMAmuxRequestGenStatusMask;\r
-\r
- /* Update error code */\r
- hdma->ErrorCode |= HAL_DMA_ERROR_REQGEN;\r
-\r
- if(hdma->XferErrorCallback != NULL)\r
- {\r
- /* Transfer error callback */\r
- hdma->XferErrorCallback(hdma);\r
- }\r
- }\r
- }\r
-}\r
-\r
-/**\r
- * @}\r
- */\r
-\r
-/**\r
- * @}\r
- */\r
-\r
-#endif /* HAL_DMA_MODULE_ENABLED */\r
-\r
-/**\r
- * @}\r
- */\r
-\r
-/**\r
- * @}\r
- */\r
-\r
-#endif /* DMAMUX1 */\r
-\r
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r