stm32g0xx_ll_dma.h 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272
  1. /**
  2. ******************************************************************************
  3. * @file stm32g0xx_ll_dma.h
  4. * @author MCD Application Team
  5. * @brief Header file of DMA LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32G0xx_LL_DMA_H
  21. #define STM32G0xx_LL_DMA_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32g0xx.h"
  27. #include "stm32g0xx_ll_dmamux.h"
  28. /** @addtogroup STM32G0xx_LL_Driver
  29. * @{
  30. */
  31. #if defined (DMA1) || defined (DMA2)
  32. /** @defgroup DMA_LL DMA
  33. * @{
  34. */
  35. /* Private types -------------------------------------------------------------*/
  36. /* Private variables ---------------------------------------------------------*/
  37. /** @defgroup DMA_LL_Private_Variables DMA Private Variables
  38. * @{
  39. */
  40. /* Array used to get the DMA channel register offset versus channel index LL_DMA_CHANNEL_x */
  41. static const uint8_t CHANNEL_OFFSET_TAB[] =
  42. {
  43. (uint8_t)(DMA1_Channel1_BASE - DMA1_BASE),
  44. (uint8_t)(DMA1_Channel2_BASE - DMA1_BASE),
  45. (uint8_t)(DMA1_Channel3_BASE - DMA1_BASE),
  46. (uint8_t)(DMA1_Channel4_BASE - DMA1_BASE),
  47. (uint8_t)(DMA1_Channel5_BASE - DMA1_BASE),
  48. #if defined(DMA1_Channel6_BASE)
  49. (uint8_t)(DMA1_Channel6_BASE - DMA1_BASE),
  50. #endif
  51. #if defined(DMA1_Channel7_BASE)
  52. (uint8_t)(DMA1_Channel7_BASE - DMA1_BASE),
  53. #endif
  54. };
  55. /**
  56. * @}
  57. */
  58. /* Private constants ---------------------------------------------------------*/
  59. /* Private macros ------------------------------------------------------------*/
  60. /** @defgroup DMA_LL_Private_Macros DMA Private Macros
  61. * @{
  62. */
  63. /**
  64. * @brief Helper macro to convert DMA Instance DMAx into DMAMUX channel
  65. * @note DMAMUX channel 0 to 6 are mapped to DMA1 channel 1 to 7.
  66. * DMAMUX channel 7 to 11 are mapped to DMA2 channel 1 to 5 (**** only available on chip which support DMA2 ****).
  67. * @param __DMA_INSTANCE__ DMAx
  68. * @retval Channel_Offset (LL_DMA_CHANNEL_7 or 0).
  69. */
  70. #define __LL_DMA_INSTANCE_TO_DMAMUX_CHANNEL(__DMA_INSTANCE__) \
  71. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) ? 0 : LL_DMA_CHANNEL_7)
  72. /**
  73. * @}
  74. */
  75. /* Exported types ------------------------------------------------------------*/
  76. #if defined(USE_FULL_LL_DRIVER)
  77. /** @defgroup DMA_LL_ES_INIT DMA Exported Init structure
  78. * @{
  79. */
  80. typedef struct
  81. {
  82. uint32_t PeriphOrM2MSrcAddress; /*!< Specifies the peripheral base address for DMA transfer
  83. or as Source base address in case of memory to memory transfer direction.
  84. This parameter must be a value between Min_Data = 0 and Max_Data = 0xFFFFFFFF. */
  85. uint32_t MemoryOrM2MDstAddress; /*!< Specifies the memory base address for DMA transfer
  86. or as Destination base address in case of memory to memory transfer direction.
  87. This parameter must be a value between Min_Data = 0 and Max_Data = 0xFFFFFFFF. */
  88. uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
  89. from memory to memory or from peripheral to memory.
  90. This parameter can be a value of @ref DMA_LL_EC_DIRECTION
  91. This feature can be modified afterwards using unitary function @ref LL_DMA_SetDataTransferDirection(). */
  92. uint32_t Mode; /*!< Specifies the normal or circular operation mode.
  93. This parameter can be a value of @ref DMA_LL_EC_MODE
  94. @note: The circular buffer mode cannot be used if the memory to memory
  95. data transfer direction is configured on the selected Channel
  96. This feature can be modified afterwards using unitary function @ref LL_DMA_SetMode(). */
  97. uint32_t PeriphOrM2MSrcIncMode; /*!< Specifies whether the Peripheral address or Source address in case of memory to memory transfer direction
  98. is incremented or not.
  99. This parameter can be a value of @ref DMA_LL_EC_PERIPH
  100. This feature can be modified afterwards using unitary function @ref LL_DMA_SetPeriphIncMode(). */
  101. uint32_t MemoryOrM2MDstIncMode; /*!< Specifies whether the Memory address or Destination address in case of memory to memory transfer direction
  102. is incremented or not.
  103. This parameter can be a value of @ref DMA_LL_EC_MEMORY
  104. This feature can be modified afterwards using unitary function @ref LL_DMA_SetMemoryIncMode(). */
  105. uint32_t PeriphOrM2MSrcDataSize; /*!< Specifies the Peripheral data size alignment or Source data size alignment (byte, half word, word)
  106. in case of memory to memory transfer direction.
  107. This parameter can be a value of @ref DMA_LL_EC_PDATAALIGN
  108. This feature can be modified afterwards using unitary function @ref LL_DMA_SetPeriphSize(). */
  109. uint32_t MemoryOrM2MDstDataSize; /*!< Specifies the Memory data size alignment or Destination data size alignment (byte, half word, word)
  110. in case of memory to memory transfer direction.
  111. This parameter can be a value of @ref DMA_LL_EC_MDATAALIGN
  112. This feature can be modified afterwards using unitary function @ref LL_DMA_SetMemorySize(). */
  113. uint32_t NbData; /*!< Specifies the number of data to transfer, in data unit.
  114. The data unit is equal to the source buffer configuration set in PeripheralSize
  115. or MemorySize parameters depending in the transfer direction.
  116. This parameter must be a value between Min_Data = 0 and Max_Data = 0x0000FFFF
  117. This feature can be modified afterwards using unitary function @ref LL_DMA_SetDataLength(). */
  118. uint32_t PeriphRequest; /*!< Specifies the peripheral request.
  119. This parameter can be a value of @ref DMAMUX_LL_EC_REQUEST
  120. This feature can be modified afterwards using unitary function @ref LL_DMA_SetPeriphRequest(). */
  121. uint32_t Priority; /*!< Specifies the channel priority level.
  122. This parameter can be a value of @ref DMA_LL_EC_PRIORITY
  123. This feature can be modified afterwards using unitary function @ref LL_DMA_SetChannelPriorityLevel(). */
  124. } LL_DMA_InitTypeDef;
  125. /**
  126. * @}
  127. */
  128. #endif /*USE_FULL_LL_DRIVER*/
  129. /* Exported constants --------------------------------------------------------*/
  130. /** @defgroup DMA_LL_Exported_Constants DMA Exported Constants
  131. * @{
  132. */
  133. /** @defgroup DMA_LL_EC_CLEAR_FLAG Clear Flags Defines
  134. * @brief Flags defines which can be used with LL_DMA_WriteReg function
  135. * @{
  136. */
  137. #define LL_DMA_IFCR_CGIF1 DMA_IFCR_CGIF1 /*!< Channel 1 global flag */
  138. #define LL_DMA_IFCR_CTCIF1 DMA_IFCR_CTCIF1 /*!< Channel 1 transfer complete flag */
  139. #define LL_DMA_IFCR_CHTIF1 DMA_IFCR_CHTIF1 /*!< Channel 1 half transfer flag */
  140. #define LL_DMA_IFCR_CTEIF1 DMA_IFCR_CTEIF1 /*!< Channel 1 transfer error flag */
  141. #define LL_DMA_IFCR_CGIF2 DMA_IFCR_CGIF2 /*!< Channel 2 global flag */
  142. #define LL_DMA_IFCR_CTCIF2 DMA_IFCR_CTCIF2 /*!< Channel 2 transfer complete flag */
  143. #define LL_DMA_IFCR_CHTIF2 DMA_IFCR_CHTIF2 /*!< Channel 2 half transfer flag */
  144. #define LL_DMA_IFCR_CTEIF2 DMA_IFCR_CTEIF2 /*!< Channel 2 transfer error flag */
  145. #define LL_DMA_IFCR_CGIF3 DMA_IFCR_CGIF3 /*!< Channel 3 global flag */
  146. #define LL_DMA_IFCR_CTCIF3 DMA_IFCR_CTCIF3 /*!< Channel 3 transfer complete flag */
  147. #define LL_DMA_IFCR_CHTIF3 DMA_IFCR_CHTIF3 /*!< Channel 3 half transfer flag */
  148. #define LL_DMA_IFCR_CTEIF3 DMA_IFCR_CTEIF3 /*!< Channel 3 transfer error flag */
  149. #define LL_DMA_IFCR_CGIF4 DMA_IFCR_CGIF4 /*!< Channel 4 global flag */
  150. #define LL_DMA_IFCR_CTCIF4 DMA_IFCR_CTCIF4 /*!< Channel 4 transfer complete flag */
  151. #define LL_DMA_IFCR_CHTIF4 DMA_IFCR_CHTIF4 /*!< Channel 4 half transfer flag */
  152. #define LL_DMA_IFCR_CTEIF4 DMA_IFCR_CTEIF4 /*!< Channel 4 transfer error flag */
  153. #define LL_DMA_IFCR_CGIF5 DMA_IFCR_CGIF5 /*!< Channel 5 global flag */
  154. #define LL_DMA_IFCR_CTCIF5 DMA_IFCR_CTCIF5 /*!< Channel 5 transfer complete flag */
  155. #define LL_DMA_IFCR_CHTIF5 DMA_IFCR_CHTIF5 /*!< Channel 5 half transfer flag */
  156. #define LL_DMA_IFCR_CTEIF5 DMA_IFCR_CTEIF5 /*!< Channel 5 transfer error flag */
  157. #if defined(DMA1_Channel6)
  158. #define LL_DMA_IFCR_CGIF6 DMA_IFCR_CGIF6 /*!< Channel 6 global flag */
  159. #define LL_DMA_IFCR_CTCIF6 DMA_IFCR_CTCIF6 /*!< Channel 6 transfer complete flag */
  160. #define LL_DMA_IFCR_CHTIF6 DMA_IFCR_CHTIF6 /*!< Channel 6 half transfer flag */
  161. #define LL_DMA_IFCR_CTEIF6 DMA_IFCR_CTEIF6 /*!< Channel 6 transfer error flag */
  162. #endif
  163. #if defined(DMA1_Channel7)
  164. #define LL_DMA_IFCR_CGIF7 DMA_IFCR_CGIF7 /*!< Channel 7 global flag */
  165. #define LL_DMA_IFCR_CTCIF7 DMA_IFCR_CTCIF7 /*!< Channel 7 transfer complete flag */
  166. #define LL_DMA_IFCR_CHTIF7 DMA_IFCR_CHTIF7 /*!< Channel 7 half transfer flag */
  167. #define LL_DMA_IFCR_CTEIF7 DMA_IFCR_CTEIF7 /*!< Channel 7 transfer error flag */
  168. #endif
  169. /**
  170. * @}
  171. */
  172. /** @defgroup DMA_LL_EC_GET_FLAG Get Flags Defines
  173. * @brief Flags defines which can be used with LL_DMA_ReadReg function
  174. * @{
  175. */
  176. #define LL_DMA_ISR_GIF1 DMA_ISR_GIF1 /*!< Channel 1 global flag */
  177. #define LL_DMA_ISR_TCIF1 DMA_ISR_TCIF1 /*!< Channel 1 transfer complete flag */
  178. #define LL_DMA_ISR_HTIF1 DMA_ISR_HTIF1 /*!< Channel 1 half transfer flag */
  179. #define LL_DMA_ISR_TEIF1 DMA_ISR_TEIF1 /*!< Channel 1 transfer error flag */
  180. #define LL_DMA_ISR_GIF2 DMA_ISR_GIF2 /*!< Channel 2 global flag */
  181. #define LL_DMA_ISR_TCIF2 DMA_ISR_TCIF2 /*!< Channel 2 transfer complete flag */
  182. #define LL_DMA_ISR_HTIF2 DMA_ISR_HTIF2 /*!< Channel 2 half transfer flag */
  183. #define LL_DMA_ISR_TEIF2 DMA_ISR_TEIF2 /*!< Channel 2 transfer error flag */
  184. #define LL_DMA_ISR_GIF3 DMA_ISR_GIF3 /*!< Channel 3 global flag */
  185. #define LL_DMA_ISR_TCIF3 DMA_ISR_TCIF3 /*!< Channel 3 transfer complete flag */
  186. #define LL_DMA_ISR_HTIF3 DMA_ISR_HTIF3 /*!< Channel 3 half transfer flag */
  187. #define LL_DMA_ISR_TEIF3 DMA_ISR_TEIF3 /*!< Channel 3 transfer error flag */
  188. #define LL_DMA_ISR_GIF4 DMA_ISR_GIF4 /*!< Channel 4 global flag */
  189. #define LL_DMA_ISR_TCIF4 DMA_ISR_TCIF4 /*!< Channel 4 transfer complete flag */
  190. #define LL_DMA_ISR_HTIF4 DMA_ISR_HTIF4 /*!< Channel 4 half transfer flag */
  191. #define LL_DMA_ISR_TEIF4 DMA_ISR_TEIF4 /*!< Channel 4 transfer error flag */
  192. #define LL_DMA_ISR_GIF5 DMA_ISR_GIF5 /*!< Channel 5 global flag */
  193. #define LL_DMA_ISR_TCIF5 DMA_ISR_TCIF5 /*!< Channel 5 transfer complete flag */
  194. #define LL_DMA_ISR_HTIF5 DMA_ISR_HTIF5 /*!< Channel 5 half transfer flag */
  195. #define LL_DMA_ISR_TEIF5 DMA_ISR_TEIF5 /*!< Channel 5 transfer error flag */
  196. #if defined(DMA1_Channel6)
  197. #define LL_DMA_ISR_GIF6 DMA_ISR_GIF6 /*!< Channel 6 global flag */
  198. #define LL_DMA_ISR_TCIF6 DMA_ISR_TCIF6 /*!< Channel 6 transfer complete flag */
  199. #define LL_DMA_ISR_HTIF6 DMA_ISR_HTIF6 /*!< Channel 6 half transfer flag */
  200. #define LL_DMA_ISR_TEIF6 DMA_ISR_TEIF6 /*!< Channel 6 transfer error flag */
  201. #endif
  202. #if defined(DMA1_Channel7)
  203. #define LL_DMA_ISR_GIF7 DMA_ISR_GIF7 /*!< Channel 7 global flag */
  204. #define LL_DMA_ISR_TCIF7 DMA_ISR_TCIF7 /*!< Channel 7 transfer complete flag */
  205. #define LL_DMA_ISR_HTIF7 DMA_ISR_HTIF7 /*!< Channel 7 half transfer flag */
  206. #define LL_DMA_ISR_TEIF7 DMA_ISR_TEIF7 /*!< Channel 7 transfer error flag */
  207. #endif
  208. /**
  209. * @}
  210. */
  211. /** @defgroup DMA_LL_EC_IT IT Defines
  212. * @brief IT defines which can be used with LL_DMA_ReadReg and LL_DMA_WriteReg functions
  213. * @{
  214. */
  215. #define LL_DMA_CCR_TCIE DMA_CCR_TCIE /*!< Transfer complete interrupt */
  216. #define LL_DMA_CCR_HTIE DMA_CCR_HTIE /*!< Half Transfer interrupt */
  217. #define LL_DMA_CCR_TEIE DMA_CCR_TEIE /*!< Transfer error interrupt */
  218. /**
  219. * @}
  220. */
  221. /** @defgroup DMA_LL_EC_CHANNEL CHANNEL
  222. * @{
  223. */
  224. #define LL_DMA_CHANNEL_1 0x00000000U /*!< DMA Channel 1 */
  225. #define LL_DMA_CHANNEL_2 0x00000001U /*!< DMA Channel 2 */
  226. #define LL_DMA_CHANNEL_3 0x00000002U /*!< DMA Channel 3 */
  227. #define LL_DMA_CHANNEL_4 0x00000003U /*!< DMA Channel 4 */
  228. #define LL_DMA_CHANNEL_5 0x00000004U /*!< DMA Channel 5 */
  229. #if defined(DMA1_Channel6)
  230. #define LL_DMA_CHANNEL_6 0x00000005U /*!< DMA Channel 6 */
  231. #endif
  232. #if defined(DMA1_Channel7)
  233. #define LL_DMA_CHANNEL_7 0x00000006U /*!< DMA Channel 7 */
  234. #endif
  235. #if defined(USE_FULL_LL_DRIVER)
  236. #define LL_DMA_CHANNEL_ALL 0xFFFF0000U /*!< DMA Channel all (used only for function @ref LL_DMA_DeInit(). */
  237. #endif /*USE_FULL_LL_DRIVER*/
  238. /**
  239. * @}
  240. */
  241. /** @defgroup DMA_LL_EC_DIRECTION Transfer Direction
  242. * @{
  243. */
  244. #define LL_DMA_DIRECTION_PERIPH_TO_MEMORY 0x00000000U /*!< Peripheral to memory direction */
  245. #define LL_DMA_DIRECTION_MEMORY_TO_PERIPH DMA_CCR_DIR /*!< Memory to peripheral direction */
  246. #define LL_DMA_DIRECTION_MEMORY_TO_MEMORY DMA_CCR_MEM2MEM /*!< Memory to memory direction */
  247. /**
  248. * @}
  249. */
  250. /** @defgroup DMA_LL_EC_MODE Transfer mode
  251. * @{
  252. */
  253. #define LL_DMA_MODE_NORMAL 0x00000000U /*!< Normal Mode */
  254. #define LL_DMA_MODE_CIRCULAR DMA_CCR_CIRC /*!< Circular Mode */
  255. /**
  256. * @}
  257. */
  258. /** @defgroup DMA_LL_EC_PERIPH Peripheral increment mode
  259. * @{
  260. */
  261. #define LL_DMA_PERIPH_INCREMENT DMA_CCR_PINC /*!< Peripheral increment mode Enable */
  262. #define LL_DMA_PERIPH_NOINCREMENT 0x00000000U /*!< Peripheral increment mode Disable */
  263. /**
  264. * @}
  265. */
  266. /** @defgroup DMA_LL_EC_MEMORY Memory increment mode
  267. * @{
  268. */
  269. #define LL_DMA_MEMORY_INCREMENT DMA_CCR_MINC /*!< Memory increment mode Enable */
  270. #define LL_DMA_MEMORY_NOINCREMENT 0x00000000U /*!< Memory increment mode Disable */
  271. /**
  272. * @}
  273. */
  274. /** @defgroup DMA_LL_EC_PDATAALIGN Peripheral data alignment
  275. * @{
  276. */
  277. #define LL_DMA_PDATAALIGN_BYTE 0x00000000U /*!< Peripheral data alignment : Byte */
  278. #define LL_DMA_PDATAALIGN_HALFWORD DMA_CCR_PSIZE_0 /*!< Peripheral data alignment : HalfWord */
  279. #define LL_DMA_PDATAALIGN_WORD DMA_CCR_PSIZE_1 /*!< Peripheral data alignment : Word */
  280. /**
  281. * @}
  282. */
  283. /** @defgroup DMA_LL_EC_MDATAALIGN Memory data alignment
  284. * @{
  285. */
  286. #define LL_DMA_MDATAALIGN_BYTE 0x00000000U /*!< Memory data alignment : Byte */
  287. #define LL_DMA_MDATAALIGN_HALFWORD DMA_CCR_MSIZE_0 /*!< Memory data alignment : HalfWord */
  288. #define LL_DMA_MDATAALIGN_WORD DMA_CCR_MSIZE_1 /*!< Memory data alignment : Word */
  289. /**
  290. * @}
  291. */
  292. /** @defgroup DMA_LL_EC_PRIORITY Transfer Priority level
  293. * @{
  294. */
  295. #define LL_DMA_PRIORITY_LOW 0x00000000U /*!< Priority level : Low */
  296. #define LL_DMA_PRIORITY_MEDIUM DMA_CCR_PL_0 /*!< Priority level : Medium */
  297. #define LL_DMA_PRIORITY_HIGH DMA_CCR_PL_1 /*!< Priority level : High */
  298. #define LL_DMA_PRIORITY_VERYHIGH DMA_CCR_PL /*!< Priority level : Very_High */
  299. /**
  300. * @}
  301. */
  302. /**
  303. * @}
  304. */
  305. /* Exported macro ------------------------------------------------------------*/
  306. /** @defgroup DMA_LL_Exported_Macros DMA Exported Macros
  307. * @{
  308. */
  309. /** @defgroup DMA_LL_EM_WRITE_READ Common Write and read registers macros
  310. * @{
  311. */
  312. /**
  313. * @brief Write a value in DMA register
  314. * @param __INSTANCE__ DMA Instance
  315. * @param __REG__ Register to be written
  316. * @param __VALUE__ Value to be written in the register
  317. * @retval None
  318. */
  319. #define LL_DMA_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  320. /**
  321. * @brief Read a value in DMA register
  322. * @param __INSTANCE__ DMA Instance
  323. * @param __REG__ Register to be read
  324. * @retval Register value
  325. */
  326. #define LL_DMA_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  327. /**
  328. * @}
  329. */
  330. /** @defgroup DMA_LL_EM_CONVERT_DMAxCHANNELy Convert DMAxChannely
  331. * @{
  332. */
  333. /**
  334. * @brief Convert DMAx_Channely into DMAx
  335. * @param __CHANNEL_INSTANCE__ DMAx_Channely
  336. * @retval DMAx
  337. */
  338. #if defined(DMA2)
  339. #define __LL_DMA_GET_INSTANCE(__CHANNEL_INSTANCE__) \
  340. (((uint32_t)(__CHANNEL_INSTANCE__) > ((uint32_t)DMA1_Channel7)) ? DMA2 : DMA1)
  341. #else /* DMA1 */
  342. #define __LL_DMA_GET_INSTANCE(__CHANNEL_INSTANCE__) (DMA1)
  343. #endif
  344. /**
  345. * @brief Convert DMAx_Channely into LL_DMA_CHANNEL_y
  346. * @param __CHANNEL_INSTANCE__ DMAx_Channely
  347. * @retval LL_DMA_CHANNEL_y
  348. */
  349. #if defined(DMA2)
  350. #define __LL_DMA_GET_CHANNEL(__CHANNEL_INSTANCE__) \
  351. (((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel1)) ? LL_DMA_CHANNEL_1 : \
  352. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA2_Channel1)) ? LL_DMA_CHANNEL_1 : \
  353. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel2)) ? LL_DMA_CHANNEL_2 : \
  354. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA2_Channel2)) ? LL_DMA_CHANNEL_2 : \
  355. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel3)) ? LL_DMA_CHANNEL_3 : \
  356. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA2_Channel3)) ? LL_DMA_CHANNEL_3 : \
  357. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel4)) ? LL_DMA_CHANNEL_4 : \
  358. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA2_Channel4)) ? LL_DMA_CHANNEL_4 : \
  359. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel5)) ? LL_DMA_CHANNEL_5 : \
  360. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA2_Channel5)) ? LL_DMA_CHANNEL_5 : \
  361. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel6)) ? LL_DMA_CHANNEL_6 : \
  362. LL_DMA_CHANNEL_7)
  363. #else /* DMA1 */
  364. #if defined(DMA1_Channel7)
  365. #define __LL_DMA_GET_CHANNEL(__CHANNEL_INSTANCE__) \
  366. (((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel1)) ? LL_DMA_CHANNEL_1 : \
  367. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel2)) ? LL_DMA_CHANNEL_2 : \
  368. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel3)) ? LL_DMA_CHANNEL_3 : \
  369. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel4)) ? LL_DMA_CHANNEL_4 : \
  370. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel5)) ? LL_DMA_CHANNEL_5 : \
  371. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel6)) ? LL_DMA_CHANNEL_6 : \
  372. LL_DMA_CHANNEL_7)
  373. #else
  374. #define __LL_DMA_GET_CHANNEL(__CHANNEL_INSTANCE__) \
  375. (((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel1)) ? LL_DMA_CHANNEL_1 : \
  376. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel2)) ? LL_DMA_CHANNEL_2 : \
  377. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel3)) ? LL_DMA_CHANNEL_3 : \
  378. ((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel4)) ? LL_DMA_CHANNEL_4 : \
  379. LL_DMA_CHANNEL_5)
  380. #endif
  381. #endif /* DMA2 */
  382. /**
  383. * @brief Convert DMA Instance DMAx and LL_DMA_CHANNEL_y into DMAx_Channely
  384. * @param __DMA_INSTANCE__ DMAx
  385. * @param __CHANNEL__ LL_DMA_CHANNEL_y
  386. * @retval DMAx_Channely
  387. */
  388. #if defined(DMA2)
  389. #define __LL_DMA_GET_CHANNEL_INSTANCE(__DMA_INSTANCE__, __CHANNEL__) \
  390. ((((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_1))) ? DMA1_Channel1 : \
  391. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA2)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_1))) ? DMA2_Channel1 : \
  392. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_2))) ? DMA1_Channel2 : \
  393. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA2)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_2))) ? DMA2_Channel2 : \
  394. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_3))) ? DMA1_Channel3 : \
  395. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA2)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_3))) ? DMA2_Channel3 : \
  396. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_4))) ? DMA1_Channel4 : \
  397. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA2)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_4))) ? DMA2_Channel4 : \
  398. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_5))) ? DMA1_Channel5 : \
  399. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA2)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_5))) ? DMA2_Channel5 : \
  400. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_6))) ? DMA1_Channel6 : \
  401. DMA1_Channel7)
  402. #else /* DMA1 */
  403. #if defined(DMA1_Channel7)
  404. #define __LL_DMA_GET_CHANNEL_INSTANCE(__DMA_INSTANCE__, __CHANNEL__) \
  405. ((((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_1))) ? DMA1_Channel1 : \
  406. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_2))) ? DMA1_Channel2 : \
  407. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_3))) ? DMA1_Channel3 : \
  408. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_4))) ? DMA1_Channel4 : \
  409. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_5))) ? DMA1_Channel5 : \
  410. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_6))) ? DMA1_Channel6 : \
  411. DMA1_Channel7)
  412. #else
  413. #define __LL_DMA_GET_CHANNEL_INSTANCE(__DMA_INSTANCE__, __CHANNEL__) \
  414. ((((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_1))) ? DMA1_Channel1 : \
  415. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_2))) ? DMA1_Channel2 : \
  416. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_3))) ? DMA1_Channel3 : \
  417. (((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_4))) ? DMA1_Channel4 : \
  418. DMA1_Channel5)
  419. #endif
  420. #endif /* DMA2 */
  421. /**
  422. * @}
  423. */
  424. /**
  425. * @}
  426. */
  427. /* Exported functions --------------------------------------------------------*/
  428. /** @defgroup DMA_LL_Exported_Functions DMA Exported Functions
  429. * @{
  430. */
  431. /** @defgroup DMA_LL_EF_Configuration Configuration
  432. * @{
  433. */
  434. /**
  435. * @brief Enable DMA channel.
  436. * @rmtoll CCR EN LL_DMA_EnableChannel
  437. * @param DMAx DMAx Instance
  438. * @param Channel This parameter can be one of the following values:
  439. * @arg @ref LL_DMA_CHANNEL_1
  440. * @arg @ref LL_DMA_CHANNEL_2
  441. * @arg @ref LL_DMA_CHANNEL_3
  442. * @arg @ref LL_DMA_CHANNEL_4
  443. * @arg @ref LL_DMA_CHANNEL_5
  444. * @arg @ref LL_DMA_CHANNEL_6
  445. * @arg @ref LL_DMA_CHANNEL_7
  446. * @retval None
  447. */
  448. __STATIC_INLINE void LL_DMA_EnableChannel(DMA_TypeDef *DMAx, uint32_t Channel)
  449. {
  450. uint32_t dma_base_addr = (uint32_t)DMAx;
  451. SET_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_EN);
  452. }
  453. /**
  454. * @brief Disable DMA channel.
  455. * @rmtoll CCR EN LL_DMA_DisableChannel
  456. * @param DMAx DMAx Instance
  457. * @param Channel This parameter can be one of the following values:
  458. * @arg @ref LL_DMA_CHANNEL_1
  459. * @arg @ref LL_DMA_CHANNEL_2
  460. * @arg @ref LL_DMA_CHANNEL_3
  461. * @arg @ref LL_DMA_CHANNEL_4
  462. * @arg @ref LL_DMA_CHANNEL_5
  463. * @arg @ref LL_DMA_CHANNEL_6
  464. * @arg @ref LL_DMA_CHANNEL_7
  465. * @retval None
  466. */
  467. __STATIC_INLINE void LL_DMA_DisableChannel(DMA_TypeDef *DMAx, uint32_t Channel)
  468. {
  469. uint32_t dma_base_addr = (uint32_t)DMAx;
  470. CLEAR_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_EN);
  471. }
  472. /**
  473. * @brief Check if DMA channel is enabled or disabled.
  474. * @rmtoll CCR EN LL_DMA_IsEnabledChannel
  475. * @param DMAx DMAx Instance
  476. * @param Channel This parameter can be one of the following values:
  477. * @arg @ref LL_DMA_CHANNEL_1
  478. * @arg @ref LL_DMA_CHANNEL_2
  479. * @arg @ref LL_DMA_CHANNEL_3
  480. * @arg @ref LL_DMA_CHANNEL_4
  481. * @arg @ref LL_DMA_CHANNEL_5
  482. * @arg @ref LL_DMA_CHANNEL_6
  483. * @arg @ref LL_DMA_CHANNEL_7
  484. * @retval State of bit (1 or 0).
  485. */
  486. __STATIC_INLINE uint32_t LL_DMA_IsEnabledChannel(DMA_TypeDef *DMAx, uint32_t Channel)
  487. {
  488. uint32_t dma_base_addr = (uint32_t)DMAx;
  489. return ((READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  490. DMA_CCR_EN) == (DMA_CCR_EN)) ? 1UL : 0UL);
  491. }
  492. /**
  493. * @brief Configure all parameters link to DMA transfer.
  494. * @rmtoll CCR DIR LL_DMA_ConfigTransfer\n
  495. * CCR MEM2MEM LL_DMA_ConfigTransfer\n
  496. * CCR CIRC LL_DMA_ConfigTransfer\n
  497. * CCR PINC LL_DMA_ConfigTransfer\n
  498. * CCR MINC LL_DMA_ConfigTransfer\n
  499. * CCR PSIZE LL_DMA_ConfigTransfer\n
  500. * CCR MSIZE LL_DMA_ConfigTransfer\n
  501. * CCR PL LL_DMA_ConfigTransfer
  502. * @param DMAx DMAx Instance
  503. * @param Channel This parameter can be one of the following values:
  504. * @arg @ref LL_DMA_CHANNEL_1
  505. * @arg @ref LL_DMA_CHANNEL_2
  506. * @arg @ref LL_DMA_CHANNEL_3
  507. * @arg @ref LL_DMA_CHANNEL_4
  508. * @arg @ref LL_DMA_CHANNEL_5
  509. * @arg @ref LL_DMA_CHANNEL_6
  510. * @arg @ref LL_DMA_CHANNEL_7
  511. * @param Configuration This parameter must be a combination of all the following values:
  512. * @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY or @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH or @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
  513. * @arg @ref LL_DMA_MODE_NORMAL or @ref LL_DMA_MODE_CIRCULAR
  514. * @arg @ref LL_DMA_PERIPH_INCREMENT or @ref LL_DMA_PERIPH_NOINCREMENT
  515. * @arg @ref LL_DMA_MEMORY_INCREMENT or @ref LL_DMA_MEMORY_NOINCREMENT
  516. * @arg @ref LL_DMA_PDATAALIGN_BYTE or @ref LL_DMA_PDATAALIGN_HALFWORD or @ref LL_DMA_PDATAALIGN_WORD
  517. * @arg @ref LL_DMA_MDATAALIGN_BYTE or @ref LL_DMA_MDATAALIGN_HALFWORD or @ref LL_DMA_MDATAALIGN_WORD
  518. * @arg @ref LL_DMA_PRIORITY_LOW or @ref LL_DMA_PRIORITY_MEDIUM or @ref LL_DMA_PRIORITY_HIGH or @ref LL_DMA_PRIORITY_VERYHIGH
  519. * @retval None
  520. */
  521. __STATIC_INLINE void LL_DMA_ConfigTransfer(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Configuration)
  522. {
  523. uint32_t dma_base_addr = (uint32_t)DMAx;
  524. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  525. DMA_CCR_DIR | DMA_CCR_MEM2MEM | DMA_CCR_CIRC | DMA_CCR_PINC | DMA_CCR_MINC | DMA_CCR_PSIZE | DMA_CCR_MSIZE | DMA_CCR_PL,
  526. Configuration);
  527. }
  528. /**
  529. * @brief Set Data transfer direction (read from peripheral or from memory).
  530. * @rmtoll CCR DIR LL_DMA_SetDataTransferDirection\n
  531. * CCR MEM2MEM LL_DMA_SetDataTransferDirection
  532. * @param DMAx DMAx Instance
  533. * @param Channel This parameter can be one of the following values:
  534. * @arg @ref LL_DMA_CHANNEL_1
  535. * @arg @ref LL_DMA_CHANNEL_2
  536. * @arg @ref LL_DMA_CHANNEL_3
  537. * @arg @ref LL_DMA_CHANNEL_4
  538. * @arg @ref LL_DMA_CHANNEL_5
  539. * @arg @ref LL_DMA_CHANNEL_6
  540. * @arg @ref LL_DMA_CHANNEL_7
  541. * @param Direction This parameter can be one of the following values:
  542. * @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY
  543. * @arg @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH
  544. * @arg @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
  545. * @retval None
  546. */
  547. __STATIC_INLINE void LL_DMA_SetDataTransferDirection(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Direction)
  548. {
  549. uint32_t dma_base_addr = (uint32_t)DMAx;
  550. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  551. DMA_CCR_DIR | DMA_CCR_MEM2MEM, Direction);
  552. }
  553. /**
  554. * @brief Get Data transfer direction (read from peripheral or from memory).
  555. * @rmtoll CCR DIR LL_DMA_GetDataTransferDirection\n
  556. * CCR MEM2MEM LL_DMA_GetDataTransferDirection
  557. * @param DMAx DMAx Instance
  558. * @param Channel This parameter can be one of the following values:
  559. * @arg @ref LL_DMA_CHANNEL_1
  560. * @arg @ref LL_DMA_CHANNEL_2
  561. * @arg @ref LL_DMA_CHANNEL_3
  562. * @arg @ref LL_DMA_CHANNEL_4
  563. * @arg @ref LL_DMA_CHANNEL_5
  564. * @arg @ref LL_DMA_CHANNEL_6
  565. * @arg @ref LL_DMA_CHANNEL_7
  566. * @retval Returned value can be one of the following values:
  567. * @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY
  568. * @arg @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH
  569. * @arg @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
  570. */
  571. __STATIC_INLINE uint32_t LL_DMA_GetDataTransferDirection(DMA_TypeDef *DMAx, uint32_t Channel)
  572. {
  573. uint32_t dma_base_addr = (uint32_t)DMAx;
  574. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  575. DMA_CCR_DIR | DMA_CCR_MEM2MEM));
  576. }
  577. /**
  578. * @brief Set DMA mode circular or normal.
  579. * @note The circular buffer mode cannot be used if the memory-to-memory
  580. * data transfer is configured on the selected Channel.
  581. * @rmtoll CCR CIRC LL_DMA_SetMode
  582. * @param DMAx DMAx Instance
  583. * @param Channel This parameter can be one of the following values:
  584. * @arg @ref LL_DMA_CHANNEL_1
  585. * @arg @ref LL_DMA_CHANNEL_2
  586. * @arg @ref LL_DMA_CHANNEL_3
  587. * @arg @ref LL_DMA_CHANNEL_4
  588. * @arg @ref LL_DMA_CHANNEL_5
  589. * @arg @ref LL_DMA_CHANNEL_6
  590. * @arg @ref LL_DMA_CHANNEL_7
  591. * @param Mode This parameter can be one of the following values:
  592. * @arg @ref LL_DMA_MODE_NORMAL
  593. * @arg @ref LL_DMA_MODE_CIRCULAR
  594. * @retval None
  595. */
  596. __STATIC_INLINE void LL_DMA_SetMode(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Mode)
  597. {
  598. uint32_t dma_base_addr = (uint32_t)DMAx;
  599. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_CIRC,
  600. Mode);
  601. }
  602. /**
  603. * @brief Get DMA mode circular or normal.
  604. * @rmtoll CCR CIRC LL_DMA_GetMode
  605. * @param DMAx DMAx Instance
  606. * @param Channel This parameter can be one of the following values:
  607. * @arg @ref LL_DMA_CHANNEL_1
  608. * @arg @ref LL_DMA_CHANNEL_2
  609. * @arg @ref LL_DMA_CHANNEL_3
  610. * @arg @ref LL_DMA_CHANNEL_4
  611. * @arg @ref LL_DMA_CHANNEL_5
  612. * @arg @ref LL_DMA_CHANNEL_6
  613. * @arg @ref LL_DMA_CHANNEL_7
  614. * @retval Returned value can be one of the following values:
  615. * @arg @ref LL_DMA_MODE_NORMAL
  616. * @arg @ref LL_DMA_MODE_CIRCULAR
  617. */
  618. __STATIC_INLINE uint32_t LL_DMA_GetMode(DMA_TypeDef *DMAx, uint32_t Channel)
  619. {
  620. uint32_t dma_base_addr = (uint32_t)DMAx;
  621. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  622. DMA_CCR_CIRC));
  623. }
  624. /**
  625. * @brief Set Peripheral increment mode.
  626. * @rmtoll CCR PINC LL_DMA_SetPeriphIncMode
  627. * @param DMAx DMAx Instance
  628. * @param Channel This parameter can be one of the following values:
  629. * @arg @ref LL_DMA_CHANNEL_1
  630. * @arg @ref LL_DMA_CHANNEL_2
  631. * @arg @ref LL_DMA_CHANNEL_3
  632. * @arg @ref LL_DMA_CHANNEL_4
  633. * @arg @ref LL_DMA_CHANNEL_5
  634. * @arg @ref LL_DMA_CHANNEL_6
  635. * @arg @ref LL_DMA_CHANNEL_7
  636. * @param PeriphOrM2MSrcIncMode This parameter can be one of the following values:
  637. * @arg @ref LL_DMA_PERIPH_INCREMENT
  638. * @arg @ref LL_DMA_PERIPH_NOINCREMENT
  639. * @retval None
  640. */
  641. __STATIC_INLINE void LL_DMA_SetPeriphIncMode(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphOrM2MSrcIncMode)
  642. {
  643. uint32_t dma_base_addr = (uint32_t)DMAx;
  644. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_PINC,
  645. PeriphOrM2MSrcIncMode);
  646. }
  647. /**
  648. * @brief Get Peripheral increment mode.
  649. * @rmtoll CCR PINC LL_DMA_GetPeriphIncMode
  650. * @param DMAx DMAx Instance
  651. * @param Channel This parameter can be one of the following values:
  652. * @arg @ref LL_DMA_CHANNEL_1
  653. * @arg @ref LL_DMA_CHANNEL_2
  654. * @arg @ref LL_DMA_CHANNEL_3
  655. * @arg @ref LL_DMA_CHANNEL_4
  656. * @arg @ref LL_DMA_CHANNEL_5
  657. * @arg @ref LL_DMA_CHANNEL_6
  658. * @arg @ref LL_DMA_CHANNEL_7
  659. * @retval Returned value can be one of the following values:
  660. * @arg @ref LL_DMA_PERIPH_INCREMENT
  661. * @arg @ref LL_DMA_PERIPH_NOINCREMENT
  662. */
  663. __STATIC_INLINE uint32_t LL_DMA_GetPeriphIncMode(DMA_TypeDef *DMAx, uint32_t Channel)
  664. {
  665. uint32_t dma_base_addr = (uint32_t)DMAx;
  666. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  667. DMA_CCR_PINC));
  668. }
  669. /**
  670. * @brief Set Memory increment mode.
  671. * @rmtoll CCR MINC LL_DMA_SetMemoryIncMode
  672. * @param DMAx DMAx Instance
  673. * @param Channel This parameter can be one of the following values:
  674. * @arg @ref LL_DMA_CHANNEL_1
  675. * @arg @ref LL_DMA_CHANNEL_2
  676. * @arg @ref LL_DMA_CHANNEL_3
  677. * @arg @ref LL_DMA_CHANNEL_4
  678. * @arg @ref LL_DMA_CHANNEL_5
  679. * @arg @ref LL_DMA_CHANNEL_6
  680. * @arg @ref LL_DMA_CHANNEL_7
  681. * @param MemoryOrM2MDstIncMode This parameter can be one of the following values:
  682. * @arg @ref LL_DMA_MEMORY_INCREMENT
  683. * @arg @ref LL_DMA_MEMORY_NOINCREMENT
  684. * @retval None
  685. */
  686. __STATIC_INLINE void LL_DMA_SetMemoryIncMode(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryOrM2MDstIncMode)
  687. {
  688. uint32_t dma_base_addr = (uint32_t)DMAx;
  689. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_MINC,
  690. MemoryOrM2MDstIncMode);
  691. }
  692. /**
  693. * @brief Get Memory increment mode.
  694. * @rmtoll CCR MINC LL_DMA_GetMemoryIncMode
  695. * @param DMAx DMAx Instance
  696. * @param Channel This parameter can be one of the following values:
  697. * @arg @ref LL_DMA_CHANNEL_1
  698. * @arg @ref LL_DMA_CHANNEL_2
  699. * @arg @ref LL_DMA_CHANNEL_3
  700. * @arg @ref LL_DMA_CHANNEL_4
  701. * @arg @ref LL_DMA_CHANNEL_5
  702. * @arg @ref LL_DMA_CHANNEL_6
  703. * @arg @ref LL_DMA_CHANNEL_7
  704. * @retval Returned value can be one of the following values:
  705. * @arg @ref LL_DMA_MEMORY_INCREMENT
  706. * @arg @ref LL_DMA_MEMORY_NOINCREMENT
  707. */
  708. __STATIC_INLINE uint32_t LL_DMA_GetMemoryIncMode(DMA_TypeDef *DMAx, uint32_t Channel)
  709. {
  710. uint32_t dma_base_addr = (uint32_t)DMAx;
  711. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  712. DMA_CCR_MINC));
  713. }
  714. /**
  715. * @brief Set Peripheral size.
  716. * @rmtoll CCR PSIZE LL_DMA_SetPeriphSize
  717. * @param DMAx DMAx Instance
  718. * @param Channel This parameter can be one of the following values:
  719. * @arg @ref LL_DMA_CHANNEL_1
  720. * @arg @ref LL_DMA_CHANNEL_2
  721. * @arg @ref LL_DMA_CHANNEL_3
  722. * @arg @ref LL_DMA_CHANNEL_4
  723. * @arg @ref LL_DMA_CHANNEL_5
  724. * @arg @ref LL_DMA_CHANNEL_6
  725. * @arg @ref LL_DMA_CHANNEL_7
  726. * @param PeriphOrM2MSrcDataSize This parameter can be one of the following values:
  727. * @arg @ref LL_DMA_PDATAALIGN_BYTE
  728. * @arg @ref LL_DMA_PDATAALIGN_HALFWORD
  729. * @arg @ref LL_DMA_PDATAALIGN_WORD
  730. * @retval None
  731. */
  732. __STATIC_INLINE void LL_DMA_SetPeriphSize(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphOrM2MSrcDataSize)
  733. {
  734. uint32_t dma_base_addr = (uint32_t)DMAx;
  735. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_PSIZE,
  736. PeriphOrM2MSrcDataSize);
  737. }
  738. /**
  739. * @brief Get Peripheral size.
  740. * @rmtoll CCR PSIZE LL_DMA_GetPeriphSize
  741. * @param DMAx DMAx Instance
  742. * @param Channel This parameter can be one of the following values:
  743. * @arg @ref LL_DMA_CHANNEL_1
  744. * @arg @ref LL_DMA_CHANNEL_2
  745. * @arg @ref LL_DMA_CHANNEL_3
  746. * @arg @ref LL_DMA_CHANNEL_4
  747. * @arg @ref LL_DMA_CHANNEL_5
  748. * @arg @ref LL_DMA_CHANNEL_6
  749. * @arg @ref LL_DMA_CHANNEL_7
  750. * @retval Returned value can be one of the following values:
  751. * @arg @ref LL_DMA_PDATAALIGN_BYTE
  752. * @arg @ref LL_DMA_PDATAALIGN_HALFWORD
  753. * @arg @ref LL_DMA_PDATAALIGN_WORD
  754. */
  755. __STATIC_INLINE uint32_t LL_DMA_GetPeriphSize(DMA_TypeDef *DMAx, uint32_t Channel)
  756. {
  757. uint32_t dma_base_addr = (uint32_t)DMAx;
  758. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  759. DMA_CCR_PSIZE));
  760. }
  761. /**
  762. * @brief Set Memory size.
  763. * @rmtoll CCR MSIZE LL_DMA_SetMemorySize
  764. * @param DMAx DMAx Instance
  765. * @param Channel This parameter can be one of the following values:
  766. * @arg @ref LL_DMA_CHANNEL_1
  767. * @arg @ref LL_DMA_CHANNEL_2
  768. * @arg @ref LL_DMA_CHANNEL_3
  769. * @arg @ref LL_DMA_CHANNEL_4
  770. * @arg @ref LL_DMA_CHANNEL_5
  771. * @arg @ref LL_DMA_CHANNEL_6
  772. * @arg @ref LL_DMA_CHANNEL_7
  773. * @param MemoryOrM2MDstDataSize This parameter can be one of the following values:
  774. * @arg @ref LL_DMA_MDATAALIGN_BYTE
  775. * @arg @ref LL_DMA_MDATAALIGN_HALFWORD
  776. * @arg @ref LL_DMA_MDATAALIGN_WORD
  777. * @retval None
  778. */
  779. __STATIC_INLINE void LL_DMA_SetMemorySize(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryOrM2MDstDataSize)
  780. {
  781. uint32_t dma_base_addr = (uint32_t)DMAx;
  782. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_MSIZE,
  783. MemoryOrM2MDstDataSize);
  784. }
  785. /**
  786. * @brief Get Memory size.
  787. * @rmtoll CCR MSIZE LL_DMA_GetMemorySize
  788. * @param DMAx DMAx Instance
  789. * @param Channel This parameter can be one of the following values:
  790. * @arg @ref LL_DMA_CHANNEL_1
  791. * @arg @ref LL_DMA_CHANNEL_2
  792. * @arg @ref LL_DMA_CHANNEL_3
  793. * @arg @ref LL_DMA_CHANNEL_4
  794. * @arg @ref LL_DMA_CHANNEL_5
  795. * @arg @ref LL_DMA_CHANNEL_6
  796. * @arg @ref LL_DMA_CHANNEL_7
  797. * @retval Returned value can be one of the following values:
  798. * @arg @ref LL_DMA_MDATAALIGN_BYTE
  799. * @arg @ref LL_DMA_MDATAALIGN_HALFWORD
  800. * @arg @ref LL_DMA_MDATAALIGN_WORD
  801. */
  802. __STATIC_INLINE uint32_t LL_DMA_GetMemorySize(DMA_TypeDef *DMAx, uint32_t Channel)
  803. {
  804. uint32_t dma_base_addr = (uint32_t)DMAx;
  805. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  806. DMA_CCR_MSIZE));
  807. }
  808. /**
  809. * @brief Set Channel priority level.
  810. * @rmtoll CCR PL LL_DMA_SetChannelPriorityLevel
  811. * @param DMAx DMAx Instance
  812. * @param Channel This parameter can be one of the following values:
  813. * @arg @ref LL_DMA_CHANNEL_1
  814. * @arg @ref LL_DMA_CHANNEL_2
  815. * @arg @ref LL_DMA_CHANNEL_3
  816. * @arg @ref LL_DMA_CHANNEL_4
  817. * @arg @ref LL_DMA_CHANNEL_5
  818. * @arg @ref LL_DMA_CHANNEL_6
  819. * @arg @ref LL_DMA_CHANNEL_7
  820. * @param Priority This parameter can be one of the following values:
  821. * @arg @ref LL_DMA_PRIORITY_LOW
  822. * @arg @ref LL_DMA_PRIORITY_MEDIUM
  823. * @arg @ref LL_DMA_PRIORITY_HIGH
  824. * @arg @ref LL_DMA_PRIORITY_VERYHIGH
  825. * @retval None
  826. */
  827. __STATIC_INLINE void LL_DMA_SetChannelPriorityLevel(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Priority)
  828. {
  829. uint32_t dma_base_addr = (uint32_t)DMAx;
  830. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_PL,
  831. Priority);
  832. }
  833. /**
  834. * @brief Get Channel priority level.
  835. * @rmtoll CCR PL LL_DMA_GetChannelPriorityLevel
  836. * @param DMAx DMAx Instance
  837. * @param Channel This parameter can be one of the following values:
  838. * @arg @ref LL_DMA_CHANNEL_1
  839. * @arg @ref LL_DMA_CHANNEL_2
  840. * @arg @ref LL_DMA_CHANNEL_3
  841. * @arg @ref LL_DMA_CHANNEL_4
  842. * @arg @ref LL_DMA_CHANNEL_5
  843. * @arg @ref LL_DMA_CHANNEL_6
  844. * @arg @ref LL_DMA_CHANNEL_7
  845. * @retval Returned value can be one of the following values:
  846. * @arg @ref LL_DMA_PRIORITY_LOW
  847. * @arg @ref LL_DMA_PRIORITY_MEDIUM
  848. * @arg @ref LL_DMA_PRIORITY_HIGH
  849. * @arg @ref LL_DMA_PRIORITY_VERYHIGH
  850. */
  851. __STATIC_INLINE uint32_t LL_DMA_GetChannelPriorityLevel(DMA_TypeDef *DMAx, uint32_t Channel)
  852. {
  853. uint32_t dma_base_addr = (uint32_t)DMAx;
  854. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  855. DMA_CCR_PL));
  856. }
  857. /**
  858. * @brief Set Number of data to transfer.
  859. * @note This action has no effect if
  860. * channel is enabled.
  861. * @rmtoll CNDTR NDT LL_DMA_SetDataLength
  862. * @param DMAx DMAx Instance
  863. * @param Channel This parameter can be one of the following values:
  864. * @arg @ref LL_DMA_CHANNEL_1
  865. * @arg @ref LL_DMA_CHANNEL_2
  866. * @arg @ref LL_DMA_CHANNEL_3
  867. * @arg @ref LL_DMA_CHANNEL_4
  868. * @arg @ref LL_DMA_CHANNEL_5
  869. * @arg @ref LL_DMA_CHANNEL_6
  870. * @arg @ref LL_DMA_CHANNEL_7
  871. * @param NbData Between Min_Data = 0 and Max_Data = 0x0000FFFF
  872. * @retval None
  873. */
  874. __STATIC_INLINE void LL_DMA_SetDataLength(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t NbData)
  875. {
  876. uint32_t dma_base_addr = (uint32_t)DMAx;
  877. MODIFY_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CNDTR,
  878. DMA_CNDTR_NDT, NbData);
  879. }
  880. /**
  881. * @brief Get Number of data to transfer.
  882. * @note Once the channel is enabled, the return value indicate the
  883. * remaining bytes to be transmitted.
  884. * @rmtoll CNDTR NDT LL_DMA_GetDataLength
  885. * @param DMAx DMAx Instance
  886. * @param Channel This parameter can be one of the following values:
  887. * @arg @ref LL_DMA_CHANNEL_1
  888. * @arg @ref LL_DMA_CHANNEL_2
  889. * @arg @ref LL_DMA_CHANNEL_3
  890. * @arg @ref LL_DMA_CHANNEL_4
  891. * @arg @ref LL_DMA_CHANNEL_5
  892. * @arg @ref LL_DMA_CHANNEL_6
  893. * @arg @ref LL_DMA_CHANNEL_7
  894. * @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  895. */
  896. __STATIC_INLINE uint32_t LL_DMA_GetDataLength(DMA_TypeDef *DMAx, uint32_t Channel)
  897. {
  898. uint32_t dma_base_addr = (uint32_t)DMAx;
  899. return (READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CNDTR,
  900. DMA_CNDTR_NDT));
  901. }
  902. /**
  903. * @brief Configure the Source and Destination addresses.
  904. * @note This API must not be called when the DMA channel is enabled.
  905. * @note Each peripheral using DMA provides an API to get directly the register address (LL_PPP_DMA_GetRegAddr).
  906. * @rmtoll CPAR PA LL_DMA_ConfigAddresses\n
  907. * CMAR MA LL_DMA_ConfigAddresses
  908. * @param DMAx DMAx Instance
  909. * @param Channel This parameter can be one of the following values:
  910. * @arg @ref LL_DMA_CHANNEL_1
  911. * @arg @ref LL_DMA_CHANNEL_2
  912. * @arg @ref LL_DMA_CHANNEL_3
  913. * @arg @ref LL_DMA_CHANNEL_4
  914. * @arg @ref LL_DMA_CHANNEL_5
  915. * @arg @ref LL_DMA_CHANNEL_6
  916. * @arg @ref LL_DMA_CHANNEL_7
  917. * @param SrcAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  918. * @param DstAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  919. * @param Direction This parameter can be one of the following values:
  920. * @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY
  921. * @arg @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH
  922. * @arg @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
  923. * @retval None
  924. */
  925. __STATIC_INLINE void LL_DMA_ConfigAddresses(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t SrcAddress,
  926. uint32_t DstAddress, uint32_t Direction)
  927. {
  928. uint32_t dma_base_addr = (uint32_t)DMAx;
  929. /* Direction Memory to Periph */
  930. if (Direction == LL_DMA_DIRECTION_MEMORY_TO_PERIPH)
  931. {
  932. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CMAR, SrcAddress);
  933. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CPAR, DstAddress);
  934. }
  935. /* Direction Periph to Memory and Memory to Memory */
  936. else
  937. {
  938. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CPAR, SrcAddress);
  939. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CMAR, DstAddress);
  940. }
  941. }
  942. /**
  943. * @brief Set the Memory address.
  944. * @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
  945. * @note This API must not be called when the DMA channel is enabled.
  946. * @rmtoll CMAR MA LL_DMA_SetMemoryAddress
  947. * @param DMAx DMAx Instance
  948. * @param Channel This parameter can be one of the following values:
  949. * @arg @ref LL_DMA_CHANNEL_1
  950. * @arg @ref LL_DMA_CHANNEL_2
  951. * @arg @ref LL_DMA_CHANNEL_3
  952. * @arg @ref LL_DMA_CHANNEL_4
  953. * @arg @ref LL_DMA_CHANNEL_5
  954. * @arg @ref LL_DMA_CHANNEL_6
  955. * @arg @ref LL_DMA_CHANNEL_7
  956. * @param MemoryAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  957. * @retval None
  958. */
  959. __STATIC_INLINE void LL_DMA_SetMemoryAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryAddress)
  960. {
  961. uint32_t dma_base_addr = (uint32_t)DMAx;
  962. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CMAR, MemoryAddress);
  963. }
  964. /**
  965. * @brief Set the Peripheral address.
  966. * @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
  967. * @note This API must not be called when the DMA channel is enabled.
  968. * @rmtoll CPAR PA LL_DMA_SetPeriphAddress
  969. * @param DMAx DMAx Instance
  970. * @param Channel This parameter can be one of the following values:
  971. * @arg @ref LL_DMA_CHANNEL_1
  972. * @arg @ref LL_DMA_CHANNEL_2
  973. * @arg @ref LL_DMA_CHANNEL_3
  974. * @arg @ref LL_DMA_CHANNEL_4
  975. * @arg @ref LL_DMA_CHANNEL_5
  976. * @arg @ref LL_DMA_CHANNEL_6
  977. * @arg @ref LL_DMA_CHANNEL_7
  978. * @param PeriphAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  979. * @retval None
  980. */
  981. __STATIC_INLINE void LL_DMA_SetPeriphAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphAddress)
  982. {
  983. uint32_t dma_base_addr = (uint32_t)DMAx;
  984. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CPAR, PeriphAddress);
  985. }
  986. /**
  987. * @brief Get Memory address.
  988. * @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
  989. * @rmtoll CMAR MA LL_DMA_GetMemoryAddress
  990. * @param DMAx DMAx Instance
  991. * @param Channel This parameter can be one of the following values:
  992. * @arg @ref LL_DMA_CHANNEL_1
  993. * @arg @ref LL_DMA_CHANNEL_2
  994. * @arg @ref LL_DMA_CHANNEL_3
  995. * @arg @ref LL_DMA_CHANNEL_4
  996. * @arg @ref LL_DMA_CHANNEL_5
  997. * @arg @ref LL_DMA_CHANNEL_6
  998. * @arg @ref LL_DMA_CHANNEL_7
  999. * @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  1000. */
  1001. __STATIC_INLINE uint32_t LL_DMA_GetMemoryAddress(DMA_TypeDef *DMAx, uint32_t Channel)
  1002. {
  1003. uint32_t dma_base_addr = (uint32_t)DMAx;
  1004. return (READ_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CMAR));
  1005. }
  1006. /**
  1007. * @brief Get Peripheral address.
  1008. * @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
  1009. * @rmtoll CPAR PA LL_DMA_GetPeriphAddress
  1010. * @param DMAx DMAx Instance
  1011. * @param Channel This parameter can be one of the following values:
  1012. * @arg @ref LL_DMA_CHANNEL_1
  1013. * @arg @ref LL_DMA_CHANNEL_2
  1014. * @arg @ref LL_DMA_CHANNEL_3
  1015. * @arg @ref LL_DMA_CHANNEL_4
  1016. * @arg @ref LL_DMA_CHANNEL_5
  1017. * @arg @ref LL_DMA_CHANNEL_6
  1018. * @arg @ref LL_DMA_CHANNEL_7
  1019. * @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  1020. */
  1021. __STATIC_INLINE uint32_t LL_DMA_GetPeriphAddress(DMA_TypeDef *DMAx, uint32_t Channel)
  1022. {
  1023. uint32_t dma_base_addr = (uint32_t)DMAx;
  1024. return (READ_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CPAR));
  1025. }
  1026. /**
  1027. * @brief Set the Memory to Memory Source address.
  1028. * @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
  1029. * @note This API must not be called when the DMA channel is enabled.
  1030. * @rmtoll CPAR PA LL_DMA_SetM2MSrcAddress
  1031. * @param DMAx DMAx Instance
  1032. * @param Channel This parameter can be one of the following values:
  1033. * @arg @ref LL_DMA_CHANNEL_1
  1034. * @arg @ref LL_DMA_CHANNEL_2
  1035. * @arg @ref LL_DMA_CHANNEL_3
  1036. * @arg @ref LL_DMA_CHANNEL_4
  1037. * @arg @ref LL_DMA_CHANNEL_5
  1038. * @arg @ref LL_DMA_CHANNEL_6
  1039. * @arg @ref LL_DMA_CHANNEL_7
  1040. * @param MemoryAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  1041. * @retval None
  1042. */
  1043. __STATIC_INLINE void LL_DMA_SetM2MSrcAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryAddress)
  1044. {
  1045. uint32_t dma_base_addr = (uint32_t)DMAx;
  1046. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CPAR, MemoryAddress);
  1047. }
  1048. /**
  1049. * @brief Set the Memory to Memory Destination address.
  1050. * @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
  1051. * @note This API must not be called when the DMA channel is enabled.
  1052. * @rmtoll CMAR MA LL_DMA_SetM2MDstAddress
  1053. * @param DMAx DMAx Instance
  1054. * @param Channel This parameter can be one of the following values:
  1055. * @arg @ref LL_DMA_CHANNEL_1
  1056. * @arg @ref LL_DMA_CHANNEL_2
  1057. * @arg @ref LL_DMA_CHANNEL_3
  1058. * @arg @ref LL_DMA_CHANNEL_4
  1059. * @arg @ref LL_DMA_CHANNEL_5
  1060. * @arg @ref LL_DMA_CHANNEL_6
  1061. * @arg @ref LL_DMA_CHANNEL_7
  1062. * @param MemoryAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  1063. * @retval None
  1064. */
  1065. __STATIC_INLINE void LL_DMA_SetM2MDstAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryAddress)
  1066. {
  1067. uint32_t dma_base_addr = (uint32_t)DMAx;
  1068. WRITE_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CMAR, MemoryAddress);
  1069. }
  1070. /**
  1071. * @brief Get the Memory to Memory Source address.
  1072. * @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
  1073. * @rmtoll CPAR PA LL_DMA_GetM2MSrcAddress
  1074. * @param DMAx DMAx Instance
  1075. * @param Channel This parameter can be one of the following values:
  1076. * @arg @ref LL_DMA_CHANNEL_1
  1077. * @arg @ref LL_DMA_CHANNEL_2
  1078. * @arg @ref LL_DMA_CHANNEL_3
  1079. * @arg @ref LL_DMA_CHANNEL_4
  1080. * @arg @ref LL_DMA_CHANNEL_5
  1081. * @arg @ref LL_DMA_CHANNEL_6
  1082. * @arg @ref LL_DMA_CHANNEL_7
  1083. * @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  1084. */
  1085. __STATIC_INLINE uint32_t LL_DMA_GetM2MSrcAddress(DMA_TypeDef *DMAx, uint32_t Channel)
  1086. {
  1087. uint32_t dma_base_addr = (uint32_t)DMAx;
  1088. return (READ_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CPAR));
  1089. }
  1090. /**
  1091. * @brief Get the Memory to Memory Destination address.
  1092. * @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
  1093. * @rmtoll CMAR MA LL_DMA_GetM2MDstAddress
  1094. * @param DMAx DMAx Instance
  1095. * @param Channel This parameter can be one of the following values:
  1096. * @arg @ref LL_DMA_CHANNEL_1
  1097. * @arg @ref LL_DMA_CHANNEL_2
  1098. * @arg @ref LL_DMA_CHANNEL_3
  1099. * @arg @ref LL_DMA_CHANNEL_4
  1100. * @arg @ref LL_DMA_CHANNEL_5
  1101. * @arg @ref LL_DMA_CHANNEL_6
  1102. * @arg @ref LL_DMA_CHANNEL_7
  1103. * @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  1104. */
  1105. __STATIC_INLINE uint32_t LL_DMA_GetM2MDstAddress(DMA_TypeDef *DMAx, uint32_t Channel)
  1106. {
  1107. uint32_t dma_base_addr = (uint32_t)DMAx;
  1108. return (READ_REG(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CMAR));
  1109. }
  1110. /**
  1111. * @brief Set DMA request for DMA Channels on DMAMUX Channel x.
  1112. * @note DMAMUX channel 0 to 6 are mapped to DMA1 channel 1 to 7.
  1113. * DMAMUX channel 7 to 11 are mapped to DMA2 channel 1 to 5 (**** only available on chip which support DMA2 ****).
  1114. * @rmtoll CxCR DMAREQ_ID LL_DMA_SetPeriphRequest
  1115. * @param DMAx DMAx Instance
  1116. * @param Channel This parameter can be one of the following values:
  1117. * @arg @ref LL_DMA_CHANNEL_1
  1118. * @arg @ref LL_DMA_CHANNEL_2
  1119. * @arg @ref LL_DMA_CHANNEL_3
  1120. * @arg @ref LL_DMA_CHANNEL_4
  1121. * @arg @ref LL_DMA_CHANNEL_5
  1122. * @arg @ref LL_DMA_CHANNEL_6
  1123. * @arg @ref LL_DMA_CHANNEL_7
  1124. * @param Request This parameter can be one of the following values:
  1125. * @arg @ref LL_DMAMUX_REQ_MEM2MEM
  1126. * @arg @ref LL_DMAMUX_REQ_GENERATOR0
  1127. * @arg @ref LL_DMAMUX_REQ_GENERATOR1
  1128. * @arg @ref LL_DMAMUX_REQ_GENERATOR2
  1129. * @arg @ref LL_DMAMUX_REQ_GENERATOR3
  1130. * @arg @ref LL_DMAMUX_REQ_ADC1
  1131. * @arg @ref LL_DMAMUX_REQ_AES_IN
  1132. * @arg @ref LL_DMAMUX_REQ_AES_OUT
  1133. * @arg @ref LL_DMAMUX_REQ_DAC1_CH1
  1134. * @arg @ref LL_DMAMUX_REQ_DAC1_CH2
  1135. * @arg @ref LL_DMAMUX_REQ_I2C1_RX
  1136. * @arg @ref LL_DMAMUX_REQ_I2C1_TX
  1137. * @arg @ref LL_DMAMUX_REQ_I2C2_RX
  1138. * @arg @ref LL_DMAMUX_REQ_I2C2_TX
  1139. * @arg @ref LL_DMAMUX_REQ_LPUART1_RX
  1140. * @arg @ref LL_DMAMUX_REQ_LPUART1_TX
  1141. * @arg @ref LL_DMAMUX_REQ_SPI1_RX
  1142. * @arg @ref LL_DMAMUX_REQ_SPI1_TX
  1143. * @arg @ref LL_DMAMUX_REQ_SPI2_RX
  1144. * @arg @ref LL_DMAMUX_REQ_SPI2_TX
  1145. * @arg @ref LL_DMAMUX_REQ_TIM1_CH1
  1146. * @arg @ref LL_DMAMUX_REQ_TIM1_CH2
  1147. * @arg @ref LL_DMAMUX_REQ_TIM1_CH3
  1148. * @arg @ref LL_DMAMUX_REQ_TIM1_CH4
  1149. * @arg @ref LL_DMAMUX_REQ_TIM1_TRIG_COM
  1150. * @arg @ref LL_DMAMUX_REQ_TIM1_UP
  1151. * @arg @ref LL_DMAMUX_REQ_TIM2_CH1
  1152. * @arg @ref LL_DMAMUX_REQ_TIM2_CH2
  1153. * @arg @ref LL_DMAMUX_REQ_TIM2_CH3
  1154. * @arg @ref LL_DMAMUX_REQ_TIM2_CH4
  1155. * @arg @ref LL_DMAMUX_REQ_TIM2_TRIG
  1156. * @arg @ref LL_DMAMUX_REQ_TIM2_UP
  1157. * @arg @ref LL_DMAMUX_REQ_TIM3_CH1
  1158. * @arg @ref LL_DMAMUX_REQ_TIM3_CH2
  1159. * @arg @ref LL_DMAMUX_REQ_TIM3_CH3
  1160. * @arg @ref LL_DMAMUX_REQ_TIM3_CH4
  1161. * @arg @ref LL_DMAMUX_REQ_TIM3_TRIG
  1162. * @arg @ref LL_DMAMUX_REQ_TIM3_UP
  1163. * @arg @ref LL_DMAMUX_REQ_TIM6_UP
  1164. * @arg @ref LL_DMAMUX_REQ_TIM7_UP
  1165. * @arg @ref LL_DMAMUX_REQ_TIM15_CH1
  1166. * @arg @ref LL_DMAMUX_REQ_TIM15_CH2
  1167. * @arg @ref LL_DMAMUX_REQ_TIM15_TRIG_COM
  1168. * @arg @ref LL_DMAMUX_REQ_TIM15_UP
  1169. * @arg @ref LL_DMAMUX_REQ_TIM16_CH1
  1170. * @arg @ref LL_DMAMUX_REQ_TIM16_COM
  1171. * @arg @ref LL_DMAMUX_REQ_TIM16_UP
  1172. * @arg @ref LL_DMAMUX_REQ_TIM17_CH1
  1173. * @arg @ref LL_DMAMUX_REQ_TIM17_COM
  1174. * @arg @ref LL_DMAMUX_REQ_TIM17_UP
  1175. * @arg @ref LL_DMAMUX_REQ_USART1_RX
  1176. * @arg @ref LL_DMAMUX_REQ_USART1_TX
  1177. * @arg @ref LL_DMAMUX_REQ_USART2_RX
  1178. * @arg @ref LL_DMAMUX_REQ_USART2_TX
  1179. * @arg @ref LL_DMAMUX_REQ_USART3_RX
  1180. * @arg @ref LL_DMAMUX_REQ_USART3_TX
  1181. * @arg @ref LL_DMAMUX_REQ_USART4_RX
  1182. * @arg @ref LL_DMAMUX_REQ_USART4_TX
  1183. * @arg @ref LL_DMAMUX_REQ_UCPD1_RX
  1184. * @arg @ref LL_DMAMUX_REQ_UCPD1_TX
  1185. * @arg @ref LL_DMAMUX_REQ_UCPD2_RX
  1186. * @arg @ref LL_DMAMUX_REQ_UCPD2_TX
  1187. * @retval None
  1188. */
  1189. __STATIC_INLINE void LL_DMA_SetPeriphRequest(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Request)
  1190. {
  1191. uint32_t dmamux_ccr_offset = ((((uint32_t)DMAx ^ (uint32_t)DMA1) >> 10U) * 7U);
  1192. MODIFY_REG((DMAMUX1_Channel0 + Channel + dmamux_ccr_offset)->CCR, DMAMUX_CxCR_DMAREQ_ID, Request);
  1193. }
  1194. /**
  1195. * @brief Get DMA request for DMA Channels on DMAMUX Channel x.
  1196. * @note DMAMUX channel 0 to 6 are mapped to DMA1 channel 1 to 7.
  1197. * DMAMUX channel 7 to 11 are mapped to DMA2 channel 1 to 5 (**** only available on chip which support DMA2 ****).
  1198. * @rmtoll CxCR DMAREQ_ID LL_DMA_GetPeriphRequest
  1199. * @param DMAx DMAx Instance
  1200. * @param Channel This parameter can be one of the following values:
  1201. * @arg @ref LL_DMA_CHANNEL_1
  1202. * @arg @ref LL_DMA_CHANNEL_2
  1203. * @arg @ref LL_DMA_CHANNEL_3
  1204. * @arg @ref LL_DMA_CHANNEL_4
  1205. * @arg @ref LL_DMA_CHANNEL_5
  1206. * @arg @ref LL_DMA_CHANNEL_6
  1207. * @arg @ref LL_DMA_CHANNEL_7
  1208. * @retval Returned value can be one of the following values:
  1209. * @arg @ref LL_DMAMUX_REQ_MEM2MEM
  1210. * @arg @ref LL_DMAMUX_REQ_GENERATOR0
  1211. * @arg @ref LL_DMAMUX_REQ_GENERATOR1
  1212. * @arg @ref LL_DMAMUX_REQ_GENERATOR2
  1213. * @arg @ref LL_DMAMUX_REQ_GENERATOR3
  1214. * @arg @ref LL_DMAMUX_REQ_ADC1
  1215. * @arg @ref LL_DMAMUX_REQ_AES_IN
  1216. * @arg @ref LL_DMAMUX_REQ_AES_OUT
  1217. * @arg @ref LL_DMAMUX_REQ_DAC1_CH1
  1218. * @arg @ref LL_DMAMUX_REQ_DAC1_CH2
  1219. * @arg @ref LL_DMAMUX_REQ_I2C1_RX
  1220. * @arg @ref LL_DMAMUX_REQ_I2C1_TX
  1221. * @arg @ref LL_DMAMUX_REQ_I2C2_RX
  1222. * @arg @ref LL_DMAMUX_REQ_I2C2_TX
  1223. * @arg @ref LL_DMAMUX_REQ_LPUART1_RX
  1224. * @arg @ref LL_DMAMUX_REQ_LPUART1_TX
  1225. * @arg @ref LL_DMAMUX_REQ_SPI1_RX
  1226. * @arg @ref LL_DMAMUX_REQ_SPI1_TX
  1227. * @arg @ref LL_DMAMUX_REQ_SPI2_RX
  1228. * @arg @ref LL_DMAMUX_REQ_SPI2_TX
  1229. * @arg @ref LL_DMAMUX_REQ_TIM1_CH1
  1230. * @arg @ref LL_DMAMUX_REQ_TIM1_CH2
  1231. * @arg @ref LL_DMAMUX_REQ_TIM1_CH3
  1232. * @arg @ref LL_DMAMUX_REQ_TIM1_CH4
  1233. * @arg @ref LL_DMAMUX_REQ_TIM1_TRIG_COM
  1234. * @arg @ref LL_DMAMUX_REQ_TIM1_UP
  1235. * @arg @ref LL_DMAMUX_REQ_TIM2_CH1
  1236. * @arg @ref LL_DMAMUX_REQ_TIM2_CH2
  1237. * @arg @ref LL_DMAMUX_REQ_TIM2_CH3
  1238. * @arg @ref LL_DMAMUX_REQ_TIM2_CH4
  1239. * @arg @ref LL_DMAMUX_REQ_TIM2_TRIG
  1240. * @arg @ref LL_DMAMUX_REQ_TIM2_UP
  1241. * @arg @ref LL_DMAMUX_REQ_TIM3_CH1
  1242. * @arg @ref LL_DMAMUX_REQ_TIM3_CH2
  1243. * @arg @ref LL_DMAMUX_REQ_TIM3_CH3
  1244. * @arg @ref LL_DMAMUX_REQ_TIM3_CH4
  1245. * @arg @ref LL_DMAMUX_REQ_TIM3_TRIG
  1246. * @arg @ref LL_DMAMUX_REQ_TIM3_UP
  1247. * @arg @ref LL_DMAMUX_REQ_TIM6_UP
  1248. * @arg @ref LL_DMAMUX_REQ_TIM7_UP
  1249. * @arg @ref LL_DMAMUX_REQ_TIM15_CH1
  1250. * @arg @ref LL_DMAMUX_REQ_TIM15_CH2
  1251. * @arg @ref LL_DMAMUX_REQ_TIM15_TRIG_COM
  1252. * @arg @ref LL_DMAMUX_REQ_TIM15_UP
  1253. * @arg @ref LL_DMAMUX_REQ_TIM16_CH1
  1254. * @arg @ref LL_DMAMUX_REQ_TIM16_COM
  1255. * @arg @ref LL_DMAMUX_REQ_TIM16_UP
  1256. * @arg @ref LL_DMAMUX_REQ_TIM17_CH1
  1257. * @arg @ref LL_DMAMUX_REQ_TIM17_COM
  1258. * @arg @ref LL_DMAMUX_REQ_TIM17_UP
  1259. * @arg @ref LL_DMAMUX_REQ_USART1_RX
  1260. * @arg @ref LL_DMAMUX_REQ_USART1_TX
  1261. * @arg @ref LL_DMAMUX_REQ_USART2_RX
  1262. * @arg @ref LL_DMAMUX_REQ_USART2_TX
  1263. * @arg @ref LL_DMAMUX_REQ_USART3_RX
  1264. * @arg @ref LL_DMAMUX_REQ_USART3_TX
  1265. * @arg @ref LL_DMAMUX_REQ_USART4_RX
  1266. * @arg @ref LL_DMAMUX_REQ_USART4_TX
  1267. * @arg @ref LL_DMAMUX_REQ_UCPD1_RX
  1268. * @arg @ref LL_DMAMUX_REQ_UCPD1_TX
  1269. * @arg @ref LL_DMAMUX_REQ_UCPD2_RX
  1270. * @arg @ref LL_DMAMUX_REQ_UCPD2_TX
  1271. */
  1272. __STATIC_INLINE uint32_t LL_DMA_GetPeriphRequest(DMA_TypeDef *DMAx, uint32_t Channel)
  1273. {
  1274. uint32_t dmamux_ccr_offset = ((((uint32_t)DMAx ^ (uint32_t)DMA1) >> 10U) * 7U);
  1275. return (READ_BIT((DMAMUX1_Channel0 + Channel + dmamux_ccr_offset)->CCR, DMAMUX_CxCR_DMAREQ_ID));
  1276. }
  1277. /**
  1278. * @}
  1279. */
  1280. /** @defgroup DMA_LL_EF_FLAG_Management FLAG_Management
  1281. * @{
  1282. */
  1283. /**
  1284. * @brief Get Channel 1 global interrupt flag.
  1285. * @rmtoll ISR GIF1 LL_DMA_IsActiveFlag_GI1
  1286. * @param DMAx DMAx Instance
  1287. * @retval State of bit (1 or 0).
  1288. */
  1289. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI1(DMA_TypeDef *DMAx)
  1290. {
  1291. return ((READ_BIT(DMAx->ISR, DMA_ISR_GIF1) == (DMA_ISR_GIF1)) ? 1UL : 0UL);
  1292. }
  1293. /**
  1294. * @brief Get Channel 2 global interrupt flag.
  1295. * @rmtoll ISR GIF2 LL_DMA_IsActiveFlag_GI2
  1296. * @param DMAx DMAx Instance
  1297. * @retval State of bit (1 or 0).
  1298. */
  1299. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI2(DMA_TypeDef *DMAx)
  1300. {
  1301. return ((READ_BIT(DMAx->ISR, DMA_ISR_GIF2) == (DMA_ISR_GIF2)) ? 1UL : 0UL);
  1302. }
  1303. /**
  1304. * @brief Get Channel 3 global interrupt flag.
  1305. * @rmtoll ISR GIF3 LL_DMA_IsActiveFlag_GI3
  1306. * @param DMAx DMAx Instance
  1307. * @retval State of bit (1 or 0).
  1308. */
  1309. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI3(DMA_TypeDef *DMAx)
  1310. {
  1311. return ((READ_BIT(DMAx->ISR, DMA_ISR_GIF3) == (DMA_ISR_GIF3)) ? 1UL : 0UL);
  1312. }
  1313. /**
  1314. * @brief Get Channel 4 global interrupt flag.
  1315. * @rmtoll ISR GIF4 LL_DMA_IsActiveFlag_GI4
  1316. * @param DMAx DMAx Instance
  1317. * @retval State of bit (1 or 0).
  1318. */
  1319. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI4(DMA_TypeDef *DMAx)
  1320. {
  1321. return ((READ_BIT(DMAx->ISR, DMA_ISR_GIF4) == (DMA_ISR_GIF4)) ? 1UL : 0UL);
  1322. }
  1323. /**
  1324. * @brief Get Channel 5 global interrupt flag.
  1325. * @rmtoll ISR GIF5 LL_DMA_IsActiveFlag_GI5
  1326. * @param DMAx DMAx Instance
  1327. * @retval State of bit (1 or 0).
  1328. */
  1329. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI5(DMA_TypeDef *DMAx)
  1330. {
  1331. return ((READ_BIT(DMAx->ISR, DMA_ISR_GIF5) == (DMA_ISR_GIF5)) ? 1UL : 0UL);
  1332. }
  1333. #if defined(DMA1_Channel6)
  1334. /**
  1335. * @brief Get Channel 6 global interrupt flag.
  1336. * @rmtoll ISR GIF6 LL_DMA_IsActiveFlag_GI6
  1337. * @param DMAx DMAx Instance
  1338. * @retval State of bit (1 or 0).
  1339. */
  1340. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI6(DMA_TypeDef *DMAx)
  1341. {
  1342. return ((READ_BIT(DMAx->ISR, DMA_ISR_GIF6) == (DMA_ISR_GIF6)) ? 1UL : 0UL);
  1343. }
  1344. #endif
  1345. #if defined(DMA1_Channel7)
  1346. /**
  1347. * @brief Get Channel 7 global interrupt flag.
  1348. * @rmtoll ISR GIF7 LL_DMA_IsActiveFlag_GI7
  1349. * @param DMAx DMAx Instance
  1350. * @retval State of bit (1 or 0).
  1351. */
  1352. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI7(DMA_TypeDef *DMAx)
  1353. {
  1354. return ((READ_BIT(DMAx->ISR, DMA_ISR_GIF7) == (DMA_ISR_GIF7)) ? 1UL : 0UL);
  1355. }
  1356. #endif
  1357. /**
  1358. * @brief Get Channel 1 transfer complete flag.
  1359. * @rmtoll ISR TCIF1 LL_DMA_IsActiveFlag_TC1
  1360. * @param DMAx DMAx Instance
  1361. * @retval State of bit (1 or 0).
  1362. */
  1363. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC1(DMA_TypeDef *DMAx)
  1364. {
  1365. return ((READ_BIT(DMAx->ISR, DMA_ISR_TCIF1) == (DMA_ISR_TCIF1)) ? 1UL : 0UL);
  1366. }
  1367. /**
  1368. * @brief Get Channel 2 transfer complete flag.
  1369. * @rmtoll ISR TCIF2 LL_DMA_IsActiveFlag_TC2
  1370. * @param DMAx DMAx Instance
  1371. * @retval State of bit (1 or 0).
  1372. */
  1373. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC2(DMA_TypeDef *DMAx)
  1374. {
  1375. return ((READ_BIT(DMAx->ISR, DMA_ISR_TCIF2) == (DMA_ISR_TCIF2)) ? 1UL : 0UL);
  1376. }
  1377. /**
  1378. * @brief Get Channel 3 transfer complete flag.
  1379. * @rmtoll ISR TCIF3 LL_DMA_IsActiveFlag_TC3
  1380. * @param DMAx DMAx Instance
  1381. * @retval State of bit (1 or 0).
  1382. */
  1383. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC3(DMA_TypeDef *DMAx)
  1384. {
  1385. return ((READ_BIT(DMAx->ISR, DMA_ISR_TCIF3) == (DMA_ISR_TCIF3)) ? 1UL : 0UL);
  1386. }
  1387. /**
  1388. * @brief Get Channel 4 transfer complete flag.
  1389. * @rmtoll ISR TCIF4 LL_DMA_IsActiveFlag_TC4
  1390. * @param DMAx DMAx Instance
  1391. * @retval State of bit (1 or 0).
  1392. */
  1393. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC4(DMA_TypeDef *DMAx)
  1394. {
  1395. return ((READ_BIT(DMAx->ISR, DMA_ISR_TCIF4) == (DMA_ISR_TCIF4)) ? 1UL : 0UL);
  1396. }
  1397. /**
  1398. * @brief Get Channel 5 transfer complete flag.
  1399. * @rmtoll ISR TCIF5 LL_DMA_IsActiveFlag_TC5
  1400. * @param DMAx DMAx Instance
  1401. * @retval State of bit (1 or 0).
  1402. */
  1403. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC5(DMA_TypeDef *DMAx)
  1404. {
  1405. return ((READ_BIT(DMAx->ISR, DMA_ISR_TCIF5) == (DMA_ISR_TCIF5)) ? 1UL : 0UL);
  1406. }
  1407. #if defined(DMA1_Channel6)
  1408. /**
  1409. * @brief Get Channel 6 transfer complete flag.
  1410. * @rmtoll ISR TCIF6 LL_DMA_IsActiveFlag_TC6
  1411. * @param DMAx DMAx Instance
  1412. * @retval State of bit (1 or 0).
  1413. */
  1414. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC6(DMA_TypeDef *DMAx)
  1415. {
  1416. return ((READ_BIT(DMAx->ISR, DMA_ISR_TCIF6) == (DMA_ISR_TCIF6)) ? 1UL : 0UL);
  1417. }
  1418. #endif
  1419. #if defined(DMA1_Channel7)
  1420. /**
  1421. * @brief Get Channel 7 transfer complete flag.
  1422. * @rmtoll ISR TCIF7 LL_DMA_IsActiveFlag_TC7
  1423. * @param DMAx DMAx Instance
  1424. * @retval State of bit (1 or 0).
  1425. */
  1426. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC7(DMA_TypeDef *DMAx)
  1427. {
  1428. return ((READ_BIT(DMAx->ISR, DMA_ISR_TCIF7) == (DMA_ISR_TCIF7)) ? 1UL : 0UL);
  1429. }
  1430. #endif
  1431. /**
  1432. * @brief Get Channel 1 half transfer flag.
  1433. * @rmtoll ISR HTIF1 LL_DMA_IsActiveFlag_HT1
  1434. * @param DMAx DMAx Instance
  1435. * @retval State of bit (1 or 0).
  1436. */
  1437. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT1(DMA_TypeDef *DMAx)
  1438. {
  1439. return ((READ_BIT(DMAx->ISR, DMA_ISR_HTIF1) == (DMA_ISR_HTIF1)) ? 1UL : 0UL);
  1440. }
  1441. /**
  1442. * @brief Get Channel 2 half transfer flag.
  1443. * @rmtoll ISR HTIF2 LL_DMA_IsActiveFlag_HT2
  1444. * @param DMAx DMAx Instance
  1445. * @retval State of bit (1 or 0).
  1446. */
  1447. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT2(DMA_TypeDef *DMAx)
  1448. {
  1449. return ((READ_BIT(DMAx->ISR, DMA_ISR_HTIF2) == (DMA_ISR_HTIF2)) ? 1UL : 0UL);
  1450. }
  1451. /**
  1452. * @brief Get Channel 3 half transfer flag.
  1453. * @rmtoll ISR HTIF3 LL_DMA_IsActiveFlag_HT3
  1454. * @param DMAx DMAx Instance
  1455. * @retval State of bit (1 or 0).
  1456. */
  1457. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT3(DMA_TypeDef *DMAx)
  1458. {
  1459. return ((READ_BIT(DMAx->ISR, DMA_ISR_HTIF3) == (DMA_ISR_HTIF3)) ? 1UL : 0UL);
  1460. }
  1461. /**
  1462. * @brief Get Channel 4 half transfer flag.
  1463. * @rmtoll ISR HTIF4 LL_DMA_IsActiveFlag_HT4
  1464. * @param DMAx DMAx Instance
  1465. * @retval State of bit (1 or 0).
  1466. */
  1467. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT4(DMA_TypeDef *DMAx)
  1468. {
  1469. return ((READ_BIT(DMAx->ISR, DMA_ISR_HTIF4) == (DMA_ISR_HTIF4)) ? 1UL : 0UL);
  1470. }
  1471. /**
  1472. * @brief Get Channel 5 half transfer flag.
  1473. * @rmtoll ISR HTIF5 LL_DMA_IsActiveFlag_HT5
  1474. * @param DMAx DMAx Instance
  1475. * @retval State of bit (1 or 0).
  1476. */
  1477. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT5(DMA_TypeDef *DMAx)
  1478. {
  1479. return ((READ_BIT(DMAx->ISR, DMA_ISR_HTIF5) == (DMA_ISR_HTIF5)) ? 1UL : 0UL);
  1480. }
  1481. #if defined(DMA1_Channel6)
  1482. /**
  1483. * @brief Get Channel 6 half transfer flag.
  1484. * @rmtoll ISR HTIF6 LL_DMA_IsActiveFlag_HT6
  1485. * @param DMAx DMAx Instance
  1486. * @retval State of bit (1 or 0).
  1487. */
  1488. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT6(DMA_TypeDef *DMAx)
  1489. {
  1490. return ((READ_BIT(DMAx->ISR, DMA_ISR_HTIF6) == (DMA_ISR_HTIF6)) ? 1UL : 0UL);
  1491. }
  1492. #endif
  1493. #if defined(DMA1_Channel7)
  1494. /**
  1495. * @brief Get Channel 7 half transfer flag.
  1496. * @rmtoll ISR HTIF7 LL_DMA_IsActiveFlag_HT7
  1497. * @param DMAx DMAx Instance
  1498. * @retval State of bit (1 or 0).
  1499. */
  1500. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT7(DMA_TypeDef *DMAx)
  1501. {
  1502. return ((READ_BIT(DMAx->ISR, DMA_ISR_HTIF7) == (DMA_ISR_HTIF7)) ? 1UL : 0UL);
  1503. }
  1504. #endif
  1505. /**
  1506. * @brief Get Channel 1 transfer error flag.
  1507. * @rmtoll ISR TEIF1 LL_DMA_IsActiveFlag_TE1
  1508. * @param DMAx DMAx Instance
  1509. * @retval State of bit (1 or 0).
  1510. */
  1511. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE1(DMA_TypeDef *DMAx)
  1512. {
  1513. return ((READ_BIT(DMAx->ISR, DMA_ISR_TEIF1) == (DMA_ISR_TEIF1)) ? 1UL : 0UL);
  1514. }
  1515. /**
  1516. * @brief Get Channel 2 transfer error flag.
  1517. * @rmtoll ISR TEIF2 LL_DMA_IsActiveFlag_TE2
  1518. * @param DMAx DMAx Instance
  1519. * @retval State of bit (1 or 0).
  1520. */
  1521. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE2(DMA_TypeDef *DMAx)
  1522. {
  1523. return ((READ_BIT(DMAx->ISR, DMA_ISR_TEIF2) == (DMA_ISR_TEIF2)) ? 1UL : 0UL);
  1524. }
  1525. /**
  1526. * @brief Get Channel 3 transfer error flag.
  1527. * @rmtoll ISR TEIF3 LL_DMA_IsActiveFlag_TE3
  1528. * @param DMAx DMAx Instance
  1529. * @retval State of bit (1 or 0).
  1530. */
  1531. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE3(DMA_TypeDef *DMAx)
  1532. {
  1533. return ((READ_BIT(DMAx->ISR, DMA_ISR_TEIF3) == (DMA_ISR_TEIF3)) ? 1UL : 0UL);
  1534. }
  1535. /**
  1536. * @brief Get Channel 4 transfer error flag.
  1537. * @rmtoll ISR TEIF4 LL_DMA_IsActiveFlag_TE4
  1538. * @param DMAx DMAx Instance
  1539. * @retval State of bit (1 or 0).
  1540. */
  1541. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE4(DMA_TypeDef *DMAx)
  1542. {
  1543. return ((READ_BIT(DMAx->ISR, DMA_ISR_TEIF4) == (DMA_ISR_TEIF4)) ? 1UL : 0UL);
  1544. }
  1545. /**
  1546. * @brief Get Channel 5 transfer error flag.
  1547. * @rmtoll ISR TEIF5 LL_DMA_IsActiveFlag_TE5
  1548. * @param DMAx DMAx Instance
  1549. * @retval State of bit (1 or 0).
  1550. */
  1551. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE5(DMA_TypeDef *DMAx)
  1552. {
  1553. return ((READ_BIT(DMAx->ISR, DMA_ISR_TEIF5) == (DMA_ISR_TEIF5)) ? 1UL : 0UL);
  1554. }
  1555. #if defined(DMA1_Channel6)
  1556. /**
  1557. * @brief Get Channel 6 transfer error flag.
  1558. * @rmtoll ISR TEIF6 LL_DMA_IsActiveFlag_TE6
  1559. * @param DMAx DMAx Instance
  1560. * @retval State of bit (1 or 0).
  1561. */
  1562. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE6(DMA_TypeDef *DMAx)
  1563. {
  1564. return ((READ_BIT(DMAx->ISR, DMA_ISR_TEIF6) == (DMA_ISR_TEIF6)) ? 1UL : 0UL);
  1565. }
  1566. #endif
  1567. #if defined(DMA1_Channel7)
  1568. /**
  1569. * @brief Get Channel 7 transfer error flag.
  1570. * @rmtoll ISR TEIF7 LL_DMA_IsActiveFlag_TE7
  1571. * @param DMAx DMAx Instance
  1572. * @retval State of bit (1 or 0).
  1573. */
  1574. __STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE7(DMA_TypeDef *DMAx)
  1575. {
  1576. return ((READ_BIT(DMAx->ISR, DMA_ISR_TEIF7) == (DMA_ISR_TEIF7)) ? 1UL : 0UL);
  1577. }
  1578. #endif
  1579. /**
  1580. * @brief Clear Channel 1 global interrupt flag.
  1581. * @note Do not Clear Channel 1 global interrupt flag when the channel in ON.
  1582. Instead clear specific flags transfer complete, half transfer & transfer
  1583. error flag with LL_DMA_ClearFlag_TC1, LL_DMA_ClearFlag_HT1,
  1584. LL_DMA_ClearFlag_TE1. bug id 2.4.1 in Product Errata Sheet.
  1585. * @rmtoll IFCR CGIF1 LL_DMA_ClearFlag_GI1
  1586. * @param DMAx DMAx Instance
  1587. * @retval None
  1588. */
  1589. __STATIC_INLINE void LL_DMA_ClearFlag_GI1(DMA_TypeDef *DMAx)
  1590. {
  1591. WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF1);
  1592. }
  1593. /**
  1594. * @brief Clear Channel 2 global interrupt flag.
  1595. * @note Do not Clear Channel 2 global interrupt flag when the channel in ON.
  1596. Instead clear specific flags transfer complete, half transfer & transfer
  1597. error flag with LL_DMA_ClearFlag_TC2, LL_DMA_ClearFlag_HT2,
  1598. LL_DMA_ClearFlag_TE2. bug id 2.4.1 in Product Errata Sheet.
  1599. * @rmtoll IFCR CGIF2 LL_DMA_ClearFlag_GI2
  1600. * @param DMAx DMAx Instance
  1601. * @retval None
  1602. */
  1603. __STATIC_INLINE void LL_DMA_ClearFlag_GI2(DMA_TypeDef *DMAx)
  1604. {
  1605. WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF2);
  1606. }
  1607. /**
  1608. * @brief Clear Channel 3 global interrupt flag.
  1609. * @note Do not Clear Channel 3 global interrupt flag when the channel in ON.
  1610. Instead clear specific flags transfer complete, half transfer & transfer
  1611. error flag with LL_DMA_ClearFlag_TC3, LL_DMA_ClearFlag_HT3,
  1612. LL_DMA_ClearFlag_TE3. bug id 2.4.1 in Product Errata Sheet.
  1613. * @rmtoll IFCR CGIF3 LL_DMA_ClearFlag_GI3
  1614. * @param DMAx DMAx Instance
  1615. * @retval None
  1616. */
  1617. __STATIC_INLINE void LL_DMA_ClearFlag_GI3(DMA_TypeDef *DMAx)
  1618. {
  1619. WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF3);
  1620. }
  1621. /**
  1622. * @brief Clear Channel 4 global interrupt flag.
  1623. * @note Do not Clear Channel 4 global interrupt flag when the channel in ON.
  1624. Instead clear specific flags transfer complete, half transfer & transfer
  1625. error flag with LL_DMA_ClearFlag_TC4, LL_DMA_ClearFlag_HT4,
  1626. LL_DMA_ClearFlag_TE4. bug id 2.4.1 in Product Errata Sheet.
  1627. * @rmtoll IFCR CGIF4 LL_DMA_ClearFlag_GI4
  1628. * @param DMAx DMAx Instance
  1629. * @retval None
  1630. */
  1631. __STATIC_INLINE void LL_DMA_ClearFlag_GI4(DMA_TypeDef *DMAx)
  1632. {
  1633. WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF4);
  1634. }
  1635. /**
  1636. * @brief Clear Channel 5 global interrupt flag.
  1637. * @note Do not Clear Channel 5 global interrupt flag when the channel in ON.
  1638. Instead clear specific flags transfer complete, half transfer & transfer
  1639. error flag with LL_DMA_ClearFlag_TC5, LL_DMA_ClearFlag_HT5,
  1640. LL_DMA_ClearFlag_TE5. bug id 2.4.1 in Product Errata Sheet.
  1641. * @rmtoll IFCR CGIF5 LL_DMA_ClearFlag_GI5
  1642. * @param DMAx DMAx Instance
  1643. * @retval None
  1644. */
  1645. __STATIC_INLINE void LL_DMA_ClearFlag_GI5(DMA_TypeDef *DMAx)
  1646. {
  1647. WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF5);
  1648. }
  1649. #if defined(DMA1_Channel6)
  1650. /**
  1651. * @brief Clear Channel 6 global interrupt flag.
  1652. * @note Do not Clear Channel 6 global interrupt flag when the channel in ON.
  1653. Instead clear specific flags transfer complete, half transfer & transfer
  1654. error flag with LL_DMA_ClearFlag_TC6, LL_DMA_ClearFlag_HT6,
  1655. LL_DMA_ClearFlag_TE6. bug id 2.4.1 in Product Errata Sheet.
  1656. * @rmtoll IFCR CGIF6 LL_DMA_ClearFlag_GI6
  1657. * @param DMAx DMAx Instance
  1658. * @retval None
  1659. */
  1660. __STATIC_INLINE void LL_DMA_ClearFlag_GI6(DMA_TypeDef *DMAx)
  1661. {
  1662. WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF6);
  1663. }
  1664. #endif
  1665. #if defined(DMA1_Channel7)
  1666. /**
  1667. * @brief Clear Channel 7 global interrupt flag.
  1668. * @note Do not Clear Channel 7 global interrupt flag when the channel in ON.
  1669. Instead clear specific flags transfer complete, half transfer & transfer
  1670. error flag with LL_DMA_ClearFlag_TC7, LL_DMA_ClearFlag_HT7,
  1671. LL_DMA_ClearFlag_TE7. bug id 2.4.1 in Product Errata Sheet.
  1672. * @rmtoll IFCR CGIF7 LL_DMA_ClearFlag_GI7
  1673. * @param DMAx DMAx Instance
  1674. * @retval None
  1675. */
  1676. __STATIC_INLINE void LL_DMA_ClearFlag_GI7(DMA_TypeDef *DMAx)
  1677. {
  1678. WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF7);
  1679. }
  1680. #endif
  1681. /**
  1682. * @brief Clear Channel 1 transfer complete flag.
  1683. * @rmtoll IFCR CTCIF1 LL_DMA_ClearFlag_TC1
  1684. * @param DMAx DMAx Instance
  1685. * @retval None
  1686. */
  1687. __STATIC_INLINE void LL_DMA_ClearFlag_TC1(DMA_TypeDef *DMAx)
  1688. {
  1689. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF1);
  1690. }
  1691. /**
  1692. * @brief Clear Channel 2 transfer complete flag.
  1693. * @rmtoll IFCR CTCIF2 LL_DMA_ClearFlag_TC2
  1694. * @param DMAx DMAx Instance
  1695. * @retval None
  1696. */
  1697. __STATIC_INLINE void LL_DMA_ClearFlag_TC2(DMA_TypeDef *DMAx)
  1698. {
  1699. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF2);
  1700. }
  1701. /**
  1702. * @brief Clear Channel 3 transfer complete flag.
  1703. * @rmtoll IFCR CTCIF3 LL_DMA_ClearFlag_TC3
  1704. * @param DMAx DMAx Instance
  1705. * @retval None
  1706. */
  1707. __STATIC_INLINE void LL_DMA_ClearFlag_TC3(DMA_TypeDef *DMAx)
  1708. {
  1709. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF3);
  1710. }
  1711. /**
  1712. * @brief Clear Channel 4 transfer complete flag.
  1713. * @rmtoll IFCR CTCIF4 LL_DMA_ClearFlag_TC4
  1714. * @param DMAx DMAx Instance
  1715. * @retval None
  1716. */
  1717. __STATIC_INLINE void LL_DMA_ClearFlag_TC4(DMA_TypeDef *DMAx)
  1718. {
  1719. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF4);
  1720. }
  1721. /**
  1722. * @brief Clear Channel 5 transfer complete flag.
  1723. * @rmtoll IFCR CTCIF5 LL_DMA_ClearFlag_TC5
  1724. * @param DMAx DMAx Instance
  1725. * @retval None
  1726. */
  1727. __STATIC_INLINE void LL_DMA_ClearFlag_TC5(DMA_TypeDef *DMAx)
  1728. {
  1729. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF5);
  1730. }
  1731. #if defined(DMA1_Channel6)
  1732. /**
  1733. * @brief Clear Channel 6 transfer complete flag.
  1734. * @rmtoll IFCR CTCIF6 LL_DMA_ClearFlag_TC6
  1735. * @param DMAx DMAx Instance
  1736. * @retval None
  1737. */
  1738. __STATIC_INLINE void LL_DMA_ClearFlag_TC6(DMA_TypeDef *DMAx)
  1739. {
  1740. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF6);
  1741. }
  1742. #endif
  1743. #if defined(DMA1_Channel7)
  1744. /**
  1745. * @brief Clear Channel 7 transfer complete flag.
  1746. * @rmtoll IFCR CTCIF7 LL_DMA_ClearFlag_TC7
  1747. * @param DMAx DMAx Instance
  1748. * @retval None
  1749. */
  1750. __STATIC_INLINE void LL_DMA_ClearFlag_TC7(DMA_TypeDef *DMAx)
  1751. {
  1752. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF7);
  1753. }
  1754. #endif
  1755. /**
  1756. * @brief Clear Channel 1 half transfer flag.
  1757. * @rmtoll IFCR CHTIF1 LL_DMA_ClearFlag_HT1
  1758. * @param DMAx DMAx Instance
  1759. * @retval None
  1760. */
  1761. __STATIC_INLINE void LL_DMA_ClearFlag_HT1(DMA_TypeDef *DMAx)
  1762. {
  1763. WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF1);
  1764. }
  1765. /**
  1766. * @brief Clear Channel 2 half transfer flag.
  1767. * @rmtoll IFCR CHTIF2 LL_DMA_ClearFlag_HT2
  1768. * @param DMAx DMAx Instance
  1769. * @retval None
  1770. */
  1771. __STATIC_INLINE void LL_DMA_ClearFlag_HT2(DMA_TypeDef *DMAx)
  1772. {
  1773. WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF2);
  1774. }
  1775. /**
  1776. * @brief Clear Channel 3 half transfer flag.
  1777. * @rmtoll IFCR CHTIF3 LL_DMA_ClearFlag_HT3
  1778. * @param DMAx DMAx Instance
  1779. * @retval None
  1780. */
  1781. __STATIC_INLINE void LL_DMA_ClearFlag_HT3(DMA_TypeDef *DMAx)
  1782. {
  1783. WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF3);
  1784. }
  1785. /**
  1786. * @brief Clear Channel 4 half transfer flag.
  1787. * @rmtoll IFCR CHTIF4 LL_DMA_ClearFlag_HT4
  1788. * @param DMAx DMAx Instance
  1789. * @retval None
  1790. */
  1791. __STATIC_INLINE void LL_DMA_ClearFlag_HT4(DMA_TypeDef *DMAx)
  1792. {
  1793. WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF4);
  1794. }
  1795. /**
  1796. * @brief Clear Channel 5 half transfer flag.
  1797. * @rmtoll IFCR CHTIF5 LL_DMA_ClearFlag_HT5
  1798. * @param DMAx DMAx Instance
  1799. * @retval None
  1800. */
  1801. __STATIC_INLINE void LL_DMA_ClearFlag_HT5(DMA_TypeDef *DMAx)
  1802. {
  1803. WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF5);
  1804. }
  1805. #if defined(DMA1_Channel6)
  1806. /**
  1807. * @brief Clear Channel 6 half transfer flag.
  1808. * @rmtoll IFCR CHTIF6 LL_DMA_ClearFlag_HT6
  1809. * @param DMAx DMAx Instance
  1810. * @retval None
  1811. */
  1812. __STATIC_INLINE void LL_DMA_ClearFlag_HT6(DMA_TypeDef *DMAx)
  1813. {
  1814. WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF6);
  1815. }
  1816. #endif
  1817. #if defined(DMA1_Channel7)
  1818. /**
  1819. * @brief Clear Channel 7 half transfer flag.
  1820. * @rmtoll IFCR CHTIF7 LL_DMA_ClearFlag_HT7
  1821. * @param DMAx DMAx Instance
  1822. * @retval None
  1823. */
  1824. __STATIC_INLINE void LL_DMA_ClearFlag_HT7(DMA_TypeDef *DMAx)
  1825. {
  1826. WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF7);
  1827. }
  1828. #endif
  1829. /**
  1830. * @brief Clear Channel 1 transfer error flag.
  1831. * @rmtoll IFCR CTEIF1 LL_DMA_ClearFlag_TE1
  1832. * @param DMAx DMAx Instance
  1833. * @retval None
  1834. */
  1835. __STATIC_INLINE void LL_DMA_ClearFlag_TE1(DMA_TypeDef *DMAx)
  1836. {
  1837. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF1);
  1838. }
  1839. /**
  1840. * @brief Clear Channel 2 transfer error flag.
  1841. * @rmtoll IFCR CTEIF2 LL_DMA_ClearFlag_TE2
  1842. * @param DMAx DMAx Instance
  1843. * @retval None
  1844. */
  1845. __STATIC_INLINE void LL_DMA_ClearFlag_TE2(DMA_TypeDef *DMAx)
  1846. {
  1847. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF2);
  1848. }
  1849. /**
  1850. * @brief Clear Channel 3 transfer error flag.
  1851. * @rmtoll IFCR CTEIF3 LL_DMA_ClearFlag_TE3
  1852. * @param DMAx DMAx Instance
  1853. * @retval None
  1854. */
  1855. __STATIC_INLINE void LL_DMA_ClearFlag_TE3(DMA_TypeDef *DMAx)
  1856. {
  1857. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF3);
  1858. }
  1859. /**
  1860. * @brief Clear Channel 4 transfer error flag.
  1861. * @rmtoll IFCR CTEIF4 LL_DMA_ClearFlag_TE4
  1862. * @param DMAx DMAx Instance
  1863. * @retval None
  1864. */
  1865. __STATIC_INLINE void LL_DMA_ClearFlag_TE4(DMA_TypeDef *DMAx)
  1866. {
  1867. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF4);
  1868. }
  1869. /**
  1870. * @brief Clear Channel 5 transfer error flag.
  1871. * @rmtoll IFCR CTEIF5 LL_DMA_ClearFlag_TE5
  1872. * @param DMAx DMAx Instance
  1873. * @retval None
  1874. */
  1875. __STATIC_INLINE void LL_DMA_ClearFlag_TE5(DMA_TypeDef *DMAx)
  1876. {
  1877. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF5);
  1878. }
  1879. #if defined(DMA1_Channel6)
  1880. /**
  1881. * @brief Clear Channel 6 transfer error flag.
  1882. * @rmtoll IFCR CTEIF6 LL_DMA_ClearFlag_TE6
  1883. * @param DMAx DMAx Instance
  1884. * @retval None
  1885. */
  1886. __STATIC_INLINE void LL_DMA_ClearFlag_TE6(DMA_TypeDef *DMAx)
  1887. {
  1888. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF6);
  1889. }
  1890. #endif
  1891. #if defined(DMA1_Channel7)
  1892. /**
  1893. * @brief Clear Channel 7 transfer error flag.
  1894. * @rmtoll IFCR CTEIF7 LL_DMA_ClearFlag_TE7
  1895. * @param DMAx DMAx Instance
  1896. * @retval None
  1897. */
  1898. __STATIC_INLINE void LL_DMA_ClearFlag_TE7(DMA_TypeDef *DMAx)
  1899. {
  1900. WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF7);
  1901. }
  1902. #endif
  1903. /**
  1904. * @}
  1905. */
  1906. /** @defgroup DMA_LL_EF_IT_Management IT_Management
  1907. * @{
  1908. */
  1909. /**
  1910. * @brief Enable Transfer complete interrupt.
  1911. * @rmtoll CCR TCIE LL_DMA_EnableIT_TC
  1912. * @param DMAx DMAx Instance
  1913. * @param Channel This parameter can be one of the following values:
  1914. * @arg @ref LL_DMA_CHANNEL_1
  1915. * @arg @ref LL_DMA_CHANNEL_2
  1916. * @arg @ref LL_DMA_CHANNEL_3
  1917. * @arg @ref LL_DMA_CHANNEL_4
  1918. * @arg @ref LL_DMA_CHANNEL_5
  1919. * @arg @ref LL_DMA_CHANNEL_6
  1920. * @arg @ref LL_DMA_CHANNEL_7
  1921. * @retval None
  1922. */
  1923. __STATIC_INLINE void LL_DMA_EnableIT_TC(DMA_TypeDef *DMAx, uint32_t Channel)
  1924. {
  1925. uint32_t dma_base_addr = (uint32_t)DMAx;
  1926. SET_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_TCIE);
  1927. }
  1928. /**
  1929. * @brief Enable Half transfer interrupt.
  1930. * @rmtoll CCR HTIE LL_DMA_EnableIT_HT
  1931. * @param DMAx DMAx Instance
  1932. * @param Channel This parameter can be one of the following values:
  1933. * @arg @ref LL_DMA_CHANNEL_1
  1934. * @arg @ref LL_DMA_CHANNEL_2
  1935. * @arg @ref LL_DMA_CHANNEL_3
  1936. * @arg @ref LL_DMA_CHANNEL_4
  1937. * @arg @ref LL_DMA_CHANNEL_5
  1938. * @arg @ref LL_DMA_CHANNEL_6
  1939. * @arg @ref LL_DMA_CHANNEL_7
  1940. * @retval None
  1941. */
  1942. __STATIC_INLINE void LL_DMA_EnableIT_HT(DMA_TypeDef *DMAx, uint32_t Channel)
  1943. {
  1944. uint32_t dma_base_addr = (uint32_t)DMAx;
  1945. SET_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_HTIE);
  1946. }
  1947. /**
  1948. * @brief Enable Transfer error interrupt.
  1949. * @rmtoll CCR TEIE LL_DMA_EnableIT_TE
  1950. * @param DMAx DMAx Instance
  1951. * @param Channel This parameter can be one of the following values:
  1952. * @arg @ref LL_DMA_CHANNEL_1
  1953. * @arg @ref LL_DMA_CHANNEL_2
  1954. * @arg @ref LL_DMA_CHANNEL_3
  1955. * @arg @ref LL_DMA_CHANNEL_4
  1956. * @arg @ref LL_DMA_CHANNEL_5
  1957. * @arg @ref LL_DMA_CHANNEL_6
  1958. * @arg @ref LL_DMA_CHANNEL_7
  1959. * @retval None
  1960. */
  1961. __STATIC_INLINE void LL_DMA_EnableIT_TE(DMA_TypeDef *DMAx, uint32_t Channel)
  1962. {
  1963. uint32_t dma_base_addr = (uint32_t)DMAx;
  1964. SET_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_TEIE);
  1965. }
  1966. /**
  1967. * @brief Disable Transfer complete interrupt.
  1968. * @rmtoll CCR TCIE LL_DMA_DisableIT_TC
  1969. * @param DMAx DMAx Instance
  1970. * @param Channel This parameter can be one of the following values:
  1971. * @arg @ref LL_DMA_CHANNEL_1
  1972. * @arg @ref LL_DMA_CHANNEL_2
  1973. * @arg @ref LL_DMA_CHANNEL_3
  1974. * @arg @ref LL_DMA_CHANNEL_4
  1975. * @arg @ref LL_DMA_CHANNEL_5
  1976. * @arg @ref LL_DMA_CHANNEL_6
  1977. * @arg @ref LL_DMA_CHANNEL_7
  1978. * @retval None
  1979. */
  1980. __STATIC_INLINE void LL_DMA_DisableIT_TC(DMA_TypeDef *DMAx, uint32_t Channel)
  1981. {
  1982. uint32_t dma_base_addr = (uint32_t)DMAx;
  1983. CLEAR_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_TCIE);
  1984. }
  1985. /**
  1986. * @brief Disable Half transfer interrupt.
  1987. * @rmtoll CCR HTIE LL_DMA_DisableIT_HT
  1988. * @param DMAx DMAx Instance
  1989. * @param Channel This parameter can be one of the following values:
  1990. * @arg @ref LL_DMA_CHANNEL_1
  1991. * @arg @ref LL_DMA_CHANNEL_2
  1992. * @arg @ref LL_DMA_CHANNEL_3
  1993. * @arg @ref LL_DMA_CHANNEL_4
  1994. * @arg @ref LL_DMA_CHANNEL_5
  1995. * @arg @ref LL_DMA_CHANNEL_6
  1996. * @arg @ref LL_DMA_CHANNEL_7
  1997. * @retval None
  1998. */
  1999. __STATIC_INLINE void LL_DMA_DisableIT_HT(DMA_TypeDef *DMAx, uint32_t Channel)
  2000. {
  2001. uint32_t dma_base_addr = (uint32_t)DMAx;
  2002. CLEAR_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_HTIE);
  2003. }
  2004. /**
  2005. * @brief Disable Transfer error interrupt.
  2006. * @rmtoll CCR TEIE LL_DMA_DisableIT_TE
  2007. * @param DMAx DMAx Instance
  2008. * @param Channel This parameter can be one of the following values:
  2009. * @arg @ref LL_DMA_CHANNEL_1
  2010. * @arg @ref LL_DMA_CHANNEL_2
  2011. * @arg @ref LL_DMA_CHANNEL_3
  2012. * @arg @ref LL_DMA_CHANNEL_4
  2013. * @arg @ref LL_DMA_CHANNEL_5
  2014. * @arg @ref LL_DMA_CHANNEL_6
  2015. * @arg @ref LL_DMA_CHANNEL_7
  2016. * @retval None
  2017. */
  2018. __STATIC_INLINE void LL_DMA_DisableIT_TE(DMA_TypeDef *DMAx, uint32_t Channel)
  2019. {
  2020. uint32_t dma_base_addr = (uint32_t)DMAx;
  2021. CLEAR_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR, DMA_CCR_TEIE);
  2022. }
  2023. /**
  2024. * @brief Check if Transfer complete Interrupt is enabled.
  2025. * @rmtoll CCR TCIE LL_DMA_IsEnabledIT_TC
  2026. * @param DMAx DMAx Instance
  2027. * @param Channel This parameter can be one of the following values:
  2028. * @arg @ref LL_DMA_CHANNEL_1
  2029. * @arg @ref LL_DMA_CHANNEL_2
  2030. * @arg @ref LL_DMA_CHANNEL_3
  2031. * @arg @ref LL_DMA_CHANNEL_4
  2032. * @arg @ref LL_DMA_CHANNEL_5
  2033. * @arg @ref LL_DMA_CHANNEL_6
  2034. * @arg @ref LL_DMA_CHANNEL_7
  2035. * @retval State of bit (1 or 0).
  2036. */
  2037. __STATIC_INLINE uint32_t LL_DMA_IsEnabledIT_TC(DMA_TypeDef *DMAx, uint32_t Channel)
  2038. {
  2039. uint32_t dma_base_addr = (uint32_t)DMAx;
  2040. return ((READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  2041. DMA_CCR_TCIE) == (DMA_CCR_TCIE)) ? 1UL : 0UL);
  2042. }
  2043. /**
  2044. * @brief Check if Half transfer Interrupt is enabled.
  2045. * @rmtoll CCR HTIE LL_DMA_IsEnabledIT_HT
  2046. * @param DMAx DMAx Instance
  2047. * @param Channel This parameter can be one of the following values:
  2048. * @arg @ref LL_DMA_CHANNEL_1
  2049. * @arg @ref LL_DMA_CHANNEL_2
  2050. * @arg @ref LL_DMA_CHANNEL_3
  2051. * @arg @ref LL_DMA_CHANNEL_4
  2052. * @arg @ref LL_DMA_CHANNEL_5
  2053. * @arg @ref LL_DMA_CHANNEL_6
  2054. * @arg @ref LL_DMA_CHANNEL_7
  2055. * @retval State of bit (1 or 0).
  2056. */
  2057. __STATIC_INLINE uint32_t LL_DMA_IsEnabledIT_HT(DMA_TypeDef *DMAx, uint32_t Channel)
  2058. {
  2059. uint32_t dma_base_addr = (uint32_t)DMAx;
  2060. return ((READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  2061. DMA_CCR_HTIE) == (DMA_CCR_HTIE)) ? 1UL : 0UL);
  2062. }
  2063. /**
  2064. * @brief Check if Transfer error Interrupt is enabled.
  2065. * @rmtoll CCR TEIE LL_DMA_IsEnabledIT_TE
  2066. * @param DMAx DMAx Instance
  2067. * @param Channel This parameter can be one of the following values:
  2068. * @arg @ref LL_DMA_CHANNEL_1
  2069. * @arg @ref LL_DMA_CHANNEL_2
  2070. * @arg @ref LL_DMA_CHANNEL_3
  2071. * @arg @ref LL_DMA_CHANNEL_4
  2072. * @arg @ref LL_DMA_CHANNEL_5
  2073. * @arg @ref LL_DMA_CHANNEL_6
  2074. * @arg @ref LL_DMA_CHANNEL_7
  2075. * @retval State of bit (1 or 0).
  2076. */
  2077. __STATIC_INLINE uint32_t LL_DMA_IsEnabledIT_TE(DMA_TypeDef *DMAx, uint32_t Channel)
  2078. {
  2079. uint32_t dma_base_addr = (uint32_t)DMAx;
  2080. return ((READ_BIT(((DMA_Channel_TypeDef *)(dma_base_addr + CHANNEL_OFFSET_TAB[Channel]))->CCR,
  2081. DMA_CCR_TEIE) == (DMA_CCR_TEIE)) ? 1UL : 0UL);
  2082. }
  2083. /**
  2084. * @}
  2085. */
  2086. #if defined(USE_FULL_LL_DRIVER)
  2087. /** @defgroup DMA_LL_EF_Init Initialization and de-initialization functions
  2088. * @{
  2089. */
  2090. ErrorStatus LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitTypeDef *DMA_InitStruct);
  2091. ErrorStatus LL_DMA_DeInit(DMA_TypeDef *DMAx, uint32_t Channel);
  2092. void LL_DMA_StructInit(LL_DMA_InitTypeDef *DMA_InitStruct);
  2093. /**
  2094. * @}
  2095. */
  2096. #endif /* USE_FULL_LL_DRIVER */
  2097. /**
  2098. * @}
  2099. */
  2100. /**
  2101. * @}
  2102. */
  2103. #endif /* DMA1 || DMA2 */
  2104. /**
  2105. * @}
  2106. */
  2107. #ifdef __cplusplus
  2108. }
  2109. #endif
  2110. #endif /* STM32G0xx_LL_DMA_H */
  2111. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/