STM32L443xx HAL User Manual
stm32l4xx_hal_dma.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_dma.c
00004   * @author  MCD Application Team
00005   * @brief   DMA HAL module driver.
00006   *          This file provides firmware functions to manage the following
00007   *          functionalities of the Direct Memory Access (DMA) peripheral:
00008   *           + Initialization and de-initialization functions
00009   *           + IO operation functions
00010   *           + Peripheral State and errors functions
00011   *
00012   ******************************************************************************
00013   * @attention
00014   *
00015   * Copyright (c) 2017 STMicroelectronics.
00016   * All rights reserved.
00017   *
00018   * This software is licensed under terms that can be found in the LICENSE file
00019   * in the root directory of this software component.
00020   * If no LICENSE file comes with this software, it is provided AS-IS.
00021   *
00022   ******************************************************************************
00023   @verbatim
00024   ==============================================================================
00025                         ##### How to use this driver #####
00026   ==============================================================================
00027   [..]
00028    (#) Enable and configure the peripheral to be connected to the DMA Channel
00029        (except for internal SRAM / FLASH memories: no initialization is
00030        necessary). Please refer to the Reference manual for connection between peripherals
00031        and DMA requests.
00032 
00033    (#) For a given Channel, program the required configuration through the following parameters:
00034        Channel request, Transfer Direction, Source and Destination data formats,
00035        Circular or Normal mode, Channel Priority level, Source and Destination Increment mode
00036        using HAL_DMA_Init() function.
00037 
00038        Prior to HAL_DMA_Init the peripheral clock shall be enabled for both DMA & DMAMUX
00039        thanks to:
00040       (##) DMA1 or DMA2: __HAL_RCC_DMA1_CLK_ENABLE() or  __HAL_RCC_DMA2_CLK_ENABLE() ;
00041       (##) DMAMUX1:      __HAL_RCC_DMAMUX1_CLK_ENABLE();
00042 
00043    (#) Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error
00044        detection.
00045 
00046    (#) Use HAL_DMA_Abort() function to abort the current transfer
00047 
00048      -@-   In Memory-to-Memory transfer mode, Circular mode is not allowed.
00049 
00050      *** Polling mode IO operation ***
00051      =================================
00052      [..]
00053        (+) Use HAL_DMA_Start() to start DMA transfer after the configuration of Source
00054            address and destination address and the Length of data to be transferred
00055        (+) Use HAL_DMA_PollForTransfer() to poll for the end of current transfer, in this
00056            case a fixed Timeout can be configured by User depending from his application.
00057 
00058      *** Interrupt mode IO operation ***
00059      ===================================
00060      [..]
00061        (+) Configure the DMA interrupt priority using HAL_NVIC_SetPriority()
00062        (+) Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ()
00063        (+) Use HAL_DMA_Start_IT() to start DMA transfer after the configuration of
00064            Source address and destination address and the Length of data to be transferred.
00065            In this case the DMA interrupt is configured
00066        (+) Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt subroutine
00067        (+) At the end of data transfer HAL_DMA_IRQHandler() function is executed and user can
00068               add his own function to register callbacks with HAL_DMA_RegisterCallback().
00069 
00070      *** DMA HAL driver macros list ***
00071      =============================================
00072      [..]
00073        Below the list of macros in DMA HAL driver.
00074 
00075        (+) __HAL_DMA_ENABLE: Enable the specified DMA Channel.
00076        (+) __HAL_DMA_DISABLE: Disable the specified DMA Channel.
00077        (+) __HAL_DMA_GET_FLAG: Get the DMA Channel pending flags.
00078        (+) __HAL_DMA_CLEAR_FLAG: Clear the DMA Channel pending flags.
00079        (+) __HAL_DMA_ENABLE_IT: Enable the specified DMA Channel interrupts.
00080        (+) __HAL_DMA_DISABLE_IT: Disable the specified DMA Channel interrupts.
00081        (+) __HAL_DMA_GET_IT_SOURCE: Check whether the specified DMA Channel interrupt is enabled or not.
00082 
00083      [..]
00084       (@) You can refer to the DMA HAL driver header file for more useful macros
00085 
00086   @endverbatim
00087   ******************************************************************************
00088   */
00089 
00090 /* Includes ------------------------------------------------------------------*/
00091 #include "stm32l4xx_hal.h"
00092 
00093 /** @addtogroup STM32L4xx_HAL_Driver
00094   * @{
00095   */
00096 
00097 /** @defgroup DMA DMA
00098   * @brief DMA HAL module driver
00099   * @{
00100   */
00101 
00102 #ifdef HAL_DMA_MODULE_ENABLED
00103 
00104 /* Private typedef -----------------------------------------------------------*/
00105 /* Private define ------------------------------------------------------------*/
00106 /* Private macro -------------------------------------------------------------*/
00107 /* Private variables ---------------------------------------------------------*/
00108 /* Private function prototypes -----------------------------------------------*/
00109 /** @defgroup DMA_Private_Functions DMA Private Functions
00110   * @{
00111   */
00112 static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
00113 #if defined(DMAMUX1)
00114 static void DMA_CalcDMAMUXChannelBaseAndMask(DMA_HandleTypeDef *hdma);
00115 static void DMA_CalcDMAMUXRequestGenBaseAndMask(DMA_HandleTypeDef *hdma);
00116 #endif /* DMAMUX1 */
00117 
00118 /**
00119   * @}
00120   */
00121 
00122 /* Exported functions ---------------------------------------------------------*/
00123 
00124 /** @defgroup DMA_Exported_Functions DMA Exported Functions
00125   * @{
00126   */
00127 
00128 /** @defgroup DMA_Exported_Functions_Group1 Initialization and de-initialization functions
00129  *  @brief   Initialization and de-initialization functions
00130  *
00131 @verbatim
00132  ===============================================================================
00133              ##### Initialization and de-initialization functions  #####
00134  ===============================================================================
00135     [..]
00136     This section provides functions allowing to initialize the DMA Channel source
00137     and destination addresses, incrementation and data sizes, transfer direction,
00138     circular/normal mode selection, memory-to-memory mode selection and Channel priority value.
00139     [..]
00140     The HAL_DMA_Init() function follows the DMA configuration procedures as described in
00141     reference manual.
00142 
00143 @endverbatim
00144   * @{
00145   */
00146 
00147 /**
00148   * @brief  Initialize the DMA according to the specified
00149   *         parameters in the DMA_InitTypeDef and initialize the associated handle.
00150   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00151   *              the configuration information for the specified DMA Channel.
00152   * @retval HAL status
00153   */
00154 HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
00155 {
00156   uint32_t tmp;
00157 
00158   /* Check the DMA handle allocation */
00159   if(hdma == NULL)
00160   {
00161     return HAL_ERROR;
00162   }
00163 
00164   /* Check the parameters */
00165   assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
00166   assert_param(IS_DMA_DIRECTION(hdma->Init.Direction));
00167   assert_param(IS_DMA_PERIPHERAL_INC_STATE(hdma->Init.PeriphInc));
00168   assert_param(IS_DMA_MEMORY_INC_STATE(hdma->Init.MemInc));
00169   assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(hdma->Init.PeriphDataAlignment));
00170   assert_param(IS_DMA_MEMORY_DATA_SIZE(hdma->Init.MemDataAlignment));
00171   assert_param(IS_DMA_MODE(hdma->Init.Mode));
00172   assert_param(IS_DMA_PRIORITY(hdma->Init.Priority));
00173 
00174   assert_param(IS_DMA_ALL_REQUEST(hdma->Init.Request));
00175 
00176   /* Compute the channel index */
00177   if ((uint32_t)(hdma->Instance) < (uint32_t)(DMA2_Channel1))
00178   {
00179     /* DMA1 */
00180     hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2U;
00181     hdma->DmaBaseAddress = DMA1;
00182   }
00183   else
00184   {
00185     /* DMA2 */
00186     hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA2_Channel1) / ((uint32_t)DMA2_Channel2 - (uint32_t)DMA2_Channel1)) << 2U;
00187     hdma->DmaBaseAddress = DMA2;
00188   }
00189 
00190   /* Change DMA peripheral state */
00191   hdma->State = HAL_DMA_STATE_BUSY;
00192 
00193   /* Get the CR register value */
00194   tmp = hdma->Instance->CCR;
00195 
00196   /* Clear PL, MSIZE, PSIZE, MINC, PINC, CIRC, DIR and MEM2MEM bits */
00197   tmp &= ((uint32_t)~(DMA_CCR_PL    | DMA_CCR_MSIZE  | DMA_CCR_PSIZE  |
00198                       DMA_CCR_MINC  | DMA_CCR_PINC   | DMA_CCR_CIRC   |
00199                       DMA_CCR_DIR   | DMA_CCR_MEM2MEM));
00200 
00201   /* Prepare the DMA Channel configuration */
00202   tmp |=  hdma->Init.Direction        |
00203           hdma->Init.PeriphInc           | hdma->Init.MemInc           |
00204           hdma->Init.PeriphDataAlignment | hdma->Init.MemDataAlignment |
00205           hdma->Init.Mode                | hdma->Init.Priority;
00206 
00207   /* Write to DMA Channel CR register */
00208   hdma->Instance->CCR = tmp;
00209 
00210 #if defined(DMAMUX1)
00211   /* Initialize parameters for DMAMUX channel :
00212      DMAmuxChannel, DMAmuxChannelStatus and DMAmuxChannelStatusMask
00213   */
00214   DMA_CalcDMAMUXChannelBaseAndMask(hdma);
00215 
00216   if(hdma->Init.Direction == DMA_MEMORY_TO_MEMORY)
00217   {
00218     /* if memory to memory force the request to 0*/
00219     hdma->Init.Request = DMA_REQUEST_MEM2MEM;
00220   }
00221 
00222   /* Set peripheral request  to DMAMUX channel */
00223   hdma->DMAmuxChannel->CCR = (hdma->Init.Request & DMAMUX_CxCR_DMAREQ_ID);
00224 
00225   /* Clear the DMAMUX synchro overrun flag */
00226   hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;
00227 
00228   if(((hdma->Init.Request > 0U) && (hdma->Init.Request <= DMA_REQUEST_GENERATOR3)))
00229   {
00230     /* Initialize parameters for DMAMUX request generator :
00231        DMAmuxRequestGen, DMAmuxRequestGenStatus and DMAmuxRequestGenStatusMask
00232     */
00233     DMA_CalcDMAMUXRequestGenBaseAndMask(hdma);
00234 
00235     /* Reset the DMAMUX request generator register*/
00236     hdma->DMAmuxRequestGen->RGCR = 0U;
00237 
00238     /* Clear the DMAMUX request generator overrun flag */
00239     hdma->DMAmuxRequestGenStatus->RGCFR = hdma->DMAmuxRequestGenStatusMask;
00240   }
00241   else
00242   {
00243     hdma->DMAmuxRequestGen = 0U;
00244     hdma->DMAmuxRequestGenStatus = 0U;
00245     hdma->DMAmuxRequestGenStatusMask = 0U;
00246   }
00247 #endif /* DMAMUX1 */
00248 
00249 #if !defined (DMAMUX1)
00250 
00251   /* Set request selection */
00252   if(hdma->Init.Direction != DMA_MEMORY_TO_MEMORY)
00253   {
00254     /* Write to DMA channel selection register */
00255     if (DMA1 == hdma->DmaBaseAddress)
00256     {
00257       /* Reset request selection for DMA1 Channelx */
00258       DMA1_CSELR->CSELR &= ~(DMA_CSELR_C1S << (hdma->ChannelIndex & 0x1cU));
00259 
00260       /* Configure request selection for DMA1 Channelx */
00261       DMA1_CSELR->CSELR |= (uint32_t) (hdma->Init.Request << (hdma->ChannelIndex & 0x1cU));
00262     }
00263     else /* DMA2 */
00264     {
00265       /* Reset request selection for DMA2 Channelx */
00266       DMA2_CSELR->CSELR &= ~(DMA_CSELR_C1S << (hdma->ChannelIndex & 0x1cU));
00267 
00268       /* Configure request selection for DMA2 Channelx */
00269       DMA2_CSELR->CSELR |= (uint32_t) (hdma->Init.Request << (hdma->ChannelIndex & 0x1cU));
00270     }
00271   }
00272 
00273 #endif /* STM32L431xx || STM32L432xx || STM32L433xx || STM32L442xx || STM32L443xx */
00274        /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L442xx || STM32L486xx */
00275        /* STM32L496xx || STM32L4A6xx                                              */
00276 
00277   /* Initialise the error code */
00278   hdma->ErrorCode = HAL_DMA_ERROR_NONE;
00279 
00280   /* Initialize the DMA state*/
00281   hdma->State = HAL_DMA_STATE_READY;
00282 
00283   /* Allocate lock resource and initialize it */
00284   hdma->Lock = HAL_UNLOCKED;
00285 
00286   return HAL_OK;
00287 }
00288 
00289 /**
00290   * @brief  DeInitialize the DMA peripheral.
00291   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00292   *               the configuration information for the specified DMA Channel.
00293   * @retval HAL status
00294   */
00295 HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
00296 {
00297 
00298   /* Check the DMA handle allocation */
00299   if (NULL == hdma )
00300   {
00301     return HAL_ERROR;
00302   }
00303 
00304   /* Check the parameters */
00305   assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
00306 
00307   /* Disable the selected DMA Channelx */
00308   __HAL_DMA_DISABLE(hdma);
00309 
00310   /* Compute the channel index */
00311   if ((uint32_t)(hdma->Instance) < (uint32_t)(DMA2_Channel1))
00312   {
00313     /* DMA1 */
00314     hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2U;
00315     hdma->DmaBaseAddress = DMA1;
00316   }
00317   else
00318   {
00319     /* DMA2 */
00320     hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA2_Channel1) / ((uint32_t)DMA2_Channel2 - (uint32_t)DMA2_Channel1)) << 2U;
00321     hdma->DmaBaseAddress = DMA2;
00322   }
00323 
00324   /* Reset DMA Channel control register */
00325   hdma->Instance->CCR = 0U;
00326 
00327   /* Clear all flags */
00328   hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1CU));
00329 
00330 #if !defined (DMAMUX1)
00331 
00332   /* Reset DMA channel selection register */
00333   if (DMA1 == hdma->DmaBaseAddress)
00334   {
00335     /* DMA1 */
00336     DMA1_CSELR->CSELR &= ~(DMA_CSELR_C1S << (hdma->ChannelIndex & 0x1cU));
00337   }
00338   else
00339   {
00340     /* DMA2 */
00341     DMA2_CSELR->CSELR &= ~(DMA_CSELR_C1S << (hdma->ChannelIndex & 0x1cU));
00342   }
00343 #endif /* STM32L431xx || STM32L432xx || STM32L433xx || STM32L442xx || STM32L443xx */
00344        /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L442xx || STM32L486xx */
00345        /* STM32L496xx || STM32L4A6xx                                              */
00346 
00347 #if defined(DMAMUX1)
00348 
00349   /* Initialize parameters for DMAMUX channel :
00350      DMAmuxChannel, DMAmuxChannelStatus and DMAmuxChannelStatusMask */
00351 
00352   DMA_CalcDMAMUXChannelBaseAndMask(hdma);
00353 
00354   /* Reset the DMAMUX channel that corresponds to the DMA channel */
00355   hdma->DMAmuxChannel->CCR = 0U;
00356 
00357   /* Clear the DMAMUX synchro overrun flag */
00358   hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;
00359 
00360   /* Reset Request generator parameters if any */
00361   if(((hdma->Init.Request >  0U) && (hdma->Init.Request <= DMA_REQUEST_GENERATOR3)))
00362   {
00363     /* Initialize parameters for DMAMUX request generator :
00364        DMAmuxRequestGen, DMAmuxRequestGenStatus and DMAmuxRequestGenStatusMask
00365     */
00366     DMA_CalcDMAMUXRequestGenBaseAndMask(hdma);
00367 
00368     /* Reset the DMAMUX request generator register*/
00369     hdma->DMAmuxRequestGen->RGCR = 0U;
00370 
00371     /* Clear the DMAMUX request generator overrun flag */
00372     hdma->DMAmuxRequestGenStatus->RGCFR = hdma->DMAmuxRequestGenStatusMask;
00373   }
00374 
00375   hdma->DMAmuxRequestGen = 0U;
00376   hdma->DMAmuxRequestGenStatus = 0U;
00377   hdma->DMAmuxRequestGenStatusMask = 0U;
00378 
00379 #endif /* DMAMUX1 */
00380 
00381   /* Clean callbacks */
00382   hdma->XferCpltCallback = NULL;
00383   hdma->XferHalfCpltCallback = NULL;
00384   hdma->XferErrorCallback = NULL;
00385   hdma->XferAbortCallback = NULL;
00386 
00387   /* Initialise the error code */
00388   hdma->ErrorCode = HAL_DMA_ERROR_NONE;
00389 
00390   /* Initialize the DMA state */
00391   hdma->State = HAL_DMA_STATE_RESET;
00392 
00393   /* Release Lock */
00394   __HAL_UNLOCK(hdma);
00395 
00396   return HAL_OK;
00397 }
00398 
00399 /**
00400   * @}
00401   */
00402 
00403 /** @defgroup DMA_Exported_Functions_Group2 Input and Output operation functions
00404  *  @brief   Input and Output operation functions
00405  *
00406 @verbatim
00407  ===============================================================================
00408                       #####  IO operation functions  #####
00409  ===============================================================================
00410     [..]  This section provides functions allowing to:
00411       (+) Configure the source, destination address and data length and Start DMA transfer
00412       (+) Configure the source, destination address and data length and
00413           Start DMA transfer with interrupt
00414       (+) Abort DMA transfer
00415       (+) Poll for transfer complete
00416       (+) Handle DMA interrupt request
00417 
00418 @endverbatim
00419   * @{
00420   */
00421 
00422 /**
00423   * @brief  Start the DMA Transfer.
00424   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00425   *               the configuration information for the specified DMA Channel.
00426   * @param  SrcAddress The source memory Buffer address
00427   * @param  DstAddress The destination memory Buffer address
00428   * @param  DataLength The length of data to be transferred from source to destination
00429   * @retval HAL status
00430   */
00431 HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
00432 {
00433   HAL_StatusTypeDef status = HAL_OK;
00434 
00435   /* Check the parameters */
00436   assert_param(IS_DMA_BUFFER_SIZE(DataLength));
00437 
00438   /* Process locked */
00439   __HAL_LOCK(hdma);
00440 
00441   if(HAL_DMA_STATE_READY == hdma->State)
00442   {
00443     /* Change DMA peripheral state */
00444     hdma->State = HAL_DMA_STATE_BUSY;
00445     hdma->ErrorCode = HAL_DMA_ERROR_NONE;
00446 
00447     /* Disable the peripheral */
00448     __HAL_DMA_DISABLE(hdma);
00449 
00450     /* Configure the source, destination address and the data length & clear flags*/
00451     DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
00452 
00453     /* Enable the Peripheral */
00454     __HAL_DMA_ENABLE(hdma);
00455   }
00456   else
00457   {
00458     /* Process Unlocked */
00459     __HAL_UNLOCK(hdma);
00460     status = HAL_BUSY;
00461   }
00462   return status;
00463 }
00464 
00465 /**
00466   * @brief  Start the DMA Transfer with interrupt enabled.
00467   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00468   *               the configuration information for the specified DMA Channel.
00469   * @param  SrcAddress The source memory Buffer address
00470   * @param  DstAddress The destination memory Buffer address
00471   * @param  DataLength The length of data to be transferred from source to destination
00472   * @retval HAL status
00473   */
00474 HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
00475 {
00476   HAL_StatusTypeDef status = HAL_OK;
00477 
00478   /* Check the parameters */
00479   assert_param(IS_DMA_BUFFER_SIZE(DataLength));
00480 
00481   /* Process locked */
00482   __HAL_LOCK(hdma);
00483 
00484   if(HAL_DMA_STATE_READY == hdma->State)
00485   {
00486     /* Change DMA peripheral state */
00487     hdma->State = HAL_DMA_STATE_BUSY;
00488     hdma->ErrorCode = HAL_DMA_ERROR_NONE;
00489 
00490     /* Disable the peripheral */
00491     __HAL_DMA_DISABLE(hdma);
00492 
00493     /* Configure the source, destination address and the data length & clear flags*/
00494     DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
00495 
00496     /* Enable the transfer complete interrupt */
00497     /* Enable the transfer Error interrupt */
00498     if(NULL != hdma->XferHalfCpltCallback )
00499     {
00500       /* Enable the Half transfer complete interrupt as well */
00501       __HAL_DMA_ENABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
00502     }
00503     else
00504     {
00505       __HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
00506       __HAL_DMA_ENABLE_IT(hdma, (DMA_IT_TC | DMA_IT_TE));
00507     }
00508 
00509 #ifdef DMAMUX1
00510 
00511     /* Check if DMAMUX Synchronization is enabled*/
00512     if((hdma->DMAmuxChannel->CCR & DMAMUX_CxCR_SE) != 0U)
00513     {
00514       /* Enable DMAMUX sync overrun IT*/
00515       hdma->DMAmuxChannel->CCR |= DMAMUX_CxCR_SOIE;
00516     }
00517 
00518     if(hdma->DMAmuxRequestGen != 0U)
00519     {
00520       /* if using DMAMUX request generator, enable the DMAMUX request generator overrun IT*/
00521       /* enable the request gen overrun IT*/
00522       hdma->DMAmuxRequestGen->RGCR |= DMAMUX_RGxCR_OIE;
00523     }
00524 
00525 #endif /* DMAMUX1 */
00526 
00527     /* Enable the Peripheral */
00528     __HAL_DMA_ENABLE(hdma);
00529   }
00530   else
00531   {
00532     /* Process Unlocked */
00533     __HAL_UNLOCK(hdma);
00534 
00535     /* Remain BUSY */
00536     status = HAL_BUSY;
00537   }
00538   return status;
00539 }
00540 
00541 /**
00542   * @brief  Abort the DMA Transfer.
00543   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00544   *               the configuration information for the specified DMA Channel.
00545     * @retval HAL status
00546   */
00547 HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
00548 {
00549   HAL_StatusTypeDef status = HAL_OK;
00550 
00551   /* Check the DMA peripheral state */
00552   if(hdma->State != HAL_DMA_STATE_BUSY)
00553   {
00554     hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
00555 
00556     /* Process Unlocked */
00557     __HAL_UNLOCK(hdma);
00558 
00559     return HAL_ERROR;
00560   }
00561   else
00562   {
00563     /* Disable DMA IT */
00564     __HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
00565 
00566 #if defined(DMAMUX1)
00567     /* disable the DMAMUX sync overrun IT*/
00568     hdma->DMAmuxChannel->CCR &= ~DMAMUX_CxCR_SOIE;
00569 #endif /* DMAMUX1 */
00570 
00571     /* Disable the channel */
00572     __HAL_DMA_DISABLE(hdma);
00573 
00574     /* Clear all flags */
00575     hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1CU));
00576 
00577 #if defined(DMAMUX1)
00578     /* Clear the DMAMUX synchro overrun flag */
00579     hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;
00580 
00581     if(hdma->DMAmuxRequestGen != 0U)
00582     {
00583       /* if using DMAMUX request generator, disable the DMAMUX request generator overrun IT*/
00584       /* disable the request gen overrun IT*/
00585       hdma->DMAmuxRequestGen->RGCR &= ~DMAMUX_RGxCR_OIE;
00586 
00587       /* Clear the DMAMUX request generator overrun flag */
00588       hdma->DMAmuxRequestGenStatus->RGCFR = hdma->DMAmuxRequestGenStatusMask;
00589     }
00590 
00591 #endif /* DMAMUX1 */
00592 
00593     /* Change the DMA state */
00594     hdma->State = HAL_DMA_STATE_READY;
00595 
00596     /* Process Unlocked */
00597     __HAL_UNLOCK(hdma);
00598 
00599     return status;
00600   }
00601 }
00602 
00603 /**
00604   * @brief  Aborts the DMA Transfer in Interrupt mode.
00605   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00606   *                 the configuration information for the specified DMA Channel.
00607   * @retval HAL status
00608   */
00609 HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
00610 {
00611   HAL_StatusTypeDef status = HAL_OK;
00612 
00613   if(HAL_DMA_STATE_BUSY != hdma->State)
00614   {
00615     /* no transfer ongoing */
00616     hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
00617 
00618     status = HAL_ERROR;
00619   }
00620   else
00621   {
00622     /* Disable DMA IT */
00623     __HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
00624 
00625     /* Disable the channel */
00626     __HAL_DMA_DISABLE(hdma);
00627 
00628 #if defined(DMAMUX1)
00629     /* disable the DMAMUX sync overrun IT*/
00630     hdma->DMAmuxChannel->CCR &= ~DMAMUX_CxCR_SOIE;
00631 
00632     /* Clear all flags */
00633     hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1CU));
00634 
00635     /* Clear the DMAMUX synchro overrun flag */
00636     hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;
00637 
00638     if(hdma->DMAmuxRequestGen != 0U)
00639     {
00640       /* if using DMAMUX request generator, disable the DMAMUX request generator overrun IT*/
00641       /* disable the request gen overrun IT*/
00642       hdma->DMAmuxRequestGen->RGCR &= ~DMAMUX_RGxCR_OIE;
00643 
00644       /* Clear the DMAMUX request generator overrun flag */
00645       hdma->DMAmuxRequestGenStatus->RGCFR = hdma->DMAmuxRequestGenStatusMask;
00646     }
00647 
00648 #else
00649     /* Clear all flags */
00650     hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1CU));
00651 #endif /* DMAMUX1 */
00652 
00653     /* Change the DMA state */
00654     hdma->State = HAL_DMA_STATE_READY;
00655 
00656     /* Process Unlocked */
00657     __HAL_UNLOCK(hdma);
00658 
00659     /* Call User Abort callback */
00660     if(hdma->XferAbortCallback != NULL)
00661     {
00662       hdma->XferAbortCallback(hdma);
00663     }
00664   }
00665   return status;
00666 }
00667 
00668 /**
00669   * @brief  Polling for transfer complete.
00670   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00671   *                  the configuration information for the specified DMA Channel.
00672   * @param  CompleteLevel Specifies the DMA level complete.
00673   * @param  Timeout       Timeout duration.
00674   * @retval HAL status
00675   */
00676 HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout)
00677 {
00678   uint32_t temp;
00679   uint32_t tickstart;
00680 
00681   if(HAL_DMA_STATE_BUSY != hdma->State)
00682   {
00683     /* no transfer ongoing */
00684     hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
00685     __HAL_UNLOCK(hdma);
00686     return HAL_ERROR;
00687   }
00688 
00689   /* Polling mode not supported in circular mode */
00690   if ((hdma->Instance->CCR & DMA_CCR_CIRC) != 0U)
00691   {
00692     hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED;
00693     return HAL_ERROR;
00694   }
00695 
00696   /* Get the level transfer complete flag */
00697   if (HAL_DMA_FULL_TRANSFER == CompleteLevel)
00698   {
00699     /* Transfer Complete flag */
00700     temp = DMA_FLAG_TC1 << (hdma->ChannelIndex & 0x1CU);
00701   }
00702   else
00703   {
00704     /* Half Transfer Complete flag */
00705     temp = DMA_FLAG_HT1 << (hdma->ChannelIndex & 0x1CU);
00706   }
00707 
00708   /* Get tick */
00709   tickstart = HAL_GetTick();
00710 
00711   while((hdma->DmaBaseAddress->ISR & temp) == 0U)
00712   {
00713     if((hdma->DmaBaseAddress->ISR & (DMA_FLAG_TE1 << (hdma->ChannelIndex& 0x1CU))) != 0U)
00714     {
00715       /* When a DMA transfer error occurs */
00716       /* A hardware clear of its EN bits is performed */
00717       /* Clear all flags */
00718       hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1CU));
00719 
00720       /* Update error code */
00721       hdma->ErrorCode = HAL_DMA_ERROR_TE;
00722 
00723       /* Change the DMA state */
00724       hdma->State= HAL_DMA_STATE_READY;
00725 
00726       /* Process Unlocked */
00727       __HAL_UNLOCK(hdma);
00728 
00729       return HAL_ERROR;
00730     }
00731     /* Check for the Timeout */
00732     if(Timeout != HAL_MAX_DELAY)
00733     {
00734       if(((HAL_GetTick() - tickstart) > Timeout) ||  (Timeout == 0U))
00735       {
00736         /* Update error code */
00737         hdma->ErrorCode = HAL_DMA_ERROR_TIMEOUT;
00738 
00739         /* Change the DMA state */
00740         hdma->State = HAL_DMA_STATE_READY;
00741 
00742         /* Process Unlocked */
00743         __HAL_UNLOCK(hdma);
00744 
00745         return HAL_ERROR;
00746       }
00747     }
00748   }
00749 
00750 #if defined(DMAMUX1)
00751   /*Check for DMAMUX Request generator (if used) overrun status */
00752   if(hdma->DMAmuxRequestGen != 0U)
00753   {
00754     /* if using DMAMUX request generator Check for DMAMUX request generator overrun */
00755     if((hdma->DMAmuxRequestGenStatus->RGSR & hdma->DMAmuxRequestGenStatusMask) != 0U)
00756     {
00757       /* Disable the request gen overrun interrupt */
00758       hdma->DMAmuxRequestGen->RGCR |= DMAMUX_RGxCR_OIE;
00759 
00760       /* Clear the DMAMUX request generator overrun flag */
00761       hdma->DMAmuxRequestGenStatus->RGCFR = hdma->DMAmuxRequestGenStatusMask;
00762 
00763       /* Update error code */
00764       hdma->ErrorCode |= HAL_DMA_ERROR_REQGEN;
00765     }
00766   }
00767 
00768   /* Check for DMAMUX Synchronization overrun */
00769   if((hdma->DMAmuxChannelStatus->CSR & hdma->DMAmuxChannelStatusMask) != 0U)
00770   {
00771     /* Clear the DMAMUX synchro overrun flag */
00772     hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;
00773 
00774     /* Update error code */
00775     hdma->ErrorCode |= HAL_DMA_ERROR_SYNC;
00776   }
00777 #endif /* DMAMUX1 */
00778 
00779   if(HAL_DMA_FULL_TRANSFER == CompleteLevel)
00780   {
00781     /* Clear the transfer complete flag */
00782     hdma->DmaBaseAddress->IFCR = (DMA_FLAG_TC1 << (hdma->ChannelIndex& 0x1CU));
00783 
00784     /* Process unlocked */
00785     __HAL_UNLOCK(hdma);
00786 
00787     /* The selected Channelx EN bit is cleared (DMA is disabled and
00788     all transfers are complete) */
00789     hdma->State = HAL_DMA_STATE_READY;
00790   }
00791   else
00792   {
00793     /* Clear the half transfer complete flag */
00794     hdma->DmaBaseAddress->IFCR = (DMA_FLAG_HT1 << (hdma->ChannelIndex & 0x1CU));
00795   }
00796 
00797   return HAL_OK;
00798 }
00799 
00800 /**
00801   * @brief  Handle DMA interrupt request.
00802   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
00803   *               the configuration information for the specified DMA Channel.
00804   * @retval None
00805   */
00806 void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma)
00807 {
00808   uint32_t flag_it = hdma->DmaBaseAddress->ISR;
00809   uint32_t source_it = hdma->Instance->CCR;
00810 
00811   /* Half Transfer Complete Interrupt management ******************************/
00812   if (((flag_it & (DMA_FLAG_HT1 << (hdma->ChannelIndex & 0x1CU))) != 0U) && ((source_it & DMA_IT_HT) != 0U))
00813   {
00814       /* Disable the half transfer interrupt if the DMA mode is not CIRCULAR */
00815       if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
00816       {
00817         /* Disable the half transfer interrupt */
00818         __HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
00819       }
00820       /* Clear the half transfer complete flag */
00821       hdma->DmaBaseAddress->IFCR = DMA_ISR_HTIF1 << (hdma->ChannelIndex & 0x1CU);
00822 
00823       /* DMA peripheral state is not updated in Half Transfer */
00824       /* but in Transfer Complete case */
00825 
00826       if(hdma->XferHalfCpltCallback != NULL)
00827       {
00828         /* Half transfer callback */
00829         hdma->XferHalfCpltCallback(hdma);
00830       }
00831   }
00832 
00833   /* Transfer Complete Interrupt management ***********************************/
00834   else if (((flag_it & (DMA_FLAG_TC1 << (hdma->ChannelIndex & 0x1CU))) != 0U) && ((source_it & DMA_IT_TC) != 0U))
00835   {
00836     if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
00837     {
00838       /* Disable the transfer complete interrupt if the DMA mode is not CIRCULAR */
00839       /* Disable the transfer complete and error interrupt */
00840       /* if the DMA mode is not CIRCULAR  */
00841       __HAL_DMA_DISABLE_IT(hdma, DMA_IT_TE | DMA_IT_TC);
00842 
00843       /* Change the DMA state */
00844       hdma->State = HAL_DMA_STATE_READY;
00845     }
00846     /* Clear the transfer complete flag */
00847     hdma->DmaBaseAddress->IFCR = (DMA_ISR_TCIF1 << (hdma->ChannelIndex & 0x1CU));
00848 
00849     /* Process Unlocked */
00850     __HAL_UNLOCK(hdma);
00851 
00852     if(hdma->XferCpltCallback != NULL)
00853     {
00854       /* Transfer complete callback */
00855       hdma->XferCpltCallback(hdma);
00856     }
00857   }
00858 
00859   /* Transfer Error Interrupt management **************************************/
00860   else if (((flag_it & (DMA_FLAG_TE1 << (hdma->ChannelIndex & 0x1CU))) != 0U) && ((source_it & DMA_IT_TE) !=  0U))
00861   {
00862     /* When a DMA transfer error occurs */
00863     /* A hardware clear of its EN bits is performed */
00864     /* Disable ALL DMA IT */
00865     __HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
00866 
00867     /* Clear all flags */
00868     hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1CU));
00869 
00870     /* Update error code */
00871     hdma->ErrorCode = HAL_DMA_ERROR_TE;
00872 
00873     /* Change the DMA state */
00874     hdma->State = HAL_DMA_STATE_READY;
00875 
00876     /* Process Unlocked */
00877     __HAL_UNLOCK(hdma);
00878 
00879     if (hdma->XferErrorCallback != NULL)
00880     {
00881       /* Transfer error callback */
00882       hdma->XferErrorCallback(hdma);
00883     }
00884   }
00885   else
00886   {
00887     /* Nothing To Do */
00888   }
00889   return;
00890 }
00891 
00892 /**
00893   * @brief  Register callbacks
00894   * @param  hdma                 pointer to a DMA_HandleTypeDef structure that contains
00895   *                               the configuration information for the specified DMA Channel.
00896   * @param  CallbackID           User Callback identifer
00897   *                               a HAL_DMA_CallbackIDTypeDef ENUM as parameter.
00898   * @param  pCallback            pointer to private callbacsk function which has pointer to
00899   *                               a DMA_HandleTypeDef structure as parameter.
00900   * @retval HAL status
00901   */
00902 HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma))
00903 {
00904   HAL_StatusTypeDef status = HAL_OK;
00905 
00906   /* Process locked */
00907   __HAL_LOCK(hdma);
00908 
00909   if(HAL_DMA_STATE_READY == hdma->State)
00910   {
00911     switch (CallbackID)
00912     {
00913      case  HAL_DMA_XFER_CPLT_CB_ID:
00914            hdma->XferCpltCallback = pCallback;
00915            break;
00916 
00917      case  HAL_DMA_XFER_HALFCPLT_CB_ID:
00918            hdma->XferHalfCpltCallback = pCallback;
00919            break;
00920 
00921      case  HAL_DMA_XFER_ERROR_CB_ID:
00922            hdma->XferErrorCallback = pCallback;
00923            break;
00924 
00925      case  HAL_DMA_XFER_ABORT_CB_ID:
00926            hdma->XferAbortCallback = pCallback;
00927            break;
00928 
00929      default:
00930            status = HAL_ERROR;
00931            break;
00932     }
00933   }
00934   else
00935   {
00936     status = HAL_ERROR;
00937   }
00938 
00939   /* Release Lock */
00940   __HAL_UNLOCK(hdma);
00941 
00942   return status;
00943 }
00944 
00945 /**
00946   * @brief  UnRegister callbacks
00947   * @param  hdma                 pointer to a DMA_HandleTypeDef structure that contains
00948   *                               the configuration information for the specified DMA Channel.
00949   * @param  CallbackID           User Callback identifer
00950   *                               a HAL_DMA_CallbackIDTypeDef ENUM as parameter.
00951   * @retval HAL status
00952   */
00953 HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID)
00954 {
00955   HAL_StatusTypeDef status = HAL_OK;
00956 
00957     /* Process locked */
00958   __HAL_LOCK(hdma);
00959 
00960   if(HAL_DMA_STATE_READY == hdma->State)
00961   {
00962     switch (CallbackID)
00963     {
00964      case  HAL_DMA_XFER_CPLT_CB_ID:
00965            hdma->XferCpltCallback = NULL;
00966            break;
00967 
00968      case  HAL_DMA_XFER_HALFCPLT_CB_ID:
00969            hdma->XferHalfCpltCallback = NULL;
00970            break;
00971 
00972      case  HAL_DMA_XFER_ERROR_CB_ID:
00973            hdma->XferErrorCallback = NULL;
00974            break;
00975 
00976      case  HAL_DMA_XFER_ABORT_CB_ID:
00977            hdma->XferAbortCallback = NULL;
00978            break;
00979 
00980     case   HAL_DMA_XFER_ALL_CB_ID:
00981            hdma->XferCpltCallback = NULL;
00982            hdma->XferHalfCpltCallback = NULL;
00983            hdma->XferErrorCallback = NULL;
00984            hdma->XferAbortCallback = NULL;
00985            break;
00986 
00987     default:
00988            status = HAL_ERROR;
00989            break;
00990     }
00991   }
00992   else
00993   {
00994     status = HAL_ERROR;
00995   }
00996 
00997   /* Release Lock */
00998   __HAL_UNLOCK(hdma);
00999 
01000   return status;
01001 }
01002 
01003 /**
01004   * @}
01005   */
01006 
01007 
01008 
01009 /** @defgroup DMA_Exported_Functions_Group3 Peripheral State and Errors functions
01010  *  @brief    Peripheral State and Errors functions
01011  *
01012 @verbatim
01013  ===============================================================================
01014             ##### Peripheral State and Errors functions #####
01015  ===============================================================================
01016     [..]
01017     This subsection provides functions allowing to
01018       (+) Check the DMA state
01019       (+) Get error code
01020 
01021 @endverbatim
01022   * @{
01023   */
01024 
01025 /**
01026   * @brief  Return the DMA handle state.
01027   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
01028   *               the configuration information for the specified DMA Channel.
01029   * @retval HAL state
01030   */
01031 HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma)
01032 {
01033   /* Return DMA handle state */
01034   return hdma->State;
01035 }
01036 
01037 /**
01038   * @brief  Return the DMA error code.
01039   * @param  hdma : pointer to a DMA_HandleTypeDef structure that contains
01040   *              the configuration information for the specified DMA Channel.
01041   * @retval DMA Error Code
01042   */
01043 uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
01044 {
01045   return hdma->ErrorCode;
01046 }
01047 
01048 /**
01049   * @}
01050   */
01051 
01052 /**
01053   * @}
01054   */
01055 
01056 /** @addtogroup DMA_Private_Functions
01057   * @{
01058   */
01059 
01060 /**
01061   * @brief  Sets the DMA Transfer parameter.
01062   * @param  hdma       pointer to a DMA_HandleTypeDef structure that contains
01063   *                     the configuration information for the specified DMA Channel.
01064   * @param  SrcAddress The source memory Buffer address
01065   * @param  DstAddress The destination memory Buffer address
01066   * @param  DataLength The length of data to be transferred from source to destination
01067   * @retval HAL status
01068   */
01069 static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
01070 {
01071 #if defined(DMAMUX1)
01072   /* Clear the DMAMUX synchro overrun flag */
01073   hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;
01074 
01075   if(hdma->DMAmuxRequestGen != 0U)
01076   {
01077     /* Clear the DMAMUX request generator overrun flag */
01078     hdma->DMAmuxRequestGenStatus->RGCFR = hdma->DMAmuxRequestGenStatusMask;
01079   }
01080 #endif
01081 
01082   /* Clear all flags */
01083   hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1CU));
01084 
01085   /* Configure DMA Channel data length */
01086   hdma->Instance->CNDTR = DataLength;
01087 
01088   /* Memory to Peripheral */
01089   if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH)
01090   {
01091     /* Configure DMA Channel destination address */
01092     hdma->Instance->CPAR = DstAddress;
01093 
01094     /* Configure DMA Channel source address */
01095     hdma->Instance->CMAR = SrcAddress;
01096   }
01097   /* Peripheral to Memory */
01098   else
01099   {
01100     /* Configure DMA Channel source address */
01101     hdma->Instance->CPAR = SrcAddress;
01102 
01103     /* Configure DMA Channel destination address */
01104     hdma->Instance->CMAR = DstAddress;
01105   }
01106 }
01107 
01108 #if defined(DMAMUX1)
01109 
01110 /**
01111   * @brief  Updates the DMA handle with the DMAMUX  channel and status mask depending on channel number
01112   * @param  hdma        pointer to a DMA_HandleTypeDef structure that contains
01113   *                     the configuration information for the specified DMA Channel.
01114   * @retval None
01115   */
01116 static void DMA_CalcDMAMUXChannelBaseAndMask(DMA_HandleTypeDef *hdma)
01117 {
01118   uint32_t channel_number;
01119 
01120   /* check if instance is not outside the DMA channel range */
01121   if ((uint32_t)hdma->Instance < (uint32_t)DMA2_Channel1)
01122   {
01123     /* DMA1 */
01124     hdma->DMAmuxChannel = (DMAMUX1_Channel0 + (hdma->ChannelIndex >> 2U));
01125   }
01126   else
01127   {
01128     /* DMA2 */
01129     hdma->DMAmuxChannel = (DMAMUX1_Channel7 + (hdma->ChannelIndex >> 2U));
01130   }
01131 
01132   channel_number = (((uint32_t)hdma->Instance & 0xFFU) - 8U) / 20U;
01133   hdma->DMAmuxChannelStatus = DMAMUX1_ChannelStatus;
01134   hdma->DMAmuxChannelStatusMask = 1UL << (channel_number & 0x1FU);
01135 }
01136 
01137 /**
01138   * @brief  Updates the DMA handle with the DMAMUX  request generator params
01139   * @param  hdma        pointer to a DMA_HandleTypeDef structure that contains
01140   *                     the configuration information for the specified DMA Channel.
01141   * @retval None
01142   */
01143 
01144 static void DMA_CalcDMAMUXRequestGenBaseAndMask(DMA_HandleTypeDef *hdma)
01145 {
01146   uint32_t request =  hdma->Init.Request & DMAMUX_CxCR_DMAREQ_ID;
01147 
01148   /* DMA Channels are connected to DMAMUX1 request generator blocks*/
01149   hdma->DMAmuxRequestGen = (DMAMUX_RequestGen_TypeDef *)((uint32_t)(((uint32_t)DMAMUX1_RequestGenerator0) + ((request - 1U) * 4U)));
01150 
01151   hdma->DMAmuxRequestGenStatus = DMAMUX1_RequestGenStatus;
01152 
01153   /* here "Request" is either DMA_REQUEST_GENERATOR0 to DMA_REQUEST_GENERATOR3, i.e. <= 4*/
01154   hdma->DMAmuxRequestGenStatusMask = 1UL << ((request - 1U) & 0x3U);
01155 }
01156 
01157 #endif /* DMAMUX1 */
01158 
01159 /**
01160   * @}
01161   */
01162 
01163 /**
01164   * @}
01165   */
01166 
01167 #endif /* HAL_DMA_MODULE_ENABLED */
01168 /**
01169   * @}
01170   */
01171 
01172 /**
01173   * @}
01174   */