You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

589 lines
26 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_dma.h
  4. * @author MCD Application Team
  5. * @version V1.3.0
  6. * @date 29-January-2016
  7. * @brief Header file of DMA HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L4xx_HAL_DMA_H
  39. #define __STM32L4xx_HAL_DMA_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l4xx_hal_def.h"
  45. /** @addtogroup STM32L4xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup DMA
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup DMA_Exported_Types DMA Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief DMA Configuration Structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t Request; /*!< Specifies the request selected for the specified channel.
  61. This parameter can be a value of @ref DMA_request */
  62. uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
  63. from memory to memory or from peripheral to memory.
  64. This parameter can be a value of @ref DMA_Data_transfer_direction */
  65. uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not.
  66. This parameter can be a value of @ref DMA_Peripheral_incremented_mode */
  67. uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not.
  68. This parameter can be a value of @ref DMA_Memory_incremented_mode */
  69. uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width.
  70. This parameter can be a value of @ref DMA_Peripheral_data_size */
  71. uint32_t MemDataAlignment; /*!< Specifies the Memory data width.
  72. This parameter can be a value of @ref DMA_Memory_data_size */
  73. uint32_t Mode; /*!< Specifies the operation mode of the DMAy Channelx.
  74. This parameter can be a value of @ref DMA_mode
  75. @note The circular buffer mode cannot be used if the memory-to-memory
  76. data transfer is configured on the selected Channel */
  77. uint32_t Priority; /*!< Specifies the software priority for the DMAy Channelx.
  78. This parameter can be a value of @ref DMA_Priority_level */
  79. } DMA_InitTypeDef;
  80. /**
  81. * @brief DMA Configuration enumeration values definition
  82. */
  83. typedef enum
  84. {
  85. DMA_MODE = 0, /*!< Control related DMA mode Parameter in DMA_InitTypeDef */
  86. DMA_PRIORITY = 1 /*!< Control related priority level Parameter in DMA_InitTypeDef */
  87. } DMA_ControlTypeDef;
  88. /**
  89. * @brief HAL DMA State structures definition
  90. */
  91. typedef enum
  92. {
  93. HAL_DMA_STATE_RESET = 0x00, /*!< DMA not yet initialized or disabled */
  94. HAL_DMA_STATE_READY = 0x01, /*!< DMA process success and ready for use */
  95. HAL_DMA_STATE_READY_HALF = 0x11, /*!< DMA Half process success */
  96. HAL_DMA_STATE_BUSY = 0x02, /*!< DMA process is ongoing */
  97. HAL_DMA_STATE_TIMEOUT = 0x03, /*!< DMA timeout state */
  98. HAL_DMA_STATE_ERROR = 0x04 /*!< DMA error state */
  99. }HAL_DMA_StateTypeDef;
  100. /**
  101. * @brief HAL DMA Error Code structure definition
  102. */
  103. typedef enum
  104. {
  105. HAL_DMA_FULL_TRANSFER = 0x00, /*!< Full transfer */
  106. HAL_DMA_HALF_TRANSFER = 0x01 /*!< Half Transfer */
  107. }HAL_DMA_LevelCompleteTypeDef;
  108. /**
  109. * @brief DMA handle Structure definition
  110. */
  111. typedef struct __DMA_HandleTypeDef
  112. {
  113. DMA_Channel_TypeDef *Instance; /*!< Register base address */
  114. DMA_InitTypeDef Init; /*!< DMA communication parameters */
  115. HAL_LockTypeDef Lock; /*!< DMA locking object */
  116. __IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
  117. void *Parent; /*!< Parent object state */
  118. void (* XferCpltCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */
  119. void (* XferHalfCpltCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */
  120. void (* XferErrorCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */
  121. __IO uint32_t ErrorCode; /*!< DMA Error code */
  122. }DMA_HandleTypeDef;
  123. /**
  124. * @}
  125. */
  126. /* Exported constants --------------------------------------------------------*/
  127. /** @defgroup DMA_Exported_Constants DMA Exported Constants
  128. * @{
  129. */
  130. /** @defgroup DMA_Error_Code DMA Error Code
  131. * @{
  132. */
  133. #define HAL_DMA_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
  134. #define HAL_DMA_ERROR_TE ((uint32_t)0x00000001) /*!< Transfer error */
  135. #define HAL_DMA_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */
  136. /**
  137. * @}
  138. */
  139. /** @defgroup DMA_request DMA request
  140. * @{
  141. */
  142. #define DMA_REQUEST_0 ((uint32_t)0x00000000)
  143. #define DMA_REQUEST_1 ((uint32_t)0x00000001)
  144. #define DMA_REQUEST_2 ((uint32_t)0x00000002)
  145. #define DMA_REQUEST_3 ((uint32_t)0x00000003)
  146. #define DMA_REQUEST_4 ((uint32_t)0x00000004)
  147. #define DMA_REQUEST_5 ((uint32_t)0x00000005)
  148. #define DMA_REQUEST_6 ((uint32_t)0x00000006)
  149. #define DMA_REQUEST_7 ((uint32_t)0x00000007)
  150. /**
  151. * @}
  152. */
  153. /** @defgroup DMA_Data_transfer_direction DMA Data transfer direction
  154. * @{
  155. */
  156. #define DMA_PERIPH_TO_MEMORY ((uint32_t)0x00000000) /*!< Peripheral to memory direction */
  157. #define DMA_MEMORY_TO_PERIPH ((uint32_t)DMA_CCR_DIR) /*!< Memory to peripheral direction */
  158. #define DMA_MEMORY_TO_MEMORY ((uint32_t)DMA_CCR_MEM2MEM) /*!< Memory to memory direction */
  159. /**
  160. * @}
  161. */
  162. /** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode
  163. * @{
  164. */
  165. #define DMA_PINC_ENABLE ((uint32_t)DMA_CCR_PINC) /*!< Peripheral increment mode Enable */
  166. #define DMA_PINC_DISABLE ((uint32_t)0x00000000) /*!< Peripheral increment mode Disable */
  167. /**
  168. * @}
  169. */
  170. /** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode
  171. * @{
  172. */
  173. #define DMA_MINC_ENABLE ((uint32_t)DMA_CCR_MINC) /*!< Memory increment mode Enable */
  174. #define DMA_MINC_DISABLE ((uint32_t)0x00000000) /*!< Memory increment mode Disable */
  175. /**
  176. * @}
  177. */
  178. /** @defgroup DMA_Peripheral_data_size DMA Peripheral data size
  179. * @{
  180. */
  181. #define DMA_PDATAALIGN_BYTE ((uint32_t)0x00000000) /*!< Peripheral data alignment : Byte */
  182. #define DMA_PDATAALIGN_HALFWORD ((uint32_t)DMA_CCR_PSIZE_0) /*!< Peripheral data alignment : HalfWord */
  183. #define DMA_PDATAALIGN_WORD ((uint32_t)DMA_CCR_PSIZE_1) /*!< Peripheral data alignment : Word */
  184. /**
  185. * @}
  186. */
  187. /** @defgroup DMA_Memory_data_size DMA Memory data size
  188. * @{
  189. */
  190. #define DMA_MDATAALIGN_BYTE ((uint32_t)0x00000000) /*!< Memory data alignment : Byte */
  191. #define DMA_MDATAALIGN_HALFWORD ((uint32_t)DMA_CCR_MSIZE_0) /*!< Memory data alignment : HalfWord */
  192. #define DMA_MDATAALIGN_WORD ((uint32_t)DMA_CCR_MSIZE_1) /*!< Memory data alignment : Word */
  193. /**
  194. * @}
  195. */
  196. /** @defgroup DMA_mode DMA mode
  197. * @{
  198. */
  199. #define DMA_NORMAL ((uint32_t)0x00000000) /*!< Normal mode */
  200. #define DMA_CIRCULAR ((uint32_t)DMA_CCR_CIRC) /*!< Circular mode */
  201. /**
  202. * @}
  203. */
  204. /** @defgroup DMA_Priority_level DMA Priority level
  205. * @{
  206. */
  207. #define DMA_PRIORITY_LOW ((uint32_t)0x00000000) /*!< Priority level : Low */
  208. #define DMA_PRIORITY_MEDIUM ((uint32_t)DMA_CCR_PL_0) /*!< Priority level : Medium */
  209. #define DMA_PRIORITY_HIGH ((uint32_t)DMA_CCR_PL_1) /*!< Priority level : High */
  210. #define DMA_PRIORITY_VERY_HIGH ((uint32_t)DMA_CCR_PL) /*!< Priority level : Very_High */
  211. /**
  212. * @}
  213. */
  214. /** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions
  215. * @{
  216. */
  217. #define DMA_IT_TC ((uint32_t)DMA_CCR_TCIE)
  218. #define DMA_IT_HT ((uint32_t)DMA_CCR_HTIE)
  219. #define DMA_IT_TE ((uint32_t)DMA_CCR_TEIE)
  220. /**
  221. * @}
  222. */
  223. /** @defgroup DMA_flag_definitions DMA flag definitions
  224. * @{
  225. */
  226. #define DMA_FLAG_GL1 ((uint32_t)0x00000001)
  227. #define DMA_FLAG_TC1 ((uint32_t)0x00000002)
  228. #define DMA_FLAG_HT1 ((uint32_t)0x00000004)
  229. #define DMA_FLAG_TE1 ((uint32_t)0x00000008)
  230. #define DMA_FLAG_GL2 ((uint32_t)0x00000010)
  231. #define DMA_FLAG_TC2 ((uint32_t)0x00000020)
  232. #define DMA_FLAG_HT2 ((uint32_t)0x00000040)
  233. #define DMA_FLAG_TE2 ((uint32_t)0x00000080)
  234. #define DMA_FLAG_GL3 ((uint32_t)0x00000100)
  235. #define DMA_FLAG_TC3 ((uint32_t)0x00000200)
  236. #define DMA_FLAG_HT3 ((uint32_t)0x00000400)
  237. #define DMA_FLAG_TE3 ((uint32_t)0x00000800)
  238. #define DMA_FLAG_GL4 ((uint32_t)0x00001000)
  239. #define DMA_FLAG_TC4 ((uint32_t)0x00002000)
  240. #define DMA_FLAG_HT4 ((uint32_t)0x00004000)
  241. #define DMA_FLAG_TE4 ((uint32_t)0x00008000)
  242. #define DMA_FLAG_GL5 ((uint32_t)0x00010000)
  243. #define DMA_FLAG_TC5 ((uint32_t)0x00020000)
  244. #define DMA_FLAG_HT5 ((uint32_t)0x00040000)
  245. #define DMA_FLAG_TE5 ((uint32_t)0x00080000)
  246. #define DMA_FLAG_GL6 ((uint32_t)0x00100000)
  247. #define DMA_FLAG_TC6 ((uint32_t)0x00200000)
  248. #define DMA_FLAG_HT6 ((uint32_t)0x00400000)
  249. #define DMA_FLAG_TE6 ((uint32_t)0x00800000)
  250. #define DMA_FLAG_GL7 ((uint32_t)0x01000000)
  251. #define DMA_FLAG_TC7 ((uint32_t)0x02000000)
  252. #define DMA_FLAG_HT7 ((uint32_t)0x04000000)
  253. #define DMA_FLAG_TE7 ((uint32_t)0x08000000)
  254. /**
  255. * @}
  256. */
  257. /**
  258. * @}
  259. */
  260. /* Exported macros -----------------------------------------------------------*/
  261. /** @defgroup DMA_Exported_Macros DMA Exported Macros
  262. * @{
  263. */
  264. /** @brief Reset DMA handle state.
  265. * @param __HANDLE__: DMA handle
  266. * @retval None
  267. */
  268. #define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
  269. /**
  270. * @brief Enable the specified DMA Channel.
  271. * @param __HANDLE__: DMA handle
  272. * @retval None
  273. */
  274. #define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR |= DMA_CCR_EN)
  275. /**
  276. * @brief Disable the specified DMA Channel.
  277. * @param __HANDLE__: DMA handle
  278. * @retval None
  279. */
  280. #define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR &= ~DMA_CCR_EN)
  281. /* Interrupt & Flag management */
  282. /**
  283. * @brief Return the current DMA Channel transfer complete flag.
  284. * @param __HANDLE__: DMA handle
  285. * @retval The specified transfer complete flag index.
  286. */
  287. #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
  288. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
  289. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TC1 :\
  290. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
  291. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TC2 :\
  292. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
  293. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TC3 :\
  294. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
  295. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TC4 :\
  296. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\
  297. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_TC5 :\
  298. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\
  299. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_TC6 :\
  300. DMA_FLAG_TC7)
  301. /**
  302. * @brief Return the current DMA Channel half transfer complete flag.
  303. * @param __HANDLE__: DMA handle
  304. * @retval The specified half transfer complete flag index.
  305. */
  306. #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
  307. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
  308. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_HT1 :\
  309. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
  310. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_HT2 :\
  311. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
  312. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_HT3 :\
  313. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
  314. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_HT4 :\
  315. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\
  316. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_HT5 :\
  317. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\
  318. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_HT6 :\
  319. DMA_FLAG_HT7)
  320. /**
  321. * @brief Return the current DMA Channel transfer error flag.
  322. * @param __HANDLE__: DMA handle
  323. * @retval The specified transfer error flag index.
  324. */
  325. #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
  326. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
  327. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TE1 :\
  328. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
  329. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TE2 :\
  330. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
  331. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TE3 :\
  332. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
  333. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TE4 :\
  334. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\
  335. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_TE5 :\
  336. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\
  337. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_TE6 :\
  338. DMA_FLAG_TE7)
  339. /**
  340. * @brief Return the current DMA Channel Global interrupt flag.
  341. * @param __HANDLE__: DMA handle
  342. * @retval The specified transfer error flag index.
  343. */
  344. #define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
  345. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_ISR_GIF1 :\
  346. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_ISR_GIF1 :\
  347. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_ISR_GIF2 :\
  348. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_ISR_GIF2 :\
  349. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_ISR_GIF3 :\
  350. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_ISR_GIF3 :\
  351. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_ISR_GIF4 :\
  352. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_ISR_GIF4 :\
  353. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_ISR_GIF5 :\
  354. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_ISR_GIF5 :\
  355. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_ISR_GIF6 :\
  356. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_ISR_GIF6 :\
  357. DMA_ISR_GIF7)
  358. /**
  359. * @brief Get the DMA Channel pending flags.
  360. * @param __HANDLE__: DMA handle
  361. * @param __FLAG__: Get the specified flag.
  362. * This parameter can be any combination of the following values:
  363. * @arg DMA_FLAG_TCIFx: Transfer complete flag
  364. * @arg DMA_FLAG_HTIFx: Half transfer complete flag
  365. * @arg DMA_FLAG_TEIFx: Transfer error flag
  366. * @arg DMA_ISR_GIFx: Global interrupt flag
  367. * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Channel flag.
  368. * @retval The state of FLAG (SET or RESET).
  369. */
  370. #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__) (((uint32_t)((__HANDLE__)->Instance) > ((uint32_t)DMA1_Channel7))? \
  371. (DMA2->ISR & (__FLAG__)) : (DMA1->ISR & (__FLAG__)))
  372. /**
  373. * @brief Clear the DMA Channel pending flags.
  374. * @param __HANDLE__: DMA handle
  375. * @param __FLAG__: specifies the flag to clear.
  376. * This parameter can be any combination of the following values:
  377. * @arg DMA_FLAG_TCIFx: Transfer complete flag
  378. * @arg DMA_FLAG_HTIFx: Half transfer complete flag
  379. * @arg DMA_FLAG_TEIFx: Transfer error flag
  380. * @arg DMA_ISR_GIFx: Global interrupt flag
  381. * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Channel flag.
  382. * @retval None
  383. */
  384. #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (((uint32_t)((__HANDLE__)->Instance) > ((uint32_t)DMA1_Channel7))? \
  385. (DMA2->IFCR |= (__FLAG__)) : (DMA1->IFCR |= (__FLAG__)))
  386. /**
  387. * @brief Enable the specified DMA Channel interrupts.
  388. * @param __HANDLE__: DMA handle
  389. * @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
  390. * This parameter can be any combination of the following values:
  391. * @arg DMA_IT_TC: Transfer complete interrupt mask
  392. * @arg DMA_IT_HT: Half transfer complete interrupt mask
  393. * @arg DMA_IT_TE: Transfer error interrupt mask
  394. * @retval None
  395. */
  396. #define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR |= (__INTERRUPT__))
  397. /**
  398. * @brief Disable the specified DMA Channel interrupts.
  399. * @param __HANDLE__: DMA handle
  400. * @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
  401. * This parameter can be any combination of the following values:
  402. * @arg DMA_IT_TC: Transfer complete interrupt mask
  403. * @arg DMA_IT_HT: Half transfer complete interrupt mask
  404. * @arg DMA_IT_TE: Transfer error interrupt mask
  405. * @retval None
  406. */
  407. #define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR &= ~(__INTERRUPT__))
  408. /**
  409. * @brief Check whether the specified DMA Channel interrupt is enabled or not.
  410. * @param __HANDLE__: DMA handle
  411. * @param __INTERRUPT__: specifies the DMA interrupt source to check.
  412. * This parameter can be one of the following values:
  413. * @arg DMA_IT_TC: Transfer complete interrupt mask
  414. * @arg DMA_IT_HT: Half transfer complete interrupt mask
  415. * @arg DMA_IT_TE: Transfer error interrupt mask
  416. * @retval The state of DMA_IT (SET or RESET).
  417. */
  418. #define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CCR & (__INTERRUPT__)))
  419. /**
  420. * @}
  421. */
  422. /* Exported functions --------------------------------------------------------*/
  423. /** @addtogroup DMA_Exported_Functions
  424. * @{
  425. */
  426. /** @addtogroup DMA_Exported_Functions_Group1
  427. * @{
  428. */
  429. /* Initialization and de-initialization functions *****************************/
  430. HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma);
  431. HAL_StatusTypeDef HAL_DMA_DeInit (DMA_HandleTypeDef *hdma);
  432. /**
  433. * @}
  434. */
  435. /** @addtogroup DMA_Exported_Functions_Group2
  436. * @{
  437. */
  438. /* IO operation functions *****************************************************/
  439. HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
  440. HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
  441. HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
  442. HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout);
  443. void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
  444. /**
  445. * @}
  446. */
  447. /** @addtogroup DMA_Exported_Functions_Group3
  448. * @{
  449. */
  450. /* Peripheral State and Error functions ***************************************/
  451. HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma);
  452. uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma);
  453. /**
  454. * @}
  455. */
  456. /**
  457. * @}
  458. */
  459. /* Private macros ------------------------------------------------------------*/
  460. /** @defgroup DMA_Private_Macros DMA Private Macros
  461. * @{
  462. */
  463. #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
  464. ((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \
  465. ((DIRECTION) == DMA_MEMORY_TO_MEMORY))
  466. #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
  467. #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
  468. ((STATE) == DMA_PINC_DISABLE))
  469. #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \
  470. ((STATE) == DMA_MINC_DISABLE))
  471. #define IS_DMA_ALL_REQUEST(REQUEST) (((REQUEST) == DMA_REQUEST_0) || \
  472. ((REQUEST) == DMA_REQUEST_1) || \
  473. ((REQUEST) == DMA_REQUEST_2) || \
  474. ((REQUEST) == DMA_REQUEST_3) || \
  475. ((REQUEST) == DMA_REQUEST_4) || \
  476. ((REQUEST) == DMA_REQUEST_5) || \
  477. ((REQUEST) == DMA_REQUEST_6) || \
  478. ((REQUEST) == DMA_REQUEST_7))
  479. #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \
  480. ((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
  481. ((SIZE) == DMA_PDATAALIGN_WORD))
  482. #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \
  483. ((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
  484. ((SIZE) == DMA_MDATAALIGN_WORD ))
  485. #define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \
  486. ((MODE) == DMA_CIRCULAR))
  487. #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \
  488. ((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
  489. ((PRIORITY) == DMA_PRIORITY_HIGH) || \
  490. ((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
  491. /**
  492. * @}
  493. */
  494. /* Private functions ---------------------------------------------------------*/
  495. /**
  496. * @}
  497. */
  498. /**
  499. * @}
  500. */
  501. #ifdef __cplusplus
  502. }
  503. #endif
  504. #endif /* __STM32L4xx_HAL_DMA_H */
  505. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/