n32g45x_dma.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. /*****************************************************************************
  2. * Copyright (c) 2019, Nations Technologies Inc.
  3. *
  4. * All rights reserved.
  5. * ****************************************************************************
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the disclaimer below.
  12. *
  13. * Nations' name may not be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. *
  16. * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  19. * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  22. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. * ****************************************************************************/
  27. /**
  28. * @file n32g45x_dma.c
  29. * @author Nations
  30. * @version v1.0.0
  31. *
  32. * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
  33. */
  34. #include "n32g45x_dma.h"
  35. #include "n32g45x_rcc.h"
  36. /** @addtogroup N32G45X_StdPeriph_Driver
  37. * @{
  38. */
  39. /** @addtogroup DMA
  40. * @brief DMA driver modules
  41. * @{
  42. */
  43. /** @addtogroup DMA_Private_TypesDefinitions
  44. * @{
  45. */
  46. /**
  47. * @}
  48. */
  49. /** @addtogroup DMA_Private_Defines
  50. * @{
  51. */
  52. /* DMA1 Channelx interrupt pending bit masks */
  53. #define DMA1_CH1_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF1 | DMA_INTSTS_TXCF1 | DMA_INTSTS_HTXF1 | DMA_INTSTS_ERRF1))
  54. #define DMA1_CH2_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF2 | DMA_INTSTS_TXCF2 | DMA_INTSTS_HTXF2 | DMA_INTSTS_ERRF2))
  55. #define DMA1_CH3_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF3 | DMA_INTSTS_TXCF3 | DMA_INTSTS_HTXF3 | DMA_INTSTS_ERRF3))
  56. #define DMA1_CH4_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF4 | DMA_INTSTS_TXCF4 | DMA_INTSTS_HTXF4 | DMA_INTSTS_ERRF4))
  57. #define DMA1_CH5_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF5 | DMA_INTSTS_TXCF5 | DMA_INTSTS_HTXF5 | DMA_INTSTS_ERRF5))
  58. #define DMA1_CH6_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF6 | DMA_INTSTS_TXCF6 | DMA_INTSTS_HTXF6 | DMA_INTSTS_ERRF6))
  59. #define DMA1_CH7_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF7 | DMA_INTSTS_TXCF7 | DMA_INTSTS_HTXF7 | DMA_INTSTS_ERRF7))
  60. #define DMA1_CH8_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF8 | DMA_INTSTS_TXCF8 | DMA_INTSTS_HTXF8 | DMA_INTSTS_ERRF8))
  61. /* DMA2 Channelx interrupt pending bit masks */
  62. #define DMA2_CH1_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF1 | DMA_INTSTS_TXCF1 | DMA_INTSTS_HTXF1 | DMA_INTSTS_ERRF1))
  63. #define DMA2_CH2_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF2 | DMA_INTSTS_TXCF2 | DMA_INTSTS_HTXF2 | DMA_INTSTS_ERRF2))
  64. #define DMA2_CH3_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF3 | DMA_INTSTS_TXCF3 | DMA_INTSTS_HTXF3 | DMA_INTSTS_ERRF3))
  65. #define DMA2_CH4_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF4 | DMA_INTSTS_TXCF4 | DMA_INTSTS_HTXF4 | DMA_INTSTS_ERRF4))
  66. #define DMA2_CH5_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF5 | DMA_INTSTS_TXCF5 | DMA_INTSTS_HTXF5 | DMA_INTSTS_ERRF5))
  67. #define DMA2_CH6_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF6 | DMA_INTSTS_TXCF6 | DMA_INTSTS_HTXF6 | DMA_INTSTS_ERRF6))
  68. #define DMA2_CH7_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF7 | DMA_INTSTS_TXCF7 | DMA_INTSTS_HTXF7 | DMA_INTSTS_ERRF7))
  69. #define DMA2_CH8_INT_MASK ((uint32_t)(DMA_INTSTS_GLBF8 | DMA_INTSTS_TXCF8 | DMA_INTSTS_HTXF8 | DMA_INTSTS_ERRF8))
  70. /* DMA CHCFGx registers Masks, MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */
  71. #define CCR_CLEAR_Mask ((uint32_t)0xFFFF800F)
  72. /**
  73. * @}
  74. */
  75. /** @addtogroup DMA_Private_Macros
  76. * @{
  77. */
  78. /**
  79. * @}
  80. */
  81. /** @addtogroup DMA_Private_Variables
  82. * @{
  83. */
  84. /**
  85. * @}
  86. */
  87. /** @addtogroup DMA_Private_FunctionPrototypes
  88. * @{
  89. */
  90. /**
  91. * @}
  92. */
  93. /** @addtogroup DMA_Private_Functions
  94. * @{
  95. */
  96. /**
  97. * @brief Deinitializes the DMAy Channelx registers to their default reset
  98. * values.
  99. * @param DMAyChx where y can be 1 or 2 to select the DMA and
  100. * x can be 1 to 8 for DMA1 and 1 to 8 for DMA2 to select the DMA Channel.
  101. */
  102. void DMA_DeInit(DMA_ChannelType* DMAyChx)
  103. {
  104. /* Check the parameters */
  105. assert_param(IS_DMA_ALL_PERIPH(DMAyChx));
  106. /* Disable the selected DMAy Channelx */
  107. DMAyChx->CHCFG &= (uint16_t)(~DMA_CHCFG1_CHEN);
  108. /* Reset DMAy Channelx control register */
  109. DMAyChx->CHCFG = 0;
  110. /* Reset DMAy Channelx remaining bytes register */
  111. DMAyChx->TXNUM = 0;
  112. /* Reset DMAy Channelx peripheral address register */
  113. DMAyChx->PADDR = 0;
  114. /* Reset DMAy Channelx memory address register */
  115. DMAyChx->MADDR = 0;
  116. if (DMAyChx == DMA1_CH1)
  117. {
  118. /* Reset interrupt pending bits for DMA1 Channel1 */
  119. DMA1->INTCLR |= DMA1_CH1_INT_MASK;
  120. }
  121. else if (DMAyChx == DMA1_CH2)
  122. {
  123. /* Reset interrupt pending bits for DMA1 Channel2 */
  124. DMA1->INTCLR |= DMA1_CH2_INT_MASK;
  125. }
  126. else if (DMAyChx == DMA1_CH3)
  127. {
  128. /* Reset interrupt pending bits for DMA1 Channel3 */
  129. DMA1->INTCLR |= DMA1_CH3_INT_MASK;
  130. }
  131. else if (DMAyChx == DMA1_CH4)
  132. {
  133. /* Reset interrupt pending bits for DMA1 Channel4 */
  134. DMA1->INTCLR |= DMA1_CH4_INT_MASK;
  135. }
  136. else if (DMAyChx == DMA1_CH5)
  137. {
  138. /* Reset interrupt pending bits for DMA1 Channel5 */
  139. DMA1->INTCLR |= DMA1_CH5_INT_MASK;
  140. }
  141. else if (DMAyChx == DMA1_CH6)
  142. {
  143. /* Reset interrupt pending bits for DMA1 Channel6 */
  144. DMA1->INTCLR |= DMA1_CH6_INT_MASK;
  145. }
  146. else if (DMAyChx == DMA1_CH7)
  147. {
  148. /* Reset interrupt pending bits for DMA1 Channel7 */
  149. DMA1->INTCLR |= DMA1_CH7_INT_MASK;
  150. }
  151. else if (DMAyChx == DMA1_CH8)
  152. {
  153. /* Reset interrupt pending bits for DMA1 Channel8 */
  154. DMA1->INTCLR |= DMA1_CH8_INT_MASK;
  155. }
  156. else if (DMAyChx == DMA2_CH1)
  157. {
  158. /* Reset interrupt pending bits for DMA2 Channel1 */
  159. DMA2->INTCLR |= DMA2_CH1_INT_MASK;
  160. }
  161. else if (DMAyChx == DMA2_CH2)
  162. {
  163. /* Reset interrupt pending bits for DMA2 Channel2 */
  164. DMA2->INTCLR |= DMA2_CH2_INT_MASK;
  165. }
  166. else if (DMAyChx == DMA2_CH3)
  167. {
  168. /* Reset interrupt pending bits for DMA2 Channel3 */
  169. DMA2->INTCLR |= DMA2_CH3_INT_MASK;
  170. }
  171. else if (DMAyChx == DMA2_CH4)
  172. {
  173. /* Reset interrupt pending bits for DMA2 Channel4 */
  174. DMA2->INTCLR |= DMA2_CH4_INT_MASK;
  175. }
  176. else if (DMAyChx == DMA2_CH5)
  177. {
  178. /* Reset interrupt pending bits for DMA2 Channel5 */
  179. DMA2->INTCLR |= DMA2_CH5_INT_MASK;
  180. }
  181. else if (DMAyChx == DMA2_CH6)
  182. {
  183. /* Reset interrupt pending bits for DMA2 Channel6 */
  184. DMA2->INTCLR |= DMA2_CH6_INT_MASK;
  185. }
  186. else if (DMAyChx == DMA2_CH7)
  187. {
  188. /* Reset interrupt pending bits for DMA2 Channel7 */
  189. DMA2->INTCLR |= DMA2_CH7_INT_MASK;
  190. }
  191. else
  192. {
  193. if (DMAyChx == DMA2_CH8)
  194. {
  195. /* Reset interrupt pending bits for DMA2 Channel8 */
  196. DMA2->INTCLR |= DMA2_CH8_INT_MASK;
  197. }
  198. }
  199. }
  200. /**
  201. * @brief Initializes the DMAy Channelx according to the specified
  202. * parameters in the DMA_InitParam.
  203. * @param DMAyChx where y can be 1 or 2 to select the DMA and
  204. * x can be 1 to 8 for DMA1 and 1 to 8 for DMA2 to select the DMA Channel.
  205. * @param DMA_InitParam pointer to a DMA_InitType structure that
  206. * contains the configuration information for the specified DMA Channel.
  207. */
  208. void DMA_Init(DMA_ChannelType* DMAyChx, DMA_InitType* DMA_InitParam)
  209. {
  210. uint32_t tmpregister = 0;
  211. /* Check the parameters */
  212. assert_param(IS_DMA_ALL_PERIPH(DMAyChx));
  213. assert_param(IS_DMA_DIR(DMA_InitParam->Direction));
  214. assert_param(IS_DMA_BUF_SIZE(DMA_InitParam->BufSize));
  215. assert_param(IS_DMA_PERIPH_INC_STATE(DMA_InitParam->PeriphInc));
  216. assert_param(IS_DMA_MEM_INC_STATE(DMA_InitParam->DMA_MemoryInc));
  217. assert_param(IS_DMA_PERIPH_DATA_SIZE(DMA_InitParam->PeriphDataSize));
  218. assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitParam->MemDataSize));
  219. assert_param(IS_DMA_MODE(DMA_InitParam->CircularMode));
  220. assert_param(IS_DMA_PRIORITY(DMA_InitParam->Priority));
  221. assert_param(IS_DMA_M2M_STATE(DMA_InitParam->Mem2Mem));
  222. /*--------------------------- DMAy Channelx CHCFG Configuration -----------------*/
  223. /* Get the DMAyChx CHCFG value */
  224. tmpregister = DMAyChx->CHCFG;
  225. /* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */
  226. tmpregister &= CCR_CLEAR_Mask;
  227. /* Configure DMAy Channelx: data transfer, data size, priority level and mode */
  228. /* Set DIR bit according to Direction value */
  229. /* Set CIRC bit according to CircularMode value */
  230. /* Set PINC bit according to PeriphInc value */
  231. /* Set MINC bit according to DMA_MemoryInc value */
  232. /* Set PSIZE bits according to PeriphDataSize value */
  233. /* Set MSIZE bits according to MemDataSize value */
  234. /* Set PL bits according to Priority value */
  235. /* Set the MEM2MEM bit according to Mem2Mem value */
  236. tmpregister |= DMA_InitParam->Direction | DMA_InitParam->CircularMode | DMA_InitParam->PeriphInc
  237. | DMA_InitParam->DMA_MemoryInc | DMA_InitParam->PeriphDataSize | DMA_InitParam->MemDataSize
  238. | DMA_InitParam->Priority | DMA_InitParam->Mem2Mem;
  239. /* Write to DMAy Channelx CHCFG */
  240. DMAyChx->CHCFG = tmpregister;
  241. /*--------------------------- DMAy Channelx TXNUM Configuration ---------------*/
  242. /* Write to DMAy Channelx TXNUM */
  243. DMAyChx->TXNUM = DMA_InitParam->BufSize;
  244. /*--------------------------- DMAy Channelx PADDR Configuration ----------------*/
  245. /* Write to DMAy Channelx PADDR */
  246. DMAyChx->PADDR = DMA_InitParam->PeriphAddr;
  247. /*--------------------------- DMAy Channelx MADDR Configuration ----------------*/
  248. /* Write to DMAy Channelx MADDR */
  249. DMAyChx->MADDR = DMA_InitParam->MemAddr;
  250. }
  251. /**
  252. * @brief Fills each DMA_InitParam member with its default value.
  253. * @param DMA_InitParam pointer to a DMA_InitType structure which will
  254. * be initialized.
  255. */
  256. void DMA_StructInit(DMA_InitType* DMA_InitParam)
  257. {
  258. /*-------------- Reset DMA init structure parameters values ------------------*/
  259. /* Initialize the PeriphAddr member */
  260. DMA_InitParam->PeriphAddr = 0;
  261. /* Initialize the MemAddr member */
  262. DMA_InitParam->MemAddr = 0;
  263. /* Initialize the Direction member */
  264. DMA_InitParam->Direction = DMA_DIR_PERIPH_SRC;
  265. /* Initialize the BufSize member */
  266. DMA_InitParam->BufSize = 0;
  267. /* Initialize the PeriphInc member */
  268. DMA_InitParam->PeriphInc = DMA_PERIPH_INC_DISABLE;
  269. /* Initialize the DMA_MemoryInc member */
  270. DMA_InitParam->DMA_MemoryInc = DMA_MEM_INC_DISABLE;
  271. /* Initialize the PeriphDataSize member */
  272. DMA_InitParam->PeriphDataSize = DMA_PERIPH_DATA_SIZE_BYTE;
  273. /* Initialize the MemDataSize member */
  274. DMA_InitParam->MemDataSize = DMA_MemoryDataSize_Byte;
  275. /* Initialize the CircularMode member */
  276. DMA_InitParam->CircularMode = DMA_MODE_NORMAL;
  277. /* Initialize the Priority member */
  278. DMA_InitParam->Priority = DMA_PRIORITY_LOW;
  279. /* Initialize the Mem2Mem member */
  280. DMA_InitParam->Mem2Mem = DMA_M2M_DISABLE;
  281. }
  282. /**
  283. * @brief Enables or disables the specified DMAy Channelx.
  284. * @param DMAyChx where y can be 1 or 2 to select the DMA and
  285. * x can be 1 to 8 for DMA1 and 1 to 8 for DMA2 to select the DMA Channel.
  286. * @param Cmd new state of the DMAy Channelx.
  287. * This parameter can be: ENABLE or DISABLE.
  288. */
  289. void DMA_EnableChannel(DMA_ChannelType* DMAyChx, FunctionalState Cmd)
  290. {
  291. /* Check the parameters */
  292. assert_param(IS_DMA_ALL_PERIPH(DMAyChx));
  293. assert_param(IS_FUNCTIONAL_STATE(Cmd));
  294. if (Cmd != DISABLE)
  295. {
  296. /* Enable the selected DMAy Channelx */
  297. DMAyChx->CHCFG |= DMA_CHCFG1_CHEN;
  298. }
  299. else
  300. {
  301. /* Disable the selected DMAy Channelx */
  302. DMAyChx->CHCFG &= (uint16_t)(~DMA_CHCFG1_CHEN);
  303. }
  304. }
  305. /**
  306. * @brief Enables or disables the specified DMAy Channelx interrupts.
  307. * @param DMAyChx where y can be 1 or 2 to select the DMA and
  308. * x can be 1 to 8 for DMA1 and 1 to 8 for DMA2 to select the DMA Channel.
  309. * @param DMAInt specifies the DMA interrupts sources to be enabled
  310. * or disabled.
  311. * This parameter can be any combination of the following values:
  312. * @arg DMA_INT_TXC Transfer complete interrupt mask
  313. * @arg DMA_INT_HTX Half transfer interrupt mask
  314. * @arg DMA_INT_ERR Transfer error interrupt mask
  315. * @param Cmd new state of the specified DMA interrupts.
  316. * This parameter can be: ENABLE or DISABLE.
  317. */
  318. void DMA_ConfigInt(DMA_ChannelType* DMAyChx, uint32_t DMAInt, FunctionalState Cmd)
  319. {
  320. /* Check the parameters */
  321. assert_param(IS_DMA_ALL_PERIPH(DMAyChx));
  322. assert_param(IS_DMA_CONFIG_INT(DMAInt));
  323. assert_param(IS_FUNCTIONAL_STATE(Cmd));
  324. if (Cmd != DISABLE)
  325. {
  326. /* Enable the selected DMA interrupts */
  327. DMAyChx->CHCFG |= DMAInt;
  328. }
  329. else
  330. {
  331. /* Disable the selected DMA interrupts */
  332. DMAyChx->CHCFG &= ~DMAInt;
  333. }
  334. }
  335. /**
  336. * @brief Sets the number of data units in the current DMAy Channelx transfer.
  337. * @param DMAyChx where y can be 1 or 2 to select the DMA and
  338. * x can be 1 to 8 for DMA1 and 1 to 8 for DMA2 to select the DMA Channel.
  339. * @param DataNumber The number of data units in the current DMAy Channelx
  340. * transfer.
  341. * @note This function can only be used when the DMAyChx is disabled.
  342. */
  343. void DMA_SetCurrDataCounter(DMA_ChannelType* DMAyChx, uint16_t DataNumber)
  344. {
  345. /* Check the parameters */
  346. assert_param(IS_DMA_ALL_PERIPH(DMAyChx));
  347. /*--------------------------- DMAy Channelx TXNUM Configuration ---------------*/
  348. /* Write to DMAy Channelx TXNUM */
  349. DMAyChx->TXNUM = DataNumber;
  350. }
  351. /**
  352. * @brief Returns the number of remaining data units in the current
  353. * DMAy Channelx transfer.
  354. * @param DMAyChx where y can be 1 or 2 to select the DMA and
  355. * x can be 1 to 8 for DMA1 and 1 to 8 for DMA2 to select the DMA Channel.
  356. * @return The number of remaining data units in the current DMAy Channelx
  357. * transfer.
  358. */
  359. uint16_t DMA_GetCurrDataCounter(DMA_ChannelType* DMAyChx)
  360. {
  361. /* Check the parameters */
  362. assert_param(IS_DMA_ALL_PERIPH(DMAyChx));
  363. /* Return the number of remaining data units for DMAy Channelx */
  364. return ((uint16_t)(DMAyChx->TXNUM));
  365. }
  366. /**
  367. * @brief Checks whether the specified DMAy Channelx flag is set or not.
  368. * @param DMAyFlag specifies the flag to check.
  369. * This parameter can be one of the following values:
  370. * @arg DMA1_FLAG_GL1 DMA1 Channel1 global flag.
  371. * @arg DMA1_FLAG_TC1 DMA1 Channel1 transfer complete flag.
  372. * @arg DMA1_FLAG_HT1 DMA1 Channel1 half transfer flag.
  373. * @arg DMA1_FLAG_TE1 DMA1 Channel1 transfer error flag.
  374. * @arg DMA1_FLAG_GL2 DMA1 Channel2 global flag.
  375. * @arg DMA1_FLAG_TC2 DMA1 Channel2 transfer complete flag.
  376. * @arg DMA1_FLAG_HT2 DMA1 Channel2 half transfer flag.
  377. * @arg DMA1_FLAG_TE2 DMA1 Channel2 transfer error flag.
  378. * @arg DMA1_FLAG_GL3 DMA1 Channel3 global flag.
  379. * @arg DMA1_FLAG_TC3 DMA1 Channel3 transfer complete flag.
  380. * @arg DMA1_FLAG_HT3 DMA1 Channel3 half transfer flag.
  381. * @arg DMA1_FLAG_TE3 DMA1 Channel3 transfer error flag.
  382. * @arg DMA1_FLAG_GL4 DMA1 Channel4 global flag.
  383. * @arg DMA1_FLAG_TC4 DMA1 Channel4 transfer complete flag.
  384. * @arg DMA1_FLAG_HT4 DMA1 Channel4 half transfer flag.
  385. * @arg DMA1_FLAG_TE4 DMA1 Channel4 transfer error flag.
  386. * @arg DMA1_FLAG_GL5 DMA1 Channel5 global flag.
  387. * @arg DMA1_FLAG_TC5 DMA1 Channel5 transfer complete flag.
  388. * @arg DMA1_FLAG_HT5 DMA1 Channel5 half transfer flag.
  389. * @arg DMA1_FLAG_TE5 DMA1 Channel5 transfer error flag.
  390. * @arg DMA1_FLAG_GL6 DMA1 Channel6 global flag.
  391. * @arg DMA1_FLAG_TC6 DMA1 Channel6 transfer complete flag.
  392. * @arg DMA1_FLAG_HT6 DMA1 Channel6 half transfer flag.
  393. * @arg DMA1_FLAG_TE6 DMA1 Channel6 transfer error flag.
  394. * @arg DMA1_FLAG_GL7 DMA1 Channel7 global flag.
  395. * @arg DMA1_FLAG_TC7 DMA1 Channel7 transfer complete flag.
  396. * @arg DMA1_FLAG_HT7 DMA1 Channel7 half transfer flag.
  397. * @arg DMA1_FLAG_TE7 DMA1 Channel7 transfer error flag.
  398. * @arg DMA1_FLAG_GL8 DMA1 Channel7 global flag.
  399. * @arg DMA1_FLAG_TC8 DMA1 Channel7 transfer complete flag.
  400. * @arg DMA1_FLAG_HT8 DMA1 Channel7 half transfer flag.
  401. * @arg DMA1_FLAG_TE8 DMA1 Channel7 transfer error flag.
  402. * @arg DMA2_FLAG_GL1 DMA2 Channel1 global flag.
  403. * @arg DMA2_FLAG_TC1 DMA2 Channel1 transfer complete flag.
  404. * @arg DMA2_FLAG_HT1 DMA2 Channel1 half transfer flag.
  405. * @arg DMA2_FLAG_TE1 DMA2 Channel1 transfer error flag.
  406. * @arg DMA2_FLAG_GL2 DMA2 Channel2 global flag.
  407. * @arg DMA2_FLAG_TC2 DMA2 Channel2 transfer complete flag.
  408. * @arg DMA2_FLAG_HT2 DMA2 Channel2 half transfer flag.
  409. * @arg DMA2_FLAG_TE2 DMA2 Channel2 transfer error flag.
  410. * @arg DMA2_FLAG_GL3 DMA2 Channel3 global flag.
  411. * @arg DMA2_FLAG_TC3 DMA2 Channel3 transfer complete flag.
  412. * @arg DMA2_FLAG_HT3 DMA2 Channel3 half transfer flag.
  413. * @arg DMA2_FLAG_TE3 DMA2 Channel3 transfer error flag.
  414. * @arg DMA2_FLAG_GL4 DMA2 Channel4 global flag.
  415. * @arg DMA2_FLAG_TC4 DMA2 Channel4 transfer complete flag.
  416. * @arg DMA2_FLAG_HT4 DMA2 Channel4 half transfer flag.
  417. * @arg DMA2_FLAG_TE4 DMA2 Channel4 transfer error flag.
  418. * @arg DMA2_FLAG_GL5 DMA2 Channel5 global flag.
  419. * @arg DMA2_FLAG_TC5 DMA2 Channel5 transfer complete flag.
  420. * @arg DMA2_FLAG_HT5 DMA2 Channel5 half transfer flag.
  421. * @arg DMA2_FLAG_TE5 DMA2 Channel5 transfer error flag.
  422. * @arg DMA2_FLAG_GL6 DMA1 Channel6 global flag.
  423. * @arg DMA2_FLAG_TC6 DMA1 Channel6 transfer complete flag.
  424. * @arg DMA2_FLAG_HT6 DMA1 Channel6 half transfer flag.
  425. * @arg DMA2_FLAG_TE6 DMA1 Channel6 transfer error flag.
  426. * @arg DMA2_FLAG_GL7 DMA1 Channel7 global flag.
  427. * @arg DMA2_FLAG_TC7 DMA1 Channel7 transfer complete flag.
  428. * @arg DMA2_FLAG_HT7 DMA1 Channel7 half transfer flag.
  429. * @arg DMA2_FLAG_TE7 DMA1 Channel7 transfer error flag.
  430. * @arg DMA2_FLAG_GL8 DMA1 Channel7 global flag.
  431. * @arg DMA2_FLAG_TC8 DMA1 Channel7 transfer complete flag.
  432. * @arg DMA2_FLAG_HT8 DMA1 Channel7 half transfer flag.
  433. * @arg DMA2_FLAG_TE8 DMA1 Channel7 transfer error flag.
  434. * @param DMAy DMA1 or DMA2.
  435. * This parameter can be one of the following values:
  436. * @arg DMA1 .
  437. * @arg DMA2 .
  438. * @return The new state of DMAyFlag (SET or RESET).
  439. */
  440. FlagStatus DMA_GetFlagStatus(uint32_t DMAyFlag, DMA_Module* DMAy)
  441. {
  442. FlagStatus bitstatus = RESET;
  443. uint32_t tmpregister = 0;
  444. /* Check the parameters */
  445. assert_param(IS_DMA_GET_FLAG(DMAyFlag));
  446. /* Calculate the used DMAy */
  447. /* Get DMAy INTSTS register value */
  448. tmpregister = DMAy->INTSTS;
  449. /* Check the status of the specified DMAy flag */
  450. if ((tmpregister & DMAyFlag) != (uint32_t)RESET)
  451. {
  452. /* DMAyFlag is set */
  453. bitstatus = SET;
  454. }
  455. else
  456. {
  457. /* DMAyFlag is reset */
  458. bitstatus = RESET;
  459. }
  460. /* Return the DMAyFlag status */
  461. return bitstatus;
  462. }
  463. /**
  464. * @brief Clears the DMAy Channelx's pending flags.
  465. * @param DMAyFlag specifies the flag to clear.
  466. * This parameter can be any combination (for the same DMA) of the following values:
  467. * @arg DMA1_FLAG_GL1 DMA1 Channel1 global flag.
  468. * @arg DMA1_FLAG_TC1 DMA1 Channel1 transfer complete flag.
  469. * @arg DMA1_FLAG_HT1 DMA1 Channel1 half transfer flag.
  470. * @arg DMA1_FLAG_TE1 DMA1 Channel1 transfer error flag.
  471. * @arg DMA1_FLAG_GL2 DMA1 Channel2 global flag.
  472. * @arg DMA1_FLAG_TC2 DMA1 Channel2 transfer complete flag.
  473. * @arg DMA1_FLAG_HT2 DMA1 Channel2 half transfer flag.
  474. * @arg DMA1_FLAG_TE2 DMA1 Channel2 transfer error flag.
  475. * @arg DMA1_FLAG_GL3 DMA1 Channel3 global flag.
  476. * @arg DMA1_FLAG_TC3 DMA1 Channel3 transfer complete flag.
  477. * @arg DMA1_FLAG_HT3 DMA1 Channel3 half transfer flag.
  478. * @arg DMA1_FLAG_TE3 DMA1 Channel3 transfer error flag.
  479. * @arg DMA1_FLAG_GL4 DMA1 Channel4 global flag.
  480. * @arg DMA1_FLAG_TC4 DMA1 Channel4 transfer complete flag.
  481. * @arg DMA1_FLAG_HT4 DMA1 Channel4 half transfer flag.
  482. * @arg DMA1_FLAG_TE4 DMA1 Channel4 transfer error flag.
  483. * @arg DMA1_FLAG_GL5 DMA1 Channel5 global flag.
  484. * @arg DMA1_FLAG_TC5 DMA1 Channel5 transfer complete flag.
  485. * @arg DMA1_FLAG_HT5 DMA1 Channel5 half transfer flag.
  486. * @arg DMA1_FLAG_TE5 DMA1 Channel5 transfer error flag.
  487. * @arg DMA1_FLAG_GL6 DMA1 Channel6 global flag.
  488. * @arg DMA1_FLAG_TC6 DMA1 Channel6 transfer complete flag.
  489. * @arg DMA1_FLAG_HT6 DMA1 Channel6 half transfer flag.
  490. * @arg DMA1_FLAG_TE6 DMA1 Channel6 transfer error flag.
  491. * @arg DMA1_FLAG_GL7 DMA1 Channel7 global flag.
  492. * @arg DMA1_FLAG_TC7 DMA1 Channel7 transfer complete flag.
  493. * @arg DMA1_FLAG_HT7 DMA1 Channel7 half transfer flag.
  494. * @arg DMA1_FLAG_TE7 DMA1 Channel7 transfer error flag.
  495. * @arg DMA1_FLAG_GL8 DMA1 Channel8 global flag.
  496. * @arg DMA1_FLAG_TC8 DMA1 Channel8 transfer complete flag.
  497. * @arg DMA1_FLAG_HT8 DMA1 Channel8 half transfer flag.
  498. * @arg DMA1_FLAG_TE8 DMA1 Channel8 transfer error flag.
  499. * @arg DMA2_FLAG_GL1 DMA2 Channel1 global flag.
  500. * @arg DMA2_FLAG_TC1 DMA2 Channel1 transfer complete flag.
  501. * @arg DMA2_FLAG_HT1 DMA2 Channel1 half transfer flag.
  502. * @arg DMA2_FLAG_TE1 DMA2 Channel1 transfer error flag.
  503. * @arg DMA2_FLAG_GL2 DMA2 Channel2 global flag.
  504. * @arg DMA2_FLAG_TC2 DMA2 Channel2 transfer complete flag.
  505. * @arg DMA2_FLAG_HT2 DMA2 Channel2 half transfer flag.
  506. * @arg DMA2_FLAG_TE2 DMA2 Channel2 transfer error flag.
  507. * @arg DMA2_FLAG_GL3 DMA2 Channel3 global flag.
  508. * @arg DMA2_FLAG_TC3 DMA2 Channel3 transfer complete flag.
  509. * @arg DMA2_FLAG_HT3 DMA2 Channel3 half transfer flag.
  510. * @arg DMA2_FLAG_TE3 DMA2 Channel3 transfer error flag.
  511. * @arg DMA2_FLAG_GL4 DMA2 Channel4 global flag.
  512. * @arg DMA2_FLAG_TC4 DMA2 Channel4 transfer complete flag.
  513. * @arg DMA2_FLAG_HT4 DMA2 Channel4 half transfer flag.
  514. * @arg DMA2_FLAG_TE4 DMA2 Channel4 transfer error flag.
  515. * @arg DMA2_FLAG_GL5 DMA2 Channel5 global flag.
  516. * @arg DMA2_FLAG_TC5 DMA2 Channel5 transfer complete flag.
  517. * @arg DMA2_FLAG_HT5 DMA2 Channel5 half transfer flag.
  518. * @arg DMA2_FLAG_TE5 DMA2 Channel5 transfer error flag.
  519. * @arg DMA2_FLAG_GL6 DMA2 Channel6 global flag.
  520. * @arg DMA2_FLAG_TC6 DMA2 Channel6 transfer complete flag.
  521. * @arg DMA2_FLAG_HT6 DMA2 Channel6 half transfer flag.
  522. * @arg DMA2_FLAG_TE6 DMA2 Channel6 transfer error flag.
  523. * @arg DMA2_FLAG_GL7 DMA2 Channel7 global flag.
  524. * @arg DMA2_FLAG_TC7 DMA2 Channel7 transfer complete flag.
  525. * @arg DMA2_FLAG_HT7 DMA2 Channel7 half transfer flag.
  526. * @arg DMA2_FLAG_TE7 DMA2 Channel7 transfer error flag.
  527. * @arg DMA2_FLAG_GL8 DMA2 Channel8 global flag.
  528. * @arg DMA2_FLAG_TC8 DMA2 Channel8 transfer complete flag.
  529. * @arg DMA2_FLAG_HT8 DMA2 Channel8 half transfer flag.
  530. * @arg DMA2_FLAG_TE8 DMA2 Channel8 transfer error flag.
  531. * @param DMAy DMA1 or DMA2.
  532. * This parameter can be one of the following values:
  533. * @arg DMA1 .
  534. * @arg DMA2 .
  535. */
  536. void DMA_ClearFlag(uint32_t DMAyFlag, DMA_Module* DMAy)
  537. {
  538. /* Check the parameters */
  539. assert_param(IS_DMA_CLEAR_FLAG(DMAyFlag));
  540. /* Calculate the used DMAy */
  541. /* Clear the selected DMAy flags */
  542. DMAy->INTCLR = DMAyFlag;
  543. }
  544. /**
  545. * @brief Checks whether the specified DMAy Channelx interrupt has occurred or not.
  546. * @param DMAy_IT specifies the DMAy interrupt source to check.
  547. * This parameter can be one of the following values:
  548. * @arg DMA1_INT_GLB1 DMA1 Channel1 global interrupt.
  549. * @arg DMA1_INT_TXC1 DMA1 Channel1 transfer complete interrupt.
  550. * @arg DMA1_INT_HTX1 DMA1 Channel1 half transfer interrupt.
  551. * @arg DMA1_INT_ERR1 DMA1 Channel1 transfer error interrupt.
  552. * @arg DMA1_INT_GLB2 DMA1 Channel2 global interrupt.
  553. * @arg DMA1_INT_TXC2 DMA1 Channel2 transfer complete interrupt.
  554. * @arg DMA1_INT_HTX2 DMA1 Channel2 half transfer interrupt.
  555. * @arg DMA1_INT_ERR2 DMA1 Channel2 transfer error interrupt.
  556. * @arg DMA1_INT_GLB3 DMA1 Channel3 global interrupt.
  557. * @arg DMA1_INT_TXC3 DMA1 Channel3 transfer complete interrupt.
  558. * @arg DMA1_INT_HTX3 DMA1 Channel3 half transfer interrupt.
  559. * @arg DMA1_INT_ERR3 DMA1 Channel3 transfer error interrupt.
  560. * @arg DMA1_INT_GLB4 DMA1 Channel4 global interrupt.
  561. * @arg DMA1_INT_TXC4 DMA1 Channel4 transfer complete interrupt.
  562. * @arg DMA1_INT_HTX4 DMA1 Channel4 half transfer interrupt.
  563. * @arg DMA1_INT_ERR4 DMA1 Channel4 transfer error interrupt.
  564. * @arg DMA1_INT_GLB5 DMA1 Channel5 global interrupt.
  565. * @arg DMA1_INT_TXC5 DMA1 Channel5 transfer complete interrupt.
  566. * @arg DMA1_INT_HTX5 DMA1 Channel5 half transfer interrupt.
  567. * @arg DMA1_INT_ERR5 DMA1 Channel5 transfer error interrupt.
  568. * @arg DMA1_INT_GLB6 DMA1 Channel6 global interrupt.
  569. * @arg DMA1_INT_TXC6 DMA1 Channel6 transfer complete interrupt.
  570. * @arg DMA1_INT_HTX6 DMA1 Channel6 half transfer interrupt.
  571. * @arg DMA1_INT_ERR6 DMA1 Channel6 transfer error interrupt.
  572. * @arg DMA1_INT_GLB7 DMA1 Channel7 global interrupt.
  573. * @arg DMA1_INT_TXC7 DMA1 Channel7 transfer complete interrupt.
  574. * @arg DMA1_INT_HTX7 DMA1 Channel7 half transfer interrupt.
  575. * @arg DMA1_INT_ERR7 DMA1 Channel7 transfer error interrupt.
  576. * @arg DMA1_INT_GLB8 DMA1 Channel8 global interrupt.
  577. * @arg DMA1_INT_TXC8 DMA1 Channel8 transfer complete interrupt.
  578. * @arg DMA1_INT_HTX8 DMA1 Channel8 half transfer interrupt.
  579. * @arg DMA1_INT_ERR8 DMA1 Channel8 transfer error interrupt.
  580. * @arg DMA2_INT_GLB1 DMA2 Channel1 global interrupt.
  581. * @arg DMA2_INT_TXC1 DMA2 Channel1 transfer complete interrupt.
  582. * @arg DMA2_INT_HTX1 DMA2 Channel1 half transfer interrupt.
  583. * @arg DMA2_INT_ERR1 DMA2 Channel1 transfer error interrupt.
  584. * @arg DMA2_INT_GLB2 DMA2 Channel2 global interrupt.
  585. * @arg DMA2_INT_TXC2 DMA2 Channel2 transfer complete interrupt.
  586. * @arg DMA2_INT_HTX2 DMA2 Channel2 half transfer interrupt.
  587. * @arg DMA2_INT_ERR2 DMA2 Channel2 transfer error interrupt.
  588. * @arg DMA2_INT_GLB3 DMA2 Channel3 global interrupt.
  589. * @arg DMA2_INT_TXC3 DMA2 Channel3 transfer complete interrupt.
  590. * @arg DMA2_INT_HTX3 DMA2 Channel3 half transfer interrupt.
  591. * @arg DMA2_INT_ERR3 DMA2 Channel3 transfer error interrupt.
  592. * @arg DMA2_INT_GLB4 DMA2 Channel4 global interrupt.
  593. * @arg DMA2_INT_TXC4 DMA2 Channel4 transfer complete interrupt.
  594. * @arg DMA2_INT_HTX4 DMA2 Channel4 half transfer interrupt.
  595. * @arg DMA2_INT_ERR4 DMA2 Channel4 transfer error interrupt.
  596. * @arg DMA2_INT_GLB5 DMA2 Channel5 global interrupt.
  597. * @arg DMA2_INT_TXC5 DMA2 Channel5 transfer complete interrupt.
  598. * @arg DMA2_INT_HTX5 DMA2 Channel5 half transfer interrupt.
  599. * @arg DMA2_INT_ERR5 DMA2 Channel5 transfer error interrupt.
  600. * @arg DMA2_INT_GLB6 DMA2 Channel6 global interrupt.
  601. * @arg DMA2_INT_TXC6 DMA2 Channel6 transfer complete interrupt.
  602. * @arg DMA2_INT_HTX6 DMA2 Channel6 half transfer interrupt.
  603. * @arg DMA2_INT_ERR6 DMA2 Channel6 transfer error interrupt.
  604. * @arg DMA2_INT_GLB7 DMA2 Channel7 global interrupt.
  605. * @arg DMA2_INT_TXC7 DMA2 Channel7 transfer complete interrupt.
  606. * @arg DMA2_INT_HTX7 DMA2 Channel7 half transfer interrupt.
  607. * @arg DMA2_INT_ERR7 DMA2 Channel7 transfer error interrupt.
  608. * @arg DMA2_INT_GLB8 DMA2 Channel8 global interrupt.
  609. * @arg DMA2_INT_TXC8 DMA2 Channel8 transfer complete interrupt.
  610. * @arg DMA2_INT_HTX8 DMA2 Channel8 half transfer interrupt.
  611. * @arg DMA2_INT_ERR8 DMA2 Channel8 transfer error interrupt.
  612. * @param DMAy DMA1 or DMA2.
  613. * This parameter can be one of the following values:
  614. * @arg DMA1 .
  615. * @arg DMA2 .
  616. * @return The new state of DMAy_IT (SET or RESET).
  617. */
  618. INTStatus DMA_GetIntStatus(uint32_t DMAy_IT, DMA_Module* DMAy)
  619. {
  620. INTStatus bitstatus = RESET;
  621. uint32_t tmpregister = 0;
  622. /* Check the parameters */
  623. assert_param(IS_DMA_GET_IT(DMAy_IT));
  624. /* Calculate the used DMA */
  625. /* Get DMAy INTSTS register value */
  626. tmpregister = DMAy->INTSTS;
  627. /* Check the status of the specified DMAy interrupt */
  628. if ((tmpregister & DMAy_IT) != (uint32_t)RESET)
  629. {
  630. /* DMAy_IT is set */
  631. bitstatus = SET;
  632. }
  633. else
  634. {
  635. /* DMAy_IT is reset */
  636. bitstatus = RESET;
  637. }
  638. /* Return the DMAInt status */
  639. return bitstatus;
  640. }
  641. /**
  642. * @brief Clears the DMAy Channelx's interrupt pending bits.
  643. * @param DMAy_IT specifies the DMAy interrupt pending bit to clear.
  644. * This parameter can be any combination (for the same DMA) of the following values:
  645. * @arg DMA1_INT_GLB1 DMA1 Channel1 global interrupt.
  646. * @arg DMA1_INT_TXC1 DMA1 Channel1 transfer complete interrupt.
  647. * @arg DMA1_INT_HTX1 DMA1 Channel1 half transfer interrupt.
  648. * @arg DMA1_INT_ERR1 DMA1 Channel1 transfer error interrupt.
  649. * @arg DMA1_INT_GLB2 DMA1 Channel2 global interrupt.
  650. * @arg DMA1_INT_TXC2 DMA1 Channel2 transfer complete interrupt.
  651. * @arg DMA1_INT_HTX2 DMA1 Channel2 half transfer interrupt.
  652. * @arg DMA1_INT_ERR2 DMA1 Channel2 transfer error interrupt.
  653. * @arg DMA1_INT_GLB3 DMA1 Channel3 global interrupt.
  654. * @arg DMA1_INT_TXC3 DMA1 Channel3 transfer complete interrupt.
  655. * @arg DMA1_INT_HTX3 DMA1 Channel3 half transfer interrupt.
  656. * @arg DMA1_INT_ERR3 DMA1 Channel3 transfer error interrupt.
  657. * @arg DMA1_INT_GLB4 DMA1 Channel4 global interrupt.
  658. * @arg DMA1_INT_TXC4 DMA1 Channel4 transfer complete interrupt.
  659. * @arg DMA1_INT_HTX4 DMA1 Channel4 half transfer interrupt.
  660. * @arg DMA1_INT_ERR4 DMA1 Channel4 transfer error interrupt.
  661. * @arg DMA1_INT_GLB5 DMA1 Channel5 global interrupt.
  662. * @arg DMA1_INT_TXC5 DMA1 Channel5 transfer complete interrupt.
  663. * @arg DMA1_INT_HTX5 DMA1 Channel5 half transfer interrupt.
  664. * @arg DMA1_INT_ERR5 DMA1 Channel5 transfer error interrupt.
  665. * @arg DMA1_INT_GLB6 DMA1 Channel6 global interrupt.
  666. * @arg DMA1_INT_TXC6 DMA1 Channel6 transfer complete interrupt.
  667. * @arg DMA1_INT_HTX6 DMA1 Channel6 half transfer interrupt.
  668. * @arg DMA1_INT_ERR6 DMA1 Channel6 transfer error interrupt.
  669. * @arg DMA1_INT_GLB7 DMA1 Channel7 global interrupt.
  670. * @arg DMA1_INT_TXC7 DMA1 Channel7 transfer complete interrupt.
  671. * @arg DMA1_INT_HTX7 DMA1 Channel7 half transfer interrupt.
  672. * @arg DMA1_INT_ERR7 DMA1 Channel7 transfer error interrupt.
  673. * @arg DMA1_INT_GLB8 DMA1 Channel8 global interrupt.
  674. * @arg DMA1_INT_TXC8 DMA1 Channel8 transfer complete interrupt.
  675. * @arg DMA1_INT_HTX8 DMA1 Channel8 half transfer interrupt.
  676. * @arg DMA1_INT_ERR8 DMA1 Channel8 transfer error interrupt.
  677. * @arg DMA2_INT_GLB1 DMA2 Channel1 global interrupt.
  678. * @arg DMA2_INT_TXC1 DMA2 Channel1 transfer complete interrupt.
  679. * @arg DMA2_INT_HTX1 DMA2 Channel1 half transfer interrupt.
  680. * @arg DMA2_INT_ERR1 DMA2 Channel1 transfer error interrupt.
  681. * @arg DMA2_INT_GLB2 DMA2 Channel2 global interrupt.
  682. * @arg DMA2_INT_TXC2 DMA2 Channel2 transfer complete interrupt.
  683. * @arg DMA2_INT_HTX2 DMA2 Channel2 half transfer interrupt.
  684. * @arg DMA2_INT_ERR2 DMA2 Channel2 transfer error interrupt.
  685. * @arg DMA2_INT_GLB3 DMA2 Channel3 global interrupt.
  686. * @arg DMA2_INT_TXC3 DMA2 Channel3 transfer complete interrupt.
  687. * @arg DMA2_INT_HTX3 DMA2 Channel3 half transfer interrupt.
  688. * @arg DMA2_INT_ERR3 DMA2 Channel3 transfer error interrupt.
  689. * @arg DMA2_INT_GLB4 DMA2 Channel4 global interrupt.
  690. * @arg DMA2_INT_TXC4 DMA2 Channel4 transfer complete interrupt.
  691. * @arg DMA2_INT_HTX4 DMA2 Channel4 half transfer interrupt.
  692. * @arg DMA2_INT_ERR4 DMA2 Channel4 transfer error interrupt.
  693. * @arg DMA2_INT_GLB5 DMA2 Channel5 global interrupt.
  694. * @arg DMA2_INT_TXC5 DMA2 Channel5 transfer complete interrupt.
  695. * @arg DMA2_INT_HTX5 DMA2 Channel5 half transfer interrupt.
  696. * @arg DMA2_INT_ERR5 DMA2 Channel5 transfer error interrupt.
  697. * @arg DMA2_INT_GLB6 DMA2 Channel6 global interrupt.
  698. * @arg DMA2_INT_TXC6 DMA2 Channel6 transfer complete interrupt.
  699. * @arg DMA2_INT_HTX6 DMA2 Channel6 half transfer interrupt.
  700. * @arg DMA2_INT_ERR6 DMA2 Channel6 transfer error interrupt.
  701. * @arg DMA2_INT_GLB7 DMA2 Channel7 global interrupt.
  702. * @arg DMA2_INT_TXC7 DMA2 Channel7 transfer complete interrupt.
  703. * @arg DMA2_INT_HTX7 DMA2 Channel7 half transfer interrupt.
  704. * @arg DMA2_INT_ERR7 DMA2 Channel7 transfer error interrupt.
  705. * @arg DMA2_INT_GLB8 DMA2 Channel8 global interrupt.
  706. * @arg DMA2_INT_TXC8 DMA2 Channel8 transfer complete interrupt.
  707. * @arg DMA2_INT_HTX8 DMA2 Channel8 half transfer interrupt.
  708. * @arg DMA2_INT_ERR8 DMA2 Channel8 transfer error interrupt.
  709. * @param DMAy DMA1 or DMA2.
  710. * This parameter can be one of the following values:
  711. * @arg DMA1 .
  712. * @arg DMA2 .
  713. */
  714. void DMA_ClrIntPendingBit(uint32_t DMAy_IT, DMA_Module* DMAy)
  715. {
  716. /* Check the parameters */
  717. assert_param(IS_DMA_CLR_INT(DMAy_IT));
  718. /* Calculate the used DMAy */
  719. /* Clear the selected DMAy interrupt pending bits */
  720. DMAy->INTCLR = DMAy_IT;
  721. }
  722. /**
  723. * @brief Set the DMAy Channelx's remap request.
  724. * @param DMAy_REMAP specifies the DMAy request.
  725. * This parameter can be set by the following values:
  726. * @arg DMA1_REMAP_ADC1 DMA1 Request For ADC1.
  727. * @arg DMA1_REMAP_UART5_TX DMA1 Request For UART5_TX.
  728. * @arg DMA1_REMAP_I2C3_TX DMA1 Request For I2C3_TX.
  729. * @arg DMA1_REMAP_TIM2_CH3 DMA1 Request For TIM2_CH3.
  730. * @arg DMA1_REMAP_TIM4_CH1 DMA1 Request For TIM4_CH1.
  731. * @arg DMA1_REMAP_USART3_TX DMA1 Request For USART3_TX.
  732. * @arg DMA1_REMAP_I2C3_RX DMA1 Request For I2C3_RX.
  733. * @arg DMA1_REMAP_TIM1_CH1 DMA1 Request For TIM1_CH1.
  734. * @arg DMA1_REMAP_TIM2_UP DMA1 Request For TIM2_UP.
  735. * @arg DMA1_REMAP_TIM3_CH3 DMA1 Request For TIM3_CH3.
  736. * @arg DMA1_REMAP_SPI1_RX DMA1 Request For SPI1_RX.
  737. * @arg DMA1_REMAP_USART3_RX DMA1 Request For USART3_RX.
  738. * @arg DMA1_REMAP_TIM1_CH2 DMA1 Request For TIM1_CH2.
  739. * @arg DMA1_REMAP_TIM3_CH4 DMA1 Request For TIM3_CH4.
  740. * @arg DMA1_REMAP_TIM3_UP DMA1 Request For TIM3_UP.
  741. * @arg DMA1_REMAP_SPI1_TX DMA1 Request For SPI1_TX.
  742. * @arg DMA1_REMAP_USART1_TX DMA1 Request For USART1_TX.
  743. * @arg DMA1_REMAP_TIM1_CH4 DMA1 Request For TIM1_CH4.
  744. * @arg DMA1_REMAP_TIM1_TRIG DMA1 Request For TIM1_TRIG.
  745. * @arg DMA1_REMAP_TIM1_COM DMA1 Request For TIM1_COM.
  746. * @arg DMA1_REMAP_TIM4_CH2 DMA1 Request For TIM4_CH2.
  747. * @arg DMA1_REMAP_SPI_I2S2_RX DMA1 Request For SPI_I2S2_RX.
  748. * @arg DMA1_REMAP_I2C2_TX DMA1 Request For I2C2_TX.
  749. * @arg DMA1_REMAP_USART1_RX DMA1 Request For USART1_RX.
  750. * @arg DMA1_REMAP_TIM1_UP DMA1 Request For TIM1_UP.
  751. * @arg DMA1_REMAP_SPI_I2S2_TX DMA1 Request For SPI_I2S2_TX.
  752. * @arg DMA1_REMAP_TIM4_CH3 DMA1 Request For TIM4_CH3.
  753. * @arg DMA1_REMAP_I2C2_RX DMA1 Request For I2C2_RX.
  754. * @arg DMA1_REMAP_TIM2_CH1 DMA1 Request For TIM2_CH1.
  755. * @arg DMA1_REMAP_USART2_RX DMA1 Request For USART2_RX.
  756. * @arg DMA1_REMAP_TIM1_CH3 DMA1 Request For TIM1_CH3.
  757. * @arg DMA1_REMAP_TIM3_CH1 DMA1 Request For TIM3_CH1.
  758. * @arg DMA1_REMAP_TIM3_TRIG DMA1 Request For TIM3_TRIG.
  759. * @arg DMA1_REMAP_I2C1_TX DMA1 Request For I2C1_TX.
  760. * @arg DMA1_REMAP_USART2_TX DMA1 Request For USART2_TX.
  761. * @arg DMA1_REMAP_TIM2_CH2 DMA1 Request For TIM2_CH2.
  762. * @arg DMA1_REMAP_TIM2_CH4 DMA1 Request For TIM2_CH4.
  763. * @arg DMA1_REMAP_TIM4_UP DMA1 Request For TIM4_UP.
  764. * @arg DMA1_REMAP_I2C1_RX DMA1 Request For I2C1_RX.
  765. * @arg DMA1_REMAP_ADC2 DMA1 Request For ADC2.
  766. * @arg DMA1_REMAP_UART5_RX DMA1 Request For UART5_RX.
  767. * @arg DMA2_REMAP_TIM5_CH4 DMA2 Request For TIM5_CH4.
  768. * @arg DMA2_REMAP_TIM5_TRIG DMA2 Request For TIM5_TRIG.
  769. * @arg DMA2_REMAP_TIM8_CH3 DMA2 Request For TIM8_CH3.
  770. * @arg DMA2_REMAP_TIM8_UP DMA2 Request For TIM8_UP.
  771. * @arg DMA2_REMAP_SPI_I2S3_RX DMA2 Request For SPI_I2S3_RX.
  772. * @arg DMA2_REMAP_UART6_RX DMA2 Request For UART6_RX.
  773. * @arg DMA2_REMAP_TIM8_CH4 DMA2 Request For TIM8_CH4.
  774. * @arg DMA2_REMAP_TIM8_TRIG DMA2 Request For TIM8_TRIG.
  775. * @arg DMA2_REMAP_TIM8_COM DMA2 Request For TIM8_COM.
  776. * @arg DMA2_REMAP_TIM5_CH3 DMA2 Request For TIM5_CH3.
  777. * @arg DMA2_REMAP_TIM5_UP DMA2 Request For TIM5_UP.
  778. * @arg DMA2_REMAP_SPI_I2S3_TX DMA2 Request For SPI_I2S3_TX.
  779. * @arg DMA2_REMAP_UART6_TX DMA2 Request For UART6_TX.
  780. * @arg DMA2_REMAP_TIM8_CH1 DMA2 Request For TIM8_CH1.
  781. * @arg DMA2_REMAP_UART4_RX DMA2 Request For UART4_RX.
  782. * @arg DMA2_REMAP_TIM6_UP DMA2 Request For TIM6_UP.
  783. * @arg DMA2_REMAP_DAC1 DMA2 Request For DAC1.
  784. * @arg DMA2_REMAP_TIM5_CH2 DMA2 Request For TIM5_CH2.
  785. * @arg DMA2_REMAP_SDIO DMA2 Request For SDIO.
  786. * @arg DMA2_REMAP_TIM7_UP DMA2 Request For TIM7_UP.
  787. * @arg DMA2_REMAP_DAC2 DMA2 Request For DAC2.
  788. * @arg DMA2_REMAP_ADC3 DMA2 Request For ADC3.
  789. * @arg DMA2_REMAP_TIM8_CH2 DMA2 Request For TIM8_CH2.
  790. * @arg DMA2_REMAP_TIM5_CH1 DMA2 Request For TIM5_CH1.
  791. * @arg DMA2_REMAP_UART4_TX DMA2 Request For UART4_TX.
  792. * @arg DMA2_REMAP_QSPI_RX DMA2 Request For QSPI_RX.
  793. * @arg DMA2_REMAP_I2C4_TX DMA2 Request For I2C4_TX.
  794. * @arg DMA2_REMAP_UART7_RX DMA2 Request For UART7_RX.
  795. * @arg DMA2_REMAP_QSPI_TX DMA2 Request For QSPI_TX.
  796. * @arg DMA2_REMAP_I2C4_RX DMA2 Request For I2C4_RX.
  797. * @arg DMA2_REMAP_UART7_TX DMA2 Request For UART7_TX.
  798. * @arg DMA2_REMAP_ADC4 DMA2 Request For ADC4.
  799. * @arg DMA2_REMAP_DVP DMA2 Request For DVP.
  800. * @param DMAy DMA1 or DMA2.
  801. * This parameter can be one of the following values:
  802. * @arg DMA1 .
  803. * @arg DMA2 .
  804. * @param DMAyChx where y can be 1 or 2 to select the DMA and
  805. * x can be 1 to 8 for DMA1 and 1 to 8 for DMA2 to select the DMA Channel.
  806. * @param Cmd new state of the DMAy Channelx.
  807. * This parameter can be: ENABLE or DISABLE.
  808. */
  809. void DMA_RequestRemap(uint32_t DMAy_REMAP, DMA_Module* DMAy, DMA_ChannelType* DMAyChx, FunctionalState Cmd)
  810. {
  811. /* Check the parameters */
  812. assert_param(IS_DMA_REMAP(DMAy_REMAP));
  813. if (Cmd != DISABLE)
  814. {
  815. /* Calculate the used DMAy */
  816. /* Set the selected DMAy remap request */
  817. DMAyChx->CHSEL = DMAy_REMAP;
  818. DMAy->CHMAPEN = 1;
  819. }
  820. else
  821. {
  822. DMAy->CHMAPEN = 0;
  823. }
  824. }
  825. /**
  826. * @}
  827. */
  828. /**
  829. * @}
  830. */
  831. /**
  832. * @}
  833. */