mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Parent:
149:1fb5f62b92bd
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #ifndef __EDMA_HAL_H__
mbed_official 146:f64d43ff0c18 31 #define __EDMA_HAL_H__
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 #include <stdint.h>
mbed_official 146:f64d43ff0c18 34 #include <stdbool.h>
mbed_official 146:f64d43ff0c18 35 #include <assert.h>
mbed_official 146:f64d43ff0c18 36 #include "fsl_edma_features.h"
mbed_official 146:f64d43ff0c18 37 #include "fsl_device_registers.h"
mbed_official 146:f64d43ff0c18 38
mbed_official 146:f64d43ff0c18 39 /*!
mbed_official 146:f64d43ff0c18 40 * @addtogroup edma_hal
mbed_official 146:f64d43ff0c18 41 * @{
mbed_official 146:f64d43ff0c18 42 */
mbed_official 146:f64d43ff0c18 43
mbed_official 146:f64d43ff0c18 44 /*******************************************************************************
mbed_official 146:f64d43ff0c18 45 * Definitions
mbed_official 146:f64d43ff0c18 46 ******************************************************************************/
mbed_official 324:406fd2029f23 47 /*! @brief Error code for the eDMA Driver. */
mbed_official 324:406fd2029f23 48 typedef enum _edma_status {
mbed_official 146:f64d43ff0c18 49 kStatus_EDMA_Success = 0U,
mbed_official 324:406fd2029f23 50 kStatus_EDMA_InvalidArgument = 1U, /*!< Parameter is invalid. */
mbed_official 324:406fd2029f23 51 kStatus_EDMA_Fail = 2U /*!< Failed operation. */
mbed_official 146:f64d43ff0c18 52 } edma_status_t;
mbed_official 146:f64d43ff0c18 53
mbed_official 324:406fd2029f23 54 /*! @brief eDMA channel arbitration algorithm used for selection among channels. */
mbed_official 324:406fd2029f23 55 typedef enum _edma_channel_arbitration {
mbed_official 324:406fd2029f23 56 kEDMAChnArbitrationFixedPriority = 0U, /*!< Fixed Priority arbitration is used for selection
mbed_official 324:406fd2029f23 57 among channels. */
mbed_official 324:406fd2029f23 58 kEDMAChnArbitrationRoundrobin /*!< Round-Robin arbitration is used for selection among
mbed_official 324:406fd2029f23 59 channels. */
mbed_official 324:406fd2029f23 60 } edma_channel_arbitration_t;
mbed_official 146:f64d43ff0c18 61
mbed_official 324:406fd2029f23 62 /*! @brief eDMA channel priority setting */
mbed_official 324:406fd2029f23 63 typedef enum _edma_chn_priority {
mbed_official 324:406fd2029f23 64 kEDMAChnPriority0 = 0U,
mbed_official 324:406fd2029f23 65 kEDMAChnPriority1,
mbed_official 324:406fd2029f23 66 kEDMAChnPriority2,
mbed_official 324:406fd2029f23 67 kEDMAChnPriority3,
mbed_official 324:406fd2029f23 68 kEDMAChnPriority4,
mbed_official 324:406fd2029f23 69 kEDMAChnPriority5,
mbed_official 324:406fd2029f23 70 kEDMAChnPriority6,
mbed_official 324:406fd2029f23 71 kEDMAChnPriority7,
mbed_official 324:406fd2029f23 72 kEDMAChnPriority8,
mbed_official 324:406fd2029f23 73 kEDMAChnPriority9,
mbed_official 324:406fd2029f23 74 kEDMAChnPriority10,
mbed_official 324:406fd2029f23 75 kEDMAChnPriority11,
mbed_official 324:406fd2029f23 76 kEDMAChnPriority12,
mbed_official 324:406fd2029f23 77 kEDMAChnPriority13,
mbed_official 324:406fd2029f23 78 kEDMAChnPriority14,
mbed_official 324:406fd2029f23 79 kEDMAChnPriority15
mbed_official 324:406fd2029f23 80 } edma_channel_priority_t;
mbed_official 146:f64d43ff0c18 81
mbed_official 324:406fd2029f23 82 #if (FSL_FEATURE_EDMA_CHANNEL_GROUP_COUNT > 0x1U)
mbed_official 324:406fd2029f23 83 /*! @brief eDMA group arbitration algorithm used for selection among channels. */
mbed_official 324:406fd2029f23 84 typedef enum _edma_group_arbitration
mbed_official 324:406fd2029f23 85 {
mbed_official 324:406fd2029f23 86 kEDMAGroupArbitrationFixedPriority = 0U, /*!< Fixed Priority arbitration is used for
mbed_official 324:406fd2029f23 87 selection among eDMA groups. */
mbed_official 324:406fd2029f23 88 kEDMAGroupArbitrationRoundrobin /*!< Round-Robin arbitration is used for selection
mbed_official 324:406fd2029f23 89 among eDMA channels. */
mbed_official 324:406fd2029f23 90 } edma_group_arbitration_t;
mbed_official 324:406fd2029f23 91
mbed_official 324:406fd2029f23 92 /*! @brief eDMA group priority setting */
mbed_official 324:406fd2029f23 93 typedef enum _edma_group_priority {
mbed_official 324:406fd2029f23 94 kEDMAGroup0PriorityLowGroup1PriorityHigh, /*!< eDMA group 0's priority is lower priority.
mbed_official 324:406fd2029f23 95 eDMA group 1's priority is higher priority. */
mbed_official 324:406fd2029f23 96 kEDMAGroup0PriorityHighGroup1PriorityLow /*!< eDMA group 0's priority is higher priority.
mbed_official 324:406fd2029f23 97 eDMA group 1's priority is lower priority. */
mbed_official 324:406fd2029f23 98 } edma_group_priority_t;
mbed_official 324:406fd2029f23 99 #endif
mbed_official 146:f64d43ff0c18 100
mbed_official 146:f64d43ff0c18 101 /*! @brief eDMA modulo configuration */
mbed_official 146:f64d43ff0c18 102 typedef enum _edma_modulo {
mbed_official 324:406fd2029f23 103 kEDMAModuloDisable = 0U,
mbed_official 324:406fd2029f23 104 kEDMAModulo2bytes,
mbed_official 324:406fd2029f23 105 kEDMAModulo4bytes,
mbed_official 324:406fd2029f23 106 kEDMAModulo8bytes,
mbed_official 324:406fd2029f23 107 kEDMAModulo16bytes,
mbed_official 324:406fd2029f23 108 kEDMAModulo32bytes,
mbed_official 324:406fd2029f23 109 kEDMAModulo64bytes,
mbed_official 324:406fd2029f23 110 kEDMAModulo128bytes,
mbed_official 324:406fd2029f23 111 kEDMAModulo256bytes,
mbed_official 324:406fd2029f23 112 kEDMAModulo512bytes,
mbed_official 324:406fd2029f23 113 kEDMAModulo1Kbytes,
mbed_official 324:406fd2029f23 114 kEDMAModulo2Kbytes,
mbed_official 324:406fd2029f23 115 kEDMAModulo4Kbytes,
mbed_official 324:406fd2029f23 116 kEDMAModulo8Kbytes,
mbed_official 324:406fd2029f23 117 kEDMAModulo16Kbytes,
mbed_official 324:406fd2029f23 118 kEDMAModulo32Kbytes,
mbed_official 324:406fd2029f23 119 kEDMAModulo64Kbytes,
mbed_official 324:406fd2029f23 120 kEDMAModulo128Kbytes,
mbed_official 324:406fd2029f23 121 kEDMAModulo256Kbytes,
mbed_official 324:406fd2029f23 122 kEDMAModulo512Kbytes,
mbed_official 324:406fd2029f23 123 kEDMAModulo1Mbytes,
mbed_official 324:406fd2029f23 124 kEDMAModulo2Mbytes,
mbed_official 324:406fd2029f23 125 kEDMAModulo4Mbytes,
mbed_official 324:406fd2029f23 126 kEDMAModulo8Mbytes,
mbed_official 324:406fd2029f23 127 kEDMAModulo16Mbytes,
mbed_official 324:406fd2029f23 128 kEDMAModulo32Mbytes,
mbed_official 324:406fd2029f23 129 kEDMAModulo64Mbytes,
mbed_official 324:406fd2029f23 130 kEDMAModulo128Mbytes,
mbed_official 324:406fd2029f23 131 kEDMAModulo256Mbytes,
mbed_official 324:406fd2029f23 132 kEDMAModulo512Mbytes,
mbed_official 324:406fd2029f23 133 kEDMAModulo1Gbytes,
mbed_official 324:406fd2029f23 134 kEDMAModulo2Gbytes
mbed_official 146:f64d43ff0c18 135 } edma_modulo_t;
mbed_official 146:f64d43ff0c18 136
mbed_official 324:406fd2029f23 137 /*! @brief eDMA transfer configuration */
mbed_official 146:f64d43ff0c18 138 typedef enum _edma_transfer_size {
mbed_official 324:406fd2029f23 139 kEDMATransferSize_1Bytes = 0x0U,
mbed_official 324:406fd2029f23 140 kEDMATransferSize_2Bytes = 0x1U,
mbed_official 324:406fd2029f23 141 kEDMATransferSize_4Bytes = 0x2U,
mbed_official 324:406fd2029f23 142 kEDMATransferSize_16Bytes = 0x4U,
mbed_official 324:406fd2029f23 143 kEDMATransferSize_32Bytes = 0x5U
mbed_official 146:f64d43ff0c18 144 } edma_transfer_size_t;
mbed_official 146:f64d43ff0c18 145
mbed_official 324:406fd2029f23 146 /*!
mbed_official 324:406fd2029f23 147 * @brief eDMA transfer size configuration.
mbed_official 324:406fd2029f23 148 *
mbed_official 324:406fd2029f23 149 * This structure configures the basic source/destination transfer attribute.
mbed_official 324:406fd2029f23 150 * This figure shows the eDMA's transfer model:
mbed_official 324:406fd2029f23 151 * _________________________________________________
mbed_official 324:406fd2029f23 152 * | Transfer Size | |
mbed_official 324:406fd2029f23 153 * Minor Loop |_______________| Major loop Count 1 |
mbed_official 324:406fd2029f23 154 * Count | Transfer Size | |
mbed_official 324:406fd2029f23 155 * ____________|_______________|____________________|--> Minor loop complete
mbed_official 324:406fd2029f23 156 * ____________________________________
mbed_official 324:406fd2029f23 157 * | | |
mbed_official 324:406fd2029f23 158 * |_______________| Major Loop Count 2 |
mbed_official 324:406fd2029f23 159 * | | |
mbed_official 324:406fd2029f23 160 * |_______________|____________________|--> Minor loop Complete
mbed_official 324:406fd2029f23 161 *
mbed_official 324:406fd2029f23 162 * ---------------------------------------------------------> Major loop complete
mbed_official 324:406fd2029f23 163 *
mbed_official 324:406fd2029f23 164 */
mbed_official 324:406fd2029f23 165 typedef struct EDMATransferConfig {
mbed_official 324:406fd2029f23 166 uint32_t srcAddr; /*!< Memory address pointing to the source data. */
mbed_official 324:406fd2029f23 167 uint32_t destAddr; /*!< Memory address pointing to the destination data. */
mbed_official 324:406fd2029f23 168 edma_transfer_size_t srcTransferSize; /*!< Source data transfer size. */
mbed_official 324:406fd2029f23 169 edma_transfer_size_t destTransferSize; /*!< Destination data transfer size. */
mbed_official 324:406fd2029f23 170 int16_t srcOffset; /*!< Sign-extended offset applied to the current source address to
mbed_official 324:406fd2029f23 171 form the next-state value as each source read/write is
mbed_official 324:406fd2029f23 172 completed. */
mbed_official 324:406fd2029f23 173 int16_t destOffset;
mbed_official 324:406fd2029f23 174 uint32_t srcLastAddrAdjust; /*!< Last source address adjustment. */
mbed_official 324:406fd2029f23 175 uint32_t destLastAddrAdjust; /*!< Last destination address adjustment. Note here it is only
mbed_official 324:406fd2029f23 176 valid when scatter/gather feature is not enabled. */
mbed_official 324:406fd2029f23 177 edma_modulo_t srcModulo; /*!< Source address modulo. */
mbed_official 324:406fd2029f23 178 edma_modulo_t destModulo; /*!< Destination address modulo. */
mbed_official 324:406fd2029f23 179 uint32_t minorLoopCount; /*!< Minor bytes transfer count. Number of bytes to be transferred
mbed_official 324:406fd2029f23 180 in each service request of the channel. */
mbed_official 324:406fd2029f23 181 uint16_t majorLoopCount; /*!< Major iteration count. */
mbed_official 324:406fd2029f23 182 } edma_transfer_config_t;
mbed_official 324:406fd2029f23 183
mbed_official 324:406fd2029f23 184 /*! @brief eDMA channel configuration. */
mbed_official 324:406fd2029f23 185 typedef enum _edma_channel_indicator {
mbed_official 324:406fd2029f23 186 kEDMAChannel0 = 0U, /*!< Channel 0. */
mbed_official 324:406fd2029f23 187 kEDMAChannel1 = 1U,
mbed_official 324:406fd2029f23 188 kEDMAChannel2 = 2U,
mbed_official 324:406fd2029f23 189 kEDMAChannel3 = 3U,
mbed_official 324:406fd2029f23 190 #if (FSL_FEATURE_EDMA_MODULE_CHANNEL > 4U)
mbed_official 324:406fd2029f23 191 kEDMAChannel4 = 4U,
mbed_official 324:406fd2029f23 192 kEDMAChannel5 = 5U,
mbed_official 324:406fd2029f23 193 kEDMAChannel6 = 6U,
mbed_official 324:406fd2029f23 194 kEDMAChannel7 = 7U,
mbed_official 324:406fd2029f23 195 kEDMAChannel8 = 8U,
mbed_official 324:406fd2029f23 196 kEDMAChannel9 = 9U,
mbed_official 324:406fd2029f23 197 kEDMAChannel10 = 10U,
mbed_official 324:406fd2029f23 198 kEDMAChannel11 = 11U,
mbed_official 324:406fd2029f23 199 kEDMAChannel12 = 12U,
mbed_official 324:406fd2029f23 200 kEDMAChannel13 = 13U,
mbed_official 324:406fd2029f23 201 kEDMAChannel14 = 14U,
mbed_official 324:406fd2029f23 202 kEDMAChannel15 = 15U,
mbed_official 324:406fd2029f23 203 #endif
mbed_official 324:406fd2029f23 204 #if (FSL_FEATURE_EDMA_MODULE_CHANNEL == 32U)
mbed_official 324:406fd2029f23 205 kEDMAChannel16 = 16U,
mbed_official 324:406fd2029f23 206 kEDMAChannel17 = 17U,
mbed_official 324:406fd2029f23 207 kEDMAChannel18 = 18U,
mbed_official 324:406fd2029f23 208 kEDMAChannel19 = 19U,
mbed_official 324:406fd2029f23 209 kEDMAChannel20 = 20U,
mbed_official 324:406fd2029f23 210 kEDMAChannel21 = 21U,
mbed_official 324:406fd2029f23 211 kEDMAChannel22 = 22U,
mbed_official 324:406fd2029f23 212 kEDMAChannel23 = 23U,
mbed_official 324:406fd2029f23 213 kEDMAChannel24 = 24U,
mbed_official 324:406fd2029f23 214 kEDMAChannel25 = 25U,
mbed_official 324:406fd2029f23 215 kEDMAChannel26 = 26U,
mbed_official 324:406fd2029f23 216 kEDMAChannel27 = 27U,
mbed_official 324:406fd2029f23 217 kEDMAChannel28 = 28U,
mbed_official 324:406fd2029f23 218 kEDMAChannel29 = 29U,
mbed_official 324:406fd2029f23 219 kEDMAChannel30 = 30U,
mbed_official 324:406fd2029f23 220 kEDMAChannel31 = 31U,
mbed_official 324:406fd2029f23 221 #endif
mbed_official 324:406fd2029f23 222 kEDMAAllChannel = 64U
mbed_official 324:406fd2029f23 223 } edma_channel_indicator_t;
mbed_official 324:406fd2029f23 224
mbed_official 324:406fd2029f23 225 /*! @brief eDMA TCD Minor loop mapping configuration */
mbed_official 324:406fd2029f23 226 typedef struct EDMAMinorLoopOffsetConfig {
mbed_official 324:406fd2029f23 227 bool enableSrcMinorloop; /*!< Enable(true) or Disable(false) source minor loop offset. */
mbed_official 324:406fd2029f23 228 bool enableDestMinorloop; /*!< Enable(true) or Disable(false) destination minor loop offset. */
mbed_official 324:406fd2029f23 229 uint32_t offset; /*!< Offset for minor loop mapping. */
mbed_official 324:406fd2029f23 230 } edma_minorloop_offset_config_t;
mbed_official 324:406fd2029f23 231
mbed_official 146:f64d43ff0c18 232 /*! @brief Error status of the eDMA module */
mbed_official 324:406fd2029f23 233 typedef union EDMAErrorStatusAll {
mbed_official 146:f64d43ff0c18 234 struct {
mbed_official 146:f64d43ff0c18 235 uint32_t destinationBusError : 1; /*!< Bus error on destination address */
mbed_official 146:f64d43ff0c18 236 uint32_t sourceBusError : 1; /*!< Bus error on the SRC address */
mbed_official 146:f64d43ff0c18 237 uint32_t scatterOrGatherConfigurationError : 1; /*!< Error on the Scatter/Gather address */
mbed_official 146:f64d43ff0c18 238 uint32_t nbyteOrCiterConfigurationError : 1; /*!< NBYTES/CITER configuration error */
mbed_official 146:f64d43ff0c18 239 uint32_t destinationOffsetError : 1; /*!< Destination offset error */
mbed_official 146:f64d43ff0c18 240 uint32_t destinationAddressError : 1; /*!< Destination address error */
mbed_official 146:f64d43ff0c18 241 uint32_t sourceOffsetError : 1; /*!< Source offset error */
mbed_official 146:f64d43ff0c18 242 uint32_t sourceAddressError : 1; /*!< Source address error */
mbed_official 146:f64d43ff0c18 243 uint32_t errorChannel : 5; /*!< Error channel number of the cancelled
mbed_official 146:f64d43ff0c18 244 channel number */
mbed_official 146:f64d43ff0c18 245 uint32_t _reserved1 : 1;
mbed_official 146:f64d43ff0c18 246 uint32_t channelPriorityError : 1; /*!< Channel priority error */
mbed_official 146:f64d43ff0c18 247 uint32_t groupPriorityError : 1; /*!< Group priority error */
mbed_official 146:f64d43ff0c18 248 uint32_t transferCancelledError : 1; /*!< Transfer cancelled */
mbed_official 146:f64d43ff0c18 249 uint32_t _reserved0 : 14;
mbed_official 146:f64d43ff0c18 250 uint32_t orOfAllError : 1; /*!< Logical OR all ERR status bits */
mbed_official 146:f64d43ff0c18 251 } U;
mbed_official 146:f64d43ff0c18 252 uint32_t B;
mbed_official 146:f64d43ff0c18 253 } edma_error_status_all_t;
mbed_official 146:f64d43ff0c18 254
mbed_official 146:f64d43ff0c18 255 /*! @brief Bandwidth control configuration */
mbed_official 324:406fd2029f23 256 typedef enum _edma_bandwidth_config {
mbed_official 324:406fd2029f23 257 kEDMABandwidthStallNone = 0U, /*!< No eDMA engine stalls. */
mbed_official 324:406fd2029f23 258 kEDMABandwidthStall4Cycle = 2U, /*!< eDMA engine stalls for 4 cycles after each read/write. */
mbed_official 324:406fd2029f23 259 kEDMABandwidthStall8Cycle = 3U /*!< eDMA engine stalls for 8 cycles after each read/write. */
mbed_official 324:406fd2029f23 260 } edma_bandwidth_config_t;
mbed_official 146:f64d43ff0c18 261
mbed_official 146:f64d43ff0c18 262 /*! @brief eDMA TCD */
mbed_official 324:406fd2029f23 263 typedef struct EDMASoftwareTcd {
mbed_official 146:f64d43ff0c18 264 uint32_t SADDR;
mbed_official 146:f64d43ff0c18 265 uint16_t SOFF;
mbed_official 146:f64d43ff0c18 266 uint16_t ATTR;
mbed_official 146:f64d43ff0c18 267 union {
mbed_official 324:406fd2029f23 268 uint32_t MLNO;
mbed_official 324:406fd2029f23 269 uint32_t MLOFFNO;
mbed_official 324:406fd2029f23 270 uint32_t MLOFFYES;
mbed_official 324:406fd2029f23 271 } NBYTES;
mbed_official 146:f64d43ff0c18 272 uint32_t SLAST;
mbed_official 146:f64d43ff0c18 273 uint32_t DADDR;
mbed_official 146:f64d43ff0c18 274 uint16_t DOFF;
mbed_official 146:f64d43ff0c18 275 union {
mbed_official 324:406fd2029f23 276 uint16_t ELINKNO;
mbed_official 324:406fd2029f23 277 uint16_t ELINKYES;
mbed_official 324:406fd2029f23 278 } CITER;
mbed_official 146:f64d43ff0c18 279 uint32_t DLAST_SGA;
mbed_official 146:f64d43ff0c18 280 uint16_t CSR;
mbed_official 146:f64d43ff0c18 281 union {
mbed_official 324:406fd2029f23 282 uint16_t ELINKNO;
mbed_official 324:406fd2029f23 283 uint16_t ELINKYES;
mbed_official 324:406fd2029f23 284 } BITER;
mbed_official 146:f64d43ff0c18 285 } edma_software_tcd_t;
mbed_official 146:f64d43ff0c18 286
mbed_official 146:f64d43ff0c18 287 /*******************************************************************************
mbed_official 146:f64d43ff0c18 288 * API
mbed_official 146:f64d43ff0c18 289 ******************************************************************************/
mbed_official 146:f64d43ff0c18 290
mbed_official 146:f64d43ff0c18 291 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 292 extern "C" {
mbed_official 146:f64d43ff0c18 293 #endif
mbed_official 146:f64d43ff0c18 294
mbed_official 146:f64d43ff0c18 295 /*!
mbed_official 324:406fd2029f23 296 * @name eDMA HAL driver module level operation
mbed_official 146:f64d43ff0c18 297 * @{
mbed_official 146:f64d43ff0c18 298 */
mbed_official 146:f64d43ff0c18 299
mbed_official 146:f64d43ff0c18 300 /*!
mbed_official 324:406fd2029f23 301 * @brief Initializes eDMA module to known state.
mbed_official 146:f64d43ff0c18 302 *
mbed_official 324:406fd2029f23 303 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 304 */
mbed_official 324:406fd2029f23 305 void EDMA_HAL_Init(uint32_t baseAddr);
mbed_official 324:406fd2029f23 306
mbed_official 324:406fd2029f23 307 /*!
mbed_official 324:406fd2029f23 308 * @brief Cancels the remaining data transfer.
mbed_official 146:f64d43ff0c18 309 *
mbed_official 324:406fd2029f23 310 * This function stops the executing channel and forces the minor loop
mbed_official 324:406fd2029f23 311 * to finish. The cancellation takes effect after the last write of the
mbed_official 324:406fd2029f23 312 * current read/write sequence. The CX clears itself after the cancel has
mbed_official 324:406fd2029f23 313 * been honored. This cancel retires the channel normally as if the minor
mbed_official 324:406fd2029f23 314 * loop had completed.
mbed_official 324:406fd2029f23 315 *
mbed_official 324:406fd2029f23 316 * @param baseAddr Register base address for eDMA module.
mbed_official 146:f64d43ff0c18 317 */
mbed_official 324:406fd2029f23 318 void EDMA_HAL_CancelTransfer(uint32_t baseAddr);
mbed_official 146:f64d43ff0c18 319
mbed_official 146:f64d43ff0c18 320 /*!
mbed_official 324:406fd2029f23 321 * @brief Cancels the remaining data transfer and treats it as an error condition.
mbed_official 146:f64d43ff0c18 322 *
mbed_official 324:406fd2029f23 323 * This function stops the executing channel and forces the minor loop
mbed_official 324:406fd2029f23 324 * to finish. The cancellation takes effect after the last write of the
mbed_official 324:406fd2029f23 325 * current read/write sequence. The CX clears itself after the cancel has
mbed_official 324:406fd2029f23 326 * been honored. This cancel retires the channel normally as if the minor
mbed_official 324:406fd2029f23 327 * loop had completed. Additional thing is to treat this operation as an error
mbed_official 324:406fd2029f23 328 * condition.
mbed_official 324:406fd2029f23 329 *
mbed_official 324:406fd2029f23 330 * @param baseAddr Register base address for eDMA module.
mbed_official 146:f64d43ff0c18 331 */
mbed_official 324:406fd2029f23 332 void EDMA_HAL_ErrorCancelTransfer(uint32_t baseAddr);
mbed_official 146:f64d43ff0c18 333
mbed_official 146:f64d43ff0c18 334 /*!
mbed_official 324:406fd2029f23 335 * @brief Halts/Un-halts the DMA Operations.
mbed_official 146:f64d43ff0c18 336 *
mbed_official 324:406fd2029f23 337 * This function stalls/un-stalls the start of any new channels. Executing channels are allowed
mbed_official 324:406fd2029f23 338 * to be completed.
mbed_official 324:406fd2029f23 339 *
mbed_official 324:406fd2029f23 340 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 341 * @param halt Halts (true) or un-halts (false) eDMA transfer.
mbed_official 146:f64d43ff0c18 342 */
mbed_official 324:406fd2029f23 343 static inline void EDMA_HAL_SetHaltCmd(uint32_t baseAddr, bool halt)
mbed_official 146:f64d43ff0c18 344 {
mbed_official 324:406fd2029f23 345 BW_DMA_CR_HALT(baseAddr, halt);
mbed_official 146:f64d43ff0c18 346 }
mbed_official 146:f64d43ff0c18 347
mbed_official 146:f64d43ff0c18 348 /*!
mbed_official 324:406fd2029f23 349 * @brief Halts or does not halt the eDMA module when an error occurs.
mbed_official 146:f64d43ff0c18 350 *
mbed_official 146:f64d43ff0c18 351 * An error causes the HALT bit to be set. Subsequently, all service requests are ignored until the
mbed_official 146:f64d43ff0c18 352 * HALT bit is cleared.
mbed_official 146:f64d43ff0c18 353 *
mbed_official 324:406fd2029f23 354 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 355 * @param haltOnError Halts (true) or not halt (false) eDMA module when an error occurs.
mbed_official 146:f64d43ff0c18 356 */
mbed_official 324:406fd2029f23 357 static inline void EDMA_HAL_SetHaltOnErrorCmd(uint32_t baseAddr, bool haltOnError)
mbed_official 324:406fd2029f23 358 {
mbed_official 324:406fd2029f23 359 BW_DMA_CR_HOE(baseAddr, haltOnError);
mbed_official 146:f64d43ff0c18 360 }
mbed_official 146:f64d43ff0c18 361
mbed_official 146:f64d43ff0c18 362 /*!
mbed_official 146:f64d43ff0c18 363 * @brief Enables/Disables the eDMA DEBUG mode.
mbed_official 146:f64d43ff0c18 364 *
mbed_official 324:406fd2029f23 365 * This function enables/disables the eDMA Debug mode.
mbed_official 146:f64d43ff0c18 366 * When in debug mode, the DMA stalls the start of a new
mbed_official 146:f64d43ff0c18 367 * channel. Executing channels are allowed to complete. Channel execution resumes
mbed_official 146:f64d43ff0c18 368 * either when the system exits debug mode or when the EDBG bit is cleared.
mbed_official 146:f64d43ff0c18 369 *
mbed_official 324:406fd2029f23 370 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 371 * @param enable Enables (true) or Disable (false) eDMA module debug mode.
mbed_official 146:f64d43ff0c18 372 */
mbed_official 324:406fd2029f23 373 static inline void EDMA_HAL_SetDebugCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 374 {
mbed_official 324:406fd2029f23 375 BW_DMA_CR_EDBG(baseAddr, enable);
mbed_official 146:f64d43ff0c18 376 }
mbed_official 324:406fd2029f23 377 /* @} */
mbed_official 146:f64d43ff0c18 378
mbed_official 324:406fd2029f23 379 /*!
mbed_official 324:406fd2029f23 380 * @name eDMA HAL driver channel priority and arbitration configuration.
mbed_official 324:406fd2029f23 381 * @{
mbed_official 324:406fd2029f23 382 */
mbed_official 146:f64d43ff0c18 383 /*!
mbed_official 324:406fd2029f23 384 * @brief Sets the preempt and preemption feature for the eDMA channel.
mbed_official 324:406fd2029f23 385 *
mbed_official 324:406fd2029f23 386 * This function sets the preempt and preemption features.
mbed_official 146:f64d43ff0c18 387 *
mbed_official 324:406fd2029f23 388 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 389 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 390 * @param preempt eDMA channel can't suspend a lower priority channel (true). eDMA channel can
mbed_official 324:406fd2029f23 391 * suspend a lower priority channel (false).
mbed_official 324:406fd2029f23 392 * @param preemption eDMA channel can be temporarily suspended by the service request of a higher
mbed_official 324:406fd2029f23 393 * priority channel (true). eDMA channel can't be suspended by a higher priority channel (false).
mbed_official 146:f64d43ff0c18 394 */
mbed_official 324:406fd2029f23 395 static inline void EDMA_HAL_SetChannelPreemptMode(
mbed_official 324:406fd2029f23 396 uint32_t baseAddr, uint32_t channel, bool preempt, bool preemption)
mbed_official 146:f64d43ff0c18 397 {
mbed_official 324:406fd2029f23 398 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 399 BW_DMA_DCHPRIn_DPA(baseAddr, HW_DMA_DCHPRIn_CHANNEL(channel), preempt);
mbed_official 324:406fd2029f23 400 BW_DMA_DCHPRIn_ECP(baseAddr, HW_DMA_DCHPRIn_CHANNEL(channel), preemption);
mbed_official 146:f64d43ff0c18 401 }
mbed_official 146:f64d43ff0c18 402
mbed_official 146:f64d43ff0c18 403 /*!
mbed_official 324:406fd2029f23 404 * @brief Sets the eDMA channel priority.
mbed_official 324:406fd2029f23 405 *
mbed_official 324:406fd2029f23 406 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 407 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 408 * @param priority Priority of the DMA channel. Different channels should have different priority
mbed_official 324:406fd2029f23 409 * setting inside a group.
mbed_official 324:406fd2029f23 410 */
mbed_official 324:406fd2029f23 411 static inline void EDMA_HAL_SetChannelPriority(
mbed_official 324:406fd2029f23 412 uint32_t baseAddr, uint32_t channel, edma_channel_priority_t priority)
mbed_official 324:406fd2029f23 413 {
mbed_official 324:406fd2029f23 414 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 415 BW_DMA_DCHPRIn_CHPRI(baseAddr, HW_DMA_DCHPRIn_CHANNEL(channel), priority);
mbed_official 324:406fd2029f23 416 }
mbed_official 324:406fd2029f23 417 /*!
mbed_official 324:406fd2029f23 418 * @brief Sets the channel arbitration algorithm.
mbed_official 146:f64d43ff0c18 419 *
mbed_official 324:406fd2029f23 420 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 421 * @param channelArbitration Round-Robin way for fixed priority way.
mbed_official 324:406fd2029f23 422 */
mbed_official 324:406fd2029f23 423 static inline void EDMA_HAL_SetChannelArbitrationMode(
mbed_official 324:406fd2029f23 424 uint32_t baseAddr, edma_channel_arbitration_t channelArbitration)
mbed_official 324:406fd2029f23 425 {
mbed_official 324:406fd2029f23 426 BW_DMA_CR_ERCA(baseAddr, channelArbitration);
mbed_official 324:406fd2029f23 427 }
mbed_official 324:406fd2029f23 428
mbed_official 324:406fd2029f23 429 #if (FSL_FEATURE_EDMA_CHANNEL_GROUP_COUNT > 0x1U)
mbed_official 324:406fd2029f23 430 /*!
mbed_official 324:406fd2029f23 431 * @brief Configures the group priority.
mbed_official 324:406fd2029f23 432 *
mbed_official 324:406fd2029f23 433 * This function configures the priority for group 0 and group 1.
mbed_official 324:406fd2029f23 434 *
mbed_official 324:406fd2029f23 435 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 436 * @param groupPriority Group priority configuration. Note that each group get its own
mbed_official 324:406fd2029f23 437 * group priority.
mbed_official 146:f64d43ff0c18 438 */
mbed_official 324:406fd2029f23 439 void EDMA_HAL_SetGroupPriority(uint32_t baseAddr, edma_group_priority_t groupPriority);
mbed_official 324:406fd2029f23 440
mbed_official 324:406fd2029f23 441 /*!
mbed_official 324:406fd2029f23 442 * @brief Sets the eDMA group arbitration algorithm.
mbed_official 324:406fd2029f23 443 *
mbed_official 324:406fd2029f23 444 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 445 * @param groupArbitration Group arbitration way. Fixed-Priority way or Round-Robin way.
mbed_official 324:406fd2029f23 446 */
mbed_official 324:406fd2029f23 447 static inline void EDMA_HAL_SetGroupArbitrationMode(
mbed_official 324:406fd2029f23 448 uint32_t baseAddr, edma_group_arbitration_t groupArbitration)
mbed_official 146:f64d43ff0c18 449 {
mbed_official 324:406fd2029f23 450 BW_DMA_CR_ERGA(baseAddr, groupArbitration);
mbed_official 324:406fd2029f23 451 }
mbed_official 324:406fd2029f23 452 #endif
mbed_official 324:406fd2029f23 453 /* @} */
mbed_official 324:406fd2029f23 454
mbed_official 324:406fd2029f23 455 /*!
mbed_official 324:406fd2029f23 456 * @name eDMA HAL driver configuration and operation.
mbed_official 324:406fd2029f23 457 * @{
mbed_official 324:406fd2029f23 458 */
mbed_official 324:406fd2029f23 459 /*!
mbed_official 324:406fd2029f23 460 * @brief Enables/Disables the minor loop mapping.
mbed_official 324:406fd2029f23 461 *
mbed_official 324:406fd2029f23 462 * This function enables/disables the minor loop mapping feature.
mbed_official 324:406fd2029f23 463 * If enabled, the NBYTES is redefined to include the individual enable fields and the NBYTES field. The
mbed_official 324:406fd2029f23 464 * individual enable fields allow the minor loop offset to be applied to the source address, the
mbed_official 324:406fd2029f23 465 * destination address, or both. The NBYTES field is reduced when either offset is enabled.
mbed_official 324:406fd2029f23 466 *
mbed_official 324:406fd2029f23 467 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 468 * @param enable Enables (true) or Disable (false) minor loop mapping.
mbed_official 324:406fd2029f23 469 */
mbed_official 324:406fd2029f23 470 static inline void EDMA_HAL_SetMinorLoopMappingCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 471 {
mbed_official 324:406fd2029f23 472 BW_DMA_CR_EMLM(baseAddr, enable);
mbed_official 146:f64d43ff0c18 473 }
mbed_official 146:f64d43ff0c18 474
mbed_official 146:f64d43ff0c18 475 /*!
mbed_official 324:406fd2029f23 476 * @brief Enables or disables the continuous transfer mode.
mbed_official 146:f64d43ff0c18 477 *
mbed_official 324:406fd2029f23 478 * This function enables or disables the continuous transfer. If set, a minor loop channel link
mbed_official 324:406fd2029f23 479 * does not go through the channel arbitration before being activated again. Upon minor loop
mbed_official 324:406fd2029f23 480 * completion, the channel activates again if that channel has a minor loop channel link enabled and
mbed_official 324:406fd2029f23 481 * the link channel is itself.
mbed_official 324:406fd2029f23 482 *
mbed_official 324:406fd2029f23 483 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 484 * @param continuous Enables (true) or Disable (false) continuous transfer mode.
mbed_official 146:f64d43ff0c18 485 */
mbed_official 324:406fd2029f23 486 static inline void EDMA_HAL_SetContinuousLinkCmd(uint32_t baseAddr, bool continuous)
mbed_official 146:f64d43ff0c18 487 {
mbed_official 324:406fd2029f23 488 BW_DMA_CR_CLM(baseAddr, continuous);
mbed_official 146:f64d43ff0c18 489 }
mbed_official 146:f64d43ff0c18 490
mbed_official 146:f64d43ff0c18 491 /*!
mbed_official 324:406fd2029f23 492 * @brief Gets the error status of the eDMA module.
mbed_official 146:f64d43ff0c18 493 *
mbed_official 324:406fd2029f23 494 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 495 * @return Detailed information of the error type in the eDMA module.
mbed_official 146:f64d43ff0c18 496 */
mbed_official 324:406fd2029f23 497 static inline uint32_t EDMA_HAL_GetErrorStatus(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 498 {
mbed_official 324:406fd2029f23 499 return HW_DMA_ES_RD(baseAddr);
mbed_official 146:f64d43ff0c18 500 }
mbed_official 146:f64d43ff0c18 501
mbed_official 146:f64d43ff0c18 502 /*!
mbed_official 324:406fd2029f23 503 * @brief Enables/Disables the error interrupt for channels.
mbed_official 146:f64d43ff0c18 504 *
mbed_official 324:406fd2029f23 505 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 506 * @param enable Enable(true) or Disable (false) error interrupt.
mbed_official 324:406fd2029f23 507 * @param channel Channel indicator. If kEDMAAllChannel is selected, all channels' error interrupt
mbed_official 324:406fd2029f23 508 * will be enabled/disabled.
mbed_official 146:f64d43ff0c18 509 */
mbed_official 324:406fd2029f23 510 void EDMA_HAL_SetErrorIntCmd(uint32_t baseAddr, bool enable, edma_channel_indicator_t channel);
mbed_official 324:406fd2029f23 511
mbed_official 324:406fd2029f23 512 /*!
mbed_official 324:406fd2029f23 513 * @brief Checks whether the eDMA channel error interrupt is enabled or disabled.
mbed_official 324:406fd2029f23 514 *
mbed_official 324:406fd2029f23 515 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 516 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 517 * @return Error interrupt is enabled (true) or disabled (false).
mbed_official 324:406fd2029f23 518 */
mbed_official 324:406fd2029f23 519 bool EDMA_HAL_GetErrorIntCmd(uint32_t baseAddr, uint32_t channel);
mbed_official 324:406fd2029f23 520
mbed_official 324:406fd2029f23 521 /*!
mbed_official 324:406fd2029f23 522 * @brief Gets the eDMA error interrupt status.
mbed_official 324:406fd2029f23 523 *
mbed_official 324:406fd2029f23 524 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 525 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 526 * @return 32 bit variable indicating error channels. If error happens on eDMA channel n, the bit n
mbed_official 324:406fd2029f23 527 * of this variable is '1'. If not, the bit n of this variable is '0'.
mbed_official 324:406fd2029f23 528 */
mbed_official 324:406fd2029f23 529 static inline uint32_t EDMA_HAL_GetErrorIntStatusFlag(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 530 {
mbed_official 324:406fd2029f23 531 return HW_DMA_ERR_RD(baseAddr);
mbed_official 146:f64d43ff0c18 532 }
mbed_official 146:f64d43ff0c18 533
mbed_official 146:f64d43ff0c18 534 /*!
mbed_official 324:406fd2029f23 535 * @brief Clears the error interrupt status for the eDMA channel or channels.
mbed_official 146:f64d43ff0c18 536 *
mbed_official 324:406fd2029f23 537 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 538 * @param enable Enable(true) or Disable (false) error interrupt.
mbed_official 324:406fd2029f23 539 * @param channel Channel indicator. If kEDMAAllChannel is selected, all channels' error interrupt
mbed_official 324:406fd2029f23 540 * status will be cleared.
mbed_official 146:f64d43ff0c18 541 */
mbed_official 324:406fd2029f23 542 static inline void EDMA_HAL_ClearErrorIntStatusFlag(
mbed_official 324:406fd2029f23 543 uint32_t baseAddr, edma_channel_indicator_t channel)
mbed_official 146:f64d43ff0c18 544 {
mbed_official 324:406fd2029f23 545 HW_DMA_CERR_WR(baseAddr, channel);
mbed_official 146:f64d43ff0c18 546 }
mbed_official 146:f64d43ff0c18 547
mbed_official 146:f64d43ff0c18 548 /*!
mbed_official 324:406fd2029f23 549 * @brief Enables/Disables the DMA request for the channel or all channels.
mbed_official 146:f64d43ff0c18 550 *
mbed_official 324:406fd2029f23 551 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 552 * @param enable Enable(true) or Disable (false) DMA request.
mbed_official 324:406fd2029f23 553 * @param channel Channel indicator. If kEDMAAllChannel is selected, all channels DMA request
mbed_official 324:406fd2029f23 554 * are enabled/disabled.
mbed_official 146:f64d43ff0c18 555 */
mbed_official 324:406fd2029f23 556 void EDMA_HAL_SetDmaRequestCmd(uint32_t baseAddr, edma_channel_indicator_t channel,bool enable);
mbed_official 324:406fd2029f23 557
mbed_official 324:406fd2029f23 558 /*!
mbed_official 324:406fd2029f23 559 * @brief Checks whether the eDMA channel DMA request is enabled or disabled.
mbed_official 324:406fd2029f23 560 *
mbed_official 324:406fd2029f23 561 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 562 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 563 * @return DMA request is enabled (true) or disabled (false).
mbed_official 324:406fd2029f23 564 */
mbed_official 324:406fd2029f23 565 static inline bool EDMA_HAL_GetDmaRequestCmd(uint32_t baseAddr, uint32_t channel)
mbed_official 146:f64d43ff0c18 566 {
mbed_official 324:406fd2029f23 567 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 568
mbed_official 324:406fd2029f23 569 return ((HW_DMA_ERQ_RD(baseAddr) >> channel) & 1U);
mbed_official 146:f64d43ff0c18 570 }
mbed_official 146:f64d43ff0c18 571
mbed_official 146:f64d43ff0c18 572 /*!
mbed_official 324:406fd2029f23 573 * @brief Gets the eDMA channel DMA request status.
mbed_official 146:f64d43ff0c18 574 *
mbed_official 324:406fd2029f23 575 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 576 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 577 * @return Hardware request is triggered in this eDMA channel (true) or not be triggered in this
mbed_official 324:406fd2029f23 578 * channel (false).
mbed_official 146:f64d43ff0c18 579 */
mbed_official 324:406fd2029f23 580 static inline bool EDMA_HAL_GetDmaRequestStatusFlag(uint32_t baseAddr, uint32_t channel)
mbed_official 146:f64d43ff0c18 581 {
mbed_official 324:406fd2029f23 582 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 583 return (((uint32_t)HW_DMA_HRS_RD(baseAddr) >> channel) & 1U);
mbed_official 146:f64d43ff0c18 584 }
mbed_official 146:f64d43ff0c18 585
mbed_official 146:f64d43ff0c18 586 /*!
mbed_official 324:406fd2029f23 587 * @brief Clears the done status for a channel or all channels.
mbed_official 146:f64d43ff0c18 588 *
mbed_official 324:406fd2029f23 589 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 590 * @param channel Channel indicator. If kEDMAAllChannel is selected, all channels' done status will
mbed_official 324:406fd2029f23 591 * be cleared.
mbed_official 146:f64d43ff0c18 592 */
mbed_official 324:406fd2029f23 593 static inline void EDMA_HAL_ClearDoneStatusFlag(uint32_t baseAddr, edma_channel_indicator_t channel)
mbed_official 146:f64d43ff0c18 594 {
mbed_official 324:406fd2029f23 595 HW_DMA_CDNE_WR(baseAddr, channel);
mbed_official 324:406fd2029f23 596 }
mbed_official 324:406fd2029f23 597
mbed_official 324:406fd2029f23 598 /*!
mbed_official 324:406fd2029f23 599 * @brief Triggers the eDMA channel.
mbed_official 324:406fd2029f23 600 *
mbed_official 324:406fd2029f23 601 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 602 * @param channel Channel indicator. If kEDMAAllChannel is selected, all channels are tirggere.
mbed_official 324:406fd2029f23 603 */
mbed_official 324:406fd2029f23 604 static inline void EDMA_HAL_TriggerChannelStart(uint32_t baseAddr, edma_channel_indicator_t channel)
mbed_official 324:406fd2029f23 605 {
mbed_official 324:406fd2029f23 606 HW_DMA_SSRT_WR(baseAddr, channel);
mbed_official 146:f64d43ff0c18 607 }
mbed_official 146:f64d43ff0c18 608
mbed_official 146:f64d43ff0c18 609 /*!
mbed_official 324:406fd2029f23 610 * @brief Gets the eDMA channel interrupt request status.
mbed_official 146:f64d43ff0c18 611 *
mbed_official 324:406fd2029f23 612 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 613 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 614 * @return Interrupt request happens in this eDMA channel (true) or not happen in this
mbed_official 324:406fd2029f23 615 * channel (false).
mbed_official 146:f64d43ff0c18 616 */
mbed_official 324:406fd2029f23 617 static inline bool EDMA_HAL_GetIntStatusFlag(uint32_t baseAddr, uint32_t channel)
mbed_official 146:f64d43ff0c18 618 {
mbed_official 324:406fd2029f23 619 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 620
mbed_official 324:406fd2029f23 621 return (((uint32_t)HW_DMA_INT_RD(baseAddr) >> channel) & 1U);
mbed_official 146:f64d43ff0c18 622 }
mbed_official 146:f64d43ff0c18 623
mbed_official 146:f64d43ff0c18 624 /*!
mbed_official 324:406fd2029f23 625 * @brief Gets the eDMA all channel's interrupt request status.
mbed_official 146:f64d43ff0c18 626 *
mbed_official 324:406fd2029f23 627 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 628 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 629 * @return Interrupt status flag of all channels.
mbed_official 146:f64d43ff0c18 630 */
mbed_official 324:406fd2029f23 631 static inline uint32_t EDMA_HAL_GetAllIntStatusFlag(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 632 {
mbed_official 324:406fd2029f23 633 return (uint32_t)HW_DMA_INT_RD(baseAddr);
mbed_official 146:f64d43ff0c18 634 }
mbed_official 146:f64d43ff0c18 635
mbed_official 324:406fd2029f23 636 /*!
mbed_official 324:406fd2029f23 637 * @brief Clears the interrupt status for the eDMA channel or all channels.
mbed_official 324:406fd2029f23 638 *
mbed_official 324:406fd2029f23 639 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 640 * @param enable Enable(true) or Disable (false) error interrupt.
mbed_official 324:406fd2029f23 641 * @param channel Channel indicator. If kEDMAAllChannel is selected, all channels' interrupt
mbed_official 324:406fd2029f23 642 * status will be cleared.
mbed_official 324:406fd2029f23 643 */
mbed_official 324:406fd2029f23 644 static inline void EDMA_HAL_ClearIntStatusFlag(
mbed_official 324:406fd2029f23 645 uint32_t baseAddr, edma_channel_indicator_t channel)
mbed_official 324:406fd2029f23 646 {
mbed_official 324:406fd2029f23 647 HW_DMA_CINT_WR(baseAddr, channel);
mbed_official 324:406fd2029f23 648 }
mbed_official 324:406fd2029f23 649
mbed_official 324:406fd2029f23 650 #if (FSL_FEATURE_EDMA_ASYNCHRO_REQUEST_CHANNEL_COUNT > 0x0U)
mbed_official 324:406fd2029f23 651 /*!
mbed_official 324:406fd2029f23 652 * @brief Enables/Disables an asynchronous request in stop mode.
mbed_official 324:406fd2029f23 653 *
mbed_official 324:406fd2029f23 654 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 655 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 656 * @param enable Enable (true) or Disable (false) async DMA request.
mbed_official 324:406fd2029f23 657 */
mbed_official 324:406fd2029f23 658 void EDMA_HAL_SetAsyncRequestInStopModeCmd(uint32_t baseAddr, uint32_t channel, bool enable);
mbed_official 324:406fd2029f23 659 #endif
mbed_official 324:406fd2029f23 660
mbed_official 146:f64d43ff0c18 661 /* @} */
mbed_official 146:f64d43ff0c18 662
mbed_official 146:f64d43ff0c18 663 /*!
mbed_official 324:406fd2029f23 664 * @name eDMA HAL driver hardware TCD configuration functions.
mbed_official 146:f64d43ff0c18 665 * @{
mbed_official 146:f64d43ff0c18 666 */
mbed_official 324:406fd2029f23 667
mbed_official 146:f64d43ff0c18 668 /*!
mbed_official 324:406fd2029f23 669 * @brief Clears all registers to 0 for the hardware TCD.
mbed_official 146:f64d43ff0c18 670 *
mbed_official 324:406fd2029f23 671 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 672 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 673 */
mbed_official 324:406fd2029f23 674 void EDMA_HAL_HTCDClearReg(uint32_t baseAddr, uint32_t channel);
mbed_official 146:f64d43ff0c18 675
mbed_official 146:f64d43ff0c18 676 /*!
mbed_official 146:f64d43ff0c18 677 * @brief Configures the source address for the hardware TCD.
mbed_official 146:f64d43ff0c18 678 *
mbed_official 324:406fd2029f23 679 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 680 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 681 * @param address The pointer to the source memory address.
mbed_official 146:f64d43ff0c18 682 */
mbed_official 324:406fd2029f23 683 static inline void EDMA_HAL_HTCDSetSrcAddr(uint32_t baseAddr, uint32_t channel, uint32_t address)
mbed_official 146:f64d43ff0c18 684 {
mbed_official 324:406fd2029f23 685 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 686 BW_DMA_TCDn_SADDR_SADDR(baseAddr, channel, address);
mbed_official 146:f64d43ff0c18 687 }
mbed_official 146:f64d43ff0c18 688
mbed_official 146:f64d43ff0c18 689 /*!
mbed_official 146:f64d43ff0c18 690 * @brief Configures the source address signed offset for the hardware TCD.
mbed_official 146:f64d43ff0c18 691 *
mbed_official 146:f64d43ff0c18 692 * Sign-extended offset applied to the current source address to form the next-state value as each
mbed_official 146:f64d43ff0c18 693 * source read is complete.
mbed_official 146:f64d43ff0c18 694 *
mbed_official 324:406fd2029f23 695 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 696 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 697 * @param offset signed-offset for source address.
mbed_official 146:f64d43ff0c18 698 */
mbed_official 324:406fd2029f23 699 static inline void EDMA_HAL_HTCDSetSrcOffset(uint32_t baseAddr, uint32_t channel, int16_t offset)
mbed_official 146:f64d43ff0c18 700 {
mbed_official 324:406fd2029f23 701 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 702 BW_DMA_TCDn_SOFF_SOFF(baseAddr, channel, offset);
mbed_official 146:f64d43ff0c18 703 }
mbed_official 146:f64d43ff0c18 704
mbed_official 146:f64d43ff0c18 705 /*!
mbed_official 324:406fd2029f23 706 * @brief Configures the transfer attribute for the eDMA channel.
mbed_official 146:f64d43ff0c18 707 *
mbed_official 324:406fd2029f23 708 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 709 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 710 * @param srcModulo enumeration type for an allowed source modulo. The value defines a specific address range
mbed_official 324:406fd2029f23 711 * specified as the value after the SADDR + SOFF calculation is performed on the original register
mbed_official 324:406fd2029f23 712 * value. Setting this field provides the ability to implement a circular data. For data queues
mbed_official 324:406fd2029f23 713 * requiring power-of-2 size bytes, the queue should start at a 0-modulo-size address and the SMOD
mbed_official 324:406fd2029f23 714 * field should be set to the appropriate value for the queue, freezing the desired number of upper
mbed_official 324:406fd2029f23 715 * address bits. The value programmed into this field specifies the number of the lower address bits
mbed_official 324:406fd2029f23 716 * allowed to change. For a circular queue application, the SOFF is typically set to the transfer
mbed_official 324:406fd2029f23 717 * size to implement post-increment addressing with SMOD function restricting the addresses to a
mbed_official 324:406fd2029f23 718 * 0-modulo-size range.
mbed_official 324:406fd2029f23 719 * @param destModulo Enum type for an allowed destination modulo.
mbed_official 324:406fd2029f23 720 * @param srcTransferSize Enum type for source transfer size.
mbed_official 324:406fd2029f23 721 * @param destTransferSize Enum type for destination transfer size.
mbed_official 146:f64d43ff0c18 722 */
mbed_official 324:406fd2029f23 723 void EDMA_HAL_HTCDSetAttribute(
mbed_official 324:406fd2029f23 724 uint32_t baseAddr, uint32_t channel,
mbed_official 324:406fd2029f23 725 edma_modulo_t srcModulo, edma_modulo_t destModulo,
mbed_official 324:406fd2029f23 726 edma_transfer_size_t srcTransferSize, edma_transfer_size_t destTransferSize);
mbed_official 146:f64d43ff0c18 727
mbed_official 146:f64d43ff0c18 728 /*!
mbed_official 324:406fd2029f23 729 * @brief Configures the nbytes for the eDMA channel.
mbed_official 146:f64d43ff0c18 730 *
mbed_official 324:406fd2029f23 731 * Note here that user need firstly configure the minor loop mapping feature and then call this
mbed_official 324:406fd2029f23 732 * function.
mbed_official 146:f64d43ff0c18 733 *
mbed_official 324:406fd2029f23 734 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 735 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 736 * @param nbytes Number of bytes to be transferred in each service request of the channel
mbed_official 146:f64d43ff0c18 737 */
mbed_official 324:406fd2029f23 738 void EDMA_HAL_HTCDSetNbytes(uint32_t baseAddr, uint32_t channel, uint32_t nbytes);
mbed_official 146:f64d43ff0c18 739
mbed_official 146:f64d43ff0c18 740 /*!
mbed_official 324:406fd2029f23 741 * @brief Gets the nbytes configuration data for the hardware TCD.
mbed_official 146:f64d43ff0c18 742 *
mbed_official 146:f64d43ff0c18 743 * This function decides whether the minor loop mapping is enabled or whether the source/dest
mbed_official 146:f64d43ff0c18 744 * minor loop mapping is enabled. Then, the nbytes are returned accordingly.
mbed_official 146:f64d43ff0c18 745 *
mbed_official 324:406fd2029f23 746 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 747 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 748 * @return nbytes configuration according to minor loop setting.
mbed_official 146:f64d43ff0c18 749 */
mbed_official 324:406fd2029f23 750 uint32_t EDMA_HAL_HTCDGetNbytes(uint32_t baseAddr, uint32_t channel);
mbed_official 146:f64d43ff0c18 751
mbed_official 146:f64d43ff0c18 752 /*!
mbed_official 324:406fd2029f23 753 * @brief Configures the minor loop offset for the hardware TCD.
mbed_official 146:f64d43ff0c18 754 *
mbed_official 324:406fd2029f23 755 * Configures both the enable bits and the offset value. If neither source nor destination offset is enabled,
mbed_official 324:406fd2029f23 756 * offset is not configured. Note here if source or destination offset is required, the eDMA module
mbed_official 324:406fd2029f23 757 * EMLM bit will be set in this function. User need to know this side effect.
mbed_official 146:f64d43ff0c18 758 *
mbed_official 324:406fd2029f23 759 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 760 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 761 * @param config Configuration data structure for the minor loop offset
mbed_official 146:f64d43ff0c18 762 */
mbed_official 324:406fd2029f23 763 void EDMA_HAL_HTCDSetMinorLoopOffset(
mbed_official 324:406fd2029f23 764 uint32_t baseAddr, uint32_t channel, edma_minorloop_offset_config_t *config);
mbed_official 146:f64d43ff0c18 765
mbed_official 146:f64d43ff0c18 766 /*!
mbed_official 146:f64d43ff0c18 767 * @brief Configures the last source address adjustment for the hardware TCD.
mbed_official 146:f64d43ff0c18 768 *
mbed_official 146:f64d43ff0c18 769 * Adjustment value added to the source address at the completion of the major iteration count. This
mbed_official 146:f64d43ff0c18 770 * value can be applied to restore the source address to the initial value, or adjust the address to
mbed_official 146:f64d43ff0c18 771 * reference the next data structure.
mbed_official 146:f64d43ff0c18 772 *
mbed_official 324:406fd2029f23 773 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 774 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 775 * @param size adjustment value
mbed_official 146:f64d43ff0c18 776 */
mbed_official 324:406fd2029f23 777 static inline void EDMA_HAL_HTCDSetSrcLastAdjust(uint32_t baseAddr, uint32_t channel, int32_t size)
mbed_official 146:f64d43ff0c18 778 {
mbed_official 324:406fd2029f23 779 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 780 BW_DMA_TCDn_SLAST_SLAST(baseAddr, channel, size);
mbed_official 146:f64d43ff0c18 781 }
mbed_official 146:f64d43ff0c18 782
mbed_official 146:f64d43ff0c18 783 /*!
mbed_official 146:f64d43ff0c18 784 * @brief Configures the destination address for the hardware TCD.
mbed_official 146:f64d43ff0c18 785 *
mbed_official 324:406fd2029f23 786 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 787 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 788 * @param address The pointer to the destination address.
mbed_official 146:f64d43ff0c18 789 */
mbed_official 324:406fd2029f23 790 static inline void EDMA_HAL_HTCDSetDestAddr(uint32_t baseAddr, uint32_t channel, uint32_t address)
mbed_official 146:f64d43ff0c18 791 {
mbed_official 324:406fd2029f23 792 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 793 BW_DMA_TCDn_DADDR_DADDR(baseAddr, channel, address);
mbed_official 146:f64d43ff0c18 794 }
mbed_official 146:f64d43ff0c18 795
mbed_official 146:f64d43ff0c18 796 /*!
mbed_official 146:f64d43ff0c18 797 * @brief Configures the destination address signed offset for the hardware TCD.
mbed_official 146:f64d43ff0c18 798 *
mbed_official 146:f64d43ff0c18 799 * Sign-extended offset applied to the current source address to form the next-state value as each
mbed_official 146:f64d43ff0c18 800 * destination write is complete.
mbed_official 146:f64d43ff0c18 801 *
mbed_official 324:406fd2029f23 802 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 803 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 804 * @param offset signed-offset
mbed_official 146:f64d43ff0c18 805 */
mbed_official 324:406fd2029f23 806 static inline void EDMA_HAL_HTCDSetDestOffset(uint32_t baseAddr, uint32_t channel, int16_t offset)
mbed_official 146:f64d43ff0c18 807 {
mbed_official 324:406fd2029f23 808 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 809 BW_DMA_TCDn_DOFF_DOFF(baseAddr, channel, offset);
mbed_official 146:f64d43ff0c18 810 }
mbed_official 146:f64d43ff0c18 811
mbed_official 146:f64d43ff0c18 812 /*!
mbed_official 324:406fd2029f23 813 * @brief Configures the last source address adjustment.
mbed_official 146:f64d43ff0c18 814 *
mbed_official 324:406fd2029f23 815 * This function adds an adjustment value added to the source address at the completion of the major
mbed_official 324:406fd2029f23 816 * iteration count. This value can be applied to restore the source address to the initial value, or
mbed_official 324:406fd2029f23 817 * adjust the address to reference the next data structure.
mbed_official 146:f64d43ff0c18 818 *
mbed_official 324:406fd2029f23 819 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 820 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 821 * @param adjust adjustment value
mbed_official 146:f64d43ff0c18 822 */
mbed_official 324:406fd2029f23 823 static inline void EDMA_HAL_HTCDSetDestLastAdjust(
mbed_official 324:406fd2029f23 824 uint32_t baseAddr, uint32_t channel, uint32_t adjust)
mbed_official 146:f64d43ff0c18 825 {
mbed_official 324:406fd2029f23 826 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 827 BW_DMA_TCDn_DLASTSGA_DLASTSGA(baseAddr, channel, adjust);
mbed_official 146:f64d43ff0c18 828 }
mbed_official 146:f64d43ff0c18 829
mbed_official 146:f64d43ff0c18 830 /*!
mbed_official 324:406fd2029f23 831 * @brief Configures the memory address for the next transfer TCD for the hardware TCD.
mbed_official 324:406fd2029f23 832 *
mbed_official 324:406fd2029f23 833 *
mbed_official 324:406fd2029f23 834 * This function enables the scatter/gather feature for the hardware TCD and configures the next
mbed_official 324:406fd2029f23 835 * TCD's address. This address points to the beginning of a 0-modulo-32 byte region containing
mbed_official 324:406fd2029f23 836 * the next transfer TCD to be loaded into this channel. The channel reload is performed as the
mbed_official 324:406fd2029f23 837 * major iteration count completes. The scatter/gather address must be 0-modulo-32-byte. Otherwise,
mbed_official 324:406fd2029f23 838 * a configuration error is reported.
mbed_official 324:406fd2029f23 839 *
mbed_official 324:406fd2029f23 840 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 841 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 842 * @param stcd The pointer to the TCD to be linked to this hardware TCD.
mbed_official 324:406fd2029f23 843 */
mbed_official 324:406fd2029f23 844 void EDMA_HAL_HTCDSetScatterGatherLink(
mbed_official 324:406fd2029f23 845 uint32_t baseAddr, uint32_t channel, edma_software_tcd_t *stcd);
mbed_official 324:406fd2029f23 846
mbed_official 324:406fd2029f23 847 /*!
mbed_official 146:f64d43ff0c18 848 * @brief Configures the bandwidth for the hardware TCD.
mbed_official 146:f64d43ff0c18 849 *
mbed_official 146:f64d43ff0c18 850 * Throttles the amount of bus bandwidth consumed by the eDMA. In general, as the eDMA processes the
mbed_official 146:f64d43ff0c18 851 * minor loop, it continuously generates read/write sequences until the minor count is exhausted.
mbed_official 146:f64d43ff0c18 852 * This field forces the eDMA to stall after the completion of each read/write access to control the
mbed_official 146:f64d43ff0c18 853 * bus request bandwidth seen by the crossbar switch.
mbed_official 146:f64d43ff0c18 854 *
mbed_official 324:406fd2029f23 855 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 856 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 857 * @param bandwidth enum type for bandwidth control
mbed_official 146:f64d43ff0c18 858 */
mbed_official 324:406fd2029f23 859 static inline void EDMA_HAL_HTCDSetBandwidth(
mbed_official 324:406fd2029f23 860 uint32_t baseAddr, uint32_t channel, edma_bandwidth_config_t bandwidth)
mbed_official 146:f64d43ff0c18 861 {
mbed_official 324:406fd2029f23 862 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 863 BW_DMA_TCDn_CSR_BWC(baseAddr, channel, bandwidth);
mbed_official 146:f64d43ff0c18 864 }
mbed_official 146:f64d43ff0c18 865
mbed_official 146:f64d43ff0c18 866 /*!
mbed_official 324:406fd2029f23 867 * @brief Configures the major channel link the hardware TCD.
mbed_official 146:f64d43ff0c18 868 *
mbed_official 324:406fd2029f23 869 * If the major link is enabled, after the major loop counter is exhausted, the eDMA engine initiates a
mbed_official 146:f64d43ff0c18 870 * channel service request at the channel defined by these six bits by setting that channel start
mbed_official 146:f64d43ff0c18 871 * bits.
mbed_official 146:f64d43ff0c18 872 *
mbed_official 324:406fd2029f23 873 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 874 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 875 * @param majorChannel channel number for major link
mbed_official 324:406fd2029f23 876 * @param enable Enables (true) or Disables (false) channel major link.
mbed_official 146:f64d43ff0c18 877 */
mbed_official 324:406fd2029f23 878 static inline void EDMA_HAL_HTCDSetChannelMajorLink(
mbed_official 324:406fd2029f23 879 uint32_t baseAddr, uint32_t channel, uint32_t majorChannel, bool enable)
mbed_official 146:f64d43ff0c18 880 {
mbed_official 324:406fd2029f23 881 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 882 BW_DMA_TCDn_CSR_MAJORLINKCH(baseAddr, channel, majorChannel);
mbed_official 324:406fd2029f23 883 BW_DMA_TCDn_CSR_MAJORELINK(baseAddr, channel, enable);
mbed_official 146:f64d43ff0c18 884 }
mbed_official 146:f64d43ff0c18 885
mbed_official 146:f64d43ff0c18 886 /*!
mbed_official 146:f64d43ff0c18 887 * @brief Gets the major link channel for the hardware TCD.
mbed_official 146:f64d43ff0c18 888 *
mbed_official 324:406fd2029f23 889 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 890 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 891 * @return major link channel number
mbed_official 146:f64d43ff0c18 892 */
mbed_official 324:406fd2029f23 893 static inline uint32_t EDMA_HAL_HTCDGetMajorLinkChannel(uint32_t baseAddr, uint32_t channel)
mbed_official 146:f64d43ff0c18 894 {
mbed_official 324:406fd2029f23 895 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 896 return BR_DMA_TCDn_CSR_MAJORLINKCH(baseAddr, channel);
mbed_official 146:f64d43ff0c18 897 }
mbed_official 146:f64d43ff0c18 898
mbed_official 146:f64d43ff0c18 899 /*!
mbed_official 146:f64d43ff0c18 900 * @brief Enables/Disables the scatter/gather feature for the hardware TCD.
mbed_official 146:f64d43ff0c18 901 *
mbed_official 324:406fd2029f23 902 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 903 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 904 * @param enable Enables (true) /Disables (false) scatter/gather feature.
mbed_official 146:f64d43ff0c18 905 */
mbed_official 324:406fd2029f23 906 static inline void EDMA_HAL_HTCDSetScatterGatherCmd(
mbed_official 324:406fd2029f23 907 uint32_t baseAddr, uint32_t channel, bool enable)
mbed_official 146:f64d43ff0c18 908 {
mbed_official 324:406fd2029f23 909 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 910 BW_DMA_TCDn_CSR_ESG(baseAddr, channel, enable);
mbed_official 146:f64d43ff0c18 911 }
mbed_official 146:f64d43ff0c18 912
mbed_official 146:f64d43ff0c18 913 /*!
mbed_official 146:f64d43ff0c18 914 * @brief Checks whether the scatter/gather feature is enabled for the hardware TCD.
mbed_official 146:f64d43ff0c18 915 *
mbed_official 324:406fd2029f23 916 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 917 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 918 * @return True stand for enabled. False stands for disabled.
mbed_official 146:f64d43ff0c18 919 */
mbed_official 324:406fd2029f23 920 static inline bool EDMA_HAL_HTCDGetScatterGatherCmd(uint32_t baseAddr, uint32_t channel)
mbed_official 146:f64d43ff0c18 921 {
mbed_official 324:406fd2029f23 922 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 923 return BR_DMA_TCDn_CSR_ESG(baseAddr, channel);
mbed_official 146:f64d43ff0c18 924
mbed_official 146:f64d43ff0c18 925 }
mbed_official 146:f64d43ff0c18 926
mbed_official 146:f64d43ff0c18 927 /*!
mbed_official 146:f64d43ff0c18 928 * @brief Disables/Enables the DMA request after the major loop completes for the hardware TCD.
mbed_official 146:f64d43ff0c18 929 *
mbed_official 146:f64d43ff0c18 930 * If disabled, the eDMA hardware automatically clears the corresponding DMA request when the
mbed_official 146:f64d43ff0c18 931 * current major iteration count reaches zero.
mbed_official 146:f64d43ff0c18 932 *
mbed_official 324:406fd2029f23 933 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 934 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 935 * @param disable Disable (true)/Enable (true) DMA request after TCD complete.
mbed_official 146:f64d43ff0c18 936 */
mbed_official 324:406fd2029f23 937 static inline void EDMA_HAL_HTCDSetDisableDmaRequestAfterTCDDoneCmd(
mbed_official 324:406fd2029f23 938 uint32_t baseAddr, uint32_t channel, bool disable)
mbed_official 146:f64d43ff0c18 939 {
mbed_official 324:406fd2029f23 940 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 941 BW_DMA_TCDn_CSR_DREQ(baseAddr, channel, disable);
mbed_official 146:f64d43ff0c18 942 }
mbed_official 146:f64d43ff0c18 943
mbed_official 146:f64d43ff0c18 944 /*!
mbed_official 146:f64d43ff0c18 945 * @brief Enables/Disables the half complete interrupt for the hardware TCD.
mbed_official 146:f64d43ff0c18 946 *
mbed_official 146:f64d43ff0c18 947 * If set, the channel generates an interrupt request by setting the appropriate bit in the
mbed_official 146:f64d43ff0c18 948 * interrupt register when the current major iteration count reaches the halfway point. Specifically,
mbed_official 146:f64d43ff0c18 949 * the comparison performed by the eDMA engine is (CITER == (BITER >> 1)). This half-way point
mbed_official 146:f64d43ff0c18 950 * interrupt request is provided to support the double-buffered schemes or other types of data movement
mbed_official 146:f64d43ff0c18 951 * where the processor needs an early indication of the transfer's process.
mbed_official 146:f64d43ff0c18 952 *
mbed_official 324:406fd2029f23 953 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 954 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 955 * @param enable Enable (true) /Disable (false) half complete interrupt.
mbed_official 146:f64d43ff0c18 956 */
mbed_official 324:406fd2029f23 957 static inline void EDMA_HAL_HTCDSetHalfCompleteIntCmd(
mbed_official 324:406fd2029f23 958 uint32_t baseAddr, uint32_t channel, bool enable)
mbed_official 146:f64d43ff0c18 959 {
mbed_official 324:406fd2029f23 960 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 961 BW_DMA_TCDn_CSR_INTHALF(baseAddr, channel, enable);
mbed_official 146:f64d43ff0c18 962 }
mbed_official 146:f64d43ff0c18 963
mbed_official 146:f64d43ff0c18 964 /*!
mbed_official 146:f64d43ff0c18 965 * @brief Enables/Disables the interrupt after the major loop completes for the hardware TCD.
mbed_official 146:f64d43ff0c18 966 *
mbed_official 146:f64d43ff0c18 967 * If enabled, the channel generates an interrupt request by setting the appropriate bit in the
mbed_official 146:f64d43ff0c18 968 * interrupt register when the current major iteration count reaches zero.
mbed_official 146:f64d43ff0c18 969 *
mbed_official 324:406fd2029f23 970 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 971 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 972 * @param enable Enable (true) /Disable (false) interrupt after TCD done.
mbed_official 146:f64d43ff0c18 973 */
mbed_official 324:406fd2029f23 974 static inline void EDMA_HAL_HTCDSetIntCmd(
mbed_official 324:406fd2029f23 975 uint32_t baseAddr, uint32_t channel, bool enable)
mbed_official 146:f64d43ff0c18 976 {
mbed_official 324:406fd2029f23 977 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 978 BW_DMA_TCDn_CSR_INTMAJOR(baseAddr, channel, enable);
mbed_official 146:f64d43ff0c18 979 }
mbed_official 146:f64d43ff0c18 980
mbed_official 146:f64d43ff0c18 981 /*!
mbed_official 146:f64d43ff0c18 982 * @brief Triggers the start bits for the hardware TCD.
mbed_official 146:f64d43ff0c18 983 *
mbed_official 146:f64d43ff0c18 984 * The eDMA hardware automatically clears this flag after the channel begins execution.
mbed_official 146:f64d43ff0c18 985 *
mbed_official 324:406fd2029f23 986 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 987 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 988 */
mbed_official 324:406fd2029f23 989 static inline void EDMA_HAL_HTCDTriggerChannelStart(uint32_t baseAddr, uint32_t channel)
mbed_official 146:f64d43ff0c18 990 {
mbed_official 324:406fd2029f23 991 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 992 BW_DMA_TCDn_CSR_START(baseAddr, channel, true);
mbed_official 146:f64d43ff0c18 993 }
mbed_official 146:f64d43ff0c18 994
mbed_official 146:f64d43ff0c18 995 /*!
mbed_official 146:f64d43ff0c18 996 * @brief Checks whether the channel is running for the hardware TCD.
mbed_official 146:f64d43ff0c18 997 *
mbed_official 324:406fd2029f23 998 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 999 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 1000 * @return True stands for running. False stands for not.
mbed_official 146:f64d43ff0c18 1001 */
mbed_official 324:406fd2029f23 1002 static inline bool EDMA_HAL_HTCDGetChannelActiveStatus(uint32_t baseAddr, uint32_t channel)
mbed_official 146:f64d43ff0c18 1003 {
mbed_official 324:406fd2029f23 1004 assert(channel < FSL_FEATURE_EDMA_MODULE_CHANNEL);
mbed_official 324:406fd2029f23 1005 return BR_DMA_TCDn_CSR_ACTIVE(baseAddr, channel);
mbed_official 146:f64d43ff0c18 1006 }
mbed_official 146:f64d43ff0c18 1007
mbed_official 146:f64d43ff0c18 1008 /*!
mbed_official 324:406fd2029f23 1009 * @brief Sets the channel minor link for the hardware TCD.
mbed_official 146:f64d43ff0c18 1010 *
mbed_official 324:406fd2029f23 1011 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1012 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1013 * @param linkChannel Channel to be linked on minor loop complete.
mbed_official 324:406fd2029f23 1014 * @param enable Enable (true)/Disable (false) channel minor link.
mbed_official 146:f64d43ff0c18 1015 */
mbed_official 324:406fd2029f23 1016 void EDMA_HAL_HTCDSetChannelMinorLink(
mbed_official 324:406fd2029f23 1017 uint32_t baseAddr, uint32_t channel, uint32_t linkChannel, bool enable);
mbed_official 146:f64d43ff0c18 1018
mbed_official 146:f64d43ff0c18 1019 /*!
mbed_official 324:406fd2029f23 1020 * @brief Sets the major iteration count according to minor loop channel link setting.
mbed_official 146:f64d43ff0c18 1021 *
mbed_official 324:406fd2029f23 1022 * Note here that user need to first set the minor loop channel link and then call this function.
mbed_official 324:406fd2029f23 1023 * The execute flow inside this function is dependent on the minor loop channel link setting.
mbed_official 146:f64d43ff0c18 1024 *
mbed_official 324:406fd2029f23 1025 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1026 * @param channel eDMA channel number.
mbed_official 146:f64d43ff0c18 1027 * @param count major loop count
mbed_official 146:f64d43ff0c18 1028 */
mbed_official 324:406fd2029f23 1029 void EDMA_HAL_HTCDSetMajorCount(uint32_t baseAddr, uint32_t channel, uint32_t count);
mbed_official 146:f64d43ff0c18 1030
mbed_official 146:f64d43ff0c18 1031 /*!
mbed_official 324:406fd2029f23 1032 * @brief Gets the number of beginning major counts for the hardware TCD.
mbed_official 146:f64d43ff0c18 1033 *
mbed_official 324:406fd2029f23 1034 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1035 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1036 * @return Begin major counts.
mbed_official 146:f64d43ff0c18 1037 */
mbed_official 324:406fd2029f23 1038 uint32_t EDMA_HAL_HTCDGetBeginMajorCount(uint32_t baseAddr, uint32_t channel);
mbed_official 324:406fd2029f23 1039
mbed_official 324:406fd2029f23 1040 /*!
mbed_official 324:406fd2029f23 1041 * @brief Gets the number of current major counts for the hardware TCD.
mbed_official 324:406fd2029f23 1042 *
mbed_official 324:406fd2029f23 1043 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1044 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1045 * @return Current major counts.
mbed_official 324:406fd2029f23 1046 */
mbed_official 324:406fd2029f23 1047 uint32_t EDMA_HAL_HTCDGetCurrentMajorCount(uint32_t baseAddr, uint32_t channel);
mbed_official 146:f64d43ff0c18 1048
mbed_official 146:f64d43ff0c18 1049 /*!
mbed_official 324:406fd2029f23 1050 * @brief Gets the number of bytes already transferred for the hardware TCD.
mbed_official 146:f64d43ff0c18 1051 *
mbed_official 324:406fd2029f23 1052 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1053 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1054 * @return data bytes already transferred
mbed_official 146:f64d43ff0c18 1055 */
mbed_official 324:406fd2029f23 1056 uint32_t EDMA_HAL_HTCDGetFinishedBytes(uint32_t baseAddr, uint32_t channel);
mbed_official 324:406fd2029f23 1057
mbed_official 324:406fd2029f23 1058 /*!
mbed_official 324:406fd2029f23 1059 * @brief Gets the number of bytes haven't transferred for the hardware TCD.
mbed_official 324:406fd2029f23 1060 *
mbed_official 324:406fd2029f23 1061 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1062 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1063 * @return data bytes already transferred
mbed_official 324:406fd2029f23 1064 */
mbed_official 324:406fd2029f23 1065 uint32_t EDMA_HAL_HTCDGetUnfinishedBytes(uint32_t baseAddr, uint32_t channel);
mbed_official 146:f64d43ff0c18 1066
mbed_official 146:f64d43ff0c18 1067 /*!
mbed_official 324:406fd2029f23 1068 * @brief Gets the channel done status.
mbed_official 146:f64d43ff0c18 1069 *
mbed_official 324:406fd2029f23 1070 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1071 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1072 * @return If channel done.
mbed_official 146:f64d43ff0c18 1073 */
mbed_official 324:406fd2029f23 1074 static inline bool EDMA_HAL_HTCDGetDoneStatusFlag(uint32_t baseAddr, uint32_t channel)
mbed_official 324:406fd2029f23 1075 {
mbed_official 324:406fd2029f23 1076 return BR_DMA_TCDn_CSR_DONE(baseAddr,channel);
mbed_official 324:406fd2029f23 1077 }
mbed_official 324:406fd2029f23 1078
mbed_official 324:406fd2029f23 1079 /* @} */
mbed_official 146:f64d43ff0c18 1080
mbed_official 146:f64d43ff0c18 1081 /*!
mbed_official 324:406fd2029f23 1082 * @name EDMA HAL driver software TCD configuration functions.
mbed_official 146:f64d43ff0c18 1083 * @{
mbed_official 146:f64d43ff0c18 1084 */
mbed_official 146:f64d43ff0c18 1085 /*!
mbed_official 146:f64d43ff0c18 1086 * @brief Configures the source address for the software TCD.
mbed_official 146:f64d43ff0c18 1087 *
mbed_official 324:406fd2029f23 1088 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1089 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1090 * @param address The pointer to the source memory address.
mbed_official 146:f64d43ff0c18 1091 */
mbed_official 324:406fd2029f23 1092 static inline void EDMA_HAL_STCDSetSrcAddr(edma_software_tcd_t *stcd, uint32_t address)
mbed_official 146:f64d43ff0c18 1093 {
mbed_official 146:f64d43ff0c18 1094 assert(stcd);
mbed_official 146:f64d43ff0c18 1095 stcd->SADDR = DMA_SADDR_SADDR(address);
mbed_official 146:f64d43ff0c18 1096 }
mbed_official 146:f64d43ff0c18 1097
mbed_official 146:f64d43ff0c18 1098 /*!
mbed_official 324:406fd2029f23 1099 * @brief Configures the source address signed offset for the software TCD.
mbed_official 324:406fd2029f23 1100 *
mbed_official 324:406fd2029f23 1101 * Sign-extended offset applied to the current source address to form the next-state value as each
mbed_official 324:406fd2029f23 1102 * source read is complete.
mbed_official 146:f64d43ff0c18 1103 *
mbed_official 324:406fd2029f23 1104 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1105 * @param offset signed-offset for source address.
mbed_official 146:f64d43ff0c18 1106 */
mbed_official 324:406fd2029f23 1107 static inline void EDMA_HAL_STCDSetSrcOffset(edma_software_tcd_t *stcd, int16_t offset)
mbed_official 146:f64d43ff0c18 1108 {
mbed_official 146:f64d43ff0c18 1109 assert(stcd);
mbed_official 146:f64d43ff0c18 1110 stcd->SOFF = DMA_SOFF_SOFF(offset);
mbed_official 146:f64d43ff0c18 1111 }
mbed_official 146:f64d43ff0c18 1112
mbed_official 146:f64d43ff0c18 1113 /*!
mbed_official 324:406fd2029f23 1114 * @brief Configures the transfer attribute for software TCD.
mbed_official 146:f64d43ff0c18 1115 *
mbed_official 324:406fd2029f23 1116 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1117 * @param srcModulo enum type for an allowed source modulo. The value defines a specific address range
mbed_official 324:406fd2029f23 1118 * specified as the value after the SADDR + SOFF calculation is performed on the original register
mbed_official 324:406fd2029f23 1119 * value. Setting this field provides the ability to implement a circular data. For data queues
mbed_official 324:406fd2029f23 1120 * requiring power-of-2 size bytes, the queue should start at a 0-modulo-size address and the SMOD
mbed_official 324:406fd2029f23 1121 * field should be set to the appropriate value for the queue, freezing the desired number of upper
mbed_official 324:406fd2029f23 1122 * address bits. The value programmed into this field specifies the number of the lower address bits
mbed_official 324:406fd2029f23 1123 * allowed to change. For a circular queue application, the SOFF is typically set to the transfer
mbed_official 324:406fd2029f23 1124 * size to implement post-increment addressing with SMOD function restricting the addresses to a
mbed_official 324:406fd2029f23 1125 * 0-modulo-size range.
mbed_official 324:406fd2029f23 1126 * @param destModulo Enum type for an allowed destination modulo.
mbed_official 324:406fd2029f23 1127 * @param srcTransferSize Enum type for source transfer size.
mbed_official 324:406fd2029f23 1128 * @param destTransferSize Enum type for destinatio transfer size.
mbed_official 146:f64d43ff0c18 1129 */
mbed_official 324:406fd2029f23 1130 void EDMA_HAL_STCDSetAttribute(
mbed_official 324:406fd2029f23 1131 edma_software_tcd_t *stcd,
mbed_official 324:406fd2029f23 1132 edma_modulo_t srcModulo, edma_modulo_t destModulo,
mbed_official 324:406fd2029f23 1133 edma_transfer_size_t srcTransferSize, edma_transfer_size_t destTransferSize);
mbed_official 146:f64d43ff0c18 1134
mbed_official 146:f64d43ff0c18 1135 /*!
mbed_official 324:406fd2029f23 1136 * @brief Configures the nbytes for software TCD.
mbed_official 146:f64d43ff0c18 1137 *
mbed_official 324:406fd2029f23 1138 * Note here that user need firstly configure the minor loop mapping feature and then call this
mbed_official 324:406fd2029f23 1139 * function.
mbed_official 146:f64d43ff0c18 1140 *
mbed_official 324:406fd2029f23 1141 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1142 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1143 * @param nbytes Number of bytes to be transferred in each service request of the channel
mbed_official 146:f64d43ff0c18 1144 */
mbed_official 324:406fd2029f23 1145 void EDMA_HAL_STCDSetNbytes(uint32_t baseAddr, edma_software_tcd_t *stcd, uint32_t nbytes);
mbed_official 146:f64d43ff0c18 1146
mbed_official 146:f64d43ff0c18 1147 /*!
mbed_official 146:f64d43ff0c18 1148 * @brief Configures the minorloop offset for the software TCD.
mbed_official 146:f64d43ff0c18 1149 *
mbed_official 324:406fd2029f23 1150 * Configures both the enable bits and the offset value. If neither source nor dest offset is enabled,
mbed_official 324:406fd2029f23 1151 * offset is not configured. Note here if source or destination offset is requred, the eDMA module
mbed_official 324:406fd2029f23 1152 * EMLM bit will be set in this function. User need to know this side effect.
mbed_official 146:f64d43ff0c18 1153 *
mbed_official 324:406fd2029f23 1154 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1155 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1156 * @param config Configuration data structure for the minorloop offset
mbed_official 146:f64d43ff0c18 1157 */
mbed_official 324:406fd2029f23 1158 void EDMA_HAL_STCDSetMinorLoopOffset(
mbed_official 324:406fd2029f23 1159 uint32_t baseAddr, edma_software_tcd_t *stcd, edma_minorloop_offset_config_t *config);
mbed_official 146:f64d43ff0c18 1160
mbed_official 146:f64d43ff0c18 1161 /*!
mbed_official 146:f64d43ff0c18 1162 * @brief Configures the last source address adjustment for the software TCD.
mbed_official 146:f64d43ff0c18 1163 *
mbed_official 146:f64d43ff0c18 1164 * Adjustment value added to the source address at the completion of the major iteration count. This
mbed_official 146:f64d43ff0c18 1165 * value can be applied to restore the source address to the initial value, or adjust the address to
mbed_official 146:f64d43ff0c18 1166 * reference the next data structure.
mbed_official 146:f64d43ff0c18 1167 *
mbed_official 324:406fd2029f23 1168 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1169 * @param size adjustment value
mbed_official 146:f64d43ff0c18 1170 */
mbed_official 324:406fd2029f23 1171 static inline void EDMA_HAL_STCDSetSrcLastAdjust(edma_software_tcd_t *stcd, int32_t size)
mbed_official 146:f64d43ff0c18 1172 {
mbed_official 146:f64d43ff0c18 1173 assert(stcd);
mbed_official 146:f64d43ff0c18 1174 stcd->SLAST = (stcd->SLAST & ~DMA_SLAST_SLAST_MASK) | DMA_SLAST_SLAST(size);
mbed_official 146:f64d43ff0c18 1175 }
mbed_official 146:f64d43ff0c18 1176
mbed_official 146:f64d43ff0c18 1177 /*!
mbed_official 146:f64d43ff0c18 1178 * @brief Configures the destination address for the software TCD.
mbed_official 146:f64d43ff0c18 1179 *
mbed_official 324:406fd2029f23 1180 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1181 * @param address The pointer to the destination addresss.
mbed_official 146:f64d43ff0c18 1182 */
mbed_official 324:406fd2029f23 1183 static inline void EDMA_HAL_STCDSetDestAddr(edma_software_tcd_t *stcd, uint32_t address)
mbed_official 146:f64d43ff0c18 1184 {
mbed_official 146:f64d43ff0c18 1185 assert(stcd);
mbed_official 146:f64d43ff0c18 1186 stcd->DADDR = DMA_DADDR_DADDR(address);
mbed_official 146:f64d43ff0c18 1187 }
mbed_official 146:f64d43ff0c18 1188
mbed_official 146:f64d43ff0c18 1189 /*!
mbed_official 146:f64d43ff0c18 1190 * @brief Configures the destination address signed offset for the software TCD.
mbed_official 146:f64d43ff0c18 1191 *
mbed_official 146:f64d43ff0c18 1192 * Sign-extended offset applied to the current source address to form the next-state value as each
mbed_official 146:f64d43ff0c18 1193 * destination write is complete.
mbed_official 146:f64d43ff0c18 1194 *
mbed_official 324:406fd2029f23 1195 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1196 * @param offset signed-offset
mbed_official 146:f64d43ff0c18 1197 */
mbed_official 324:406fd2029f23 1198 static inline void EDMA_HAL_STCDSetDestOffset(edma_software_tcd_t *stcd, int16_t offset)
mbed_official 146:f64d43ff0c18 1199 {
mbed_official 146:f64d43ff0c18 1200 assert(stcd);
mbed_official 146:f64d43ff0c18 1201 stcd->DOFF = DMA_DOFF_DOFF(offset);
mbed_official 146:f64d43ff0c18 1202 }
mbed_official 146:f64d43ff0c18 1203
mbed_official 146:f64d43ff0c18 1204 /*!
mbed_official 324:406fd2029f23 1205 * @brief Configures the last source address adjustment.
mbed_official 146:f64d43ff0c18 1206 *
mbed_official 324:406fd2029f23 1207 * This function add an adjustment value added to the source address at the completion of the major
mbed_official 324:406fd2029f23 1208 * iteration count. This value can be applied to restore the source address to the initial value, or
mbed_official 324:406fd2029f23 1209 * adjust the address to reference the next data structure.
mbed_official 146:f64d43ff0c18 1210 *
mbed_official 324:406fd2029f23 1211 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1212 * @param adjust adjustment value
mbed_official 146:f64d43ff0c18 1213 */
mbed_official 324:406fd2029f23 1214 static inline void EDMA_HAL_STCDSetDestLastAdjust(
mbed_official 324:406fd2029f23 1215 edma_software_tcd_t *stcd, uint32_t adjust)
mbed_official 146:f64d43ff0c18 1216 {
mbed_official 146:f64d43ff0c18 1217 assert(stcd);
mbed_official 324:406fd2029f23 1218 stcd->DLAST_SGA = DMA_DLAST_SGA_DLASTSGA(adjust);
mbed_official 146:f64d43ff0c18 1219 }
mbed_official 146:f64d43ff0c18 1220
mbed_official 146:f64d43ff0c18 1221 /*!
mbed_official 324:406fd2029f23 1222 * @brief Configures the memory address for the next transfer TCD for the software TCD.
mbed_official 324:406fd2029f23 1223 *
mbed_official 324:406fd2029f23 1224 *
mbed_official 324:406fd2029f23 1225 * This function enable the scatter/gather feature for the software TCD and configure the next
mbed_official 324:406fd2029f23 1226 * TCD's address.This address points to the beginning of a 0-modulo-32 byte region containing
mbed_official 324:406fd2029f23 1227 * the next transfer TCD to be loaded into this channel. The channel reload is performed as the
mbed_official 324:406fd2029f23 1228 * major iteration count completes. The scatter/gather address must be 0-modulo-32-byte. Otherwise,
mbed_official 324:406fd2029f23 1229 * a configuration error is reported.
mbed_official 324:406fd2029f23 1230 *
mbed_official 324:406fd2029f23 1231 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1232 * @param nextStcd The pointer to the TCD to be linked to this software TCD.
mbed_official 324:406fd2029f23 1233 */
mbed_official 324:406fd2029f23 1234 void EDMA_HAL_STCDSetScatterGatherLink(
mbed_official 324:406fd2029f23 1235 edma_software_tcd_t *stcd, edma_software_tcd_t *nextStcd);
mbed_official 324:406fd2029f23 1236
mbed_official 324:406fd2029f23 1237 /*!
mbed_official 146:f64d43ff0c18 1238 * @brief Configures the bandwidth for the software TCD.
mbed_official 146:f64d43ff0c18 1239 *
mbed_official 324:406fd2029f23 1240 * Throttles the amount of bus bandwidth consumed by the eDMA. In general, as the eDMA processes the
mbed_official 146:f64d43ff0c18 1241 * minor loop, it continuously generates read/write sequences until the minor count is exhausted.
mbed_official 146:f64d43ff0c18 1242 * This field forces the eDMA to stall after the completion of each read/write access to control the
mbed_official 146:f64d43ff0c18 1243 * bus request bandwidth seen by the crossbar switch.
mbed_official 146:f64d43ff0c18 1244 *
mbed_official 324:406fd2029f23 1245 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1246 * @param bandwidth enum type for bandwidth control
mbed_official 146:f64d43ff0c18 1247 */
mbed_official 324:406fd2029f23 1248 static inline void EDMA_HAL_STCDSetBandwidth(
mbed_official 324:406fd2029f23 1249 edma_software_tcd_t *stcd, edma_bandwidth_config_t bandwidth)
mbed_official 146:f64d43ff0c18 1250 {
mbed_official 146:f64d43ff0c18 1251 assert(stcd);
mbed_official 146:f64d43ff0c18 1252 stcd->CSR = (stcd->CSR & ~DMA_CSR_BWC_MASK) | DMA_CSR_BWC(bandwidth);
mbed_official 146:f64d43ff0c18 1253 }
mbed_official 146:f64d43ff0c18 1254
mbed_official 146:f64d43ff0c18 1255 /*!
mbed_official 324:406fd2029f23 1256 * @brief Configures the major channel link the software TCD.
mbed_official 146:f64d43ff0c18 1257 *
mbed_official 324:406fd2029f23 1258 * If the majorlink is enabled, after the major loop counter is exhausted, the eDMA engine initiates a
mbed_official 146:f64d43ff0c18 1259 * channel service request at the channel defined by these six bits by setting that channel start
mbed_official 146:f64d43ff0c18 1260 * bits.
mbed_official 146:f64d43ff0c18 1261 *
mbed_official 324:406fd2029f23 1262 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1263 * @param majorChannel channel number for major link
mbed_official 324:406fd2029f23 1264 * @param enable Enables (true) or Disables (false) channel major link.
mbed_official 146:f64d43ff0c18 1265 */
mbed_official 324:406fd2029f23 1266 static inline void EDMA_HAL_STCDSetChannelMajorLink(
mbed_official 324:406fd2029f23 1267 edma_software_tcd_t *stcd, uint32_t majorChannel, bool enable)
mbed_official 146:f64d43ff0c18 1268 {
mbed_official 146:f64d43ff0c18 1269 assert(stcd);
mbed_official 324:406fd2029f23 1270 stcd->CSR = (stcd->CSR & ~DMA_CSR_MAJORLINKCH_MASK) | DMA_CSR_MAJORLINKCH(majorChannel);
mbed_official 324:406fd2029f23 1271 stcd->CSR = (stcd->CSR & ~DMA_CSR_MAJORELINK_MASK) |
mbed_official 324:406fd2029f23 1272 ((uint32_t)enable << DMA_CSR_MAJORELINK_SHIFT);
mbed_official 146:f64d43ff0c18 1273 }
mbed_official 146:f64d43ff0c18 1274
mbed_official 146:f64d43ff0c18 1275
mbed_official 146:f64d43ff0c18 1276 /*!
mbed_official 146:f64d43ff0c18 1277 * @brief Enables/Disables the scatter/gather feature for the software TCD.
mbed_official 146:f64d43ff0c18 1278 *
mbed_official 324:406fd2029f23 1279 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1280 * @param enable Enables (true) /Disables (false) scatter/gather feature.
mbed_official 146:f64d43ff0c18 1281 */
mbed_official 324:406fd2029f23 1282 static inline void EDMA_HAL_STCDSetScatterGatherCmd(
mbed_official 324:406fd2029f23 1283 edma_software_tcd_t *stcd, bool enable)
mbed_official 146:f64d43ff0c18 1284 {
mbed_official 146:f64d43ff0c18 1285 assert(stcd);
mbed_official 324:406fd2029f23 1286 stcd->CSR = (stcd->CSR & ~DMA_CSR_ESG_MASK) | ((uint32_t)enable << DMA_CSR_ESG_SHIFT);
mbed_official 146:f64d43ff0c18 1287 }
mbed_official 146:f64d43ff0c18 1288
mbed_official 324:406fd2029f23 1289
mbed_official 146:f64d43ff0c18 1290 /*!
mbed_official 146:f64d43ff0c18 1291 * @brief Disables/Enables the DMA request after the major loop completes for the software TCD.
mbed_official 146:f64d43ff0c18 1292 *
mbed_official 146:f64d43ff0c18 1293 * If disabled, the eDMA hardware automatically clears the corresponding DMA request when the
mbed_official 146:f64d43ff0c18 1294 * current major iteration count reaches zero.
mbed_official 146:f64d43ff0c18 1295 *
mbed_official 324:406fd2029f23 1296 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1297 * @param disable Disable (true)/Enable (true) dma request after TCD complete.
mbed_official 146:f64d43ff0c18 1298 */
mbed_official 324:406fd2029f23 1299 static inline void EDMA_HAL_STCDSetDisableDmaRequestAfterTCDDoneCmd(
mbed_official 324:406fd2029f23 1300 edma_software_tcd_t *stcd, bool disable)
mbed_official 146:f64d43ff0c18 1301 {
mbed_official 146:f64d43ff0c18 1302 assert(stcd);
mbed_official 324:406fd2029f23 1303 stcd->CSR = (stcd->CSR & ~DMA_CSR_DREQ_MASK) | ((uint32_t)disable << DMA_CSR_DREQ_SHIFT);
mbed_official 146:f64d43ff0c18 1304 }
mbed_official 146:f64d43ff0c18 1305
mbed_official 146:f64d43ff0c18 1306 /*!
mbed_official 146:f64d43ff0c18 1307 * @brief Enables/Disables the half complete interrupt for the software TCD.
mbed_official 146:f64d43ff0c18 1308 *
mbed_official 146:f64d43ff0c18 1309 * If set, the channel generates an interrupt request by setting the appropriate bit in the
mbed_official 146:f64d43ff0c18 1310 * interrupt register when the current major iteration count reaches the halfway point. Specifically,
mbed_official 324:406fd2029f23 1311 * the comparison performed by the eDMA engine is (CITER == (BITER >> 1)). This half-way point
mbed_official 146:f64d43ff0c18 1312 * interrupt request is provided to support the double-buffered schemes or other types of data movement
mbed_official 324:406fd2029f23 1313 * where the processor needs an early indication of the transfer's process.
mbed_official 146:f64d43ff0c18 1314 *
mbed_official 324:406fd2029f23 1315 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1316 * @param enable Enable (true) /Disable (false) half complete interrupt.
mbed_official 146:f64d43ff0c18 1317 */
mbed_official 324:406fd2029f23 1318 static inline void EDMA_HAL_STCDSetHalfCompleteIntCmd(
mbed_official 324:406fd2029f23 1319 edma_software_tcd_t *stcd, bool enable)
mbed_official 146:f64d43ff0c18 1320 {
mbed_official 146:f64d43ff0c18 1321 assert(stcd);
mbed_official 324:406fd2029f23 1322 stcd->CSR = (stcd->CSR & ~DMA_CSR_INTHALF_MASK) | ((uint32_t)enable << DMA_CSR_INTHALF_SHIFT);
mbed_official 146:f64d43ff0c18 1323 }
mbed_official 146:f64d43ff0c18 1324
mbed_official 146:f64d43ff0c18 1325 /*!
mbed_official 324:406fd2029f23 1326 * @brief Enables/Disables the interrupt after the major loop completes for the software TCD.
mbed_official 146:f64d43ff0c18 1327 *
mbed_official 146:f64d43ff0c18 1328 * If enabled, the channel generates an interrupt request by setting the appropriate bit in the
mbed_official 146:f64d43ff0c18 1329 * interrupt register when the current major iteration count reaches zero.
mbed_official 146:f64d43ff0c18 1330 *
mbed_official 324:406fd2029f23 1331 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1332 * @param enable Enable (true) /Disable (false) interrupt after TCD done.
mbed_official 146:f64d43ff0c18 1333 */
mbed_official 324:406fd2029f23 1334 static inline void EDMA_HAL_STCDSetIntCmd(edma_software_tcd_t *stcd, bool enable)
mbed_official 146:f64d43ff0c18 1335 {
mbed_official 146:f64d43ff0c18 1336 assert(stcd);
mbed_official 324:406fd2029f23 1337 stcd->CSR = (stcd->CSR & ~DMA_CSR_INTMAJOR_MASK) | ((uint32_t)enable << DMA_CSR_INTMAJOR_SHIFT);
mbed_official 146:f64d43ff0c18 1338 }
mbed_official 146:f64d43ff0c18 1339
mbed_official 146:f64d43ff0c18 1340 /*!
mbed_official 324:406fd2029f23 1341 * @brief Triggers the start bits for the software TCD.
mbed_official 146:f64d43ff0c18 1342 *
mbed_official 324:406fd2029f23 1343 * The eDMA hardware automatically clears this flag after the channel begins execution.
mbed_official 324:406fd2029f23 1344 *
mbed_official 324:406fd2029f23 1345 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1346 */
mbed_official 324:406fd2029f23 1347 static inline void EDMA_HAL_STCDTriggerChannelStart(edma_software_tcd_t *stcd)
mbed_official 146:f64d43ff0c18 1348 {
mbed_official 146:f64d43ff0c18 1349 assert(stcd);
mbed_official 146:f64d43ff0c18 1350 stcd->CSR |= DMA_CSR_START_MASK;
mbed_official 146:f64d43ff0c18 1351 }
mbed_official 146:f64d43ff0c18 1352
mbed_official 146:f64d43ff0c18 1353 /*!
mbed_official 324:406fd2029f23 1354 * @brief Set Channel minor link for software TCD.
mbed_official 146:f64d43ff0c18 1355 *
mbed_official 324:406fd2029f23 1356 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1357 * @param linkChannel Channel to be linked on minor loop complete.
mbed_official 324:406fd2029f23 1358 * @param enable Enable (true)/Disable (false) channel minor link.
mbed_official 146:f64d43ff0c18 1359 */
mbed_official 324:406fd2029f23 1360 void EDMA_HAL_STCDSetChannelMinorLink(
mbed_official 324:406fd2029f23 1361 edma_software_tcd_t *stcd, uint32_t linkChannel, bool enable);
mbed_official 146:f64d43ff0c18 1362
mbed_official 146:f64d43ff0c18 1363 /*!
mbed_official 324:406fd2029f23 1364 * @brief Sets the major iteration count according to minor loop channel link setting.
mbed_official 146:f64d43ff0c18 1365 *
mbed_official 324:406fd2029f23 1366 * Note here that user need to first set the minor loop channel link and then call this function.
mbed_official 324:406fd2029f23 1367 * The execute flow inside this function is dependent on the minor loop channel link setting.
mbed_official 146:f64d43ff0c18 1368 *
mbed_official 324:406fd2029f23 1369 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1370 * @param count major loop count
mbed_official 146:f64d43ff0c18 1371 */
mbed_official 324:406fd2029f23 1372 void EDMA_HAL_STCDSetMajorCount(edma_software_tcd_t *stcd, uint32_t count);
mbed_official 146:f64d43ff0c18 1373
mbed_official 146:f64d43ff0c18 1374 /*!
mbed_official 146:f64d43ff0c18 1375 * @brief Copy the software TCD configuration to the hardware TCD.
mbed_official 146:f64d43ff0c18 1376 *
mbed_official 324:406fd2029f23 1377 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1378 * @param channel eDMA channel number.
mbed_official 324:406fd2029f23 1379 * @param stcd The pointer to the software TCD.
mbed_official 146:f64d43ff0c18 1380 */
mbed_official 324:406fd2029f23 1381 void EDMA_HAL_PushSTCDToHTCD(uint32_t baseAddr, uint32_t channel, edma_software_tcd_t *stcd);
mbed_official 324:406fd2029f23 1382
mbed_official 324:406fd2029f23 1383 /*!
mbed_official 324:406fd2029f23 1384 * @brief Set the basic transfer for software TCD.
mbed_official 324:406fd2029f23 1385 *
mbed_official 324:406fd2029f23 1386 * This function is used to setup the basic transfer for software TCD. The minor loop setting is not
mbed_official 324:406fd2029f23 1387 * involved here cause minor loop's configuration will lay a impact on the global eDMA setting. And
mbed_official 324:406fd2029f23 1388 * the source minor loop offset is relevant to the dest minor loop offset. For these reasons, minor
mbed_official 324:406fd2029f23 1389 * loop offset configuration is treated as an advanced configuration. User can call the
mbed_official 324:406fd2029f23 1390 * EDMA_HAL_STCDSetMinorLoopOffset() to configure the minor loop offset feature.
mbed_official 324:406fd2029f23 1391 *
mbed_official 324:406fd2029f23 1392 * @param baseAddr Register base address for eDMA module.
mbed_official 324:406fd2029f23 1393 * @param stcd The pointer to the software TCD.
mbed_official 324:406fd2029f23 1394 * @param config The pointer to the transfer configuration structure.
mbed_official 324:406fd2029f23 1395 * @param enableInt Enables (true) or Disables (false) interrupt on TCD complete.
mbed_official 324:406fd2029f23 1396 * @param disableDmaRequest Disables (true) or Enable (false) dma request on TCD complete.
mbed_official 324:406fd2029f23 1397 */
mbed_official 324:406fd2029f23 1398 edma_status_t EDMA_HAL_STCDSetBasicTransfer(
mbed_official 324:406fd2029f23 1399 uint32_t baseAddr, edma_software_tcd_t *stcd, edma_transfer_config_t *config,
mbed_official 324:406fd2029f23 1400 bool enableInt, bool disableDmaRequest);
mbed_official 324:406fd2029f23 1401
mbed_official 146:f64d43ff0c18 1402
mbed_official 146:f64d43ff0c18 1403 /* @} */
mbed_official 146:f64d43ff0c18 1404
mbed_official 324:406fd2029f23 1405
mbed_official 146:f64d43ff0c18 1406 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 1407 }
mbed_official 146:f64d43ff0c18 1408 #endif
mbed_official 146:f64d43ff0c18 1409
mbed_official 146:f64d43ff0c18 1410 /*! @} */
mbed_official 146:f64d43ff0c18 1411
mbed_official 146:f64d43ff0c18 1412 #endif /* __EDMA_HAL_H__ */
mbed_official 146:f64d43ff0c18 1413
mbed_official 146:f64d43ff0c18 1414 /*******************************************************************************
mbed_official 146:f64d43ff0c18 1415 * EOF
mbed_official 146:f64d43ff0c18 1416 ******************************************************************************/
mbed_official 146:f64d43ff0c18 1417
mbed_official 324:406fd2029f23 1418