The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_KL82Z/TOOLCHAIN_IAR/fsl_edma.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 145:64910690c574 | 1 | /* |
AnnaBridge | 145:64910690c574 | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
AnnaBridge | 145:64910690c574 | 3 | * All rights reserved. |
AnnaBridge | 145:64910690c574 | 4 | * |
AnnaBridge | 145:64910690c574 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 145:64910690c574 | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 145:64910690c574 | 7 | * |
AnnaBridge | 145:64910690c574 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 145:64910690c574 | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 145:64910690c574 | 10 | * |
AnnaBridge | 145:64910690c574 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 145:64910690c574 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 145:64910690c574 | 13 | * other materials provided with the distribution. |
AnnaBridge | 145:64910690c574 | 14 | * |
AnnaBridge | 145:64910690c574 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 145:64910690c574 | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 145:64910690c574 | 17 | * software without specific prior written permission. |
AnnaBridge | 145:64910690c574 | 18 | * |
AnnaBridge | 145:64910690c574 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 145:64910690c574 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 145:64910690c574 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 145:64910690c574 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 145:64910690c574 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 145:64910690c574 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 145:64910690c574 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 145:64910690c574 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 145:64910690c574 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 145:64910690c574 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 145:64910690c574 | 29 | */ |
AnnaBridge | 145:64910690c574 | 30 | |
AnnaBridge | 145:64910690c574 | 31 | #ifndef _FSL_EDMA_H_ |
AnnaBridge | 145:64910690c574 | 32 | #define _FSL_EDMA_H_ |
AnnaBridge | 145:64910690c574 | 33 | |
AnnaBridge | 145:64910690c574 | 34 | #include "fsl_common.h" |
AnnaBridge | 145:64910690c574 | 35 | |
AnnaBridge | 145:64910690c574 | 36 | /*! |
AnnaBridge | 145:64910690c574 | 37 | * @addtogroup edma |
AnnaBridge | 145:64910690c574 | 38 | * @{ |
AnnaBridge | 145:64910690c574 | 39 | */ |
AnnaBridge | 145:64910690c574 | 40 | |
AnnaBridge | 145:64910690c574 | 41 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 42 | * Definitions |
AnnaBridge | 145:64910690c574 | 43 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 44 | |
AnnaBridge | 145:64910690c574 | 45 | /*! @name Driver version */ |
AnnaBridge | 145:64910690c574 | 46 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 47 | /*! @brief eDMA driver version */ |
AnnaBridge | 145:64910690c574 | 48 | #define FSL_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) /*!< Version 2.0.1. */ |
AnnaBridge | 145:64910690c574 | 49 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 50 | |
AnnaBridge | 145:64910690c574 | 51 | /*! @brief Compute the offset unit from DCHPRI3 */ |
AnnaBridge | 145:64910690c574 | 52 | #define DMA_DCHPRI_INDEX(channel) (((channel) & ~0x03U) | (3 - ((channel)&0x03U))) |
AnnaBridge | 145:64910690c574 | 53 | |
AnnaBridge | 145:64910690c574 | 54 | /*! @brief Get the pointer of DCHPRIn */ |
AnnaBridge | 145:64910690c574 | 55 | #define DMA_DCHPRIn(base, channel) ((volatile uint8_t *)&(base->DCHPRI3))[DMA_DCHPRI_INDEX(channel)] |
AnnaBridge | 145:64910690c574 | 56 | |
AnnaBridge | 145:64910690c574 | 57 | /*! @brief eDMA transfer configuration */ |
AnnaBridge | 145:64910690c574 | 58 | typedef enum _edma_transfer_size |
AnnaBridge | 145:64910690c574 | 59 | { |
AnnaBridge | 145:64910690c574 | 60 | kEDMA_TransferSize1Bytes = 0x0U, /*!< Source/Destination data transfer size is 1 byte every time */ |
AnnaBridge | 145:64910690c574 | 61 | kEDMA_TransferSize2Bytes = 0x1U, /*!< Source/Destination data transfer size is 2 bytes every time */ |
AnnaBridge | 145:64910690c574 | 62 | kEDMA_TransferSize4Bytes = 0x2U, /*!< Source/Destination data transfer size is 4 bytes every time */ |
AnnaBridge | 145:64910690c574 | 63 | kEDMA_TransferSize16Bytes = 0x4U, /*!< Source/Destination data transfer size is 16 bytes every time */ |
AnnaBridge | 145:64910690c574 | 64 | kEDMA_TransferSize32Bytes = 0x5U, /*!< Source/Destination data transfer size is 32 bytes every time */ |
AnnaBridge | 145:64910690c574 | 65 | } edma_transfer_size_t; |
AnnaBridge | 145:64910690c574 | 66 | |
AnnaBridge | 145:64910690c574 | 67 | /*! @brief eDMA modulo configuration */ |
AnnaBridge | 145:64910690c574 | 68 | typedef enum _edma_modulo |
AnnaBridge | 145:64910690c574 | 69 | { |
AnnaBridge | 145:64910690c574 | 70 | kEDMA_ModuloDisable = 0x0U, /*!< Disable modulo */ |
AnnaBridge | 145:64910690c574 | 71 | kEDMA_Modulo2bytes, /*!< Circular buffer size is 2 bytes. */ |
AnnaBridge | 145:64910690c574 | 72 | kEDMA_Modulo4bytes, /*!< Circular buffer size is 4 bytes. */ |
AnnaBridge | 145:64910690c574 | 73 | kEDMA_Modulo8bytes, /*!< Circular buffer size is 8 bytes. */ |
AnnaBridge | 145:64910690c574 | 74 | kEDMA_Modulo16bytes, /*!< Circular buffer size is 16 bytes. */ |
AnnaBridge | 145:64910690c574 | 75 | kEDMA_Modulo32bytes, /*!< Circular buffer size is 32 bytes. */ |
AnnaBridge | 145:64910690c574 | 76 | kEDMA_Modulo64bytes, /*!< Circular buffer size is 64 bytes. */ |
AnnaBridge | 145:64910690c574 | 77 | kEDMA_Modulo128bytes, /*!< Circular buffer size is 128 bytes. */ |
AnnaBridge | 145:64910690c574 | 78 | kEDMA_Modulo256bytes, /*!< Circular buffer size is 256 bytes. */ |
AnnaBridge | 145:64910690c574 | 79 | kEDMA_Modulo512bytes, /*!< Circular buffer size is 512 bytes. */ |
AnnaBridge | 145:64910690c574 | 80 | kEDMA_Modulo1Kbytes, /*!< Circular buffer size is 1K bytes. */ |
AnnaBridge | 145:64910690c574 | 81 | kEDMA_Modulo2Kbytes, /*!< Circular buffer size is 2K bytes. */ |
AnnaBridge | 145:64910690c574 | 82 | kEDMA_Modulo4Kbytes, /*!< Circular buffer size is 4K bytes. */ |
AnnaBridge | 145:64910690c574 | 83 | kEDMA_Modulo8Kbytes, /*!< Circular buffer size is 8K bytes. */ |
AnnaBridge | 145:64910690c574 | 84 | kEDMA_Modulo16Kbytes, /*!< Circular buffer size is 16K bytes. */ |
AnnaBridge | 145:64910690c574 | 85 | kEDMA_Modulo32Kbytes, /*!< Circular buffer size is 32K bytes. */ |
AnnaBridge | 145:64910690c574 | 86 | kEDMA_Modulo64Kbytes, /*!< Circular buffer size is 64K bytes. */ |
AnnaBridge | 145:64910690c574 | 87 | kEDMA_Modulo128Kbytes, /*!< Circular buffer size is 128K bytes. */ |
AnnaBridge | 145:64910690c574 | 88 | kEDMA_Modulo256Kbytes, /*!< Circular buffer size is 256K bytes. */ |
AnnaBridge | 145:64910690c574 | 89 | kEDMA_Modulo512Kbytes, /*!< Circular buffer size is 512K bytes. */ |
AnnaBridge | 145:64910690c574 | 90 | kEDMA_Modulo1Mbytes, /*!< Circular buffer size is 1M bytes. */ |
AnnaBridge | 145:64910690c574 | 91 | kEDMA_Modulo2Mbytes, /*!< Circular buffer size is 2M bytes. */ |
AnnaBridge | 145:64910690c574 | 92 | kEDMA_Modulo4Mbytes, /*!< Circular buffer size is 4M bytes. */ |
AnnaBridge | 145:64910690c574 | 93 | kEDMA_Modulo8Mbytes, /*!< Circular buffer size is 8M bytes. */ |
AnnaBridge | 145:64910690c574 | 94 | kEDMA_Modulo16Mbytes, /*!< Circular buffer size is 16M bytes. */ |
AnnaBridge | 145:64910690c574 | 95 | kEDMA_Modulo32Mbytes, /*!< Circular buffer size is 32M bytes. */ |
AnnaBridge | 145:64910690c574 | 96 | kEDMA_Modulo64Mbytes, /*!< Circular buffer size is 64M bytes. */ |
AnnaBridge | 145:64910690c574 | 97 | kEDMA_Modulo128Mbytes, /*!< Circular buffer size is 128M bytes. */ |
AnnaBridge | 145:64910690c574 | 98 | kEDMA_Modulo256Mbytes, /*!< Circular buffer size is 256M bytes. */ |
AnnaBridge | 145:64910690c574 | 99 | kEDMA_Modulo512Mbytes, /*!< Circular buffer size is 512M bytes. */ |
AnnaBridge | 145:64910690c574 | 100 | kEDMA_Modulo1Gbytes, /*!< Circular buffer size is 1G bytes. */ |
AnnaBridge | 145:64910690c574 | 101 | kEDMA_Modulo2Gbytes, /*!< Circular buffer size is 2G bytes. */ |
AnnaBridge | 145:64910690c574 | 102 | } edma_modulo_t; |
AnnaBridge | 145:64910690c574 | 103 | |
AnnaBridge | 145:64910690c574 | 104 | /*! @brief Bandwidth control */ |
AnnaBridge | 145:64910690c574 | 105 | typedef enum _edma_bandwidth |
AnnaBridge | 145:64910690c574 | 106 | { |
AnnaBridge | 145:64910690c574 | 107 | kEDMA_BandwidthStallNone = 0x0U, /*!< No eDMA engine stalls. */ |
AnnaBridge | 145:64910690c574 | 108 | kEDMA_BandwidthStall4Cycle = 0x2U, /*!< eDMA engine stalls for 4 cycles after each read/write. */ |
AnnaBridge | 145:64910690c574 | 109 | kEDMA_BandwidthStall8Cycle = 0x3U, /*!< eDMA engine stalls for 8 cycles after each read/write. */ |
AnnaBridge | 145:64910690c574 | 110 | } edma_bandwidth_t; |
AnnaBridge | 145:64910690c574 | 111 | |
AnnaBridge | 145:64910690c574 | 112 | /*! @brief Channel link type */ |
AnnaBridge | 145:64910690c574 | 113 | typedef enum _edma_channel_link_type |
AnnaBridge | 145:64910690c574 | 114 | { |
AnnaBridge | 145:64910690c574 | 115 | kEDMA_LinkNone = 0x0U, /*!< No channel link */ |
AnnaBridge | 145:64910690c574 | 116 | kEDMA_MinorLink, /*!< Channel link after each minor loop */ |
AnnaBridge | 145:64910690c574 | 117 | kEDMA_MajorLink, /*!< Channel link while major loop count exhausted */ |
AnnaBridge | 145:64910690c574 | 118 | } edma_channel_link_type_t; |
AnnaBridge | 145:64910690c574 | 119 | |
AnnaBridge | 145:64910690c574 | 120 | /*!@brief eDMA channel status flags. */ |
AnnaBridge | 145:64910690c574 | 121 | enum _edma_channel_status_flags |
AnnaBridge | 145:64910690c574 | 122 | { |
AnnaBridge | 145:64910690c574 | 123 | kEDMA_DoneFlag = 0x1U, /*!< DONE flag, set while transfer finished, CITER value exhausted*/ |
AnnaBridge | 145:64910690c574 | 124 | kEDMA_ErrorFlag = 0x2U, /*!< eDMA error flag, an error occurred in a transfer */ |
AnnaBridge | 145:64910690c574 | 125 | kEDMA_InterruptFlag = 0x4U, /*!< eDMA interrupt flag, set while an interrupt occurred of this channel */ |
AnnaBridge | 145:64910690c574 | 126 | }; |
AnnaBridge | 145:64910690c574 | 127 | |
AnnaBridge | 145:64910690c574 | 128 | /*! @brief eDMA channel error status flags. */ |
AnnaBridge | 145:64910690c574 | 129 | enum _edma_error_status_flags |
AnnaBridge | 145:64910690c574 | 130 | { |
AnnaBridge | 145:64910690c574 | 131 | kEDMA_DestinationBusErrorFlag = DMA_ES_DBE_MASK, /*!< Bus error on destination address */ |
AnnaBridge | 145:64910690c574 | 132 | kEDMA_SourceBusErrorFlag = DMA_ES_SBE_MASK, /*!< Bus error on the source address */ |
AnnaBridge | 145:64910690c574 | 133 | kEDMA_ScatterGatherErrorFlag = DMA_ES_SGE_MASK, /*!< Error on the Scatter/Gather address, not 32byte aligned. */ |
AnnaBridge | 145:64910690c574 | 134 | kEDMA_NbytesErrorFlag = DMA_ES_NCE_MASK, /*!< NBYTES/CITER configuration error */ |
AnnaBridge | 145:64910690c574 | 135 | kEDMA_DestinationOffsetErrorFlag = DMA_ES_DOE_MASK, /*!< Destination offset not aligned with destination size */ |
AnnaBridge | 145:64910690c574 | 136 | kEDMA_DestinationAddressErrorFlag = DMA_ES_DAE_MASK, /*!< Destination address not aligned with destination size */ |
AnnaBridge | 145:64910690c574 | 137 | kEDMA_SourceOffsetErrorFlag = DMA_ES_SOE_MASK, /*!< Source offset not aligned with source size */ |
AnnaBridge | 145:64910690c574 | 138 | kEDMA_SourceAddressErrorFlag = DMA_ES_SAE_MASK, /*!< Source address not aligned with source size*/ |
AnnaBridge | 145:64910690c574 | 139 | kEDMA_ErrorChannelFlag = DMA_ES_ERRCHN_MASK, /*!< Error channel number of the cancelled channel number */ |
AnnaBridge | 145:64910690c574 | 140 | kEDMA_ChannelPriorityErrorFlag = DMA_ES_CPE_MASK, /*!< Channel priority is not unique. */ |
AnnaBridge | 145:64910690c574 | 141 | kEDMA_TransferCanceledFlag = DMA_ES_ECX_MASK, /*!< Transfer cancelled */ |
AnnaBridge | 145:64910690c574 | 142 | #if defined(FSL_FEATURE_EDMA_CHANNEL_GROUP_COUNT) && FSL_FEATURE_EDMA_CHANNEL_GROUP_COUNT > 1 |
AnnaBridge | 145:64910690c574 | 143 | kEDMA_GroupPriorityErrorFlag = DMA_ES_GPE_MASK, /*!< Group priority is not unique. */ |
AnnaBridge | 145:64910690c574 | 144 | #endif |
AnnaBridge | 145:64910690c574 | 145 | kEDMA_ValidFlag = DMA_ES_VLD_MASK, /*!< No error occurred, this bit is 0. Otherwise, it is 1. */ |
AnnaBridge | 145:64910690c574 | 146 | }; |
AnnaBridge | 145:64910690c574 | 147 | |
AnnaBridge | 145:64910690c574 | 148 | /*! @brief eDMA interrupt source */ |
AnnaBridge | 145:64910690c574 | 149 | typedef enum _edma_interrupt_enable |
AnnaBridge | 145:64910690c574 | 150 | { |
AnnaBridge | 145:64910690c574 | 151 | kEDMA_ErrorInterruptEnable = 0x1U, /*!< Enable interrupt while channel error occurs. */ |
AnnaBridge | 145:64910690c574 | 152 | kEDMA_MajorInterruptEnable = DMA_CSR_INTMAJOR_MASK, /*!< Enable interrupt while major count exhausted. */ |
AnnaBridge | 145:64910690c574 | 153 | kEDMA_HalfInterruptEnable = DMA_CSR_INTHALF_MASK, /*!< Enable interrupt while major count to half value. */ |
AnnaBridge | 145:64910690c574 | 154 | } edma_interrupt_enable_t; |
AnnaBridge | 145:64910690c574 | 155 | |
AnnaBridge | 145:64910690c574 | 156 | /*! @brief eDMA transfer type */ |
AnnaBridge | 145:64910690c574 | 157 | typedef enum _edma_transfer_type |
AnnaBridge | 145:64910690c574 | 158 | { |
AnnaBridge | 145:64910690c574 | 159 | kEDMA_MemoryToMemory = 0x0U, /*!< Transfer from memory to memory */ |
AnnaBridge | 145:64910690c574 | 160 | kEDMA_PeripheralToMemory, /*!< Transfer from peripheral to memory */ |
AnnaBridge | 145:64910690c574 | 161 | kEDMA_MemoryToPeripheral, /*!< Transfer from memory to peripheral */ |
AnnaBridge | 145:64910690c574 | 162 | } edma_transfer_type_t; |
AnnaBridge | 145:64910690c574 | 163 | |
AnnaBridge | 145:64910690c574 | 164 | /*! @brief eDMA transfer status */ |
AnnaBridge | 145:64910690c574 | 165 | enum _edma_transfer_status |
AnnaBridge | 145:64910690c574 | 166 | { |
AnnaBridge | 145:64910690c574 | 167 | kStatus_EDMA_QueueFull = MAKE_STATUS(kStatusGroup_EDMA, 0), /*!< TCD queue is full. */ |
AnnaBridge | 145:64910690c574 | 168 | kStatus_EDMA_Busy = MAKE_STATUS(kStatusGroup_EDMA, 1), /*!< Channel is busy and can't handle the |
AnnaBridge | 145:64910690c574 | 169 | transfer request. */ |
AnnaBridge | 145:64910690c574 | 170 | }; |
AnnaBridge | 145:64910690c574 | 171 | |
AnnaBridge | 145:64910690c574 | 172 | /*! @brief eDMA global configuration structure.*/ |
AnnaBridge | 145:64910690c574 | 173 | typedef struct _edma_config |
AnnaBridge | 145:64910690c574 | 174 | { |
AnnaBridge | 145:64910690c574 | 175 | bool enableContinuousLinkMode; /*!< Enable (true) continuous link mode. Upon minor loop completion, the channel |
AnnaBridge | 145:64910690c574 | 176 | activates again if that channel has a minor loop channel link enabled and |
AnnaBridge | 145:64910690c574 | 177 | the link channel is itself. */ |
AnnaBridge | 145:64910690c574 | 178 | bool enableHaltOnError; /*!< Enable (true) transfer halt on error. Any error causes the HALT bit to set. |
AnnaBridge | 145:64910690c574 | 179 | Subsequently, all service requests are ignored until the HALT bit is cleared.*/ |
AnnaBridge | 145:64910690c574 | 180 | bool enableRoundRobinArbitration; /*!< Enable (true) round robin channel arbitration method, or fixed priority |
AnnaBridge | 145:64910690c574 | 181 | arbitration is used for channel selection */ |
AnnaBridge | 145:64910690c574 | 182 | bool enableDebugMode; /*!< Enable(true) eDMA debug mode. When in debug mode, the eDMA stalls the start of |
AnnaBridge | 145:64910690c574 | 183 | a new channel. Executing channels are allowed to complete. */ |
AnnaBridge | 145:64910690c574 | 184 | } edma_config_t; |
AnnaBridge | 145:64910690c574 | 185 | |
AnnaBridge | 145:64910690c574 | 186 | /*! |
AnnaBridge | 145:64910690c574 | 187 | * @brief eDMA transfer configuration |
AnnaBridge | 145:64910690c574 | 188 | * |
AnnaBridge | 145:64910690c574 | 189 | * This structure configures the source/destination transfer attribute. |
AnnaBridge | 145:64910690c574 | 190 | * This figure shows the eDMA's transfer model: |
AnnaBridge | 145:64910690c574 | 191 | * _________________________________________________ |
AnnaBridge | 145:64910690c574 | 192 | * | Transfer Size | | |
AnnaBridge | 145:64910690c574 | 193 | * Minor Loop |_______________| Major loop Count 1 | |
AnnaBridge | 145:64910690c574 | 194 | * Bytes | Transfer Size | | |
AnnaBridge | 145:64910690c574 | 195 | * ____________|_______________|____________________|--> Minor loop complete |
AnnaBridge | 145:64910690c574 | 196 | * ____________________________________ |
AnnaBridge | 145:64910690c574 | 197 | * | | | |
AnnaBridge | 145:64910690c574 | 198 | * |_______________| Major Loop Count 2 | |
AnnaBridge | 145:64910690c574 | 199 | * | | | |
AnnaBridge | 145:64910690c574 | 200 | * |_______________|____________________|--> Minor loop Complete |
AnnaBridge | 145:64910690c574 | 201 | * |
AnnaBridge | 145:64910690c574 | 202 | * ---------------------------------------------------------> Transfer complete |
AnnaBridge | 145:64910690c574 | 203 | */ |
AnnaBridge | 145:64910690c574 | 204 | typedef struct _edma_transfer_config |
AnnaBridge | 145:64910690c574 | 205 | { |
AnnaBridge | 145:64910690c574 | 206 | uint32_t srcAddr; /*!< Source data address. */ |
AnnaBridge | 145:64910690c574 | 207 | uint32_t destAddr; /*!< Destination data address. */ |
AnnaBridge | 145:64910690c574 | 208 | edma_transfer_size_t srcTransferSize; /*!< Source data transfer size. */ |
AnnaBridge | 145:64910690c574 | 209 | edma_transfer_size_t destTransferSize; /*!< Destination data transfer size. */ |
AnnaBridge | 145:64910690c574 | 210 | int16_t srcOffset; /*!< Sign-extended offset applied to the current source address to |
AnnaBridge | 145:64910690c574 | 211 | form the next-state value as each source read is completed. */ |
AnnaBridge | 145:64910690c574 | 212 | int16_t destOffset; /*!< Sign-extended offset applied to the current destination address to |
AnnaBridge | 145:64910690c574 | 213 | form the next-state value as each destination write is completed. */ |
AnnaBridge | 145:64910690c574 | 214 | uint16_t minorLoopBytes; /*!< Bytes to transfer in a minor loop*/ |
AnnaBridge | 145:64910690c574 | 215 | uint32_t majorLoopCounts; /*!< Major loop iteration count. */ |
AnnaBridge | 145:64910690c574 | 216 | } edma_transfer_config_t; |
AnnaBridge | 145:64910690c574 | 217 | |
AnnaBridge | 145:64910690c574 | 218 | /*! @brief eDMA channel priority configuration */ |
AnnaBridge | 145:64910690c574 | 219 | typedef struct _edma_channel_Preemption_config |
AnnaBridge | 145:64910690c574 | 220 | { |
AnnaBridge | 145:64910690c574 | 221 | bool enableChannelPreemption; /*!< If true: channel can be suspended by other channel with higher priority */ |
AnnaBridge | 145:64910690c574 | 222 | bool enablePreemptAbility; /*!< If true: channel can suspend other channel with low priority */ |
AnnaBridge | 145:64910690c574 | 223 | uint8_t channelPriority; /*!< Channel priority */ |
AnnaBridge | 145:64910690c574 | 224 | } edma_channel_Preemption_config_t; |
AnnaBridge | 145:64910690c574 | 225 | |
AnnaBridge | 145:64910690c574 | 226 | /*! @brief eDMA minor offset configuration */ |
AnnaBridge | 145:64910690c574 | 227 | typedef struct _edma_minor_offset_config |
AnnaBridge | 145:64910690c574 | 228 | { |
AnnaBridge | 145:64910690c574 | 229 | bool enableSrcMinorOffset; /*!< Enable(true) or Disable(false) source minor loop offset. */ |
AnnaBridge | 145:64910690c574 | 230 | bool enableDestMinorOffset; /*!< Enable(true) or Disable(false) destination minor loop offset. */ |
AnnaBridge | 145:64910690c574 | 231 | uint32_t minorOffset; /*!< Offset for minor loop mapping. */ |
AnnaBridge | 145:64910690c574 | 232 | } edma_minor_offset_config_t; |
AnnaBridge | 145:64910690c574 | 233 | |
AnnaBridge | 145:64910690c574 | 234 | /*! |
AnnaBridge | 145:64910690c574 | 235 | * @brief eDMA TCD. |
AnnaBridge | 145:64910690c574 | 236 | * |
AnnaBridge | 145:64910690c574 | 237 | * This structure is same as TCD register which is described in reference manual, |
AnnaBridge | 145:64910690c574 | 238 | * and is used to configure the scatter/gather feature as a next hardware TCD. |
AnnaBridge | 145:64910690c574 | 239 | */ |
AnnaBridge | 145:64910690c574 | 240 | typedef struct _edma_tcd |
AnnaBridge | 145:64910690c574 | 241 | { |
AnnaBridge | 145:64910690c574 | 242 | __IO uint32_t SADDR; /*!< SADDR register, used to save source address */ |
AnnaBridge | 145:64910690c574 | 243 | __IO uint16_t SOFF; /*!< SOFF register, save offset bytes every transfer */ |
AnnaBridge | 145:64910690c574 | 244 | __IO uint16_t ATTR; /*!< ATTR register, source/destination transfer size and modulo */ |
AnnaBridge | 145:64910690c574 | 245 | __IO uint32_t NBYTES; /*!< Nbytes register, minor loop length in bytes */ |
AnnaBridge | 145:64910690c574 | 246 | __IO uint32_t SLAST; /*!< SLAST register */ |
AnnaBridge | 145:64910690c574 | 247 | __IO uint32_t DADDR; /*!< DADDR register, used for destination address */ |
AnnaBridge | 145:64910690c574 | 248 | __IO uint16_t DOFF; /*!< DOFF register, used for destination offset */ |
AnnaBridge | 145:64910690c574 | 249 | __IO uint16_t CITER; /*!< CITER register, current minor loop numbers, for unfinished minor loop.*/ |
AnnaBridge | 145:64910690c574 | 250 | __IO uint32_t DLAST_SGA; /*!< DLASTSGA register, next stcd address used in scatter-gather mode */ |
AnnaBridge | 145:64910690c574 | 251 | __IO uint16_t CSR; /*!< CSR register, for TCD control status */ |
AnnaBridge | 145:64910690c574 | 252 | __IO uint16_t BITER; /*!< BITER register, begin minor loop count. */ |
AnnaBridge | 145:64910690c574 | 253 | } edma_tcd_t; |
AnnaBridge | 145:64910690c574 | 254 | |
AnnaBridge | 145:64910690c574 | 255 | /*! @brief Callback for eDMA */ |
AnnaBridge | 145:64910690c574 | 256 | struct _edma_handle; |
AnnaBridge | 145:64910690c574 | 257 | |
AnnaBridge | 145:64910690c574 | 258 | /*! @brief Define Callback function for eDMA. */ |
AnnaBridge | 145:64910690c574 | 259 | typedef void (*edma_callback)(struct _edma_handle *handle, void *userData, bool transferDone, uint32_t tcds); |
AnnaBridge | 145:64910690c574 | 260 | |
AnnaBridge | 145:64910690c574 | 261 | /*! @brief eDMA transfer handle structure */ |
AnnaBridge | 145:64910690c574 | 262 | typedef struct _edma_handle |
AnnaBridge | 145:64910690c574 | 263 | { |
AnnaBridge | 145:64910690c574 | 264 | edma_callback callback; /*!< Callback function for major count exhausted. */ |
AnnaBridge | 145:64910690c574 | 265 | void *userData; /*!< Callback function parameter. */ |
AnnaBridge | 145:64910690c574 | 266 | DMA_Type *base; /*!< eDMA peripheral base address. */ |
AnnaBridge | 145:64910690c574 | 267 | edma_tcd_t *tcdPool; /*!< Pointer to memory stored TCDs. */ |
AnnaBridge | 145:64910690c574 | 268 | uint8_t channel; /*!< eDMA channel number. */ |
AnnaBridge | 145:64910690c574 | 269 | volatile int8_t header; /*!< The first TCD index. */ |
AnnaBridge | 145:64910690c574 | 270 | volatile int8_t tail; /*!< The last TCD index. */ |
AnnaBridge | 145:64910690c574 | 271 | volatile int8_t tcdUsed; /*!< The number of used TCD slots. */ |
AnnaBridge | 145:64910690c574 | 272 | volatile int8_t tcdSize; /*!< The total number of TCD slots in the queue. */ |
AnnaBridge | 145:64910690c574 | 273 | uint8_t flags; /*!< The status of the current channel. */ |
AnnaBridge | 145:64910690c574 | 274 | } edma_handle_t; |
AnnaBridge | 145:64910690c574 | 275 | |
AnnaBridge | 145:64910690c574 | 276 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 277 | * APIs |
AnnaBridge | 145:64910690c574 | 278 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 279 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 280 | extern "C" { |
AnnaBridge | 145:64910690c574 | 281 | #endif /* __cplusplus */ |
AnnaBridge | 145:64910690c574 | 282 | |
AnnaBridge | 145:64910690c574 | 283 | /*! |
AnnaBridge | 145:64910690c574 | 284 | * @name eDMA initialization and De-initialization |
AnnaBridge | 145:64910690c574 | 285 | * @{ |
AnnaBridge | 145:64910690c574 | 286 | */ |
AnnaBridge | 145:64910690c574 | 287 | |
AnnaBridge | 145:64910690c574 | 288 | /*! |
AnnaBridge | 145:64910690c574 | 289 | * @brief Initializes eDMA peripheral. |
AnnaBridge | 145:64910690c574 | 290 | * |
AnnaBridge | 145:64910690c574 | 291 | * This function ungates the eDMA clock and configures the eDMA peripheral according |
AnnaBridge | 145:64910690c574 | 292 | * to the configuration structure. |
AnnaBridge | 145:64910690c574 | 293 | * |
AnnaBridge | 145:64910690c574 | 294 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 295 | * @param config Pointer to configuration structure, see "edma_config_t". |
AnnaBridge | 145:64910690c574 | 296 | * @note This function enable the minor loop map feature. |
AnnaBridge | 145:64910690c574 | 297 | */ |
AnnaBridge | 145:64910690c574 | 298 | void EDMA_Init(DMA_Type *base, const edma_config_t *config); |
AnnaBridge | 145:64910690c574 | 299 | |
AnnaBridge | 145:64910690c574 | 300 | /*! |
AnnaBridge | 145:64910690c574 | 301 | * @brief Deinitializes eDMA peripheral. |
AnnaBridge | 145:64910690c574 | 302 | * |
AnnaBridge | 145:64910690c574 | 303 | * This function gates the eDMA clock. |
AnnaBridge | 145:64910690c574 | 304 | * |
AnnaBridge | 145:64910690c574 | 305 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 306 | */ |
AnnaBridge | 145:64910690c574 | 307 | void EDMA_Deinit(DMA_Type *base); |
AnnaBridge | 145:64910690c574 | 308 | |
AnnaBridge | 145:64910690c574 | 309 | /*! |
AnnaBridge | 145:64910690c574 | 310 | * @brief Gets the eDMA default configuration structure. |
AnnaBridge | 145:64910690c574 | 311 | * |
AnnaBridge | 145:64910690c574 | 312 | * This function sets the configuration structure to a default value. |
AnnaBridge | 145:64910690c574 | 313 | * The default configuration is set to the following value: |
AnnaBridge | 145:64910690c574 | 314 | * @code |
AnnaBridge | 145:64910690c574 | 315 | * config.enableContinuousLinkMode = false; |
AnnaBridge | 145:64910690c574 | 316 | * config.enableHaltOnError = true; |
AnnaBridge | 145:64910690c574 | 317 | * config.enableRoundRobinArbitration = false; |
AnnaBridge | 145:64910690c574 | 318 | * config.enableDebugMode = false; |
AnnaBridge | 145:64910690c574 | 319 | * @endcode |
AnnaBridge | 145:64910690c574 | 320 | * |
AnnaBridge | 145:64910690c574 | 321 | * @param config Pointer to eDMA configuration structure. |
AnnaBridge | 145:64910690c574 | 322 | */ |
AnnaBridge | 145:64910690c574 | 323 | void EDMA_GetDefaultConfig(edma_config_t *config); |
AnnaBridge | 145:64910690c574 | 324 | |
AnnaBridge | 145:64910690c574 | 325 | /* @} */ |
AnnaBridge | 145:64910690c574 | 326 | /*! |
AnnaBridge | 145:64910690c574 | 327 | * @name eDMA Channel Operation |
AnnaBridge | 145:64910690c574 | 328 | * @{ |
AnnaBridge | 145:64910690c574 | 329 | */ |
AnnaBridge | 145:64910690c574 | 330 | |
AnnaBridge | 145:64910690c574 | 331 | /*! |
AnnaBridge | 145:64910690c574 | 332 | * @brief Sets all TCD registers to a default value. |
AnnaBridge | 145:64910690c574 | 333 | * |
AnnaBridge | 145:64910690c574 | 334 | * This function sets TCD registers for this channel to default value. |
AnnaBridge | 145:64910690c574 | 335 | * |
AnnaBridge | 145:64910690c574 | 336 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 337 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 338 | * @note This function must not be called while the channel transfer is on-going, |
AnnaBridge | 145:64910690c574 | 339 | * or it causes unpredictable results. |
AnnaBridge | 145:64910690c574 | 340 | * @note This function enables the auto stop request feature. |
AnnaBridge | 145:64910690c574 | 341 | */ |
AnnaBridge | 145:64910690c574 | 342 | void EDMA_ResetChannel(DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 343 | |
AnnaBridge | 145:64910690c574 | 344 | /*! |
AnnaBridge | 145:64910690c574 | 345 | * @brief Configures the eDMA transfer attribute. |
AnnaBridge | 145:64910690c574 | 346 | * |
AnnaBridge | 145:64910690c574 | 347 | * This function configures the transfer attribute, including source address, destination address, |
AnnaBridge | 145:64910690c574 | 348 | * transfer size, address offset, and so on. It also configures the scatter gather feature if the |
AnnaBridge | 145:64910690c574 | 349 | * user supplies the TCD address. |
AnnaBridge | 145:64910690c574 | 350 | * Example: |
AnnaBridge | 145:64910690c574 | 351 | * @code |
AnnaBridge | 145:64910690c574 | 352 | * edma_transfer_t config; |
AnnaBridge | 145:64910690c574 | 353 | * edma_tcd_t tcd; |
AnnaBridge | 145:64910690c574 | 354 | * config.srcAddr = ..; |
AnnaBridge | 145:64910690c574 | 355 | * config.destAddr = ..; |
AnnaBridge | 145:64910690c574 | 356 | * ... |
AnnaBridge | 145:64910690c574 | 357 | * EDMA_SetTransferConfig(DMA0, channel, &config, &stcd); |
AnnaBridge | 145:64910690c574 | 358 | * @endcode |
AnnaBridge | 145:64910690c574 | 359 | * |
AnnaBridge | 145:64910690c574 | 360 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 361 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 362 | * @param config Pointer to eDMA transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 363 | * @param nextTcd Point to TCD structure. It can be NULL if users |
AnnaBridge | 145:64910690c574 | 364 | * do not want to enable scatter/gather feature. |
AnnaBridge | 145:64910690c574 | 365 | * @note If nextTcd is not NULL, it means scatter gather feature is enabled |
AnnaBridge | 145:64910690c574 | 366 | * and DREQ bit is cleared in the previous transfer configuration, which |
AnnaBridge | 145:64910690c574 | 367 | * is set in eDMA_ResetChannel. |
AnnaBridge | 145:64910690c574 | 368 | */ |
AnnaBridge | 145:64910690c574 | 369 | void EDMA_SetTransferConfig(DMA_Type *base, |
AnnaBridge | 145:64910690c574 | 370 | uint32_t channel, |
AnnaBridge | 145:64910690c574 | 371 | const edma_transfer_config_t *config, |
AnnaBridge | 145:64910690c574 | 372 | edma_tcd_t *nextTcd); |
AnnaBridge | 145:64910690c574 | 373 | |
AnnaBridge | 145:64910690c574 | 374 | /*! |
AnnaBridge | 145:64910690c574 | 375 | * @brief Configures the eDMA minor offset feature. |
AnnaBridge | 145:64910690c574 | 376 | * |
AnnaBridge | 145:64910690c574 | 377 | * Minor offset means signed-extended value added to source address or destination |
AnnaBridge | 145:64910690c574 | 378 | * address after each minor loop. |
AnnaBridge | 145:64910690c574 | 379 | * |
AnnaBridge | 145:64910690c574 | 380 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 381 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 382 | * @param config Pointer to Minor offset configuration structure. |
AnnaBridge | 145:64910690c574 | 383 | */ |
AnnaBridge | 145:64910690c574 | 384 | void EDMA_SetMinorOffsetConfig(DMA_Type *base, uint32_t channel, const edma_minor_offset_config_t *config); |
AnnaBridge | 145:64910690c574 | 385 | |
AnnaBridge | 145:64910690c574 | 386 | /*! |
AnnaBridge | 145:64910690c574 | 387 | * @brief Configures the eDMA channel preemption feature. |
AnnaBridge | 145:64910690c574 | 388 | * |
AnnaBridge | 145:64910690c574 | 389 | * This function configures the channel preemption attribute and the priority of the channel. |
AnnaBridge | 145:64910690c574 | 390 | * |
AnnaBridge | 145:64910690c574 | 391 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 392 | * @param channel eDMA channel number |
AnnaBridge | 145:64910690c574 | 393 | * @param config Pointer to channel preemption configuration structure. |
AnnaBridge | 145:64910690c574 | 394 | */ |
AnnaBridge | 145:64910690c574 | 395 | static inline void EDMA_SetChannelPreemptionConfig(DMA_Type *base, |
AnnaBridge | 145:64910690c574 | 396 | uint32_t channel, |
AnnaBridge | 145:64910690c574 | 397 | const edma_channel_Preemption_config_t *config) |
AnnaBridge | 145:64910690c574 | 398 | { |
AnnaBridge | 145:64910690c574 | 399 | assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 400 | assert(config != NULL); |
AnnaBridge | 145:64910690c574 | 401 | |
AnnaBridge | 145:64910690c574 | 402 | DMA_DCHPRIn(base, channel) = |
AnnaBridge | 145:64910690c574 | 403 | (DMA_DCHPRI0_DPA(!config->enablePreemptAbility) | DMA_DCHPRI0_ECP(config->enableChannelPreemption) | |
AnnaBridge | 145:64910690c574 | 404 | DMA_DCHPRI0_CHPRI(config->channelPriority)); |
AnnaBridge | 145:64910690c574 | 405 | } |
AnnaBridge | 145:64910690c574 | 406 | |
AnnaBridge | 145:64910690c574 | 407 | /*! |
AnnaBridge | 145:64910690c574 | 408 | * @brief Sets the channel link for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 409 | * |
AnnaBridge | 145:64910690c574 | 410 | * This function configures minor link or major link mode. The minor link means that the channel link is |
AnnaBridge | 145:64910690c574 | 411 | * triggered every time CITER decreases by 1. The major link means that the channel link is triggered when the CITER is |
AnnaBridge | 145:64910690c574 | 412 | * exhausted. |
AnnaBridge | 145:64910690c574 | 413 | * |
AnnaBridge | 145:64910690c574 | 414 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 415 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 416 | * @param type Channel link type, it can be one of: |
AnnaBridge | 145:64910690c574 | 417 | * @arg kEDMA_LinkNone |
AnnaBridge | 145:64910690c574 | 418 | * @arg kEDMA_MinorLink |
AnnaBridge | 145:64910690c574 | 419 | * @arg kEDMA_MajorLink |
AnnaBridge | 145:64910690c574 | 420 | * @param linkedChannel The linked channel number. |
AnnaBridge | 145:64910690c574 | 421 | * @note Users should ensure that DONE flag is cleared before calling this interface, or the configuration is invalid. |
AnnaBridge | 145:64910690c574 | 422 | */ |
AnnaBridge | 145:64910690c574 | 423 | void EDMA_SetChannelLink(DMA_Type *base, uint32_t channel, edma_channel_link_type_t type, uint32_t linkedChannel); |
AnnaBridge | 145:64910690c574 | 424 | |
AnnaBridge | 145:64910690c574 | 425 | /*! |
AnnaBridge | 145:64910690c574 | 426 | * @brief Sets the bandwidth for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 427 | * |
AnnaBridge | 145:64910690c574 | 428 | * In general, because the eDMA processes the minor loop, it continuously generates read/write sequences |
AnnaBridge | 145:64910690c574 | 429 | * until the minor count is exhausted. The bandwidth forces the eDMA to stall after the completion of |
AnnaBridge | 145:64910690c574 | 430 | * each read/write access to control the bus request bandwidth seen by the crossbar switch. |
AnnaBridge | 145:64910690c574 | 431 | * |
AnnaBridge | 145:64910690c574 | 432 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 433 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 434 | * @param bandWidth Bandwidth setting, it can be one of: |
AnnaBridge | 145:64910690c574 | 435 | * @arg kEDMABandwidthStallNone |
AnnaBridge | 145:64910690c574 | 436 | * @arg kEDMABandwidthStall4Cycle |
AnnaBridge | 145:64910690c574 | 437 | * @arg kEDMABandwidthStall8Cycle |
AnnaBridge | 145:64910690c574 | 438 | */ |
AnnaBridge | 145:64910690c574 | 439 | void EDMA_SetBandWidth(DMA_Type *base, uint32_t channel, edma_bandwidth_t bandWidth); |
AnnaBridge | 145:64910690c574 | 440 | |
AnnaBridge | 145:64910690c574 | 441 | /*! |
AnnaBridge | 145:64910690c574 | 442 | * @brief Sets the source modulo and destination modulo for eDMA transfer. |
AnnaBridge | 145:64910690c574 | 443 | * |
AnnaBridge | 145:64910690c574 | 444 | * This function defines a specific address range specified to be the value after (SADDR + SOFF)/(DADDR + DOFF) |
AnnaBridge | 145:64910690c574 | 445 | * calculation is performed or the original register value. It provides the ability to implement a circular data |
AnnaBridge | 145:64910690c574 | 446 | * queue easily. |
AnnaBridge | 145:64910690c574 | 447 | * |
AnnaBridge | 145:64910690c574 | 448 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 449 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 450 | * @param srcModulo Source modulo value. |
AnnaBridge | 145:64910690c574 | 451 | * @param destModulo Destination modulo value. |
AnnaBridge | 145:64910690c574 | 452 | */ |
AnnaBridge | 145:64910690c574 | 453 | void EDMA_SetModulo(DMA_Type *base, uint32_t channel, edma_modulo_t srcModulo, edma_modulo_t destModulo); |
AnnaBridge | 145:64910690c574 | 454 | |
AnnaBridge | 145:64910690c574 | 455 | #if defined(FSL_FEATURE_EDMA_ASYNCHRO_REQUEST_CHANNEL_COUNT) && FSL_FEATURE_EDMA_ASYNCHRO_REQUEST_CHANNEL_COUNT |
AnnaBridge | 145:64910690c574 | 456 | /*! |
AnnaBridge | 145:64910690c574 | 457 | * @brief Enables an async request for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 458 | * |
AnnaBridge | 145:64910690c574 | 459 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 460 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 461 | * @param enable The command for enable(ture) or disable(false). |
AnnaBridge | 145:64910690c574 | 462 | */ |
AnnaBridge | 145:64910690c574 | 463 | static inline void EDMA_EnableAsyncRequest(DMA_Type *base, uint32_t channel, bool enable) |
AnnaBridge | 145:64910690c574 | 464 | { |
AnnaBridge | 145:64910690c574 | 465 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 466 | |
AnnaBridge | 145:64910690c574 | 467 | base->EARS = (base->EARS & (~(1U << channel))) | ((uint32_t)enable << channel); |
AnnaBridge | 145:64910690c574 | 468 | } |
AnnaBridge | 145:64910690c574 | 469 | #endif /* FSL_FEATURE_EDMA_ASYNCHRO_REQUEST_CHANNEL_COUNT */ |
AnnaBridge | 145:64910690c574 | 470 | |
AnnaBridge | 145:64910690c574 | 471 | /*! |
AnnaBridge | 145:64910690c574 | 472 | * @brief Enables an auto stop request for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 473 | * |
AnnaBridge | 145:64910690c574 | 474 | * If enabling the auto stop request, the eDMA hardware automatically disables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 475 | * |
AnnaBridge | 145:64910690c574 | 476 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 477 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 478 | * @param enable The command for enable (true) or disable (false). |
AnnaBridge | 145:64910690c574 | 479 | */ |
AnnaBridge | 145:64910690c574 | 480 | static inline void EDMA_EnableAutoStopRequest(DMA_Type *base, uint32_t channel, bool enable) |
AnnaBridge | 145:64910690c574 | 481 | { |
AnnaBridge | 145:64910690c574 | 482 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 483 | |
AnnaBridge | 145:64910690c574 | 484 | base->TCD[channel].CSR = (base->TCD[channel].CSR & (~DMA_CSR_DREQ_MASK)) | DMA_CSR_DREQ(enable); |
AnnaBridge | 145:64910690c574 | 485 | } |
AnnaBridge | 145:64910690c574 | 486 | |
AnnaBridge | 145:64910690c574 | 487 | /*! |
AnnaBridge | 145:64910690c574 | 488 | * @brief Enables the interrupt source for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 489 | * |
AnnaBridge | 145:64910690c574 | 490 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 491 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 492 | * @param mask The mask of interrupt source to be set. Users need to use |
AnnaBridge | 145:64910690c574 | 493 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 494 | */ |
AnnaBridge | 145:64910690c574 | 495 | void EDMA_EnableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 496 | |
AnnaBridge | 145:64910690c574 | 497 | /*! |
AnnaBridge | 145:64910690c574 | 498 | * @brief Disables the interrupt source for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 499 | * |
AnnaBridge | 145:64910690c574 | 500 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 501 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 502 | * @param mask The mask of interrupt source to be set. Use |
AnnaBridge | 145:64910690c574 | 503 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 504 | */ |
AnnaBridge | 145:64910690c574 | 505 | void EDMA_DisableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 506 | |
AnnaBridge | 145:64910690c574 | 507 | /* @} */ |
AnnaBridge | 145:64910690c574 | 508 | /*! |
AnnaBridge | 145:64910690c574 | 509 | * @name eDMA TCD Operation |
AnnaBridge | 145:64910690c574 | 510 | * @{ |
AnnaBridge | 145:64910690c574 | 511 | */ |
AnnaBridge | 145:64910690c574 | 512 | |
AnnaBridge | 145:64910690c574 | 513 | /*! |
AnnaBridge | 145:64910690c574 | 514 | * @brief Sets all fields to default values for the TCD structure. |
AnnaBridge | 145:64910690c574 | 515 | * |
AnnaBridge | 145:64910690c574 | 516 | * This function sets all fields for this TCD structure to default value. |
AnnaBridge | 145:64910690c574 | 517 | * |
AnnaBridge | 145:64910690c574 | 518 | * @param tcd Pointer to the TCD structure. |
AnnaBridge | 145:64910690c574 | 519 | * @note This function enables the auto stop request feature. |
AnnaBridge | 145:64910690c574 | 520 | */ |
AnnaBridge | 145:64910690c574 | 521 | void EDMA_TcdReset(edma_tcd_t *tcd); |
AnnaBridge | 145:64910690c574 | 522 | |
AnnaBridge | 145:64910690c574 | 523 | /*! |
AnnaBridge | 145:64910690c574 | 524 | * @brief Configures the eDMA TCD transfer attribute. |
AnnaBridge | 145:64910690c574 | 525 | * |
AnnaBridge | 145:64910690c574 | 526 | * TCD is a transfer control descriptor. The content of the TCD is the same as hardware TCD registers. |
AnnaBridge | 145:64910690c574 | 527 | * STCD is used in scatter-gather mode. |
AnnaBridge | 145:64910690c574 | 528 | * This function configures the TCD transfer attribute, including source address, destination address, |
AnnaBridge | 145:64910690c574 | 529 | * transfer size, address offset, and so on. It also configures the scatter gather feature if the |
AnnaBridge | 145:64910690c574 | 530 | * user supplies the next TCD address. |
AnnaBridge | 145:64910690c574 | 531 | * Example: |
AnnaBridge | 145:64910690c574 | 532 | * @code |
AnnaBridge | 145:64910690c574 | 533 | * edma_transfer_t config = { |
AnnaBridge | 145:64910690c574 | 534 | * ... |
AnnaBridge | 145:64910690c574 | 535 | * } |
AnnaBridge | 145:64910690c574 | 536 | * edma_tcd_t tcd __aligned(32); |
AnnaBridge | 145:64910690c574 | 537 | * edma_tcd_t nextTcd __aligned(32); |
AnnaBridge | 145:64910690c574 | 538 | * EDMA_TcdSetTransferConfig(&tcd, &config, &nextTcd); |
AnnaBridge | 145:64910690c574 | 539 | * @endcode |
AnnaBridge | 145:64910690c574 | 540 | * |
AnnaBridge | 145:64910690c574 | 541 | * @param tcd Pointer to the TCD structure. |
AnnaBridge | 145:64910690c574 | 542 | * @param config Pointer to eDMA transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 543 | * @param nextTcd Pointer to the next TCD structure. It can be NULL if users |
AnnaBridge | 145:64910690c574 | 544 | * do not want to enable scatter/gather feature. |
AnnaBridge | 145:64910690c574 | 545 | * @note TCD address should be 32 bytes aligned, or it causes an eDMA error. |
AnnaBridge | 145:64910690c574 | 546 | * @note If the nextTcd is not NULL, the scatter gather feature is enabled |
AnnaBridge | 145:64910690c574 | 547 | * and DREQ bit is cleared in the previous transfer configuration, which |
AnnaBridge | 145:64910690c574 | 548 | * is set in the EDMA_TcdReset. |
AnnaBridge | 145:64910690c574 | 549 | */ |
AnnaBridge | 145:64910690c574 | 550 | void EDMA_TcdSetTransferConfig(edma_tcd_t *tcd, const edma_transfer_config_t *config, edma_tcd_t *nextTcd); |
AnnaBridge | 145:64910690c574 | 551 | |
AnnaBridge | 145:64910690c574 | 552 | /*! |
AnnaBridge | 145:64910690c574 | 553 | * @brief Configures the eDMA TCD minor offset feature. |
AnnaBridge | 145:64910690c574 | 554 | * |
AnnaBridge | 145:64910690c574 | 555 | * Minor offset is a signed-extended value added to the source address or destination |
AnnaBridge | 145:64910690c574 | 556 | * address after each minor loop. |
AnnaBridge | 145:64910690c574 | 557 | * |
AnnaBridge | 145:64910690c574 | 558 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 559 | * @param config Pointer to Minor offset configuration structure. |
AnnaBridge | 145:64910690c574 | 560 | */ |
AnnaBridge | 145:64910690c574 | 561 | void EDMA_TcdSetMinorOffsetConfig(edma_tcd_t *tcd, const edma_minor_offset_config_t *config); |
AnnaBridge | 145:64910690c574 | 562 | |
AnnaBridge | 145:64910690c574 | 563 | /*! |
AnnaBridge | 145:64910690c574 | 564 | * @brief Sets the channel link for eDMA TCD. |
AnnaBridge | 145:64910690c574 | 565 | * |
AnnaBridge | 145:64910690c574 | 566 | * This function configures either a minor link or a major link. The minor link means the channel link is |
AnnaBridge | 145:64910690c574 | 567 | * triggered every time CITER decreases by 1. The major link means that the channel link is triggered when the CITER is |
AnnaBridge | 145:64910690c574 | 568 | * exhausted. |
AnnaBridge | 145:64910690c574 | 569 | * |
AnnaBridge | 145:64910690c574 | 570 | * @note Users should ensure that DONE flag is cleared before calling this interface, or the configuration is invalid. |
AnnaBridge | 145:64910690c574 | 571 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 572 | * @param type Channel link type, it can be one of: |
AnnaBridge | 145:64910690c574 | 573 | * @arg kEDMA_LinkNone |
AnnaBridge | 145:64910690c574 | 574 | * @arg kEDMA_MinorLink |
AnnaBridge | 145:64910690c574 | 575 | * @arg kEDMA_MajorLink |
AnnaBridge | 145:64910690c574 | 576 | * @param linkedChannel The linked channel number. |
AnnaBridge | 145:64910690c574 | 577 | */ |
AnnaBridge | 145:64910690c574 | 578 | void EDMA_TcdSetChannelLink(edma_tcd_t *tcd, edma_channel_link_type_t type, uint32_t linkedChannel); |
AnnaBridge | 145:64910690c574 | 579 | |
AnnaBridge | 145:64910690c574 | 580 | /*! |
AnnaBridge | 145:64910690c574 | 581 | * @brief Sets the bandwidth for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 582 | * |
AnnaBridge | 145:64910690c574 | 583 | * In general, because the eDMA processes the minor loop, it continuously generates read/write sequences |
AnnaBridge | 145:64910690c574 | 584 | * until the minor count is exhausted. Bandwidth forces the eDMA to stall after the completion of |
AnnaBridge | 145:64910690c574 | 585 | * each read/write access to control the bus request bandwidth seen by the crossbar switch. |
AnnaBridge | 145:64910690c574 | 586 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 587 | * @param bandWidth Bandwidth setting, it can be one of: |
AnnaBridge | 145:64910690c574 | 588 | * @arg kEDMABandwidthStallNone |
AnnaBridge | 145:64910690c574 | 589 | * @arg kEDMABandwidthStall4Cycle |
AnnaBridge | 145:64910690c574 | 590 | * @arg kEDMABandwidthStall8Cycle |
AnnaBridge | 145:64910690c574 | 591 | */ |
AnnaBridge | 145:64910690c574 | 592 | static inline void EDMA_TcdSetBandWidth(edma_tcd_t *tcd, edma_bandwidth_t bandWidth) |
AnnaBridge | 145:64910690c574 | 593 | { |
AnnaBridge | 145:64910690c574 | 594 | assert(tcd != NULL); |
AnnaBridge | 145:64910690c574 | 595 | assert(((uint32_t)tcd & 0x1FU) == 0); |
AnnaBridge | 145:64910690c574 | 596 | |
AnnaBridge | 145:64910690c574 | 597 | tcd->CSR = (tcd->CSR & (~DMA_CSR_BWC_MASK)) | DMA_CSR_BWC(bandWidth); |
AnnaBridge | 145:64910690c574 | 598 | } |
AnnaBridge | 145:64910690c574 | 599 | |
AnnaBridge | 145:64910690c574 | 600 | /*! |
AnnaBridge | 145:64910690c574 | 601 | * @brief Sets the source modulo and destination modulo for eDMA TCD. |
AnnaBridge | 145:64910690c574 | 602 | * |
AnnaBridge | 145:64910690c574 | 603 | * This function defines a specific address range specified to be the value after (SADDR + SOFF)/(DADDR + DOFF) |
AnnaBridge | 145:64910690c574 | 604 | * calculation is performed or the original register value. It provides the ability to implement a circular data |
AnnaBridge | 145:64910690c574 | 605 | * queue easily. |
AnnaBridge | 145:64910690c574 | 606 | * |
AnnaBridge | 145:64910690c574 | 607 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 608 | * @param srcModulo Source modulo value. |
AnnaBridge | 145:64910690c574 | 609 | * @param destModulo Destination modulo value. |
AnnaBridge | 145:64910690c574 | 610 | */ |
AnnaBridge | 145:64910690c574 | 611 | void EDMA_TcdSetModulo(edma_tcd_t *tcd, edma_modulo_t srcModulo, edma_modulo_t destModulo); |
AnnaBridge | 145:64910690c574 | 612 | |
AnnaBridge | 145:64910690c574 | 613 | /*! |
AnnaBridge | 145:64910690c574 | 614 | * @brief Sets the auto stop request for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 615 | * |
AnnaBridge | 145:64910690c574 | 616 | * If enabling the auto stop request, the eDMA hardware automatically disables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 617 | * |
AnnaBridge | 145:64910690c574 | 618 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 619 | * @param enable The command for enable(ture) or disable(false). |
AnnaBridge | 145:64910690c574 | 620 | */ |
AnnaBridge | 145:64910690c574 | 621 | static inline void EDMA_TcdEnableAutoStopRequest(edma_tcd_t *tcd, bool enable) |
AnnaBridge | 145:64910690c574 | 622 | { |
AnnaBridge | 145:64910690c574 | 623 | assert(tcd != NULL); |
AnnaBridge | 145:64910690c574 | 624 | assert(((uint32_t)tcd & 0x1FU) == 0); |
AnnaBridge | 145:64910690c574 | 625 | |
AnnaBridge | 145:64910690c574 | 626 | tcd->CSR = (tcd->CSR & (~DMA_CSR_DREQ_MASK)) | DMA_CSR_DREQ(enable); |
AnnaBridge | 145:64910690c574 | 627 | } |
AnnaBridge | 145:64910690c574 | 628 | |
AnnaBridge | 145:64910690c574 | 629 | /*! |
AnnaBridge | 145:64910690c574 | 630 | * @brief Enables the interrupt source for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 631 | * |
AnnaBridge | 145:64910690c574 | 632 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 633 | * @param mask The mask of interrupt source to be set. Users need to use |
AnnaBridge | 145:64910690c574 | 634 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 635 | */ |
AnnaBridge | 145:64910690c574 | 636 | void EDMA_TcdEnableInterrupts(edma_tcd_t *tcd, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 637 | |
AnnaBridge | 145:64910690c574 | 638 | /*! |
AnnaBridge | 145:64910690c574 | 639 | * @brief Disables the interrupt source for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 640 | * |
AnnaBridge | 145:64910690c574 | 641 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 642 | * @param mask The mask of interrupt source to be set. Users need to use |
AnnaBridge | 145:64910690c574 | 643 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 644 | */ |
AnnaBridge | 145:64910690c574 | 645 | void EDMA_TcdDisableInterrupts(edma_tcd_t *tcd, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 646 | |
AnnaBridge | 145:64910690c574 | 647 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 648 | /*! |
AnnaBridge | 145:64910690c574 | 649 | * @name eDMA Channel Transfer Operation |
AnnaBridge | 145:64910690c574 | 650 | * @{ |
AnnaBridge | 145:64910690c574 | 651 | */ |
AnnaBridge | 145:64910690c574 | 652 | |
AnnaBridge | 145:64910690c574 | 653 | /*! |
AnnaBridge | 145:64910690c574 | 654 | * @brief Enables the eDMA hardware channel request. |
AnnaBridge | 145:64910690c574 | 655 | * |
AnnaBridge | 145:64910690c574 | 656 | * This function enables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 657 | * |
AnnaBridge | 145:64910690c574 | 658 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 659 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 660 | */ |
AnnaBridge | 145:64910690c574 | 661 | static inline void EDMA_EnableChannelRequest(DMA_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 662 | { |
AnnaBridge | 145:64910690c574 | 663 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 664 | |
AnnaBridge | 145:64910690c574 | 665 | base->SERQ = DMA_SERQ_SERQ(channel); |
AnnaBridge | 145:64910690c574 | 666 | } |
AnnaBridge | 145:64910690c574 | 667 | |
AnnaBridge | 145:64910690c574 | 668 | /*! |
AnnaBridge | 145:64910690c574 | 669 | * @brief Disables the eDMA hardware channel request. |
AnnaBridge | 145:64910690c574 | 670 | * |
AnnaBridge | 145:64910690c574 | 671 | * This function disables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 672 | * |
AnnaBridge | 145:64910690c574 | 673 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 674 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 675 | */ |
AnnaBridge | 145:64910690c574 | 676 | static inline void EDMA_DisableChannelRequest(DMA_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 677 | { |
AnnaBridge | 145:64910690c574 | 678 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 679 | |
AnnaBridge | 145:64910690c574 | 680 | base->CERQ = DMA_CERQ_CERQ(channel); |
AnnaBridge | 145:64910690c574 | 681 | } |
AnnaBridge | 145:64910690c574 | 682 | |
AnnaBridge | 145:64910690c574 | 683 | /*! |
AnnaBridge | 145:64910690c574 | 684 | * @brief Starts the eDMA transfer by software trigger. |
AnnaBridge | 145:64910690c574 | 685 | * |
AnnaBridge | 145:64910690c574 | 686 | * This function starts a minor loop transfer. |
AnnaBridge | 145:64910690c574 | 687 | * |
AnnaBridge | 145:64910690c574 | 688 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 689 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 690 | */ |
AnnaBridge | 145:64910690c574 | 691 | static inline void EDMA_TriggerChannelStart(DMA_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 692 | { |
AnnaBridge | 145:64910690c574 | 693 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 694 | |
AnnaBridge | 145:64910690c574 | 695 | base->SSRT = DMA_SSRT_SSRT(channel); |
AnnaBridge | 145:64910690c574 | 696 | } |
AnnaBridge | 145:64910690c574 | 697 | |
AnnaBridge | 145:64910690c574 | 698 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 699 | /*! |
AnnaBridge | 145:64910690c574 | 700 | * @name eDMA Channel Status Operation |
AnnaBridge | 145:64910690c574 | 701 | * @{ |
AnnaBridge | 145:64910690c574 | 702 | */ |
AnnaBridge | 145:64910690c574 | 703 | |
AnnaBridge | 145:64910690c574 | 704 | /*! |
AnnaBridge | 145:64910690c574 | 705 | * @brief Gets the Remaining bytes from the eDMA current channel TCD. |
AnnaBridge | 145:64910690c574 | 706 | * |
AnnaBridge | 145:64910690c574 | 707 | * This function checks the TCD (Task Control Descriptor) status for a specified |
AnnaBridge | 145:64910690c574 | 708 | * eDMA channel and returns the the number of bytes that have not finished. |
AnnaBridge | 145:64910690c574 | 709 | * |
AnnaBridge | 145:64910690c574 | 710 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 711 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 712 | * @return Bytes have not been transferred yet for the current TCD. |
AnnaBridge | 145:64910690c574 | 713 | * @note This function can only be used to get unfinished bytes of transfer without |
AnnaBridge | 145:64910690c574 | 714 | * the next TCD, or it might be inaccuracy. |
AnnaBridge | 145:64910690c574 | 715 | */ |
AnnaBridge | 145:64910690c574 | 716 | uint32_t EDMA_GetRemainingBytes(DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 717 | |
AnnaBridge | 145:64910690c574 | 718 | /*! |
AnnaBridge | 145:64910690c574 | 719 | * @brief Gets the eDMA channel error status flags. |
AnnaBridge | 145:64910690c574 | 720 | * |
AnnaBridge | 145:64910690c574 | 721 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 722 | * @return The mask of error status flags. Users need to use the |
AnnaBridge | 145:64910690c574 | 723 | * _edma_error_status_flags type to decode the return variables. |
AnnaBridge | 145:64910690c574 | 724 | */ |
AnnaBridge | 145:64910690c574 | 725 | static inline uint32_t EDMA_GetErrorStatusFlags(DMA_Type *base) |
AnnaBridge | 145:64910690c574 | 726 | { |
AnnaBridge | 145:64910690c574 | 727 | return base->ES; |
AnnaBridge | 145:64910690c574 | 728 | } |
AnnaBridge | 145:64910690c574 | 729 | |
AnnaBridge | 145:64910690c574 | 730 | /*! |
AnnaBridge | 145:64910690c574 | 731 | * @brief Gets the eDMA channel status flags. |
AnnaBridge | 145:64910690c574 | 732 | * |
AnnaBridge | 145:64910690c574 | 733 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 734 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 735 | * @return The mask of channel status flags. Users need to use the |
AnnaBridge | 145:64910690c574 | 736 | * _edma_channel_status_flags type to decode the return variables. |
AnnaBridge | 145:64910690c574 | 737 | */ |
AnnaBridge | 145:64910690c574 | 738 | uint32_t EDMA_GetChannelStatusFlags(DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 739 | |
AnnaBridge | 145:64910690c574 | 740 | /*! |
AnnaBridge | 145:64910690c574 | 741 | * @brief Clears the eDMA channel status flags. |
AnnaBridge | 145:64910690c574 | 742 | * |
AnnaBridge | 145:64910690c574 | 743 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 744 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 745 | * @param mask The mask of channel status to be cleared. Users need to use |
AnnaBridge | 145:64910690c574 | 746 | * the defined _edma_channel_status_flags type. |
AnnaBridge | 145:64910690c574 | 747 | */ |
AnnaBridge | 145:64910690c574 | 748 | void EDMA_ClearChannelStatusFlags(DMA_Type *base, uint32_t channel, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 749 | |
AnnaBridge | 145:64910690c574 | 750 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 751 | /*! |
AnnaBridge | 145:64910690c574 | 752 | * @name eDMA Transactional Operation |
AnnaBridge | 145:64910690c574 | 753 | */ |
AnnaBridge | 145:64910690c574 | 754 | |
AnnaBridge | 145:64910690c574 | 755 | /*! |
AnnaBridge | 145:64910690c574 | 756 | * @brief Creates the eDMA handle. |
AnnaBridge | 145:64910690c574 | 757 | * |
AnnaBridge | 145:64910690c574 | 758 | * This function is called if using transaction API for eDMA. This function |
AnnaBridge | 145:64910690c574 | 759 | * initializes the internal state of eDMA handle. |
AnnaBridge | 145:64910690c574 | 760 | * |
AnnaBridge | 145:64910690c574 | 761 | * @param handle eDMA handle pointer. The eDMA handle stores callback function and |
AnnaBridge | 145:64910690c574 | 762 | * parameters. |
AnnaBridge | 145:64910690c574 | 763 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 764 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 765 | */ |
AnnaBridge | 145:64910690c574 | 766 | void EDMA_CreateHandle(edma_handle_t *handle, DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 767 | |
AnnaBridge | 145:64910690c574 | 768 | /*! |
AnnaBridge | 145:64910690c574 | 769 | * @brief Installs the TCDs memory pool into eDMA handle. |
AnnaBridge | 145:64910690c574 | 770 | * |
AnnaBridge | 145:64910690c574 | 771 | * This function is called after the EDMA_CreateHandle to use scatter/gather feature. |
AnnaBridge | 145:64910690c574 | 772 | * |
AnnaBridge | 145:64910690c574 | 773 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 774 | * @param tcdPool Memory pool to store TCDs. It must be 32 bytes aligned. |
AnnaBridge | 145:64910690c574 | 775 | * @param tcdSize The number of TCD slots. |
AnnaBridge | 145:64910690c574 | 776 | */ |
AnnaBridge | 145:64910690c574 | 777 | void EDMA_InstallTCDMemory(edma_handle_t *handle, edma_tcd_t *tcdPool, uint32_t tcdSize); |
AnnaBridge | 145:64910690c574 | 778 | |
AnnaBridge | 145:64910690c574 | 779 | /*! |
AnnaBridge | 145:64910690c574 | 780 | * @brief Installs a callback function for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 781 | * |
AnnaBridge | 145:64910690c574 | 782 | * This callback is called in eDMA IRQ handler. Use the callback to do something after |
AnnaBridge | 145:64910690c574 | 783 | * the current major loop transfer completes. |
AnnaBridge | 145:64910690c574 | 784 | * |
AnnaBridge | 145:64910690c574 | 785 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 786 | * @param callback eDMA callback function pointer. |
AnnaBridge | 145:64910690c574 | 787 | * @param userData Parameter for callback function. |
AnnaBridge | 145:64910690c574 | 788 | */ |
AnnaBridge | 145:64910690c574 | 789 | void EDMA_SetCallback(edma_handle_t *handle, edma_callback callback, void *userData); |
AnnaBridge | 145:64910690c574 | 790 | |
AnnaBridge | 145:64910690c574 | 791 | /*! |
AnnaBridge | 145:64910690c574 | 792 | * @brief Prepares the eDMA transfer structure. |
AnnaBridge | 145:64910690c574 | 793 | * |
AnnaBridge | 145:64910690c574 | 794 | * This function prepares the transfer configuration structure according to the user input. |
AnnaBridge | 145:64910690c574 | 795 | * |
AnnaBridge | 145:64910690c574 | 796 | * @param config The user configuration structure of type edma_transfer_t. |
AnnaBridge | 145:64910690c574 | 797 | * @param srcAddr eDMA transfer source address. |
AnnaBridge | 145:64910690c574 | 798 | * @param srcWidth eDMA transfer source address width(bytes). |
AnnaBridge | 145:64910690c574 | 799 | * @param destAddr eDMA transfer destination address. |
AnnaBridge | 145:64910690c574 | 800 | * @param destWidth eDMA transfer destination address width(bytes). |
AnnaBridge | 145:64910690c574 | 801 | * @param bytesEachRequest eDMA transfer bytes per channel request. |
AnnaBridge | 145:64910690c574 | 802 | * @param transferBytes eDMA transfer bytes to be transferred. |
AnnaBridge | 145:64910690c574 | 803 | * @param type eDMA transfer type. |
AnnaBridge | 145:64910690c574 | 804 | * @note The data address and the data width must be consistent. For example, if the SRC |
AnnaBridge | 145:64910690c574 | 805 | * is 4 bytes, so the source address must be 4 bytes aligned, or it shall result in |
AnnaBridge | 145:64910690c574 | 806 | * source address error(SAE). |
AnnaBridge | 145:64910690c574 | 807 | */ |
AnnaBridge | 145:64910690c574 | 808 | void EDMA_PrepareTransfer(edma_transfer_config_t *config, |
AnnaBridge | 145:64910690c574 | 809 | void *srcAddr, |
AnnaBridge | 145:64910690c574 | 810 | uint32_t srcWidth, |
AnnaBridge | 145:64910690c574 | 811 | void *destAddr, |
AnnaBridge | 145:64910690c574 | 812 | uint32_t destWidth, |
AnnaBridge | 145:64910690c574 | 813 | uint32_t bytesEachRequest, |
AnnaBridge | 145:64910690c574 | 814 | uint32_t transferBytes, |
AnnaBridge | 145:64910690c574 | 815 | edma_transfer_type_t type); |
AnnaBridge | 145:64910690c574 | 816 | |
AnnaBridge | 145:64910690c574 | 817 | /*! |
AnnaBridge | 145:64910690c574 | 818 | * @brief Submits the eDMA transfer request. |
AnnaBridge | 145:64910690c574 | 819 | * |
AnnaBridge | 145:64910690c574 | 820 | * This function submits the eDMA transfer request according to the transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 821 | * If the user submits the transfer request repeatedly, this function packs an unprocessed request as |
AnnaBridge | 145:64910690c574 | 822 | * a TCD and enables scatter/gather feature to process it in the next time. |
AnnaBridge | 145:64910690c574 | 823 | * |
AnnaBridge | 145:64910690c574 | 824 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 825 | * @param config Pointer to eDMA transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 826 | * @retval kStatus_EDMA_Success It means submit transfer request succeed. |
AnnaBridge | 145:64910690c574 | 827 | * @retval kStatus_EDMA_QueueFull It means TCD queue is full. Submit transfer request is not allowed. |
AnnaBridge | 145:64910690c574 | 828 | * @retval kStatus_EDMA_Busy It means the given channel is busy, need to submit request later. |
AnnaBridge | 145:64910690c574 | 829 | */ |
AnnaBridge | 145:64910690c574 | 830 | status_t EDMA_SubmitTransfer(edma_handle_t *handle, const edma_transfer_config_t *config); |
AnnaBridge | 145:64910690c574 | 831 | |
AnnaBridge | 145:64910690c574 | 832 | /*! |
AnnaBridge | 145:64910690c574 | 833 | * @brief eDMA start transfer. |
AnnaBridge | 145:64910690c574 | 834 | * |
AnnaBridge | 145:64910690c574 | 835 | * This function enables the channel request. Users can call this function after submitting the transfer request |
AnnaBridge | 145:64910690c574 | 836 | * or before submitting the transfer request. |
AnnaBridge | 145:64910690c574 | 837 | * |
AnnaBridge | 145:64910690c574 | 838 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 839 | */ |
AnnaBridge | 145:64910690c574 | 840 | void EDMA_StartTransfer(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 841 | |
AnnaBridge | 145:64910690c574 | 842 | /*! |
AnnaBridge | 145:64910690c574 | 843 | * @brief eDMA stop transfer. |
AnnaBridge | 145:64910690c574 | 844 | * |
AnnaBridge | 145:64910690c574 | 845 | * This function disables the channel request to pause the transfer. Users can call EDMA_StartTransfer() |
AnnaBridge | 145:64910690c574 | 846 | * again to resume the transfer. |
AnnaBridge | 145:64910690c574 | 847 | * |
AnnaBridge | 145:64910690c574 | 848 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 849 | */ |
AnnaBridge | 145:64910690c574 | 850 | void EDMA_StopTransfer(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 851 | |
AnnaBridge | 145:64910690c574 | 852 | /*! |
AnnaBridge | 145:64910690c574 | 853 | * @brief eDMA abort transfer. |
AnnaBridge | 145:64910690c574 | 854 | * |
AnnaBridge | 145:64910690c574 | 855 | * This function disables the channel request and clear transfer status bits. |
AnnaBridge | 145:64910690c574 | 856 | * Users can submit another transfer after calling this API. |
AnnaBridge | 145:64910690c574 | 857 | * |
AnnaBridge | 145:64910690c574 | 858 | * @param handle DMA handle pointer. |
AnnaBridge | 145:64910690c574 | 859 | */ |
AnnaBridge | 145:64910690c574 | 860 | void EDMA_AbortTransfer(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 861 | |
AnnaBridge | 145:64910690c574 | 862 | /*! |
AnnaBridge | 145:64910690c574 | 863 | * @brief eDMA IRQ handler for current major loop transfer complete. |
AnnaBridge | 145:64910690c574 | 864 | * |
AnnaBridge | 145:64910690c574 | 865 | * This function clears the channel major interrupt flag and call |
AnnaBridge | 145:64910690c574 | 866 | * the callback function if it is not NULL. |
AnnaBridge | 145:64910690c574 | 867 | * |
AnnaBridge | 145:64910690c574 | 868 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 869 | */ |
AnnaBridge | 145:64910690c574 | 870 | void EDMA_HandleIRQ(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 871 | |
AnnaBridge | 145:64910690c574 | 872 | /* @} */ |
AnnaBridge | 145:64910690c574 | 873 | |
AnnaBridge | 145:64910690c574 | 874 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 875 | } |
AnnaBridge | 145:64910690c574 | 876 | #endif /* __cplusplus */ |
AnnaBridge | 145:64910690c574 | 877 | |
AnnaBridge | 145:64910690c574 | 878 | /* @} */ |
AnnaBridge | 145:64910690c574 | 879 | |
AnnaBridge | 145:64910690c574 | 880 | #endif /*_FSL_EDMA_H_*/ |