stm32f0xx_dma.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_dma.c
  4. * @author MCD Application Team
  5. * @version V1.5.0
  6. * @date 05-December-2014
  7. * @brief This file provides firmware functions to manage the following
  8. * functionalities of the Direct Memory Access controller (DMA):
  9. * + Initialization and Configuration
  10. * + Data Counter
  11. * + Interrupts and flags management
  12. *
  13. * @verbatim
  14. ==============================================================================
  15. ##### How to use this driver #####
  16. ==============================================================================
  17. [..]
  18. (#) Enable The DMA controller clock using
  19. RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE) function for DMA1.
  20. (#) Enable and configure the peripheral to be connected to the DMA channel
  21. (except for internal SRAM / FLASH memories: no initialization is necessary).
  22. (#) For a given Channel, program the Source and Destination addresses,
  23. the transfer Direction, the Buffer Size, the Peripheral and Memory
  24. Incrementation mode and Data Size, the Circular or Normal mode,
  25. the channel transfer Priority and the Memory-to-Memory transfer
  26. mode (if needed) using the DMA_Init() function.
  27. (#) Enable the NVIC and the corresponding interrupt(s) using the function
  28. DMA_ITConfig() if you need to use DMA interrupts.
  29. (#) Enable the DMA channel using the DMA_Cmd() function.
  30. (#) Activate the needed channel Request using PPP_DMACmd() function for
  31. any PPP peripheral except internal SRAM and FLASH (ie. SPI, USART ...)
  32. The function allowing this operation is provided in each PPP peripheral
  33. driver (ie. SPI_DMACmd for SPI peripheral).
  34. (#) Optionally, you can configure the number of data to be transferred
  35. when the channel is disabled (ie. after each Transfer Complete event
  36. or when a Transfer Error occurs) using the function DMA_SetCurrDataCounter().
  37. And you can get the number of remaining data to be transferred using
  38. the function DMA_GetCurrDataCounter() at run time (when the DMA channel is
  39. enabled and running).
  40. (#) To control DMA events you can use one of the following two methods:
  41. (##) Check on DMA channel flags using the function DMA_GetFlagStatus().
  42. (##) Use DMA interrupts through the function DMA_ITConfig() at initialization
  43. phase and DMA_GetITStatus() function into interrupt routines in
  44. communication phase.
  45. After checking on a flag you should clear it using DMA_ClearFlag()
  46. function. And after checking on an interrupt event you should
  47. clear it using DMA_ClearITPendingBit() function.
  48. @endverbatim
  49. *
  50. ******************************************************************************
  51. * @attention
  52. *
  53. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  54. *
  55. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  56. * You may not use this file except in compliance with the License.
  57. * You may obtain a copy of the License at:
  58. *
  59. * http://www.st.com/software_license_agreement_liberty_v2
  60. *
  61. * Unless required by applicable law or agreed to in writing, software
  62. * distributed under the License is distributed on an "AS IS" BASIS,
  63. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  64. * See the License for the specific language governing permissions and
  65. * limitations under the License.
  66. *
  67. ******************************************************************************
  68. */
  69. /* Includes ------------------------------------------------------------------*/
  70. #include "stm32f0xx_dma.h"
  71. /** @addtogroup STM32F0xx_StdPeriph_Driver
  72. * @{
  73. */
  74. /** @defgroup DMA
  75. * @brief DMA driver modules
  76. * @{
  77. */
  78. /* Private typedef -----------------------------------------------------------*/
  79. /* Private define ------------------------------------------------------------*/
  80. #define CCR_CLEAR_MASK ((uint32_t)0xFFFF800F) /* DMA Channel config registers Masks */
  81. #define FLAG_Mask ((uint32_t)0x10000000) /* DMA2 FLAG mask */
  82. /* DMA1 Channelx interrupt pending bit masks */
  83. #define DMA1_CHANNEL1_IT_MASK ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1))
  84. #define DMA1_CHANNEL2_IT_MASK ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2))
  85. #define DMA1_CHANNEL3_IT_MASK ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3))
  86. #define DMA1_CHANNEL4_IT_MASK ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4))
  87. #define DMA1_CHANNEL5_IT_MASK ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5))
  88. #define DMA1_CHANNEL6_IT_MASK ((uint32_t)(DMA_ISR_GIF6 | DMA_ISR_TCIF6 | DMA_ISR_HTIF6 | DMA_ISR_TEIF6)) /*!< Only applicable for STM32F072 and STM32F091 devices */
  89. #define DMA1_CHANNEL7_IT_MASK ((uint32_t)(DMA_ISR_GIF7 | DMA_ISR_TCIF7 | DMA_ISR_HTIF7 | DMA_ISR_TEIF7)) /*!< Only applicable for STM32F072 and STM32F091 devices */
  90. /* DMA2 Channelx interrupt pending bit masks: Only applicable for STM32F091 devices */
  91. #define DMA2_CHANNEL1_IT_MASK ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1))
  92. #define DMA2_CHANNEL2_IT_MASK ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2))
  93. #define DMA2_CHANNEL3_IT_MASK ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3))
  94. #define DMA2_CHANNEL4_IT_MASK ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4))
  95. #define DMA2_CHANNEL5_IT_MASK ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5))
  96. /* Private macro -------------------------------------------------------------*/
  97. /* Private variables ---------------------------------------------------------*/
  98. /* Private function prototypes -----------------------------------------------*/
  99. /* Private functions ---------------------------------------------------------*/
  100. /** @defgroup DMA_Private_Functions
  101. * @{
  102. */
  103. /** @defgroup DMA_Group1 Initialization and Configuration functions
  104. * @brief Initialization and Configuration functions
  105. *
  106. @verbatim
  107. ===============================================================================
  108. ##### Initialization and Configuration functions #####
  109. ===============================================================================
  110. [..] This subsection provides functions allowing to initialize the DMA channel
  111. source and destination addresses, incrementation and data sizes, transfer
  112. direction, buffer size, circular/normal mode selection, memory-to-memory
  113. mode selection and channel priority value.
  114. [..] The DMA_Init() function follows the DMA configuration procedures as described
  115. in reference manual (RM0091).
  116. @endverbatim
  117. * @{
  118. */
  119. /**
  120. * @brief Deinitializes the DMAy Channelx registers to their default reset
  121. * values.
  122. * @param DMAy_Channelx: where y can be 1 to select the DMA and
  123. * x can be 1 to 7 for DMA1 to select the DMA Channel.
  124. * @note Channel 6 and 7 are available only for STM32F072 devices.
  125. * @retval None
  126. */
  127. void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx)
  128. {
  129. /* Check the parameters */
  130. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  131. /* Disable the selected DMAy Channelx */
  132. DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR_EN);
  133. /* Reset DMAy Channelx control register */
  134. DMAy_Channelx->CCR = 0;
  135. /* Reset DMAy Channelx remaining bytes register */
  136. DMAy_Channelx->CNDTR = 0;
  137. /* Reset DMAy Channelx peripheral address register */
  138. DMAy_Channelx->CPAR = 0;
  139. /* Reset DMAy Channelx memory address register */
  140. DMAy_Channelx->CMAR = 0;
  141. if (DMAy_Channelx == DMA1_Channel1)
  142. {
  143. /* Reset interrupt pending bits for DMA1 Channel1 */
  144. DMA1->IFCR |= DMA1_CHANNEL1_IT_MASK;
  145. }
  146. else if (DMAy_Channelx == DMA1_Channel2)
  147. {
  148. /* Reset interrupt pending bits for DMA1 Channel2 */
  149. DMA1->IFCR |= DMA1_CHANNEL2_IT_MASK;
  150. }
  151. else if (DMAy_Channelx == DMA1_Channel3)
  152. {
  153. /* Reset interrupt pending bits for DMA1 Channel3 */
  154. DMA1->IFCR |= DMA1_CHANNEL3_IT_MASK;
  155. }
  156. else if (DMAy_Channelx == DMA1_Channel4)
  157. {
  158. /* Reset interrupt pending bits for DMA1 Channel4 */
  159. DMA1->IFCR |= DMA1_CHANNEL4_IT_MASK;
  160. }
  161. else if (DMAy_Channelx == DMA1_Channel5)
  162. {
  163. /* Reset interrupt pending bits for DMA1 Channel5 */
  164. DMA1->IFCR |= DMA1_CHANNEL5_IT_MASK;
  165. }
  166. else if (DMAy_Channelx == DMA1_Channel6)
  167. {
  168. /* Reset interrupt pending bits for DMA1 Channel6 */
  169. DMA1->IFCR |= DMA1_CHANNEL6_IT_MASK;
  170. }
  171. else if (DMAy_Channelx == DMA1_Channel7)
  172. {
  173. /* Reset interrupt pending bits for DMA1 Channel7 */
  174. DMA1->IFCR |= DMA1_CHANNEL7_IT_MASK;
  175. }
  176. else if (DMAy_Channelx == DMA2_Channel1)
  177. {
  178. /* Reset interrupt pending bits for DMA2 Channel1 */
  179. DMA2->IFCR |= DMA2_CHANNEL1_IT_MASK;
  180. }
  181. else if (DMAy_Channelx == DMA2_Channel2)
  182. {
  183. /* Reset interrupt pending bits for DMA2 Channel2 */
  184. DMA2->IFCR |= DMA2_CHANNEL2_IT_MASK;
  185. }
  186. else if (DMAy_Channelx == DMA2_Channel3)
  187. {
  188. /* Reset interrupt pending bits for DMA2 Channel3 */
  189. DMA2->IFCR |= DMA2_CHANNEL3_IT_MASK;
  190. }
  191. else if (DMAy_Channelx == DMA2_Channel4)
  192. {
  193. /* Reset interrupt pending bits for DMA2 Channel4 */
  194. DMA2->IFCR |= DMA2_CHANNEL4_IT_MASK;
  195. }
  196. else
  197. {
  198. if (DMAy_Channelx == DMA2_Channel5)
  199. {
  200. /* Reset interrupt pending bits for DMA2 Channel5 */
  201. DMA2->IFCR |= DMA2_CHANNEL5_IT_MASK;
  202. }
  203. }
  204. }
  205. /**
  206. * @brief Initializes the DMAy Channelx according to the specified parameters
  207. * in the DMA_InitStruct.
  208. * @param DMAy_Channelx: where y can be 1 to select the DMA and x can be 1 to 7
  209. * for DMA1 to select the DMA Channel and 1 to 5 for DMA2 to select the DMA Channel.
  210. * @note DMA1 Channel 6 and 7 are available only for STM32F072 and STM32F091 devices.
  211. * @note DMA2 Channel 1 to 5 are available only for STM32F091 devices.
  212. * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that contains
  213. * the configuration information for the specified DMA Channel.
  214. * @retval None
  215. */
  216. void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct)
  217. {
  218. uint32_t tmpreg = 0;
  219. /* Check the parameters */
  220. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  221. assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR));
  222. assert_param(IS_DMA_BUFFER_SIZE(DMA_InitStruct->DMA_BufferSize));
  223. assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc));
  224. assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc));
  225. assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize));
  226. assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize));
  227. assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode));
  228. assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority));
  229. assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M));
  230. /*--------------------------- DMAy Channelx CCR Configuration ----------------*/
  231. /* Get the DMAy_Channelx CCR value */
  232. tmpreg = DMAy_Channelx->CCR;
  233. /* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */
  234. tmpreg &= CCR_CLEAR_MASK;
  235. /* Configure DMAy Channelx: data transfer, data size, priority level and mode */
  236. /* Set DIR bit according to DMA_DIR value */
  237. /* Set CIRC bit according to DMA_Mode value */
  238. /* Set PINC bit according to DMA_PeripheralInc value */
  239. /* Set MINC bit according to DMA_MemoryInc value */
  240. /* Set PSIZE bits according to DMA_PeripheralDataSize value */
  241. /* Set MSIZE bits according to DMA_MemoryDataSize value */
  242. /* Set PL bits according to DMA_Priority value */
  243. /* Set the MEM2MEM bit according to DMA_M2M value */
  244. tmpreg |= DMA_InitStruct->DMA_DIR | DMA_InitStruct->DMA_Mode |
  245. DMA_InitStruct->DMA_PeripheralInc | DMA_InitStruct->DMA_MemoryInc |
  246. DMA_InitStruct->DMA_PeripheralDataSize | DMA_InitStruct->DMA_MemoryDataSize |
  247. DMA_InitStruct->DMA_Priority | DMA_InitStruct->DMA_M2M;
  248. /* Write to DMAy Channelx CCR */
  249. DMAy_Channelx->CCR = tmpreg;
  250. /*--------------------------- DMAy Channelx CNDTR Configuration --------------*/
  251. /* Write to DMAy Channelx CNDTR */
  252. DMAy_Channelx->CNDTR = DMA_InitStruct->DMA_BufferSize;
  253. /*--------------------------- DMAy Channelx CPAR Configuration ---------------*/
  254. /* Write to DMAy Channelx CPAR */
  255. DMAy_Channelx->CPAR = DMA_InitStruct->DMA_PeripheralBaseAddr;
  256. /*--------------------------- DMAy Channelx CMAR Configuration ---------------*/
  257. /* Write to DMAy Channelx CMAR */
  258. DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr;
  259. }
  260. /**
  261. * @brief Fills each DMA_InitStruct member with its default value.
  262. * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure which will
  263. * be initialized.
  264. * @retval None
  265. */
  266. void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct)
  267. {
  268. /*-------------- Reset DMA init structure parameters values ------------------*/
  269. /* Initialize the DMA_PeripheralBaseAddr member */
  270. DMA_InitStruct->DMA_PeripheralBaseAddr = 0;
  271. /* Initialize the DMA_MemoryBaseAddr member */
  272. DMA_InitStruct->DMA_MemoryBaseAddr = 0;
  273. /* Initialize the DMA_DIR member */
  274. DMA_InitStruct->DMA_DIR = DMA_DIR_PeripheralSRC;
  275. /* Initialize the DMA_BufferSize member */
  276. DMA_InitStruct->DMA_BufferSize = 0;
  277. /* Initialize the DMA_PeripheralInc member */
  278. DMA_InitStruct->DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  279. /* Initialize the DMA_MemoryInc member */
  280. DMA_InitStruct->DMA_MemoryInc = DMA_MemoryInc_Disable;
  281. /* Initialize the DMA_PeripheralDataSize member */
  282. DMA_InitStruct->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  283. /* Initialize the DMA_MemoryDataSize member */
  284. DMA_InitStruct->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  285. /* Initialize the DMA_Mode member */
  286. DMA_InitStruct->DMA_Mode = DMA_Mode_Normal;
  287. /* Initialize the DMA_Priority member */
  288. DMA_InitStruct->DMA_Priority = DMA_Priority_Low;
  289. /* Initialize the DMA_M2M member */
  290. DMA_InitStruct->DMA_M2M = DMA_M2M_Disable;
  291. }
  292. /**
  293. * @brief Enables or disables the specified DMAy Channelx.
  294. * @param DMAy_Channelx: where y can be 1 to select the DMA and x can be 1 to 7
  295. * for DMA1 to select the DMA Channel and 1 to 5 for DMA2 to select the DMA Channel.
  296. * @note DMA1 Channel 6 and 7 are available only for STM32F072 and STM32F091 devices.
  297. * @note DMA2 Channel 1 to 5 are available only for STM32F091 devices.
  298. * @param NewState: new state of the DMAy Channelx.
  299. * This parameter can be: ENABLE or DISABLE.
  300. * @retval None
  301. */
  302. void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState)
  303. {
  304. /* Check the parameters */
  305. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  306. assert_param(IS_FUNCTIONAL_STATE(NewState));
  307. if (NewState != DISABLE)
  308. {
  309. /* Enable the selected DMAy Channelx */
  310. DMAy_Channelx->CCR |= DMA_CCR_EN;
  311. }
  312. else
  313. {
  314. /* Disable the selected DMAy Channelx */
  315. DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR_EN);
  316. }
  317. }
  318. /**
  319. * @brief Configure the DMAx channels remapping.
  320. * @param DMAy: where x can be 1 or 2 to select the DMA peripheral.
  321. * @param DMAy_CHx_RemapRequest: where y can be 1 or 2 to select the DMA and x can be 1 to 7
  322. * for DMA1 to select the DMA1 Channel and can be 1 to 5 for DMA2 to select the DMA2 Channel.
  323. * @note This function is available only for STM32F091 devices.
  324. * @retval None
  325. */
  326. void DMA_RemapConfig(DMA_TypeDef* DMAy, uint32_t DMAx_CHy_RemapRequest)
  327. {
  328. assert_param(IS_DMA_ALL_LIST(DMAy));
  329. if (DMAy == DMA1)
  330. {
  331. assert_param(IS_DMA1_REMAP(DMAx_CHy_RemapRequest));
  332. }
  333. else
  334. {
  335. assert_param(IS_DMA2_REMAP(DMAx_CHy_RemapRequest));
  336. }
  337. DMAy->RMPCR &= ~((uint32_t)0x0F << (uint32_t)((DMAx_CHy_RemapRequest >> 28) * 4));
  338. DMAy->RMPCR |= (uint32_t)(DMAx_CHy_RemapRequest & 0x0FFFFFFF);
  339. }
  340. /**
  341. * @}
  342. */
  343. /** @defgroup DMA_Group2 Data Counter functions
  344. * @brief Data Counter functions
  345. *
  346. @verbatim
  347. ===============================================================================
  348. ##### Data Counter functions #####
  349. ===============================================================================
  350. [..] This subsection provides function allowing to configure and read the buffer
  351. size (number of data to be transferred).The DMA data counter can be written
  352. only when the DMA channel is disabled (ie. after transfer complete event).
  353. [..] The following function can be used to write the Channel data counter value:
  354. (+) void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t
  355. DataNumber).
  356. -@- It is advised to use this function rather than DMA_Init() in situations
  357. where only the Data buffer needs to be reloaded.
  358. [..] The DMA data counter can be read to indicate the number of remaining transfers
  359. for the relative DMA channel. This counter is decremented at the end of each
  360. data transfer and when the transfer is complete:
  361. (+) If Normal mode is selected: the counter is set to 0.
  362. (+) If Circular mode is selected: the counter is reloaded with the initial
  363. value(configured before enabling the DMA channel).
  364. [..] The following function can be used to read the Channel data counter value:
  365. (+) uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx).
  366. @endverbatim
  367. * @{
  368. */
  369. /**
  370. * @brief Sets the number of data units in the current DMAy Channelx transfer.
  371. * @param DMAy_Channelx: where y can be 1 to select the DMA and x can be 1 to 7
  372. * for DMA1 to select the DMA Channel and 1 to 5 for DMA2 to select the DMA Channel.
  373. * @note DMA1 Channel 6 and 7 are available only for STM32F072 and STM32F091 devices.
  374. * @note DMA2 Channel 1 to 5 are available only for STM32F091 devices.
  375. * @param DataNumber: The number of data units in the current DMAy Channelx
  376. * transfer.
  377. * @note This function can only be used when the DMAy_Channelx is disabled.
  378. * @retval None.
  379. */
  380. void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber)
  381. {
  382. /* Check the parameters */
  383. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  384. /*--------------------------- DMAy Channelx CNDTR Configuration --------------*/
  385. /* Write to DMAy Channelx CNDTR */
  386. DMAy_Channelx->CNDTR = DataNumber;
  387. }
  388. /**
  389. * @brief Returns the number of remaining data units in the current
  390. * DMAy Channelx transfer.
  391. * @param DMAy_Channelx: where y can be 1 to select the DMA and x can be 1 to 7
  392. * for DMA1 to select the DMA Channel and 1 to 5 for DMA2 to select the DMA Channel.
  393. * @note DMA1 Channel 6 and 7 are available only for STM32F072 and STM32F091 devices.
  394. * @note DMA2 Channel 1 to 5 are available only for STM32F091 devices.
  395. * @retval The number of remaining data units in the current DMAy Channelx
  396. * transfer.
  397. */
  398. uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx)
  399. {
  400. /* Check the parameters */
  401. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  402. /* Return the number of remaining data units for DMAy Channelx */
  403. return ((uint16_t)(DMAy_Channelx->CNDTR));
  404. }
  405. /**
  406. * @}
  407. */
  408. /** @defgroup DMA_Group3 Interrupts and flags management functions
  409. * @brief Interrupts and flags management functions
  410. *
  411. @verbatim
  412. ===============================================================================
  413. ##### Interrupts and flags management functions #####
  414. ===============================================================================
  415. [..] This subsection provides functions allowing to configure the DMA Interrupts
  416. sources and check or clear the flags or pending bits status.
  417. The user should identify which mode will be used in his application to manage
  418. the DMA controller events: Polling mode or Interrupt mode.
  419. *** Polling Mode ***
  420. ====================
  421. [..] Each DMA channel can be managed through 4 event Flags:(y : DMA Controller
  422. number x : DMA channel number ).
  423. (#) DMAy_FLAG_TCx : to indicate that a Transfer Complete event occurred.
  424. (#) DMAy_FLAG_HTx : to indicate that a Half-Transfer Complete event occurred.
  425. (#) DMAy_FLAG_TEx : to indicate that a Transfer Error occurred.
  426. (#) DMAy_FLAG_GLx : to indicate that at least one of the events described
  427. above occurred.
  428. -@- Clearing DMAy_FLAG_GLx results in clearing all other pending flags of the
  429. same channel (DMAy_FLAG_TCx, DMAy_FLAG_HTx and DMAy_FLAG_TEx).
  430. [..]In this Mode it is advised to use the following functions:
  431. (+) FlagStatus DMA_GetFlagStatus(uint32_t DMA_FLAG);
  432. (+) void DMA_ClearFlag(uint32_t DMA_FLAG);
  433. *** Interrupt Mode ***
  434. ======================
  435. [..] Each DMA channel can be managed through 4 Interrupts:
  436. (+) Interrupt Source
  437. (##) DMA_IT_TC: specifies the interrupt source for the Transfer Complete
  438. event.
  439. (##) DMA_IT_HT : specifies the interrupt source for the Half-transfer Complete
  440. event.
  441. (##) DMA_IT_TE : specifies the interrupt source for the transfer errors event.
  442. (##) DMA_IT_GL : to indicate that at least one of the interrupts described
  443. above occurred.
  444. -@@- Clearing DMA_IT_GL interrupt results in clearing all other interrupts of
  445. the same channel (DMA_IT_TCx, DMA_IT_HT and DMA_IT_TE).
  446. [..]In this Mode it is advised to use the following functions:
  447. (+) void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT,
  448. FunctionalState NewState);
  449. (+) ITStatus DMA_GetITStatus(uint32_t DMA_IT);
  450. (+) void DMA_ClearITPendingBit(uint32_t DMA_IT);
  451. @endverbatim
  452. * @{
  453. */
  454. /**
  455. * @brief Enables or disables the specified DMAy Channelx interrupts.
  456. * @param DMAy_Channelx: where y can be 1 to select the DMA and x can be 1 to 7
  457. * for DMA1 to select the DMA Channel and 1 to 5 for DMA2 to select the DMA Channel.
  458. * @note DMA1 Channel 6 and 7 are available only for STM32F072 and STM32F091 devices.
  459. * @note DMA2 Channel 1 to 5 are available only for STM32F091 devices.
  460. * @param DMA_IT: specifies the DMA interrupts sources to be enabled
  461. * or disabled.
  462. * This parameter can be any combination of the following values:
  463. * @arg DMA_IT_TC: Transfer complete interrupt mask
  464. * @arg DMA_IT_HT: Half transfer interrupt mask
  465. * @arg DMA_IT_TE: Transfer error interrupt mask
  466. * @param NewState: new state of the specified DMA interrupts.
  467. * This parameter can be: ENABLE or DISABLE.
  468. * @retval None
  469. */
  470. void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
  471. {
  472. /* Check the parameters */
  473. assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  474. assert_param(IS_DMA_CONFIG_IT(DMA_IT));
  475. assert_param(IS_FUNCTIONAL_STATE(NewState));
  476. if (NewState != DISABLE)
  477. {
  478. /* Enable the selected DMA interrupts */
  479. DMAy_Channelx->CCR |= DMA_IT;
  480. }
  481. else
  482. {
  483. /* Disable the selected DMA interrupts */
  484. DMAy_Channelx->CCR &= ~DMA_IT;
  485. }
  486. }
  487. /**
  488. * @brief Checks whether the specified DMAy Channelx flag is set or not.
  489. * @param DMA_FLAG: specifies the flag to check.
  490. * This parameter can be one of the following values:
  491. * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
  492. * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
  493. * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
  494. * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
  495. * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
  496. * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
  497. * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
  498. * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
  499. * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
  500. * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
  501. * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
  502. * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
  503. * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
  504. * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
  505. * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
  506. * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
  507. * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
  508. * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
  509. * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
  510. * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
  511. * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag, applicable only for STM32F072 and STM32FO91 devices.
  512. * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag, applicable only for STM32F072 and STM32FO91 devices.
  513. * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag, applicable only for STM32F072 and STM32FO91 devices.
  514. * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag, applicable only for STM32F072 and STM32FO91 devices.
  515. * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag, applicable only for STM32F072 and STM32FO91 devices.
  516. * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag, applicable only for STM32F072 and STM32FO91 devices.
  517. * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag, applicable only for STM32F072 and STM32FO91 devices.
  518. * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag, applicable only for STM32F072 and STM32FO91 devices.
  519. * @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag, applicable only for STM32FO91 devices.
  520. * @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag, applicable only for STM32FO91 devices.
  521. * @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag, applicable only for STM32FO91 devices.
  522. * @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag, applicable only for STM32FO91 devices.
  523. * @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag, applicable only for STM32FO91 devices.
  524. * @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag, applicable only for STM32FO91 devices.
  525. * @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag, applicable only for STM32FO91 devices.
  526. * @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag, applicable only for STM32FO91 devices.
  527. * @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag, applicable only for STM32FO91 devices.
  528. * @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag, applicable only for STM32FO91 devices.
  529. * @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag, applicable only for STM32FO91 devices.
  530. * @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag, applicable only for STM32FO91 devices.
  531. * @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag, applicable only for STM32FO91 devices.
  532. * @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag, applicable only for STM32FO91 devices.
  533. * @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag, applicable only for STM32FO91 devices.
  534. * @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag, applicable only for STM32FO91 devices.
  535. * @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag, applicable only for STM32FO91 devices.
  536. * @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag, applicable only for STM32FO91 devices.
  537. * @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag, applicable only for STM32FO91 devices.
  538. * @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag, applicable only for STM32FO91 devices.
  539. * @note The Global flag (DMAy_FLAG_GLx) is set whenever any of the other flags
  540. * relative to the same channel is set (Transfer Complete, Half-transfer
  541. * Complete or Transfer Error flags: DMAy_FLAG_TCx, DMAy_FLAG_HTx or
  542. * DMAy_FLAG_TEx).
  543. *
  544. * @retval The new state of DMA_FLAG (SET or RESET).
  545. */
  546. FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
  547. {
  548. FlagStatus bitstatus = RESET;
  549. uint32_t tmpreg = 0;
  550. /* Check the parameters */
  551. assert_param(IS_DMA_GET_FLAG(DMAy_FLAG));
  552. /* Calculate the used DMAy */
  553. if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET)
  554. {
  555. /* Get DMA2 ISR register value */
  556. tmpreg = DMA2->ISR ;
  557. }
  558. else
  559. {
  560. /* Get DMA1 ISR register value */
  561. tmpreg = DMA1->ISR ;
  562. }
  563. /* Check the status of the specified DMAy flag */
  564. if ((tmpreg & DMAy_FLAG) != (uint32_t)RESET)
  565. {
  566. /* DMAy_FLAG is set */
  567. bitstatus = SET;
  568. }
  569. else
  570. {
  571. /* DMAy_FLAG is reset */
  572. bitstatus = RESET;
  573. }
  574. /* Return the DMAy_FLAG status */
  575. return bitstatus;
  576. }
  577. /**
  578. * @brief Clears the DMAy Channelx's pending flags.
  579. * @param DMA_FLAG: specifies the flag to clear.
  580. * This parameter can be any combination (for the same DMA) of the following values:
  581. * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
  582. * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
  583. * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
  584. * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
  585. * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
  586. * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
  587. * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
  588. * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
  589. * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
  590. * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
  591. * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
  592. * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
  593. * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
  594. * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
  595. * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
  596. * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
  597. * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
  598. * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
  599. * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
  600. * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
  601. * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag, applicable only for STM32F072 and STM32FO91 devices.
  602. * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag, applicable only for STM32F072 and STM32FO91 devices.
  603. * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag, applicable only for STM32F072 and STM32FO91 devices.
  604. * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag, applicable only for STM32F072 and STM32FO91 devices.
  605. * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag, applicable only for STM32F072 and STM32FO91 devices.
  606. * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag, applicable only for STM32F072 and STM32FO91 devices.
  607. * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag, applicable only for STM32F072 and STM32FO91 devices.
  608. * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag, applicable only for STM32F072 and STM32FO91 devices.
  609. * @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag, applicable only for STM32FO91 devices.
  610. * @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag, applicable only for STM32FO91 devices.
  611. * @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag, applicable only for STM32FO91 devices.
  612. * @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag, applicable only for STM32FO91 devices.
  613. * @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag, applicable only for STM32FO91 devices.
  614. * @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag, applicable only for STM32FO91 devices.
  615. * @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag, applicable only for STM32FO91 devices.
  616. * @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag, applicable only for STM32FO91 devices.
  617. * @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag, applicable only for STM32FO91 devices.
  618. * @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag, applicable only for STM32FO91 devices.
  619. * @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag, applicable only for STM32FO91 devices.
  620. * @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag, applicable only for STM32FO91 devices.
  621. * @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag, applicable only for STM32FO91 devices.
  622. * @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag, applicable only for STM32FO91 devices.
  623. * @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag, applicable only for STM32FO91 devices.
  624. * @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag, applicable only for STM32FO91 devices.
  625. * @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag, applicable only for STM32FO91 devices.
  626. * @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag, applicable only for STM32FO91 devices.
  627. * @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag, applicable only for STM32FO91 devices.
  628. * @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag, applicable only for STM32FO91 devices.
  629. *
  630. * @note Clearing the Global flag (DMAy_FLAG_GLx) results in clearing all other flags
  631. * relative to the same channel (Transfer Complete, Half-transfer Complete and
  632. * Transfer Error flags: DMAy_FLAG_TCx, DMAy_FLAG_HTx and DMAy_FLAG_TEx).
  633. *
  634. * @retval None
  635. */
  636. void DMA_ClearFlag(uint32_t DMAy_FLAG)
  637. {
  638. /* Check the parameters */
  639. assert_param(IS_DMA_CLEAR_FLAG(DMAy_FLAG));
  640. /* Calculate the used DMAy */
  641. if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET)
  642. {
  643. /* Clear the selected DMAy flags */
  644. DMA2->IFCR = DMAy_FLAG;
  645. }
  646. else
  647. {
  648. /* Clear the selected DMAy flags */
  649. DMA1->IFCR = DMAy_FLAG;
  650. }
  651. }
  652. /**
  653. * @brief Checks whether the specified DMAy Channelx interrupt has occurred or not.
  654. * @param DMA_IT: specifies the DMA interrupt source to check.
  655. * This parameter can be one of the following values:
  656. * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
  657. * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
  658. * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
  659. * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
  660. * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
  661. * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
  662. * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
  663. * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
  664. * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
  665. * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
  666. * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
  667. * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
  668. * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
  669. * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
  670. * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
  671. * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
  672. * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
  673. * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
  674. * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
  675. * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
  676. * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt, applicable only for STM32F072 and STM32FO91 devices.
  677. * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt, applicable only for STM32F072 and STM32FO91 devices.
  678. * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt, applicable only for STM32F072 and STM32FO91 devices.
  679. * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt, applicable only for STM32F072 and STM32FO91 devices.
  680. * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt, applicable only for STM32F072 and STM32FO91 devices.
  681. * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt, applicable only for STM32F072 and STM32FO91 devices.
  682. * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt, applicable only for STM32F072 and STM32FO91 devices.
  683. * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt, applicable only for STM32F072 and STM32FO91 devices.
  684. * @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt, applicable only for STM32FO91 devices.
  685. * @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt, applicable only for STM32FO91 devices.
  686. * @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt, applicable only for STM32FO91 devices.
  687. * @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt, applicable only for STM32FO91 devices.
  688. * @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt, applicable only for STM32FO91 devices.
  689. * @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt, applicable only for STM32FO91 devices.
  690. * @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt, applicable only for STM32FO91 devices.
  691. * @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt, applicable only for STM32FO91 devices.
  692. * @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt, applicable only for STM32FO91 devices.
  693. * @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt, applicable only for STM32FO91 devices.
  694. * @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt, applicable only for STM32FO91 devices.
  695. * @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt, applicable only for STM32FO91 devices.
  696. * @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt, applicable only for STM32FO91 devices.
  697. * @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt, applicable only for STM32FO91 devices.
  698. * @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt, applicable only for STM32FO91 devices.
  699. * @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt, applicable only for STM32FO91 devices.
  700. * @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt, applicable only for STM32FO91 devices.
  701. * @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt, applicable only for STM32FO91 devices.
  702. * @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt, applicable only for STM32FO91 devices.
  703. * @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt, applicable only for STM32FO91 devices.
  704. * @note The Global interrupt (DMAy_FLAG_GLx) is set whenever any of the other
  705. * interrupts relative to the same channel is set (Transfer Complete,
  706. * Half-transfer Complete or Transfer Error interrupts: DMAy_IT_TCx,
  707. * DMAy_IT_HTx or DMAy_IT_TEx).
  708. *
  709. * @retval The new state of DMA_IT (SET or RESET).
  710. */
  711. ITStatus DMA_GetITStatus(uint32_t DMAy_IT)
  712. {
  713. ITStatus bitstatus = RESET;
  714. uint32_t tmpreg = 0;
  715. /* Check the parameters */
  716. assert_param(IS_DMA_GET_IT(DMAy_IT));
  717. /* Calculate the used DMA */
  718. if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET)
  719. {
  720. /* Get DMA2 ISR register value */
  721. tmpreg = DMA2->ISR;
  722. }
  723. else
  724. {
  725. /* Get DMA1 ISR register value */
  726. tmpreg = DMA1->ISR;
  727. }
  728. /* Check the status of the specified DMAy interrupt */
  729. if ((tmpreg & DMAy_IT) != (uint32_t)RESET)
  730. {
  731. /* DMAy_IT is set */
  732. bitstatus = SET;
  733. }
  734. else
  735. {
  736. /* DMAy_IT is reset */
  737. bitstatus = RESET;
  738. }
  739. /* Return the DMAy_IT status */
  740. return bitstatus;
  741. }
  742. /**
  743. * @brief Clears the DMAy Channelx's interrupt pending bits.
  744. * @param DMA_IT: specifies the DMA interrupt pending bit to clear.
  745. * This parameter can be any combination (for the same DMA) of the following values:
  746. * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
  747. * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
  748. * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
  749. * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
  750. * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
  751. * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
  752. * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
  753. * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
  754. * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
  755. * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
  756. * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
  757. * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
  758. * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
  759. * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
  760. * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
  761. * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
  762. * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
  763. * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
  764. * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
  765. * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
  766. * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt, applicable only for STM32F072 and STM32FO91 devices.
  767. * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt, applicable only for STM32F072 and STM32FO91 devices.
  768. * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt, applicable only for STM32F072 and STM32FO91 devices.
  769. * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt, applicable only for STM32F072 and STM32FO91 devices.
  770. * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt, applicable only for STM32F072 and STM32FO91 devices.
  771. * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt, applicable only for STM32F072 and STM32FO91 devices.
  772. * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt, applicable only for STM32F072 and STM32FO91 devices.
  773. * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt, applicable only for STM32F072 and STM32FO91 devices.
  774. * @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt, applicable only for STM32FO91 devices.
  775. * @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt, applicable only for STM32FO91 devices.
  776. * @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt, applicable only for STM32FO91 devices.
  777. * @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt, applicable only for STM32FO91 devices.
  778. * @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt, applicable only for STM32FO91 devices.
  779. * @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt, applicable only for STM32FO91 devices.
  780. * @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt, applicable only for STM32FO91 devices.
  781. * @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt, applicable only for STM32FO91 devices.
  782. * @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt, applicable only for STM32FO91 devices.
  783. * @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt, applicable only for STM32FO91 devices.
  784. * @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt, applicable only for STM32FO91 devices.
  785. * @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt, applicable only for STM32FO91 devices.
  786. * @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt, applicable only for STM32FO91 devices.
  787. * @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt, applicable only for STM32FO91 devices.
  788. * @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt, applicable only for STM32FO91 devices.
  789. * @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt, applicable only for STM32FO91 devices.
  790. * @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt, applicable only for STM32FO91 devices.
  791. * @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt, applicable only for STM32FO91 devices.
  792. * @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt, applicable only for STM32FO91 devices.
  793. * @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt, applicable only for STM32FO91 devices.
  794. *
  795. * @note Clearing the Global interrupt (DMAy_IT_GLx) results in clearing all other
  796. * interrupts relative to the same channel (Transfer Complete, Half-transfer
  797. * Complete and Transfer Error interrupts: DMAy_IT_TCx, DMAy_IT_HTx and
  798. * DMAy_IT_TEx).
  799. *
  800. * @retval None
  801. */
  802. void DMA_ClearITPendingBit(uint32_t DMAy_IT)
  803. {
  804. /* Check the parameters */
  805. assert_param(IS_DMA_CLEAR_IT(DMAy_IT));
  806. /* Calculate the used DMAy */
  807. if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET)
  808. {
  809. /* Clear the selected DMAy interrupt pending bits */
  810. DMA2->IFCR = DMAy_IT;
  811. }
  812. else
  813. {
  814. /* Clear the selected DMAy interrupt pending bits */
  815. DMA1->IFCR = DMAy_IT;
  816. }
  817. }
  818. /**
  819. * @}
  820. */
  821. /**
  822. * @}
  823. */
  824. /**
  825. * @}
  826. */
  827. /**
  828. * @}
  829. */
  830. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/