fsl_dma.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _FSL_DMA_H_
  35. #define _FSL_DMA_H_
  36. #include "fsl_common.h"
  37. /*!
  38. * @addtogroup dma
  39. * @{
  40. */
  41. /*! @file */
  42. /*******************************************************************************
  43. * Definitions
  44. ******************************************************************************/
  45. /*! @name Driver version */
  46. /*@{*/
  47. /*! @brief DMA driver version */
  48. #define FSL_DMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Version 2.0.0. */
  49. /*@}*/
  50. #define DMA_MAX_TRANSFER_COUNT 0x400
  51. #if defined FSL_FEATURE_DMA_NUMBER_OF_CHANNELS
  52. #define FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(x) FSL_FEATURE_DMA_NUMBER_OF_CHANNELS
  53. #define FSL_FEATURE_DMA_MAX_CHANNELS FSL_FEATURE_DMA_NUMBER_OF_CHANNELS
  54. #define FSL_FEATURE_DMA_ALL_CHANNELS (FSL_FEATURE_DMA_NUMBER_OF_CHANNELS * FSL_FEATURE_SOC_DMA_COUNT)
  55. #define FSL_FEATURE_DMA_DESCRIPTOR_ALIGN_SIZE (512)
  56. #endif
  57. /* Channel group consists of 32 channels. channel_group = (channel / 32) */
  58. #define DMA_CHANNEL_GROUP(channel) (((uint8_t)(channel)) >> 5U)
  59. /* Channel index in channel group. channel_index = (channel % 32) */
  60. #define DMA_CHANNEL_INDEX(channel) (((uint8_t)(channel)) & 0x1F)
  61. #define DMA_COMMON_REG_GET(base, channel, reg) (((volatile uint32_t *)(&((base)->COMMON[0].reg)))[DMA_CHANNEL_GROUP(channel)])
  62. #define DMA_COMMON_CONST_REG_GET(base, channel, reg) (((volatile const uint32_t *)(&((base)->COMMON[0].reg)))[DMA_CHANNEL_GROUP(channel)])
  63. #define DMA_COMMON_REG_SET(base, channel, reg, value) \
  64. (((volatile uint32_t *)(&((base)->COMMON[0].reg)))[DMA_CHANNEL_GROUP(channel)] = (value))
  65. /*! @brief DMA descriptor structure */
  66. typedef struct _dma_descriptor
  67. {
  68. uint32_t xfercfg; /*!< Transfer configuration */
  69. void *srcEndAddr; /*!< Last source address of DMA transfer */
  70. void *dstEndAddr; /*!< Last destination address of DMA transfer */
  71. void *linkToNextDesc; /*!< Address of next DMA descriptor in chain */
  72. } dma_descriptor_t;
  73. /*! @brief DMA transfer configuration */
  74. typedef struct _dma_xfercfg
  75. {
  76. bool valid; /*!< Descriptor is ready to transfer */
  77. bool reload; /*!< Reload channel configuration register after
  78. current descriptor is exhausted */
  79. bool swtrig; /*!< Perform software trigger. Transfer if fired
  80. when 'valid' is set */
  81. bool clrtrig; /*!< Clear trigger */
  82. bool intA; /*!< Raises IRQ when transfer is done and set IRQA status register flag */
  83. bool intB; /*!< Raises IRQ when transfer is done and set IRQB status register flag */
  84. uint8_t byteWidth; /*!< Byte width of data to transfer */
  85. uint8_t srcInc; /*!< Increment source address by 'srcInc' x 'byteWidth' */
  86. uint8_t dstInc; /*!< Increment destination address by 'dstInc' x 'byteWidth' */
  87. uint16_t transferCount; /*!< Number of transfers */
  88. } dma_xfercfg_t;
  89. /*! @brief DMA channel priority */
  90. typedef enum _dma_priority
  91. {
  92. kDMA_ChannelPriority0 = 0, /*!< Highest channel priority - priority 0 */
  93. kDMA_ChannelPriority1, /*!< Channel priority 1 */
  94. kDMA_ChannelPriority2, /*!< Channel priority 2 */
  95. kDMA_ChannelPriority3, /*!< Channel priority 3 */
  96. kDMA_ChannelPriority4, /*!< Channel priority 4 */
  97. kDMA_ChannelPriority5, /*!< Channel priority 5 */
  98. kDMA_ChannelPriority6, /*!< Channel priority 6 */
  99. kDMA_ChannelPriority7, /*!< Lowest channel priority - priority 7 */
  100. } dma_priority_t;
  101. /*! @brief DMA interrupt flags */
  102. typedef enum _dma_int
  103. {
  104. kDMA_IntA, /*!< DMA interrupt flag A */
  105. kDMA_IntB, /*!< DMA interrupt flag B */
  106. kDMA_IntError, /*!< DMA interrupt flag error */
  107. } dma_irq_t;
  108. /*! @brief DMA trigger type*/
  109. typedef enum _dma_trigger_type
  110. {
  111. kDMA_NoTrigger = 0, /*!< Trigger is disabled */
  112. kDMA_LowLevelTrigger = DMA_CHANNEL_CFG_HWTRIGEN(1) | DMA_CHANNEL_CFG_TRIGTYPE(1), /*!< Low level active trigger */
  113. kDMA_HighLevelTrigger = DMA_CHANNEL_CFG_HWTRIGEN(1) | DMA_CHANNEL_CFG_TRIGTYPE(1) |
  114. DMA_CHANNEL_CFG_TRIGPOL(1), /*!< High level active trigger */
  115. kDMA_FallingEdgeTrigger = DMA_CHANNEL_CFG_HWTRIGEN(1), /*!< Falling edge active trigger */
  116. kDMA_RisingEdgeTrigger =
  117. DMA_CHANNEL_CFG_HWTRIGEN(1) | DMA_CHANNEL_CFG_TRIGPOL(1), /*!< Rising edge active trigger */
  118. } dma_trigger_type_t;
  119. /*! @brief DMA trigger burst */
  120. typedef enum _dma_trigger_burst
  121. {
  122. kDMA_SingleTransfer = 0, /*!< Single transfer */
  123. kDMA_LevelBurstTransfer = DMA_CHANNEL_CFG_TRIGBURST(1), /*!< Burst transfer driven by level trigger */
  124. kDMA_EdgeBurstTransfer1 = DMA_CHANNEL_CFG_TRIGBURST(1), /*!< Perform 1 transfer by edge trigger */
  125. kDMA_EdgeBurstTransfer2 =
  126. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(1), /*!< Perform 2 transfers by edge trigger */
  127. kDMA_EdgeBurstTransfer4 =
  128. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(2), /*!< Perform 4 transfers by edge trigger */
  129. kDMA_EdgeBurstTransfer8 =
  130. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(3), /*!< Perform 8 transfers by edge trigger */
  131. kDMA_EdgeBurstTransfer16 =
  132. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(4), /*!< Perform 16 transfers by edge trigger */
  133. kDMA_EdgeBurstTransfer32 =
  134. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(5), /*!< Perform 32 transfers by edge trigger */
  135. kDMA_EdgeBurstTransfer64 =
  136. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(6), /*!< Perform 64 transfers by edge trigger */
  137. kDMA_EdgeBurstTransfer128 =
  138. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(7), /*!< Perform 128 transfers by edge trigger */
  139. kDMA_EdgeBurstTransfer256 =
  140. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(8), /*!< Perform 256 transfers by edge trigger */
  141. kDMA_EdgeBurstTransfer512 =
  142. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(9), /*!< Perform 512 transfers by edge trigger */
  143. kDMA_EdgeBurstTransfer1024 =
  144. DMA_CHANNEL_CFG_TRIGBURST(1) | DMA_CHANNEL_CFG_BURSTPOWER(10), /*!< Perform 1024 transfers by edge trigger */
  145. } dma_trigger_burst_t;
  146. /*! @brief DMA burst wrapping */
  147. typedef enum _dma_burst_wrap
  148. {
  149. kDMA_NoWrap = 0, /*!< Wrapping is disabled */
  150. kDMA_SrcWrap = DMA_CHANNEL_CFG_SRCBURSTWRAP(1), /*!< Wrapping is enabled for source */
  151. kDMA_DstWrap = DMA_CHANNEL_CFG_DSTBURSTWRAP(1), /*!< Wrapping is enabled for destination */
  152. kDMA_SrcAndDstWrap = DMA_CHANNEL_CFG_SRCBURSTWRAP(1) |
  153. DMA_CHANNEL_CFG_DSTBURSTWRAP(1), /*!< Wrapping is enabled for source and destination */
  154. } dma_burst_wrap_t;
  155. /*! @brief DMA transfer type */
  156. typedef enum _dma_transfer_type
  157. {
  158. kDMA_MemoryToMemory = 0x0U, /*!< Transfer from memory to memory (increment source and destination) */
  159. kDMA_PeripheralToMemory, /*!< Transfer from peripheral to memory (increment only destination) */
  160. kDMA_MemoryToPeripheral, /*!< Transfer from memory to peripheral (increment only source)*/
  161. kDMA_StaticToStatic, /*!< Peripheral to static memory (do not increment source or destination) */
  162. } dma_transfer_type_t;
  163. /*! @brief DMA channel trigger */
  164. typedef struct _dma_channel_trigger
  165. {
  166. dma_trigger_type_t type; /*!< Select hardware trigger as edge triggered or level triggered. */
  167. dma_trigger_burst_t burst; /*!< Select whether hardware triggers cause a single or burst transfer. */
  168. dma_burst_wrap_t wrap; /*!< Select wrap type, source wrap or dest wrap, or both. */
  169. } dma_channel_trigger_t;
  170. /*! @brief DMA transfer status */
  171. enum _dma_transfer_status
  172. {
  173. kStatus_DMA_Busy = MAKE_STATUS(kStatusGroup_DMA, 0), /*!< Channel is busy and can't handle the
  174. transfer request. */
  175. };
  176. /*! @brief DMA transfer configuration */
  177. typedef struct _dma_transfer_config
  178. {
  179. uint8_t *srcAddr; /*!< Source data address */
  180. uint8_t *dstAddr; /*!< Destination data address */
  181. uint8_t *nextDesc; /*!< Chain custom descriptor */
  182. dma_xfercfg_t xfercfg; /*!< Transfer options */
  183. bool isPeriph; /*!< DMA transfer is driven by peripheral */
  184. } dma_transfer_config_t;
  185. /*! @brief Callback for DMA */
  186. struct _dma_handle;
  187. /*! @brief Define Callback function for DMA. */
  188. typedef void (*dma_callback)(struct _dma_handle *handle, void *userData, bool transferDone, uint32_t intmode);
  189. /*! @brief DMA transfer handle structure */
  190. typedef struct _dma_handle
  191. {
  192. dma_callback callback; /*!< Callback function. Invoked when transfer
  193. of descriptor with interrupt flag finishes */
  194. void *userData; /*!< Callback function parameter */
  195. DMA_Type *base; /*!< DMA peripheral base address */
  196. uint8_t channel; /*!< DMA channel number */
  197. } dma_handle_t;
  198. /*******************************************************************************
  199. * APIs
  200. ******************************************************************************/
  201. #if defined(__cplusplus)
  202. extern "C" {
  203. #endif /* __cplusplus */
  204. /*!
  205. * @name DMA initialization and De-initialization
  206. * @{
  207. */
  208. /*!
  209. * @brief Initializes DMA peripheral.
  210. *
  211. * This function enable the DMA clock, set descriptor table and
  212. * enable DMA peripheral.
  213. *
  214. * @param base DMA peripheral base address.
  215. */
  216. void DMA_Init(DMA_Type *base);
  217. /*!
  218. * @brief Deinitializes DMA peripheral.
  219. *
  220. * This function gates the DMA clock.
  221. *
  222. * @param base DMA peripheral base address.
  223. */
  224. void DMA_Deinit(DMA_Type *base);
  225. /* @} */
  226. /*!
  227. * @name DMA Channel Operation
  228. * @{
  229. */
  230. /*!
  231. * @brief Return whether DMA channel is processing transfer
  232. *
  233. * @param base DMA peripheral base address.
  234. * @param channel DMA channel number.
  235. * @return True for active state, false otherwise.
  236. */
  237. static inline bool DMA_ChannelIsActive(DMA_Type *base, uint32_t channel)
  238. {
  239. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  240. return (DMA_COMMON_CONST_REG_GET(base, channel, ACTIVE) & (1U << DMA_CHANNEL_INDEX(channel))) ? true : false;
  241. }
  242. /*!
  243. * @brief Enables the interrupt source for the DMA transfer.
  244. *
  245. * @param base DMA peripheral base address.
  246. * @param channel DMA channel number.
  247. */
  248. static inline void DMA_EnableChannelInterrupts(DMA_Type *base, uint32_t channel)
  249. {
  250. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  251. DMA_COMMON_REG_GET(base, channel, INTENSET) |= 1U << DMA_CHANNEL_INDEX(channel);
  252. }
  253. /*!
  254. * @brief Disables the interrupt source for the DMA transfer.
  255. *
  256. * @param base DMA peripheral base address.
  257. * @param channel DMA channel number.
  258. */
  259. static inline void DMA_DisableChannelInterrupts(DMA_Type *base, uint32_t channel)
  260. {
  261. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  262. DMA_COMMON_REG_GET(base, channel, INTENCLR) |= 1U << DMA_CHANNEL_INDEX(channel);
  263. }
  264. /*!
  265. * @brief Enable DMA channel.
  266. *
  267. * @param base DMA peripheral base address.
  268. * @param channel DMA channel number.
  269. */
  270. static inline void DMA_EnableChannel(DMA_Type *base, uint32_t channel)
  271. {
  272. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  273. DMA_COMMON_REG_GET(base, channel, ENABLESET) |= 1U << DMA_CHANNEL_INDEX(channel);
  274. }
  275. /*!
  276. * @brief Disable DMA channel.
  277. *
  278. * @param base DMA peripheral base address.
  279. * @param channel DMA channel number.
  280. */
  281. static inline void DMA_DisableChannel(DMA_Type *base, uint32_t channel)
  282. {
  283. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  284. DMA_COMMON_REG_GET(base, channel, ENABLECLR) |= 1U << DMA_CHANNEL_INDEX(channel);
  285. }
  286. /*!
  287. * @brief Set PERIPHREQEN of channel configuration register.
  288. *
  289. * @param base DMA peripheral base address.
  290. * @param channel DMA channel number.
  291. */
  292. static inline void DMA_EnableChannelPeriphRq(DMA_Type *base, uint32_t channel)
  293. {
  294. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  295. base->CHANNEL[channel].CFG |= DMA_CHANNEL_CFG_PERIPHREQEN_MASK;
  296. }
  297. /*!
  298. * @brief Get PERIPHREQEN value of channel configuration register.
  299. *
  300. * @param base DMA peripheral base address.
  301. * @param channel DMA channel number.
  302. * @return True for enabled PeriphRq, false for disabled.
  303. */
  304. static inline void DMA_DisableChannelPeriphRq(DMA_Type *base, uint32_t channel)
  305. {
  306. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  307. base->CHANNEL[channel].CFG &= ~DMA_CHANNEL_CFG_PERIPHREQEN_MASK;
  308. }
  309. /*!
  310. * @brief Set trigger settings of DMA channel.
  311. *
  312. * @param base DMA peripheral base address.
  313. * @param channel DMA channel number.
  314. * @param trigger trigger configuration.
  315. */
  316. void DMA_ConfigureChannelTrigger(DMA_Type *base, uint32_t channel, dma_channel_trigger_t *trigger);
  317. /*!
  318. * @brief Gets the remaining bytes of the current DMA descriptor transfer.
  319. *
  320. * @param base DMA peripheral base address.
  321. * @param channel DMA channel number.
  322. * @return The number of bytes which have not been transferred yet.
  323. */
  324. uint32_t DMA_GetRemainingBytes(DMA_Type *base, uint32_t channel);
  325. /*!
  326. * @brief Set priority of channel configuration register.
  327. *
  328. * @param base DMA peripheral base address.
  329. * @param channel DMA channel number.
  330. * @param priority Channel priority value.
  331. */
  332. static inline void DMA_SetChannelPriority(DMA_Type *base, uint32_t channel, dma_priority_t priority)
  333. {
  334. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  335. base->CHANNEL[channel].CFG =
  336. (base->CHANNEL[channel].CFG & (~(DMA_CHANNEL_CFG_CHPRIORITY_MASK))) | DMA_CHANNEL_CFG_CHPRIORITY(priority);
  337. }
  338. /*!
  339. * @brief Get priority of channel configuration register.
  340. *
  341. * @param base DMA peripheral base address.
  342. * @param channel DMA channel number.
  343. * @return Channel priority value.
  344. */
  345. static inline dma_priority_t DMA_GetChannelPriority(DMA_Type *base, uint32_t channel)
  346. {
  347. assert(channel < FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
  348. return (dma_priority_t)((base->CHANNEL[channel].CFG & DMA_CHANNEL_CFG_CHPRIORITY_MASK) >>
  349. DMA_CHANNEL_CFG_CHPRIORITY_SHIFT);
  350. }
  351. /*!
  352. * @brief Create application specific DMA descriptor
  353. * to be used in a chain in transfer
  354. *
  355. * @param desc DMA descriptor address.
  356. * @param xfercfg Transfer configuration for DMA descriptor.
  357. * @param srcAddr Address of last item to transmit
  358. * @param dstAddr Address of last item to receive.
  359. * @param nextDesc Address of next descriptor in chain.
  360. */
  361. void DMA_CreateDescriptor(dma_descriptor_t *desc, dma_xfercfg_t *xfercfg, void *srcAddr, void *dstAddr, void *nextDesc);
  362. /* @} */
  363. /*!
  364. * @name DMA Transactional Operation
  365. * @{
  366. */
  367. /*!
  368. * @brief Abort running transfer by handle.
  369. *
  370. * This function aborts DMA transfer specified by handle.
  371. *
  372. * @param handle DMA handle pointer.
  373. */
  374. void DMA_AbortTransfer(dma_handle_t *handle);
  375. /*!
  376. * @brief Creates the DMA handle.
  377. *
  378. * This function is called if using transaction API for DMA. This function
  379. * initializes the internal state of DMA handle.
  380. *
  381. * @param handle DMA handle pointer. The DMA handle stores callback function and
  382. * parameters.
  383. * @param base DMA peripheral base address.
  384. * @param channel DMA channel number.
  385. */
  386. void DMA_CreateHandle(dma_handle_t *handle, DMA_Type *base, uint32_t channel);
  387. /*!
  388. * @brief Installs a callback function for the DMA transfer.
  389. *
  390. * This callback is called in DMA IRQ handler. Use the callback to do something after
  391. * the current major loop transfer completes.
  392. *
  393. * @param handle DMA handle pointer.
  394. * @param callback DMA callback function pointer.
  395. * @param userData Parameter for callback function.
  396. */
  397. void DMA_SetCallback(dma_handle_t *handle, dma_callback callback, void *userData);
  398. /*!
  399. * @brief Prepares the DMA transfer structure.
  400. *
  401. * This function prepares the transfer configuration structure according to the user input.
  402. *
  403. * @param config The user configuration structure of type dma_transfer_t.
  404. * @param srcAddr DMA transfer source address.
  405. * @param dstAddr DMA transfer destination address.
  406. * @param byteWidth DMA transfer destination address width(bytes).
  407. * @param transferBytes DMA transfer bytes to be transferred.
  408. * @param type DMA transfer type.
  409. * @param nextDesc Chain custom descriptor to transfer.
  410. * @note The data address and the data width must be consistent. For example, if the SRC
  411. * is 4 bytes, so the source address must be 4 bytes aligned, or it shall result in
  412. * source address error(SAE).
  413. */
  414. void DMA_PrepareTransfer(dma_transfer_config_t *config,
  415. void *srcAddr,
  416. void *dstAddr,
  417. uint32_t byteWidth,
  418. uint32_t transferBytes,
  419. dma_transfer_type_t type,
  420. void *nextDesc);
  421. /*!
  422. * @brief Submits the DMA transfer request.
  423. *
  424. * This function submits the DMA transfer request according to the transfer configuration structure.
  425. * If the user submits the transfer request repeatedly, this function packs an unprocessed request as
  426. * a TCD and enables scatter/gather feature to process it in the next time.
  427. *
  428. * @param handle DMA handle pointer.
  429. * @param config Pointer to DMA transfer configuration structure.
  430. * @retval kStatus_DMA_Success It means submit transfer request succeed.
  431. * @retval kStatus_DMA_QueueFull It means TCD queue is full. Submit transfer request is not allowed.
  432. * @retval kStatus_DMA_Busy It means the given channel is busy, need to submit request later.
  433. */
  434. status_t DMA_SubmitTransfer(dma_handle_t *handle, dma_transfer_config_t *config);
  435. /*!
  436. * @brief DMA start transfer.
  437. *
  438. * This function enables the channel request. User can call this function after submitting the transfer request
  439. * or before submitting the transfer request.
  440. *
  441. * @param handle DMA handle pointer.
  442. */
  443. void DMA_StartTransfer(dma_handle_t *handle);
  444. /*!
  445. * @brief DMA IRQ handler for descriptor transfer complete.
  446. *
  447. * This function clears the channel major interrupt flag and call
  448. * the callback function if it is not NULL.
  449. */
  450. void DMA_HandleIRQ(void);
  451. /* @} */
  452. #if defined(__cplusplus)
  453. }
  454. #endif /* __cplusplus */
  455. /* @} */
  456. #endif /*_FSL_DMA_H_*/