1 /**
2   ******************************************************************************
3   * @file    stm32mp1xx_hal_dma_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of DMA HAL extension module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32MP1xx_HAL_DMA_EX_H
21 #define STM32MP1xx_HAL_DMA_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32mp1xx_hal_def.h"
29 
30 /** @addtogroup STM32MP1xx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup DMAEx
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup DMAEx_Exported_Types DMAEx Exported Types
40   * @brief DMAEx Exported types
41   * @{
42   */
43 
44 /**
45   * @brief  HAL DMA Memory definition
46   */
47 typedef enum
48 {
49   MEMORY0      = 0x00U,    /*!< Memory 0     */
50   MEMORY1      = 0x01U,    /*!< Memory 1     */
51 
52 } HAL_DMA_MemoryTypeDef;
53 
54 /**
55   * @brief  HAL DMAMUX Synchronization configuration structure definition
56   */
57 typedef struct
58 {
59   uint32_t SyncSignalID;  /*!< Specifies the synchronization signal gating the DMA request in periodic mode.
60                               This parameter can be a value of @ref DMAEx_MUX_SyncSignalID_selection */
61 
62   uint32_t SyncPolarity;  /*!< Specifies the polarity of the signal on which the DMA request is synchronized.
63                               This parameter can be a value of @ref DMAEx_MUX_SyncPolarity_selection */
64 
65   FunctionalState SyncEnable;  /*!< Specifies if the synchronization shall be enabled or disabled
66                                     This parameter can take the value ENABLE or DISABLE*/
67 
68 
69   FunctionalState EventEnable;    /*!< Specifies if an event shall be generated once the RequestNumber is reached.
70                                        This parameter can take the value ENABLE or DISABLE */
71 
72   uint32_t RequestNumber; /*!< Specifies the number of DMA request that will be authorized after a sync event.
73                                This parameters can be in the range 1 to 32 */
74 
75 } HAL_DMA_MuxSyncConfigTypeDef;
76 
77 
78 /**
79   * @brief  HAL DMAMUX request generator parameters structure definition
80   */
81 typedef struct
82 {
83   uint32_t SignalID;      /*!< Specifies the ID of the signal used for DMAMUX request generator
84                               This parameter can be a value of @ref DMAEx_MUX_SignalGeneratorID_selection */
85 
86   uint32_t Polarity;       /*!< Specifies the polarity of the signal on which the request is generated.
87                              This parameter can be a value of @ref DMAEx_MUX_RequestGeneneratorPolarity_selection */
88 
89   uint32_t RequestNumber;  /*!< Specifies the number of DMA request that will be generated after a signal event.
90                                 This parameters can be in the range 1 to 32 */
91 
92 } HAL_DMA_MuxRequestGeneratorConfigTypeDef;
93 
94 /**
95   * @}
96   */
97 
98 /* Exported constants --------------------------------------------------------*/
99 
100 /** @defgroup DMAEx_Exported_Constants DMA Exported Constants
101   * @brief    DMAEx Exported constants
102   * @{
103   */
104 
105 /** @defgroup DMAEx_MUX_SyncSignalID_selection DMAEx MUX SyncSignalID selection
106   * @brief    DMAEx MUX SyncSignalID selection
107   * @{
108   */
109 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH0_EVT   0U   /*!< DMAMUX1 synchronization Signal is DMAMUX1 Channel0 Event */
110 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH1_EVT   1U   /*!< DMAMUX1 synchronization Signal is DMAMUX1 Channel1 Event */
111 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH2_EVT   2U   /*!< DMAMUX1 synchronization Signal is DMAMUX1 Channel2 Event */
112 #define HAL_DMAMUX1_SYNC_LPTIM1_OUT        3U   /*!< DMAMUX1 synchronization Signal is LPTIM1 OUT             */
113 #define HAL_DMAMUX1_SYNC_LPTIM2_OUT        4U   /*!< DMAMUX1 synchronization Signal is LPTIM2 OUT             */
114 #define HAL_DMAMUX1_SYNC_LPTIM3_OUT        5U   /*!< DMAMUX1 synchronization Signal is LPTIM3 OUT             */
115 #define HAL_DMAMUX1_SYNC_EXTI0             6U   /*!< DMAMUX1 synchronization Signal is EXTI0 IT               */
116 #define HAL_DMAMUX1_SYNC_TIM12_TRGO        7U   /*!< DMAMUX1 synchronization Signal is TIM12 TRGO             */
117 
118 /**
119   * @}
120   */
121 
122 /** @defgroup DMAEx_MUX_SyncPolarity_selection DMAEx MUX SyncPolarity selection
123   * @brief    DMAEx MUX SyncPolarity selection
124   * @{
125   */
126 #define HAL_DMAMUX_SYNC_NO_EVENT        0x00000000U             /*!< block synchronization events                    */
127 #define HAL_DMAMUX_SYNC_RISING          DMAMUX_CxCR_SPOL_0      /*!< synchronize with rising edge events             */
128 #define HAL_DMAMUX_SYNC_FALLING         DMAMUX_CxCR_SPOL_1      /*!< synchronize with falling edge events            */
129 #define HAL_DMAMUX_SYNC_RISING_FALLING  DMAMUX_CxCR_SPOL        /*!< synchronize with rising and falling edge events */
130 
131 /**
132   * @}
133   */
134 
135 
136 /** @defgroup DMAEx_MUX_SignalGeneratorID_selection DMAEx MUX SignalGeneratorID selection
137   * @brief    DMAEx MUX SignalGeneratorID selection
138   * @{
139   */
140 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH0_EVT   0U   /*!< DMAMUX1 Request generator Signal is DMAMUX1 Channel0 Event */
141 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH1_EVT   1U   /*!< DMAMUX1 Request generator Signal is DMAMUX1 Channel1 Event */
142 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH2_EVT   2U   /*!< DMAMUX1 Request generator Signal is DMAMUX1 Channel2 Event */
143 #define HAL_DMAMUX1_REQ_GEN_LPTIM1_OUT        3U   /*!< DMAMUX1 Request generator Signal is LPTIM1 OUT             */
144 #define HAL_DMAMUX1_REQ_GEN_LPTIM2_OUT        4U   /*!< DMAMUX1 Request generator Signal is LPTIM2 OUT             */
145 #define HAL_DMAMUX1_REQ_GEN_LPTIM3_OUT        5U   /*!< DMAMUX1 Request generator Signal is LPTIM3 OUT             */
146 #define HAL_DMAMUX1_REQ_GEN_EXTI0             6U   /*!< DMAMUX1 Request generator Signal is EXTI0 IT               */
147 #define HAL_DMAMUX1_REQ_GEN_TIM12_TRGO        7U   /*!< DMAMUX1 Request generator Signal is TIM12 TRGO             */
148 
149 
150 /**
151   * @}
152   */
153 
154 /** @defgroup DMAEx_MUX_RequestGeneneratorPolarity_selection DMAEx MUX RequestGeneneratorPolarity selection
155   * @brief    DMAEx MUX RequestGeneneratorPolarity selection
156   * @{
157   */
158 #define HAL_DMAMUX_REQ_GEN_NO_EVENT        0x00000000U           /*!< block request generator events                     */
159 #define HAL_DMAMUX_REQ_GEN_RISING          DMAMUX_RGxCR_GPOL_0  /*!< generate request on rising edge events             */
160 #define HAL_DMAMUX_REQ_GEN_FALLING         DMAMUX_RGxCR_GPOL_1  /*!< generate request on falling edge events            */
161 #define HAL_DMAMUX_REQ_GEN_RISING_FALLING  DMAMUX_RGxCR_GPOL    /*!< generate request on rising and falling edge events */
162 
163 /**
164   * @}
165   */
166 
167 /**
168   * @}
169   */
170 
171 /* Exported functions --------------------------------------------------------*/
172 /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions
173   * @brief   DMAEx Exported functions
174   * @{
175   */
176 
177 /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions
178   * @brief   Extended features functions
179   * @{
180   */
181 
182 /* IO operation functions *******************************************************/
183 HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength);
184 HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength);
185 HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory);
186 HAL_StatusTypeDef HAL_DMAEx_ConfigMuxSync(DMA_HandleTypeDef *hdma, HAL_DMA_MuxSyncConfigTypeDef *pSyncConfig);
187 HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator(DMA_HandleTypeDef *hdma, HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig);
188 HAL_StatusTypeDef HAL_DMAEx_EnableMuxRequestGenerator(DMA_HandleTypeDef *hdma);
189 HAL_StatusTypeDef HAL_DMAEx_DisableMuxRequestGenerator(DMA_HandleTypeDef *hdma);
190 
191 void HAL_DMAEx_MUX_IRQHandler(DMA_HandleTypeDef *hdma);
192 /**
193   * @}
194   */
195 /**
196   * @}
197   */
198 
199 /* Private macros ------------------------------------------------------------*/
200 /** @defgroup DMAEx_Private_Macros DMA Private Macros
201   * @brief    DMAEx private macros
202   * @{
203   */
204 
205 #define IS_DMAMUX_SYNC_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_SYNC_TIM12_TRGO)
206 #define IS_DMAMUX_SYNC_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U))
207 
208 #define IS_DMAMUX_SYNC_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_SYNC_NO_EVENT)    || \
209                                            ((POLARITY) == HAL_DMAMUX_SYNC_RISING)   || \
210                                            ((POLARITY) == HAL_DMAMUX_SYNC_FALLING)  || \
211                                            ((POLARITY) == HAL_DMAMUX_SYNC_RISING_FALLING))
212 
213 #define IS_DMAMUX_SYNC_STATE(SYNC) (((SYNC) == DISABLE)   || ((SYNC) == ENABLE))
214 
215 #define IS_DMAMUX_SYNC_EVENT(EVENT) (((EVENT) == DISABLE)   || \
216                                      ((EVENT) == ENABLE))
217 
218 #define IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_REQ_GEN_TIM12_TRGO)
219 
220 #define IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U))
221 
222 #define IS_DMAMUX_REQUEST_GEN_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_REQ_GEN_NO_EVENT) || \
223                                                   ((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING)   || \
224                                                   ((POLARITY) == HAL_DMAMUX_REQ_GEN_FALLING)   || \
225                                                   ((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING_FALLING))
226 
227 /**
228   * @}
229   */
230 
231 /* Private functions ---------------------------------------------------------*/
232 /** @defgroup DMAEx_Private_Functions DMAEx Private Functions
233   * @brief DMAEx Private functions
234   * @{
235   */
236 /**
237   * @}
238   */
239 
240 /**
241   * @}
242   */
243 
244 /**
245   * @}
246   */
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 
252 #endif /* STM32MP1xx_HAL_DMA_EX_H */
253