HAL_dma_bak.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /**
  2. ******************************************************************************
  3. * @file HAL_dma.c
  4. * @author IC Applications Department
  5. * @version V0.8
  6. * @date 2019_08_02
  7. * @brief This file provides all the DMA firmware functions.
  8. ******************************************************************************
  9. * @copy
  10. *
  11. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13. * TIME. AS A RESULT, HOLOCENE SHALL NOT BE HELD LIABLE FOR ANY
  14. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17. *
  18. * <h2><center>&copy; COPYRIGHT 2016 HOLOCENE</center></h2>
  19. */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "HAL_dma.h"
  22. //??
  23. #ifdef 0
  24. /** @addtogroup StdPeriph_Driver
  25. * @{
  26. */
  27. /** @defgroup DMA
  28. * @brief DMA driver modules
  29. * @{
  30. */
  31. /** @defgroup DMA_Private_TypesDefinitions
  32. * @{
  33. */
  34. /**
  35. * @}
  36. */
  37. /** @defgroup DMA_Private_Defines
  38. * @{
  39. */
  40. /* DMA ENABLE mask */
  41. #define CCR_ENABLE_Set ((uint32_t)0x00000001)
  42. #define CCR_ENABLE_Reset ((uint32_t)0xFFFFFFFE)
  43. /* DMA1 Channelx interrupt pending bit masks */
  44. #define DMA1_Channel1_IT_Mask ((uint32_t)0x0000000F)
  45. #define DMA1_Channel2_IT_Mask ((uint32_t)0x000000F0)
  46. #define DMA1_Channel3_IT_Mask ((uint32_t)0x00000F00)
  47. #define DMA1_Channel4_IT_Mask ((uint32_t)0x0000F000)
  48. #define DMA1_Channel5_IT_Mask ((uint32_t)0x000F0000)
  49. /* DMA registers Masks */
  50. #define CCR_CLEAR_Mask ((uint32_t)0xFFFF800F)
  51. /**
  52. * @}
  53. */
  54. /** @defgroup DMA_Private_Macros
  55. * @{
  56. */
  57. /**
  58. * @}
  59. */
  60. /** @defgroup DMA_Private_Variables
  61. * @{
  62. */
  63. /**
  64. * @}
  65. */
  66. /** @defgroup DMA_Private_FunctionPrototypes
  67. * @{
  68. */
  69. /**
  70. * @}
  71. */
  72. /** @defgroup DMA_Private_Functions
  73. * @{
  74. */
  75. /**
  76. * @brief Deinitializes the DMAy Channelx registers to their default reset
  77. * values.
  78. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
  79. * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the
  80. * DMA Channel.
  81. * @retval : None
  82. */
  83. void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx)
  84. {
  85. /* Check the parameters */
  86. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  87. /* Disable the selected DMAy Channelx */
  88. DMAy_Channelx->CCR &= CCR_ENABLE_Reset;
  89. /* Reset DMAy Channelx control register */
  90. DMAy_Channelx->CCR = 0;
  91. /* Reset DMAy Channelx remaining bytes register */
  92. DMAy_Channelx->CNDTR = 0;
  93. /* Reset DMAy Channelx peripheral address register */
  94. DMAy_Channelx->CPAR = 0;
  95. /* Reset DMAy Channelx memory address register */
  96. DMAy_Channelx->CMAR = 0;
  97. switch (*(uint32_t*)&DMAy_Channelx)
  98. {
  99. case DMA1_Channel1_BASE:
  100. /* Reset interrupt pending bits for DMA1 Channel1 */
  101. DMA1->IFCR |= DMA1_Channel1_IT_Mask;
  102. break;
  103. case DMA1_Channel2_BASE:
  104. /* Reset interrupt pending bits for DMA1 Channel2 */
  105. DMA1->IFCR |= DMA1_Channel2_IT_Mask;
  106. break;
  107. case DMA1_Channel3_BASE:
  108. /* Reset interrupt pending bits for DMA1 Channel3 */
  109. DMA1->IFCR |= DMA1_Channel3_IT_Mask;
  110. break;
  111. case DMA1_Channel4_BASE:
  112. /* Reset interrupt pending bits for DMA1 Channel4 */
  113. DMA1->IFCR |= DMA1_Channel4_IT_Mask;
  114. break;
  115. case DMA1_Channel5_BASE:
  116. /* Reset interrupt pending bits for DMA1 Channel5 */
  117. DMA1->IFCR |= DMA1_Channel5_IT_Mask;
  118. break;
  119. default:
  120. break;
  121. }
  122. }
  123. /**
  124. * @brief Initializes the DMAy Channelx according to the specified
  125. * parameters in the DMA_InitStruct.
  126. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
  127. * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the
  128. * DMA Channel.
  129. * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that
  130. * contains the configuration information for the specified
  131. * DMA Channel.
  132. * @retval : None
  133. */
  134. void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct)
  135. {
  136. uint32_t tmpreg = 0;
  137. /* Check the parameters */
  138. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  139. assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR));
  140. assert_param(IS_DMA_BUFFER_SIZE(DMA_InitStruct->DMA_BufferSize));
  141. assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc));
  142. assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc));
  143. assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize));
  144. assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize));
  145. assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode));
  146. assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority));
  147. assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M));
  148. /*--------------------------- DMAy Channelx CCR Configuration -----------------*/
  149. /* Get the DMAy_Channelx CCR value */
  150. tmpreg = DMAy_Channelx->CCR;
  151. /* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */
  152. tmpreg &= CCR_CLEAR_Mask;
  153. /* Configure DMAy Channelx: data transfer, data size, priority level and mode */
  154. /* Set DIR bit according to DMA_DIR value */
  155. /* Set CIRC bit according to DMA_Mode value */
  156. /* Set PINC bit according to DMA_PeripheralInc value */
  157. /* Set MINC bit according to DMA_MemoryInc value */
  158. /* Set PSIZE bits according to DMA_PeripheralDataSize value */
  159. /* Set MSIZE bits according to DMA_MemoryDataSize value */
  160. /* Set PL bits according to DMA_Priority value */
  161. /* Set the MEM2MEM bit according to DMA_M2M value */
  162. tmpreg |= DMA_InitStruct->DMA_DIR | DMA_InitStruct->DMA_Mode |
  163. DMA_InitStruct->DMA_PeripheralInc | DMA_InitStruct->DMA_MemoryInc |
  164. DMA_InitStruct->DMA_PeripheralDataSize | DMA_InitStruct->DMA_MemoryDataSize |
  165. DMA_InitStruct->DMA_Priority | DMA_InitStruct->DMA_M2M;
  166. /* Write to DMAy Channelx CCR */
  167. DMAy_Channelx->CCR = tmpreg;
  168. /*--------------------------- DMAy Channelx CNDTR Configuration ---------------*/
  169. /* Write to DMAy Channelx CNDTR */
  170. DMAy_Channelx->CNDTR = DMA_InitStruct->DMA_BufferSize;
  171. /*--------------------------- DMAy Channelx CPAR Configuration ----------------*/
  172. /* Write to DMAy Channelx CPAR */
  173. DMAy_Channelx->CPAR = DMA_InitStruct->DMA_PeripheralBaseAddr;
  174. /*--------------------------- DMAy Channelx CMAR Configuration ----------------*/
  175. /* Write to DMAy Channelx CMAR */
  176. DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr;
  177. }
  178. /**
  179. * @brief Fills each DMA_InitStruct member with its default value.
  180. * @param DMA_InitStruct : pointer to a DMA_InitTypeDef structure
  181. * which will be initialized.
  182. * @retval : None
  183. */
  184. void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct)
  185. {
  186. /*-------------- Reset DMA init structure parameters values ------------------*/
  187. /* Initialize the DMA_PeripheralBaseAddr member */
  188. DMA_InitStruct->DMA_PeripheralBaseAddr = 0;
  189. /* Initialize the DMA_MemoryBaseAddr member */
  190. DMA_InitStruct->DMA_MemoryBaseAddr = 0;
  191. /* Initialize the DMA_DIR member */
  192. DMA_InitStruct->DMA_DIR = DMA_DIR_PeripheralSRC;
  193. /* Initialize the DMA_BufferSize member */
  194. DMA_InitStruct->DMA_BufferSize = 0;
  195. /* Initialize the DMA_PeripheralInc member */
  196. DMA_InitStruct->DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  197. /* Initialize the DMA_MemoryInc member */
  198. DMA_InitStruct->DMA_MemoryInc = DMA_MemoryInc_Disable;
  199. /* Initialize the DMA_PeripheralDataSize member */
  200. DMA_InitStruct->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  201. /* Initialize the DMA_MemoryDataSize member */
  202. DMA_InitStruct->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  203. /* Initialize the DMA_Mode member */
  204. DMA_InitStruct->DMA_Mode = DMA_Mode_Normal;
  205. /* Initialize the DMA_Priority member */
  206. DMA_InitStruct->DMA_Priority = DMA_Priority_Low;
  207. /* Initialize the DMA_M2M member */
  208. DMA_InitStruct->DMA_M2M = DMA_M2M_Disable;
  209. }
  210. /**
  211. * @brief Enables or disables the specified DMAy Channelx.
  212. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
  213. * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the
  214. * DMA Channel.
  215. * @param NewState: new state of the DMAy Channelx.
  216. * This parameter can be: ENABLE or DISABLE.
  217. * @retval : None
  218. */
  219. void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState)
  220. {
  221. /* Check the parameters */
  222. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  223. assert_param(IS_FUNCTIONAL_STATE(NewState));
  224. if (NewState != DISABLE)
  225. {
  226. /* Enable the selected DMAy Channelx */
  227. DMAy_Channelx->CCR |= CCR_ENABLE_Set;
  228. }
  229. else
  230. {
  231. /* Disable the selected DMAy Channelx */
  232. DMAy_Channelx->CCR &= CCR_ENABLE_Reset;
  233. }
  234. }
  235. /**
  236. * @brief Enables or disables the specified DMAy Channelx interrupts.
  237. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
  238. * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the
  239. * DMA Channel.
  240. * @param DMA_IT: specifies the DMA interrupts sources to be enabled
  241. * or disabled.
  242. * This parameter can be any combination of the following values:
  243. * @arg DMA_IT_TC: Transfer complete interrupt mask
  244. * @arg DMA_IT_HT: Half transfer interrupt mask
  245. * @arg DMA_IT_TE: Transfer error interrupt mask
  246. * @param NewState: new state of the specified DMA interrupts.
  247. * This parameter can be: ENABLE or DISABLE.
  248. * @retval : None
  249. */
  250. void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
  251. {
  252. /* Check the parameters */
  253. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  254. assert_param(IS_DMA_CONFIG_IT(DMA_IT));
  255. assert_param(IS_FUNCTIONAL_STATE(NewState));
  256. if (NewState != DISABLE)
  257. {
  258. /* Enable the selected DMA interrupts */
  259. DMAy_Channelx->CCR |= DMA_IT;
  260. }
  261. else
  262. {
  263. /* Disable the selected DMA interrupts */
  264. DMAy_Channelx->CCR &= ~DMA_IT;
  265. }
  266. }
  267. /**
  268. * @brief Returns the number of remaining data units in the current
  269. * DMAy Channelx transfer.
  270. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
  271. * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the
  272. * DMA Channel.
  273. * @retval : The number of remaining data units in the current DMAy Channelx
  274. * transfer.
  275. */
  276. uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx)
  277. {
  278. /* Check the parameters */
  279. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  280. /* Return the number of remaining data units for DMAy Channelx */
  281. return ((uint16_t)(DMAy_Channelx->CNDTR));
  282. }
  283. /**
  284. * @brief Checks whether the specified DMAy Channelx flag is set or not.
  285. * @param DMA_FLAG: specifies the flag to check.
  286. * This parameter can be one of the following values:
  287. * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
  288. * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
  289. * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
  290. * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
  291. * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
  292. * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
  293. * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
  294. * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
  295. * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
  296. * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
  297. * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
  298. * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
  299. * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
  300. * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
  301. * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
  302. * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
  303. * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
  304. * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
  305. * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
  306. * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
  307. * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag.
  308. * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag.
  309. * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag.
  310. * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag.
  311. * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag.
  312. * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag.
  313. * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag.
  314. * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag.
  315. * @retval : The new state of DMA_FLAG (SET or RESET).
  316. */
  317. FlagStatus DMA_GetFlagStatus(uint32_t DMA_FLAG)
  318. {
  319. FlagStatus bitstatus = RESET;
  320. uint32_t tmpreg = 0;
  321. /* Check the parameters */
  322. assert_param(IS_DMA_GET_FLAG(DMA_FLAG));
  323. /* Get DMA1 ISR register value */
  324. tmpreg = DMA1->ISR ;
  325. /* Check the status of the specified DMA flag */
  326. if ((tmpreg & DMA_FLAG) != (uint32_t)RESET)
  327. {
  328. /* DMA_FLAG is set */
  329. bitstatus = SET;
  330. }
  331. else
  332. {
  333. /* DMA_FLAG is reset */
  334. bitstatus = RESET;
  335. }
  336. /* Return the DMA_FLAG status */
  337. return bitstatus;
  338. }
  339. /**
  340. * @brief Clears the DMAy Channelx's pending flags.
  341. * @param DMA_FLAG: specifies the flag to clear.
  342. * This parameter can be any combination (for the same DMA) of
  343. * the following values:
  344. * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
  345. * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
  346. * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
  347. * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
  348. * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
  349. * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
  350. * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
  351. * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
  352. * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
  353. * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
  354. * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
  355. * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
  356. * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
  357. * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
  358. * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
  359. * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
  360. * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
  361. * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
  362. * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
  363. * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
  364. * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag.
  365. * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag.
  366. * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag.
  367. * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag.
  368. * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag.
  369. * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag.
  370. * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag.
  371. * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag.
  372. * @retval : None
  373. */
  374. void DMA_ClearFlag(uint32_t DMA_FLAG)
  375. {
  376. /* Check the parameters */
  377. assert_param(IS_DMA_CLEAR_FLAG(DMA_FLAG));
  378. /* Clear the selected DMA flags */
  379. DMA1->IFCR = DMA_FLAG;
  380. }
  381. /**
  382. * @brief Checks whether the specified DMAy Channelx interrupt has
  383. * occurred or not.
  384. * @param DMA_IT: specifies the DMA interrupt source to check.
  385. * This parameter can be one of the following values:
  386. * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
  387. * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
  388. * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
  389. * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
  390. * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
  391. * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
  392. * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
  393. * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
  394. * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
  395. * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
  396. * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
  397. * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
  398. * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
  399. * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
  400. * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
  401. * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
  402. * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
  403. * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
  404. * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
  405. * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
  406. * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt.
  407. * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt.
  408. * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt.
  409. * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt.
  410. * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt.
  411. * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt.
  412. * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt.
  413. * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt.
  414. * @retval : The new state of DMA_IT (SET or RESET).
  415. */
  416. ITStatus DMA_GetITStatus(uint32_t DMA_IT)
  417. {
  418. ITStatus bitstatus = RESET;
  419. uint32_t tmpreg = 0;
  420. /* Check the parameters */
  421. assert_param(IS_DMA_GET_IT(DMA_IT));
  422. /* Get DMA1 ISR register value */
  423. tmpreg = DMA1->ISR ;
  424. /* Check the status of the specified DMA interrupt */
  425. if ((tmpreg & DMA_IT) != (uint32_t)RESET)
  426. {
  427. /* DMA_IT is set */
  428. bitstatus = SET;
  429. }
  430. else
  431. {
  432. /* DMA_IT is reset */
  433. bitstatus = RESET;
  434. }
  435. /* Return the DMA_IT status */
  436. return bitstatus;
  437. }
  438. /**
  439. * @brief Clears the DMAy Channelx’s interrupt pending bits.
  440. * @param DMA_IT: specifies the DMA interrupt pending bit to clear.
  441. * This parameter can be any combination (for the same DMA) of
  442. * the following values:
  443. * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
  444. * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
  445. * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
  446. * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
  447. * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
  448. * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
  449. * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
  450. * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
  451. * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
  452. * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
  453. * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
  454. * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
  455. * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
  456. * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
  457. * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
  458. * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
  459. * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
  460. * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
  461. * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
  462. * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
  463. * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt.
  464. * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt.
  465. * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt.
  466. * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt.
  467. * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt.
  468. * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt.
  469. * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt.
  470. * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt.
  471. * @retval : None
  472. */
  473. void DMA_ClearITPendingBit(uint32_t DMA_IT)
  474. {
  475. /* Check the parameters */
  476. assert_param(IS_DMA_CLEAR_IT(DMA_IT));
  477. /* Clear the selected DMA interrupt pending bits */
  478. DMA1->IFCR = DMA_IT;
  479. }
  480. /**
  481. * @}
  482. */
  483. /**
  484. * @}
  485. */
  486. /**
  487. * @}
  488. */
  489. #endif // 0
  490. /*-------------------------(C) COPYRIGHT 2016 HOLOCENE ----------------------*/