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_K64F/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, 1, 1)) /*!< Version 2.1.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 1 K bytes. */ |
AnnaBridge | 145:64910690c574 | 81 | kEDMA_Modulo2Kbytes, /*!< Circular buffer size is 2 K bytes. */ |
AnnaBridge | 145:64910690c574 | 82 | kEDMA_Modulo4Kbytes, /*!< Circular buffer size is 4 K bytes. */ |
AnnaBridge | 145:64910690c574 | 83 | kEDMA_Modulo8Kbytes, /*!< Circular buffer size is 8 K bytes. */ |
AnnaBridge | 145:64910690c574 | 84 | kEDMA_Modulo16Kbytes, /*!< Circular buffer size is 16 K bytes. */ |
AnnaBridge | 145:64910690c574 | 85 | kEDMA_Modulo32Kbytes, /*!< Circular buffer size is 32 K bytes. */ |
AnnaBridge | 145:64910690c574 | 86 | kEDMA_Modulo64Kbytes, /*!< Circular buffer size is 64 K bytes. */ |
AnnaBridge | 145:64910690c574 | 87 | kEDMA_Modulo128Kbytes, /*!< Circular buffer size is 128 K bytes. */ |
AnnaBridge | 145:64910690c574 | 88 | kEDMA_Modulo256Kbytes, /*!< Circular buffer size is 256 K bytes. */ |
AnnaBridge | 145:64910690c574 | 89 | kEDMA_Modulo512Kbytes, /*!< Circular buffer size is 512 K bytes. */ |
AnnaBridge | 145:64910690c574 | 90 | kEDMA_Modulo1Mbytes, /*!< Circular buffer size is 1 M bytes. */ |
AnnaBridge | 145:64910690c574 | 91 | kEDMA_Modulo2Mbytes, /*!< Circular buffer size is 2 M bytes. */ |
AnnaBridge | 145:64910690c574 | 92 | kEDMA_Modulo4Mbytes, /*!< Circular buffer size is 4 M bytes. */ |
AnnaBridge | 145:64910690c574 | 93 | kEDMA_Modulo8Mbytes, /*!< Circular buffer size is 8 M bytes. */ |
AnnaBridge | 145:64910690c574 | 94 | kEDMA_Modulo16Mbytes, /*!< Circular buffer size is 16 M bytes. */ |
AnnaBridge | 145:64910690c574 | 95 | kEDMA_Modulo32Mbytes, /*!< Circular buffer size is 32 M bytes. */ |
AnnaBridge | 145:64910690c574 | 96 | kEDMA_Modulo64Mbytes, /*!< Circular buffer size is 64 M bytes. */ |
AnnaBridge | 145:64910690c574 | 97 | kEDMA_Modulo128Mbytes, /*!< Circular buffer size is 128 M bytes. */ |
AnnaBridge | 145:64910690c574 | 98 | kEDMA_Modulo256Mbytes, /*!< Circular buffer size is 256 M bytes. */ |
AnnaBridge | 145:64910690c574 | 99 | kEDMA_Modulo512Mbytes, /*!< Circular buffer size is 512 M bytes. */ |
AnnaBridge | 145:64910690c574 | 100 | kEDMA_Modulo1Gbytes, /*!< Circular buffer size is 1 G bytes. */ |
AnnaBridge | 145:64910690c574 | 101 | kEDMA_Modulo2Gbytes, /*!< Circular buffer size is 2 G 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 | uint32_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: a channel can be suspended by other channel with higher priority */ |
AnnaBridge | 145:64910690c574 | 222 | bool enablePreemptAbility; /*!< If true: a 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 a 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. Should point to the next TCD to be loaded into the eDMA engine. */ |
AnnaBridge | 145:64910690c574 | 270 | volatile int8_t tail; /*!< The last TCD index. Should point to the next TCD to be stored into the memory pool. */ |
AnnaBridge | 145:64910690c574 | 271 | volatile int8_t tcdUsed; /*!< The number of used TCD slots. Should reflect the number of TCDs can be used/loaded in |
AnnaBridge | 145:64910690c574 | 272 | the memory. */ |
AnnaBridge | 145:64910690c574 | 273 | volatile int8_t tcdSize; /*!< The total number of TCD slots in the queue. */ |
AnnaBridge | 145:64910690c574 | 274 | uint8_t flags; /*!< The status of the current channel. */ |
AnnaBridge | 145:64910690c574 | 275 | } edma_handle_t; |
AnnaBridge | 145:64910690c574 | 276 | |
AnnaBridge | 145:64910690c574 | 277 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 278 | * APIs |
AnnaBridge | 145:64910690c574 | 279 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 280 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 281 | extern "C" { |
AnnaBridge | 145:64910690c574 | 282 | #endif /* __cplusplus */ |
AnnaBridge | 145:64910690c574 | 283 | |
AnnaBridge | 145:64910690c574 | 284 | /*! |
AnnaBridge | 145:64910690c574 | 285 | * @name eDMA initialization and de-initialization |
AnnaBridge | 145:64910690c574 | 286 | * @{ |
AnnaBridge | 145:64910690c574 | 287 | */ |
AnnaBridge | 145:64910690c574 | 288 | |
AnnaBridge | 145:64910690c574 | 289 | /*! |
AnnaBridge | 145:64910690c574 | 290 | * @brief Initializes the eDMA peripheral. |
AnnaBridge | 145:64910690c574 | 291 | * |
AnnaBridge | 145:64910690c574 | 292 | * This function ungates the eDMA clock and configures the eDMA peripheral according |
AnnaBridge | 145:64910690c574 | 293 | * to the configuration structure. |
AnnaBridge | 145:64910690c574 | 294 | * |
AnnaBridge | 145:64910690c574 | 295 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 296 | * @param config A pointer to the configuration structure, see "edma_config_t". |
AnnaBridge | 145:64910690c574 | 297 | * @note This function enables the minor loop map feature. |
AnnaBridge | 145:64910690c574 | 298 | */ |
AnnaBridge | 145:64910690c574 | 299 | void EDMA_Init(DMA_Type *base, const edma_config_t *config); |
AnnaBridge | 145:64910690c574 | 300 | |
AnnaBridge | 145:64910690c574 | 301 | /*! |
AnnaBridge | 145:64910690c574 | 302 | * @brief Deinitializes the eDMA peripheral. |
AnnaBridge | 145:64910690c574 | 303 | * |
AnnaBridge | 145:64910690c574 | 304 | * This function gates the eDMA clock. |
AnnaBridge | 145:64910690c574 | 305 | * |
AnnaBridge | 145:64910690c574 | 306 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 307 | */ |
AnnaBridge | 145:64910690c574 | 308 | void EDMA_Deinit(DMA_Type *base); |
AnnaBridge | 145:64910690c574 | 309 | |
AnnaBridge | 145:64910690c574 | 310 | /*! |
AnnaBridge | 145:64910690c574 | 311 | * @brief Gets the eDMA default configuration structure. |
AnnaBridge | 145:64910690c574 | 312 | * |
AnnaBridge | 145:64910690c574 | 313 | * This function sets the configuration structure to default values. |
AnnaBridge | 145:64910690c574 | 314 | * The default configuration is set to the following values. |
AnnaBridge | 145:64910690c574 | 315 | * @code |
AnnaBridge | 145:64910690c574 | 316 | * config.enableContinuousLinkMode = false; |
AnnaBridge | 145:64910690c574 | 317 | * config.enableHaltOnError = true; |
AnnaBridge | 145:64910690c574 | 318 | * config.enableRoundRobinArbitration = false; |
AnnaBridge | 145:64910690c574 | 319 | * config.enableDebugMode = false; |
AnnaBridge | 145:64910690c574 | 320 | * @endcode |
AnnaBridge | 145:64910690c574 | 321 | * |
AnnaBridge | 145:64910690c574 | 322 | * @param config A pointer to the eDMA configuration structure. |
AnnaBridge | 145:64910690c574 | 323 | */ |
AnnaBridge | 145:64910690c574 | 324 | void EDMA_GetDefaultConfig(edma_config_t *config); |
AnnaBridge | 145:64910690c574 | 325 | |
AnnaBridge | 145:64910690c574 | 326 | /* @} */ |
AnnaBridge | 145:64910690c574 | 327 | /*! |
AnnaBridge | 145:64910690c574 | 328 | * @name eDMA Channel Operation |
AnnaBridge | 145:64910690c574 | 329 | * @{ |
AnnaBridge | 145:64910690c574 | 330 | */ |
AnnaBridge | 145:64910690c574 | 331 | |
AnnaBridge | 145:64910690c574 | 332 | /*! |
AnnaBridge | 145:64910690c574 | 333 | * @brief Sets all TCD registers to default values. |
AnnaBridge | 145:64910690c574 | 334 | * |
AnnaBridge | 145:64910690c574 | 335 | * This function sets TCD registers for this channel to default values. |
AnnaBridge | 145:64910690c574 | 336 | * |
AnnaBridge | 145:64910690c574 | 337 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 338 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 339 | * @note This function must not be called while the channel transfer is ongoing |
AnnaBridge | 145:64910690c574 | 340 | * or it causes unpredictable results. |
AnnaBridge | 145:64910690c574 | 341 | * @note This function enables the auto stop request feature. |
AnnaBridge | 145:64910690c574 | 342 | */ |
AnnaBridge | 145:64910690c574 | 343 | void EDMA_ResetChannel(DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 344 | |
AnnaBridge | 145:64910690c574 | 345 | /*! |
AnnaBridge | 145:64910690c574 | 346 | * @brief Configures the eDMA transfer attribute. |
AnnaBridge | 145:64910690c574 | 347 | * |
AnnaBridge | 145:64910690c574 | 348 | * This function configures the transfer attribute, including source address, destination address, |
AnnaBridge | 145:64910690c574 | 349 | * transfer size, address offset, and so on. It also configures the scatter gather feature if the |
AnnaBridge | 145:64910690c574 | 350 | * user supplies the TCD address. |
AnnaBridge | 145:64910690c574 | 351 | * Example: |
AnnaBridge | 145:64910690c574 | 352 | * @code |
AnnaBridge | 145:64910690c574 | 353 | * edma_transfer_t config; |
AnnaBridge | 145:64910690c574 | 354 | * edma_tcd_t tcd; |
AnnaBridge | 145:64910690c574 | 355 | * config.srcAddr = ..; |
AnnaBridge | 145:64910690c574 | 356 | * config.destAddr = ..; |
AnnaBridge | 145:64910690c574 | 357 | * ... |
AnnaBridge | 145:64910690c574 | 358 | * EDMA_SetTransferConfig(DMA0, channel, &config, &stcd); |
AnnaBridge | 145:64910690c574 | 359 | * @endcode |
AnnaBridge | 145:64910690c574 | 360 | * |
AnnaBridge | 145:64910690c574 | 361 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 362 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 363 | * @param config Pointer to eDMA transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 364 | * @param nextTcd Point to TCD structure. It can be NULL if users |
AnnaBridge | 145:64910690c574 | 365 | * do not want to enable scatter/gather feature. |
AnnaBridge | 145:64910690c574 | 366 | * @note If nextTcd is not NULL, it means scatter gather feature is enabled |
AnnaBridge | 145:64910690c574 | 367 | * and DREQ bit is cleared in the previous transfer configuration, which |
AnnaBridge | 145:64910690c574 | 368 | * is set in the eDMA_ResetChannel. |
AnnaBridge | 145:64910690c574 | 369 | */ |
AnnaBridge | 145:64910690c574 | 370 | void EDMA_SetTransferConfig(DMA_Type *base, |
AnnaBridge | 145:64910690c574 | 371 | uint32_t channel, |
AnnaBridge | 145:64910690c574 | 372 | const edma_transfer_config_t *config, |
AnnaBridge | 145:64910690c574 | 373 | edma_tcd_t *nextTcd); |
AnnaBridge | 145:64910690c574 | 374 | |
AnnaBridge | 145:64910690c574 | 375 | /*! |
AnnaBridge | 145:64910690c574 | 376 | * @brief Configures the eDMA minor offset feature. |
AnnaBridge | 145:64910690c574 | 377 | * |
AnnaBridge | 145:64910690c574 | 378 | * The minor offset means that the signed-extended value is added to the source address or destination |
AnnaBridge | 145:64910690c574 | 379 | * address after each minor loop. |
AnnaBridge | 145:64910690c574 | 380 | * |
AnnaBridge | 145:64910690c574 | 381 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 382 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 383 | * @param config A pointer to the minor offset configuration structure. |
AnnaBridge | 145:64910690c574 | 384 | */ |
AnnaBridge | 145:64910690c574 | 385 | void EDMA_SetMinorOffsetConfig(DMA_Type *base, uint32_t channel, const edma_minor_offset_config_t *config); |
AnnaBridge | 145:64910690c574 | 386 | |
AnnaBridge | 145:64910690c574 | 387 | /*! |
AnnaBridge | 145:64910690c574 | 388 | * @brief Configures the eDMA channel preemption feature. |
AnnaBridge | 145:64910690c574 | 389 | * |
AnnaBridge | 145:64910690c574 | 390 | * This function configures the channel preemption attribute and the priority of the channel. |
AnnaBridge | 145:64910690c574 | 391 | * |
AnnaBridge | 145:64910690c574 | 392 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 393 | * @param channel eDMA channel number |
AnnaBridge | 145:64910690c574 | 394 | * @param config A pointer to the channel preemption configuration structure. |
AnnaBridge | 145:64910690c574 | 395 | */ |
AnnaBridge | 145:64910690c574 | 396 | static inline void EDMA_SetChannelPreemptionConfig(DMA_Type *base, |
AnnaBridge | 145:64910690c574 | 397 | uint32_t channel, |
AnnaBridge | 145:64910690c574 | 398 | const edma_channel_Preemption_config_t *config) |
AnnaBridge | 145:64910690c574 | 399 | { |
AnnaBridge | 145:64910690c574 | 400 | assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 401 | assert(config != NULL); |
AnnaBridge | 145:64910690c574 | 402 | |
AnnaBridge | 145:64910690c574 | 403 | DMA_DCHPRIn(base, channel) = |
AnnaBridge | 145:64910690c574 | 404 | (DMA_DCHPRI0_DPA(!config->enablePreemptAbility) | DMA_DCHPRI0_ECP(config->enableChannelPreemption) | |
AnnaBridge | 145:64910690c574 | 405 | DMA_DCHPRI0_CHPRI(config->channelPriority)); |
AnnaBridge | 145:64910690c574 | 406 | } |
AnnaBridge | 145:64910690c574 | 407 | |
AnnaBridge | 145:64910690c574 | 408 | /*! |
AnnaBridge | 145:64910690c574 | 409 | * @brief Sets the channel link for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 410 | * |
AnnaBridge | 145:64910690c574 | 411 | * This function configures either the minor link or the major link mode. The minor link means that the channel link is |
AnnaBridge | 145:64910690c574 | 412 | * triggered every time CITER decreases by 1. The major link means that the channel link is triggered when the CITER is |
AnnaBridge | 145:64910690c574 | 413 | * exhausted. |
AnnaBridge | 145:64910690c574 | 414 | * |
AnnaBridge | 145:64910690c574 | 415 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 416 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 417 | * @param type A channel link type, which can be one of the following: |
AnnaBridge | 145:64910690c574 | 418 | * @arg kEDMA_LinkNone |
AnnaBridge | 145:64910690c574 | 419 | * @arg kEDMA_MinorLink |
AnnaBridge | 145:64910690c574 | 420 | * @arg kEDMA_MajorLink |
AnnaBridge | 145:64910690c574 | 421 | * @param linkedChannel The linked channel number. |
AnnaBridge | 145:64910690c574 | 422 | * @note Users should ensure that DONE flag is cleared before calling this interface, or the configuration is invalid. |
AnnaBridge | 145:64910690c574 | 423 | */ |
AnnaBridge | 145:64910690c574 | 424 | void EDMA_SetChannelLink(DMA_Type *base, uint32_t channel, edma_channel_link_type_t type, uint32_t linkedChannel); |
AnnaBridge | 145:64910690c574 | 425 | |
AnnaBridge | 145:64910690c574 | 426 | /*! |
AnnaBridge | 145:64910690c574 | 427 | * @brief Sets the bandwidth for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 428 | * |
AnnaBridge | 145:64910690c574 | 429 | * Because the eDMA processes the minor loop, it continuously generates read/write sequences |
AnnaBridge | 145:64910690c574 | 430 | * until the minor count is exhausted. The bandwidth forces the eDMA to stall after the completion of |
AnnaBridge | 145:64910690c574 | 431 | * each read/write access to control the bus request bandwidth seen by the crossbar switch. |
AnnaBridge | 145:64910690c574 | 432 | * |
AnnaBridge | 145:64910690c574 | 433 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 434 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 435 | * @param bandWidth A bandwidth setting, which can be one of the following: |
AnnaBridge | 145:64910690c574 | 436 | * @arg kEDMABandwidthStallNone |
AnnaBridge | 145:64910690c574 | 437 | * @arg kEDMABandwidthStall4Cycle |
AnnaBridge | 145:64910690c574 | 438 | * @arg kEDMABandwidthStall8Cycle |
AnnaBridge | 145:64910690c574 | 439 | */ |
AnnaBridge | 145:64910690c574 | 440 | void EDMA_SetBandWidth(DMA_Type *base, uint32_t channel, edma_bandwidth_t bandWidth); |
AnnaBridge | 145:64910690c574 | 441 | |
AnnaBridge | 145:64910690c574 | 442 | /*! |
AnnaBridge | 145:64910690c574 | 443 | * @brief Sets the source modulo and the destination modulo for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 444 | * |
AnnaBridge | 145:64910690c574 | 445 | * This function defines a specific address range specified to be the value after (SADDR + SOFF)/(DADDR + DOFF) |
AnnaBridge | 145:64910690c574 | 446 | * calculation is performed or the original register value. It provides the ability to implement a circular data |
AnnaBridge | 145:64910690c574 | 447 | * queue easily. |
AnnaBridge | 145:64910690c574 | 448 | * |
AnnaBridge | 145:64910690c574 | 449 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 450 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 451 | * @param srcModulo A source modulo value. |
AnnaBridge | 145:64910690c574 | 452 | * @param destModulo A destination modulo value. |
AnnaBridge | 145:64910690c574 | 453 | */ |
AnnaBridge | 145:64910690c574 | 454 | void EDMA_SetModulo(DMA_Type *base, uint32_t channel, edma_modulo_t srcModulo, edma_modulo_t destModulo); |
AnnaBridge | 145:64910690c574 | 455 | |
AnnaBridge | 145:64910690c574 | 456 | #if defined(FSL_FEATURE_EDMA_ASYNCHRO_REQUEST_CHANNEL_COUNT) && FSL_FEATURE_EDMA_ASYNCHRO_REQUEST_CHANNEL_COUNT |
AnnaBridge | 145:64910690c574 | 457 | /*! |
AnnaBridge | 145:64910690c574 | 458 | * @brief Enables an async request for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 459 | * |
AnnaBridge | 145:64910690c574 | 460 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 461 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 462 | * @param enable The command to enable (true) or disable (false). |
AnnaBridge | 145:64910690c574 | 463 | */ |
AnnaBridge | 145:64910690c574 | 464 | static inline void EDMA_EnableAsyncRequest(DMA_Type *base, uint32_t channel, bool enable) |
AnnaBridge | 145:64910690c574 | 465 | { |
AnnaBridge | 145:64910690c574 | 466 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 467 | |
AnnaBridge | 145:64910690c574 | 468 | base->EARS = (base->EARS & (~(1U << channel))) | ((uint32_t)enable << channel); |
AnnaBridge | 145:64910690c574 | 469 | } |
AnnaBridge | 145:64910690c574 | 470 | #endif /* FSL_FEATURE_EDMA_ASYNCHRO_REQUEST_CHANNEL_COUNT */ |
AnnaBridge | 145:64910690c574 | 471 | |
AnnaBridge | 145:64910690c574 | 472 | /*! |
AnnaBridge | 145:64910690c574 | 473 | * @brief Enables an auto stop request for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 474 | * |
AnnaBridge | 145:64910690c574 | 475 | * If enabling the auto stop request, the eDMA hardware automatically disables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 476 | * |
AnnaBridge | 145:64910690c574 | 477 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 478 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 479 | * @param enable The command to enable (true) or disable (false). |
AnnaBridge | 145:64910690c574 | 480 | */ |
AnnaBridge | 145:64910690c574 | 481 | static inline void EDMA_EnableAutoStopRequest(DMA_Type *base, uint32_t channel, bool enable) |
AnnaBridge | 145:64910690c574 | 482 | { |
AnnaBridge | 145:64910690c574 | 483 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 484 | |
AnnaBridge | 145:64910690c574 | 485 | base->TCD[channel].CSR = (base->TCD[channel].CSR & (~DMA_CSR_DREQ_MASK)) | DMA_CSR_DREQ(enable); |
AnnaBridge | 145:64910690c574 | 486 | } |
AnnaBridge | 145:64910690c574 | 487 | |
AnnaBridge | 145:64910690c574 | 488 | /*! |
AnnaBridge | 145:64910690c574 | 489 | * @brief Enables the interrupt source for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 490 | * |
AnnaBridge | 145:64910690c574 | 491 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 492 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 493 | * @param mask The mask of interrupt source to be set. Users need to use |
AnnaBridge | 145:64910690c574 | 494 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 495 | */ |
AnnaBridge | 145:64910690c574 | 496 | void EDMA_EnableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 497 | |
AnnaBridge | 145:64910690c574 | 498 | /*! |
AnnaBridge | 145:64910690c574 | 499 | * @brief Disables the interrupt source for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 500 | * |
AnnaBridge | 145:64910690c574 | 501 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 502 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 503 | * @param mask The mask of the interrupt source to be set. Use |
AnnaBridge | 145:64910690c574 | 504 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 505 | */ |
AnnaBridge | 145:64910690c574 | 506 | void EDMA_DisableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 507 | |
AnnaBridge | 145:64910690c574 | 508 | /* @} */ |
AnnaBridge | 145:64910690c574 | 509 | /*! |
AnnaBridge | 145:64910690c574 | 510 | * @name eDMA TCD Operation |
AnnaBridge | 145:64910690c574 | 511 | * @{ |
AnnaBridge | 145:64910690c574 | 512 | */ |
AnnaBridge | 145:64910690c574 | 513 | |
AnnaBridge | 145:64910690c574 | 514 | /*! |
AnnaBridge | 145:64910690c574 | 515 | * @brief Sets all fields to default values for the TCD structure. |
AnnaBridge | 145:64910690c574 | 516 | * |
AnnaBridge | 145:64910690c574 | 517 | * This function sets all fields for this TCD structure to default value. |
AnnaBridge | 145:64910690c574 | 518 | * |
AnnaBridge | 145:64910690c574 | 519 | * @param tcd Pointer to the TCD structure. |
AnnaBridge | 145:64910690c574 | 520 | * @note This function enables the auto stop request feature. |
AnnaBridge | 145:64910690c574 | 521 | */ |
AnnaBridge | 145:64910690c574 | 522 | void EDMA_TcdReset(edma_tcd_t *tcd); |
AnnaBridge | 145:64910690c574 | 523 | |
AnnaBridge | 145:64910690c574 | 524 | /*! |
AnnaBridge | 145:64910690c574 | 525 | * @brief Configures the eDMA TCD transfer attribute. |
AnnaBridge | 145:64910690c574 | 526 | * |
AnnaBridge | 145:64910690c574 | 527 | * The TCD is a transfer control descriptor. The content of the TCD is the same as the hardware TCD registers. |
AnnaBridge | 145:64910690c574 | 528 | * The STCD is used in the scatter-gather mode. |
AnnaBridge | 145:64910690c574 | 529 | * This function configures the TCD transfer attribute, including source address, destination address, |
AnnaBridge | 145:64910690c574 | 530 | * transfer size, address offset, and so on. It also configures the scatter gather feature if the |
AnnaBridge | 145:64910690c574 | 531 | * user supplies the next TCD address. |
AnnaBridge | 145:64910690c574 | 532 | * Example: |
AnnaBridge | 145:64910690c574 | 533 | * @code |
AnnaBridge | 145:64910690c574 | 534 | * edma_transfer_t config = { |
AnnaBridge | 145:64910690c574 | 535 | * ... |
AnnaBridge | 145:64910690c574 | 536 | * } |
AnnaBridge | 145:64910690c574 | 537 | * edma_tcd_t tcd __aligned(32); |
AnnaBridge | 145:64910690c574 | 538 | * edma_tcd_t nextTcd __aligned(32); |
AnnaBridge | 145:64910690c574 | 539 | * EDMA_TcdSetTransferConfig(&tcd, &config, &nextTcd); |
AnnaBridge | 145:64910690c574 | 540 | * @endcode |
AnnaBridge | 145:64910690c574 | 541 | * |
AnnaBridge | 145:64910690c574 | 542 | * @param tcd Pointer to the TCD structure. |
AnnaBridge | 145:64910690c574 | 543 | * @param config Pointer to eDMA transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 544 | * @param nextTcd Pointer to the next TCD structure. It can be NULL if users |
AnnaBridge | 145:64910690c574 | 545 | * do not want to enable scatter/gather feature. |
AnnaBridge | 145:64910690c574 | 546 | * @note TCD address should be 32 bytes aligned or it causes an eDMA error. |
AnnaBridge | 145:64910690c574 | 547 | * @note If the nextTcd is not NULL, the scatter gather feature is enabled |
AnnaBridge | 145:64910690c574 | 548 | * and DREQ bit is cleared in the previous transfer configuration, which |
AnnaBridge | 145:64910690c574 | 549 | * is set in the EDMA_TcdReset. |
AnnaBridge | 145:64910690c574 | 550 | */ |
AnnaBridge | 145:64910690c574 | 551 | void EDMA_TcdSetTransferConfig(edma_tcd_t *tcd, const edma_transfer_config_t *config, edma_tcd_t *nextTcd); |
AnnaBridge | 145:64910690c574 | 552 | |
AnnaBridge | 145:64910690c574 | 553 | /*! |
AnnaBridge | 145:64910690c574 | 554 | * @brief Configures the eDMA TCD minor offset feature. |
AnnaBridge | 145:64910690c574 | 555 | * |
AnnaBridge | 145:64910690c574 | 556 | * A minor offset is a signed-extended value added to the source address or a destination |
AnnaBridge | 145:64910690c574 | 557 | * address after each minor loop. |
AnnaBridge | 145:64910690c574 | 558 | * |
AnnaBridge | 145:64910690c574 | 559 | * @param tcd A point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 560 | * @param config A pointer to the minor offset configuration structure. |
AnnaBridge | 145:64910690c574 | 561 | */ |
AnnaBridge | 145:64910690c574 | 562 | void EDMA_TcdSetMinorOffsetConfig(edma_tcd_t *tcd, const edma_minor_offset_config_t *config); |
AnnaBridge | 145:64910690c574 | 563 | |
AnnaBridge | 145:64910690c574 | 564 | /*! |
AnnaBridge | 145:64910690c574 | 565 | * @brief Sets the channel link for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 566 | * |
AnnaBridge | 145:64910690c574 | 567 | * This function configures either a minor link or a major link. The minor link means the channel link is |
AnnaBridge | 145:64910690c574 | 568 | * triggered every time CITER decreases by 1. The major link means that the channel link is triggered when the CITER is |
AnnaBridge | 145:64910690c574 | 569 | * exhausted. |
AnnaBridge | 145:64910690c574 | 570 | * |
AnnaBridge | 145:64910690c574 | 571 | * @note Users should ensure that DONE flag is cleared before calling this interface, or the configuration is invalid. |
AnnaBridge | 145:64910690c574 | 572 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 573 | * @param type Channel link type, it can be one of: |
AnnaBridge | 145:64910690c574 | 574 | * @arg kEDMA_LinkNone |
AnnaBridge | 145:64910690c574 | 575 | * @arg kEDMA_MinorLink |
AnnaBridge | 145:64910690c574 | 576 | * @arg kEDMA_MajorLink |
AnnaBridge | 145:64910690c574 | 577 | * @param linkedChannel The linked channel number. |
AnnaBridge | 145:64910690c574 | 578 | */ |
AnnaBridge | 145:64910690c574 | 579 | void EDMA_TcdSetChannelLink(edma_tcd_t *tcd, edma_channel_link_type_t type, uint32_t linkedChannel); |
AnnaBridge | 145:64910690c574 | 580 | |
AnnaBridge | 145:64910690c574 | 581 | /*! |
AnnaBridge | 145:64910690c574 | 582 | * @brief Sets the bandwidth for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 583 | * |
AnnaBridge | 145:64910690c574 | 584 | * Because the eDMA processes the minor loop, it continuously generates read/write sequences |
AnnaBridge | 145:64910690c574 | 585 | * until the minor count is exhausted. The bandwidth forces the eDMA to stall after the completion of |
AnnaBridge | 145:64910690c574 | 586 | * each read/write access to control the bus request bandwidth seen by the crossbar switch. |
AnnaBridge | 145:64910690c574 | 587 | * @param tcd A pointer to the TCD structure. |
AnnaBridge | 145:64910690c574 | 588 | * @param bandWidth A bandwidth setting, which can be one of the following: |
AnnaBridge | 145:64910690c574 | 589 | * @arg kEDMABandwidthStallNone |
AnnaBridge | 145:64910690c574 | 590 | * @arg kEDMABandwidthStall4Cycle |
AnnaBridge | 145:64910690c574 | 591 | * @arg kEDMABandwidthStall8Cycle |
AnnaBridge | 145:64910690c574 | 592 | */ |
AnnaBridge | 145:64910690c574 | 593 | static inline void EDMA_TcdSetBandWidth(edma_tcd_t *tcd, edma_bandwidth_t bandWidth) |
AnnaBridge | 145:64910690c574 | 594 | { |
AnnaBridge | 145:64910690c574 | 595 | assert(tcd != NULL); |
AnnaBridge | 145:64910690c574 | 596 | assert(((uint32_t)tcd & 0x1FU) == 0); |
AnnaBridge | 145:64910690c574 | 597 | |
AnnaBridge | 145:64910690c574 | 598 | tcd->CSR = (tcd->CSR & (~DMA_CSR_BWC_MASK)) | DMA_CSR_BWC(bandWidth); |
AnnaBridge | 145:64910690c574 | 599 | } |
AnnaBridge | 145:64910690c574 | 600 | |
AnnaBridge | 145:64910690c574 | 601 | /*! |
AnnaBridge | 145:64910690c574 | 602 | * @brief Sets the source modulo and the destination modulo for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 603 | * |
AnnaBridge | 145:64910690c574 | 604 | * This function defines a specific address range specified to be the value after (SADDR + SOFF)/(DADDR + DOFF) |
AnnaBridge | 145:64910690c574 | 605 | * calculation is performed or the original register value. It provides the ability to implement a circular data |
AnnaBridge | 145:64910690c574 | 606 | * queue easily. |
AnnaBridge | 145:64910690c574 | 607 | * |
AnnaBridge | 145:64910690c574 | 608 | * @param tcd A pointer to the TCD structure. |
AnnaBridge | 145:64910690c574 | 609 | * @param srcModulo A source modulo value. |
AnnaBridge | 145:64910690c574 | 610 | * @param destModulo A destination modulo value. |
AnnaBridge | 145:64910690c574 | 611 | */ |
AnnaBridge | 145:64910690c574 | 612 | void EDMA_TcdSetModulo(edma_tcd_t *tcd, edma_modulo_t srcModulo, edma_modulo_t destModulo); |
AnnaBridge | 145:64910690c574 | 613 | |
AnnaBridge | 145:64910690c574 | 614 | /*! |
AnnaBridge | 145:64910690c574 | 615 | * @brief Sets the auto stop request for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 616 | * |
AnnaBridge | 145:64910690c574 | 617 | * If enabling the auto stop request, the eDMA hardware automatically disables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 618 | * |
AnnaBridge | 145:64910690c574 | 619 | * @param tcd A pointer to the TCD structure. |
AnnaBridge | 145:64910690c574 | 620 | * @param enable The command to enable (true) or disable (false). |
AnnaBridge | 145:64910690c574 | 621 | */ |
AnnaBridge | 145:64910690c574 | 622 | static inline void EDMA_TcdEnableAutoStopRequest(edma_tcd_t *tcd, bool enable) |
AnnaBridge | 145:64910690c574 | 623 | { |
AnnaBridge | 145:64910690c574 | 624 | assert(tcd != NULL); |
AnnaBridge | 145:64910690c574 | 625 | assert(((uint32_t)tcd & 0x1FU) == 0); |
AnnaBridge | 145:64910690c574 | 626 | |
AnnaBridge | 145:64910690c574 | 627 | tcd->CSR = (tcd->CSR & (~DMA_CSR_DREQ_MASK)) | DMA_CSR_DREQ(enable); |
AnnaBridge | 145:64910690c574 | 628 | } |
AnnaBridge | 145:64910690c574 | 629 | |
AnnaBridge | 145:64910690c574 | 630 | /*! |
AnnaBridge | 145:64910690c574 | 631 | * @brief Enables the interrupt source for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 632 | * |
AnnaBridge | 145:64910690c574 | 633 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 634 | * @param mask The mask of interrupt source to be set. Users need to use |
AnnaBridge | 145:64910690c574 | 635 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 636 | */ |
AnnaBridge | 145:64910690c574 | 637 | void EDMA_TcdEnableInterrupts(edma_tcd_t *tcd, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 638 | |
AnnaBridge | 145:64910690c574 | 639 | /*! |
AnnaBridge | 145:64910690c574 | 640 | * @brief Disables the interrupt source for the eDMA TCD. |
AnnaBridge | 145:64910690c574 | 641 | * |
AnnaBridge | 145:64910690c574 | 642 | * @param tcd Point to the TCD structure. |
AnnaBridge | 145:64910690c574 | 643 | * @param mask The mask of interrupt source to be set. Users need to use |
AnnaBridge | 145:64910690c574 | 644 | * the defined edma_interrupt_enable_t type. |
AnnaBridge | 145:64910690c574 | 645 | */ |
AnnaBridge | 145:64910690c574 | 646 | void EDMA_TcdDisableInterrupts(edma_tcd_t *tcd, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 647 | |
AnnaBridge | 145:64910690c574 | 648 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 649 | /*! |
AnnaBridge | 145:64910690c574 | 650 | * @name eDMA Channel Transfer Operation |
AnnaBridge | 145:64910690c574 | 651 | * @{ |
AnnaBridge | 145:64910690c574 | 652 | */ |
AnnaBridge | 145:64910690c574 | 653 | |
AnnaBridge | 145:64910690c574 | 654 | /*! |
AnnaBridge | 145:64910690c574 | 655 | * @brief Enables the eDMA hardware channel request. |
AnnaBridge | 145:64910690c574 | 656 | * |
AnnaBridge | 145:64910690c574 | 657 | * This function enables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 658 | * |
AnnaBridge | 145:64910690c574 | 659 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 660 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 661 | */ |
AnnaBridge | 145:64910690c574 | 662 | static inline void EDMA_EnableChannelRequest(DMA_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 663 | { |
AnnaBridge | 145:64910690c574 | 664 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 665 | |
AnnaBridge | 145:64910690c574 | 666 | base->SERQ = DMA_SERQ_SERQ(channel); |
AnnaBridge | 145:64910690c574 | 667 | } |
AnnaBridge | 145:64910690c574 | 668 | |
AnnaBridge | 145:64910690c574 | 669 | /*! |
AnnaBridge | 145:64910690c574 | 670 | * @brief Disables the eDMA hardware channel request. |
AnnaBridge | 145:64910690c574 | 671 | * |
AnnaBridge | 145:64910690c574 | 672 | * This function disables the hardware channel request. |
AnnaBridge | 145:64910690c574 | 673 | * |
AnnaBridge | 145:64910690c574 | 674 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 675 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 676 | */ |
AnnaBridge | 145:64910690c574 | 677 | static inline void EDMA_DisableChannelRequest(DMA_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 678 | { |
AnnaBridge | 145:64910690c574 | 679 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 680 | |
AnnaBridge | 145:64910690c574 | 681 | base->CERQ = DMA_CERQ_CERQ(channel); |
AnnaBridge | 145:64910690c574 | 682 | } |
AnnaBridge | 145:64910690c574 | 683 | |
AnnaBridge | 145:64910690c574 | 684 | /*! |
AnnaBridge | 145:64910690c574 | 685 | * @brief Starts the eDMA transfer by using the software trigger. |
AnnaBridge | 145:64910690c574 | 686 | * |
AnnaBridge | 145:64910690c574 | 687 | * This function starts a minor loop transfer. |
AnnaBridge | 145:64910690c574 | 688 | * |
AnnaBridge | 145:64910690c574 | 689 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 690 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 691 | */ |
AnnaBridge | 145:64910690c574 | 692 | static inline void EDMA_TriggerChannelStart(DMA_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 693 | { |
AnnaBridge | 145:64910690c574 | 694 | assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL); |
AnnaBridge | 145:64910690c574 | 695 | |
AnnaBridge | 145:64910690c574 | 696 | base->SSRT = DMA_SSRT_SSRT(channel); |
AnnaBridge | 145:64910690c574 | 697 | } |
AnnaBridge | 145:64910690c574 | 698 | |
AnnaBridge | 145:64910690c574 | 699 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 700 | /*! |
AnnaBridge | 145:64910690c574 | 701 | * @name eDMA Channel Status Operation |
AnnaBridge | 145:64910690c574 | 702 | * @{ |
AnnaBridge | 145:64910690c574 | 703 | */ |
AnnaBridge | 145:64910690c574 | 704 | |
AnnaBridge | 145:64910690c574 | 705 | /*! |
AnnaBridge | 145:64910690c574 | 706 | * @brief Gets the remaining major loop count from the eDMA current channel TCD. |
AnnaBridge | 145:64910690c574 | 707 | * |
AnnaBridge | 145:64910690c574 | 708 | * This function checks the TCD (Task Control Descriptor) status for a specified |
AnnaBridge | 145:64910690c574 | 709 | * eDMA channel and returns the the number of major loop count that has not finished. |
AnnaBridge | 145:64910690c574 | 710 | * |
AnnaBridge | 145:64910690c574 | 711 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 712 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 713 | * @return Major loop count which has not been transferred yet for the current TCD. |
AnnaBridge | 145:64910690c574 | 714 | * @note 1. This function can only be used to get unfinished major loop count of transfer without |
AnnaBridge | 145:64910690c574 | 715 | * the next TCD, or it might be inaccuracy. |
AnnaBridge | 145:64910690c574 | 716 | * 2. The unfinished/remaining transfer bytes cannot be obtained directly from registers while |
AnnaBridge | 145:64910690c574 | 717 | * the channel is running. |
AnnaBridge | 145:64910690c574 | 718 | * Because to calculate the remaining bytes, the initial NBYTES configured in DMA_TCDn_NBYTES_MLNO |
AnnaBridge | 145:64910690c574 | 719 | * register is needed while the eDMA IP does not support getting it while a channel is active. |
AnnaBridge | 145:64910690c574 | 720 | * In another word, the NBYTES value reading is always the actual (decrementing) NBYTES value the dma_engine |
AnnaBridge | 145:64910690c574 | 721 | * is working with while a channel is running. |
AnnaBridge | 145:64910690c574 | 722 | * Consequently, to get the remaining transfer bytes, a software-saved initial value of NBYTES (for example |
AnnaBridge | 145:64910690c574 | 723 | * copied before enabling the channel) is needed. The formula to calculate it is shown below: |
AnnaBridge | 145:64910690c574 | 724 | * RemainingBytes = RemainingMajorLoopCount * NBYTES(initially configured) |
AnnaBridge | 145:64910690c574 | 725 | */ |
AnnaBridge | 145:64910690c574 | 726 | uint32_t EDMA_GetRemainingMajorLoopCount(DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 727 | |
AnnaBridge | 145:64910690c574 | 728 | /*! |
AnnaBridge | 145:64910690c574 | 729 | * @brief Gets the eDMA channel error status flags. |
AnnaBridge | 145:64910690c574 | 730 | * |
AnnaBridge | 145:64910690c574 | 731 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 732 | * @return The mask of error status flags. Users need to use the |
AnnaBridge | 145:64910690c574 | 733 | * _edma_error_status_flags type to decode the return variables. |
AnnaBridge | 145:64910690c574 | 734 | */ |
AnnaBridge | 145:64910690c574 | 735 | static inline uint32_t EDMA_GetErrorStatusFlags(DMA_Type *base) |
AnnaBridge | 145:64910690c574 | 736 | { |
AnnaBridge | 145:64910690c574 | 737 | return base->ES; |
AnnaBridge | 145:64910690c574 | 738 | } |
AnnaBridge | 145:64910690c574 | 739 | |
AnnaBridge | 145:64910690c574 | 740 | /*! |
AnnaBridge | 145:64910690c574 | 741 | * @brief Gets 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 | * @return The mask of channel status flags. Users need to use the |
AnnaBridge | 145:64910690c574 | 746 | * _edma_channel_status_flags type to decode the return variables. |
AnnaBridge | 145:64910690c574 | 747 | */ |
AnnaBridge | 145:64910690c574 | 748 | uint32_t EDMA_GetChannelStatusFlags(DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 749 | |
AnnaBridge | 145:64910690c574 | 750 | /*! |
AnnaBridge | 145:64910690c574 | 751 | * @brief Clears the eDMA channel status flags. |
AnnaBridge | 145:64910690c574 | 752 | * |
AnnaBridge | 145:64910690c574 | 753 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 754 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 755 | * @param mask The mask of channel status to be cleared. Users need to use |
AnnaBridge | 145:64910690c574 | 756 | * the defined _edma_channel_status_flags type. |
AnnaBridge | 145:64910690c574 | 757 | */ |
AnnaBridge | 145:64910690c574 | 758 | void EDMA_ClearChannelStatusFlags(DMA_Type *base, uint32_t channel, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 759 | |
AnnaBridge | 145:64910690c574 | 760 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 761 | /*! |
AnnaBridge | 145:64910690c574 | 762 | * @name eDMA Transactional Operation |
AnnaBridge | 145:64910690c574 | 763 | */ |
AnnaBridge | 145:64910690c574 | 764 | |
AnnaBridge | 145:64910690c574 | 765 | /*! |
AnnaBridge | 145:64910690c574 | 766 | * @brief Creates the eDMA handle. |
AnnaBridge | 145:64910690c574 | 767 | * |
AnnaBridge | 145:64910690c574 | 768 | * This function is called if using the transactional API for eDMA. This function |
AnnaBridge | 145:64910690c574 | 769 | * initializes the internal state of the eDMA handle. |
AnnaBridge | 145:64910690c574 | 770 | * |
AnnaBridge | 145:64910690c574 | 771 | * @param handle eDMA handle pointer. The eDMA handle stores callback function and |
AnnaBridge | 145:64910690c574 | 772 | * parameters. |
AnnaBridge | 145:64910690c574 | 773 | * @param base eDMA peripheral base address. |
AnnaBridge | 145:64910690c574 | 774 | * @param channel eDMA channel number. |
AnnaBridge | 145:64910690c574 | 775 | */ |
AnnaBridge | 145:64910690c574 | 776 | void EDMA_CreateHandle(edma_handle_t *handle, DMA_Type *base, uint32_t channel); |
AnnaBridge | 145:64910690c574 | 777 | |
AnnaBridge | 145:64910690c574 | 778 | /*! |
AnnaBridge | 145:64910690c574 | 779 | * @brief Installs the TCDs memory pool into the eDMA handle. |
AnnaBridge | 145:64910690c574 | 780 | * |
AnnaBridge | 145:64910690c574 | 781 | * This function is called after the EDMA_CreateHandle to use scatter/gather feature. |
AnnaBridge | 145:64910690c574 | 782 | * |
AnnaBridge | 145:64910690c574 | 783 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 784 | * @param tcdPool A memory pool to store TCDs. It must be 32 bytes aligned. |
AnnaBridge | 145:64910690c574 | 785 | * @param tcdSize The number of TCD slots. |
AnnaBridge | 145:64910690c574 | 786 | */ |
AnnaBridge | 145:64910690c574 | 787 | void EDMA_InstallTCDMemory(edma_handle_t *handle, edma_tcd_t *tcdPool, uint32_t tcdSize); |
AnnaBridge | 145:64910690c574 | 788 | |
AnnaBridge | 145:64910690c574 | 789 | /*! |
AnnaBridge | 145:64910690c574 | 790 | * @brief Installs a callback function for the eDMA transfer. |
AnnaBridge | 145:64910690c574 | 791 | * |
AnnaBridge | 145:64910690c574 | 792 | * This callback is called in the eDMA IRQ handler. Use the callback to do something after |
AnnaBridge | 145:64910690c574 | 793 | * the current major loop transfer completes. |
AnnaBridge | 145:64910690c574 | 794 | * |
AnnaBridge | 145:64910690c574 | 795 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 796 | * @param callback eDMA callback function pointer. |
AnnaBridge | 145:64910690c574 | 797 | * @param userData A parameter for the callback function. |
AnnaBridge | 145:64910690c574 | 798 | */ |
AnnaBridge | 145:64910690c574 | 799 | void EDMA_SetCallback(edma_handle_t *handle, edma_callback callback, void *userData); |
AnnaBridge | 145:64910690c574 | 800 | |
AnnaBridge | 145:64910690c574 | 801 | /*! |
AnnaBridge | 145:64910690c574 | 802 | * @brief Prepares the eDMA transfer structure. |
AnnaBridge | 145:64910690c574 | 803 | * |
AnnaBridge | 145:64910690c574 | 804 | * This function prepares the transfer configuration structure according to the user input. |
AnnaBridge | 145:64910690c574 | 805 | * |
AnnaBridge | 145:64910690c574 | 806 | * @param config The user configuration structure of type edma_transfer_t. |
AnnaBridge | 145:64910690c574 | 807 | * @param srcAddr eDMA transfer source address. |
AnnaBridge | 145:64910690c574 | 808 | * @param srcWidth eDMA transfer source address width(bytes). |
AnnaBridge | 145:64910690c574 | 809 | * @param destAddr eDMA transfer destination address. |
AnnaBridge | 145:64910690c574 | 810 | * @param destWidth eDMA transfer destination address width(bytes). |
AnnaBridge | 145:64910690c574 | 811 | * @param bytesEachRequest eDMA transfer bytes per channel request. |
AnnaBridge | 145:64910690c574 | 812 | * @param transferBytes eDMA transfer bytes to be transferred. |
AnnaBridge | 145:64910690c574 | 813 | * @param type eDMA transfer type. |
AnnaBridge | 145:64910690c574 | 814 | * @note The data address and the data width must be consistent. For example, if the SRC |
AnnaBridge | 145:64910690c574 | 815 | * is 4 bytes, the source address must be 4 bytes aligned, or it results in |
AnnaBridge | 145:64910690c574 | 816 | * source address error (SAE). |
AnnaBridge | 145:64910690c574 | 817 | */ |
AnnaBridge | 145:64910690c574 | 818 | void EDMA_PrepareTransfer(edma_transfer_config_t *config, |
AnnaBridge | 145:64910690c574 | 819 | void *srcAddr, |
AnnaBridge | 145:64910690c574 | 820 | uint32_t srcWidth, |
AnnaBridge | 145:64910690c574 | 821 | void *destAddr, |
AnnaBridge | 145:64910690c574 | 822 | uint32_t destWidth, |
AnnaBridge | 145:64910690c574 | 823 | uint32_t bytesEachRequest, |
AnnaBridge | 145:64910690c574 | 824 | uint32_t transferBytes, |
AnnaBridge | 145:64910690c574 | 825 | edma_transfer_type_t type); |
AnnaBridge | 145:64910690c574 | 826 | |
AnnaBridge | 145:64910690c574 | 827 | /*! |
AnnaBridge | 145:64910690c574 | 828 | * @brief Submits the eDMA transfer request. |
AnnaBridge | 145:64910690c574 | 829 | * |
AnnaBridge | 145:64910690c574 | 830 | * This function submits the eDMA transfer request according to the transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 831 | * If submitting the transfer request repeatedly, this function packs an unprocessed request as |
AnnaBridge | 145:64910690c574 | 832 | * a TCD and enables scatter/gather feature to process it in the next time. |
AnnaBridge | 145:64910690c574 | 833 | * |
AnnaBridge | 145:64910690c574 | 834 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 835 | * @param config Pointer to eDMA transfer configuration structure. |
AnnaBridge | 145:64910690c574 | 836 | * @retval kStatus_EDMA_Success It means submit transfer request succeed. |
AnnaBridge | 145:64910690c574 | 837 | * @retval kStatus_EDMA_QueueFull It means TCD queue is full. Submit transfer request is not allowed. |
AnnaBridge | 145:64910690c574 | 838 | * @retval kStatus_EDMA_Busy It means the given channel is busy, need to submit request later. |
AnnaBridge | 145:64910690c574 | 839 | */ |
AnnaBridge | 145:64910690c574 | 840 | status_t EDMA_SubmitTransfer(edma_handle_t *handle, const edma_transfer_config_t *config); |
AnnaBridge | 145:64910690c574 | 841 | |
AnnaBridge | 145:64910690c574 | 842 | /*! |
AnnaBridge | 145:64910690c574 | 843 | * @brief eDMA starts transfer. |
AnnaBridge | 145:64910690c574 | 844 | * |
AnnaBridge | 145:64910690c574 | 845 | * This function enables the channel request. Users can call this function after submitting the transfer request |
AnnaBridge | 145:64910690c574 | 846 | * or before submitting the transfer request. |
AnnaBridge | 145:64910690c574 | 847 | * |
AnnaBridge | 145:64910690c574 | 848 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 849 | */ |
AnnaBridge | 145:64910690c574 | 850 | void EDMA_StartTransfer(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 851 | |
AnnaBridge | 145:64910690c574 | 852 | /*! |
AnnaBridge | 145:64910690c574 | 853 | * @brief eDMA stops transfer. |
AnnaBridge | 145:64910690c574 | 854 | * |
AnnaBridge | 145:64910690c574 | 855 | * This function disables the channel request to pause the transfer. Users can call EDMA_StartTransfer() |
AnnaBridge | 145:64910690c574 | 856 | * again to resume the transfer. |
AnnaBridge | 145:64910690c574 | 857 | * |
AnnaBridge | 145:64910690c574 | 858 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 859 | */ |
AnnaBridge | 145:64910690c574 | 860 | void EDMA_StopTransfer(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 861 | |
AnnaBridge | 145:64910690c574 | 862 | /*! |
AnnaBridge | 145:64910690c574 | 863 | * @brief eDMA aborts transfer. |
AnnaBridge | 145:64910690c574 | 864 | * |
AnnaBridge | 145:64910690c574 | 865 | * This function disables the channel request and clear transfer status bits. |
AnnaBridge | 145:64910690c574 | 866 | * Users can submit another transfer after calling this API. |
AnnaBridge | 145:64910690c574 | 867 | * |
AnnaBridge | 145:64910690c574 | 868 | * @param handle DMA handle pointer. |
AnnaBridge | 145:64910690c574 | 869 | */ |
AnnaBridge | 145:64910690c574 | 870 | void EDMA_AbortTransfer(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 871 | |
AnnaBridge | 145:64910690c574 | 872 | /*! |
AnnaBridge | 145:64910690c574 | 873 | * @brief eDMA IRQ handler for the current major loop transfer completion. |
AnnaBridge | 145:64910690c574 | 874 | * |
AnnaBridge | 145:64910690c574 | 875 | * This function clears the channel major interrupt flag and calls |
AnnaBridge | 145:64910690c574 | 876 | * the callback function if it is not NULL. |
AnnaBridge | 145:64910690c574 | 877 | * |
AnnaBridge | 145:64910690c574 | 878 | * Note: |
AnnaBridge | 145:64910690c574 | 879 | * For the case using TCD queue, when the major iteration count is exhausted, additional operations are performed. |
AnnaBridge | 145:64910690c574 | 880 | * These include the final address adjustments and reloading of the BITER field into the CITER. |
AnnaBridge | 145:64910690c574 | 881 | * Assertion of an optional interrupt request also occurs at this time, as does a possible fetch of a new TCD from |
AnnaBridge | 145:64910690c574 | 882 | * memory using the scatter/gather address pointer included in the descriptor (if scatter/gather is enabled). |
AnnaBridge | 145:64910690c574 | 883 | * |
AnnaBridge | 145:64910690c574 | 884 | * For instance, when the time interrupt of TCD[0] happens, the TCD[1] has already been loaded into the eDMA engine. |
AnnaBridge | 145:64910690c574 | 885 | * As sga and sga_index are calculated based on the DLAST_SGA bitfield lies in the TCD_CSR register, the sga_index |
AnnaBridge | 145:64910690c574 | 886 | * in this case should be 2 (DLAST_SGA of TCD[1] stores the address of TCD[2]). Thus, the "tcdUsed" updated should be |
AnnaBridge | 145:64910690c574 | 887 | * (tcdUsed - 2U) which indicates the number of TCDs can be loaded in the memory pool (because TCD[0] and TCD[1] have |
AnnaBridge | 145:64910690c574 | 888 | * been loaded into the eDMA engine at this point already.). |
AnnaBridge | 145:64910690c574 | 889 | * |
AnnaBridge | 145:64910690c574 | 890 | * For the last two continuous ISRs in a scatter/gather process, they both load the last TCD (The last ISR does not |
AnnaBridge | 145:64910690c574 | 891 | * load a new TCD) from the memory pool to the eDMA engine when major loop completes. |
AnnaBridge | 145:64910690c574 | 892 | * Therefore, ensure that the header and tcdUsed updated are identical for them. |
AnnaBridge | 145:64910690c574 | 893 | * tcdUsed are both 0 in this case as no TCD to be loaded. |
AnnaBridge | 145:64910690c574 | 894 | * |
AnnaBridge | 145:64910690c574 | 895 | * See the "eDMA basic data flow" in the eDMA Functional description section of the Reference Manual for |
AnnaBridge | 145:64910690c574 | 896 | * further details. |
AnnaBridge | 145:64910690c574 | 897 | * |
AnnaBridge | 145:64910690c574 | 898 | * @param handle eDMA handle pointer. |
AnnaBridge | 145:64910690c574 | 899 | */ |
AnnaBridge | 145:64910690c574 | 900 | void EDMA_HandleIRQ(edma_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 901 | |
AnnaBridge | 145:64910690c574 | 902 | /* @} */ |
AnnaBridge | 145:64910690c574 | 903 | |
AnnaBridge | 145:64910690c574 | 904 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 905 | } |
AnnaBridge | 145:64910690c574 | 906 | #endif /* __cplusplus */ |
AnnaBridge | 145:64910690c574 | 907 | |
AnnaBridge | 145:64910690c574 | 908 | /* @} */ |
AnnaBridge | 145:64910690c574 | 909 | |
AnnaBridge | 145:64910690c574 | 910 | #endif /*_FSL_EDMA_H_*/ |