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 Apr 03 11:45:06 2014 +0100
Revision:
149:1fb5f62b92bd
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK_MCUS/TARGET_KSDK_CODE/hal/edma/fsl_edma_hal.c@146:f64d43ff0c18
Child:
324:406fd2029f23
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

Full URL: https://github.com/mbedmicro/mbed/commit/220c0bb39ceee40016e1e86350c058963d01ed42/

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 #include "fsl_edma_hal.h"
mbed_official 146:f64d43ff0c18 31
mbed_official 146:f64d43ff0c18 32 /*******************************************************************************
mbed_official 146:f64d43ff0c18 33 * Code
mbed_official 146:f64d43ff0c18 34 ******************************************************************************/
mbed_official 146:f64d43ff0c18 35
mbed_official 146:f64d43ff0c18 36 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 37 *
mbed_official 146:f64d43ff0c18 38 * Function Name : edma_hal_init
mbed_official 146:f64d43ff0c18 39 * Description : Init edma module.
mbed_official 146:f64d43ff0c18 40 *
mbed_official 146:f64d43ff0c18 41 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 42 void edma_hal_init(uint32_t instance, const edma_config_t *init)
mbed_official 146:f64d43ff0c18 43 {
mbed_official 146:f64d43ff0c18 44 assert(instance < HW_DMA_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 45 assert(init);
mbed_official 146:f64d43ff0c18 46
mbed_official 146:f64d43ff0c18 47 edma_hal_set_minor_loop_mapping(instance, init->isEnableMinorLoopping);
mbed_official 146:f64d43ff0c18 48 edma_hal_set_continuous_mode(instance, init->isEnableContinuousMode);
mbed_official 146:f64d43ff0c18 49 edma_hal_set_halt_on_error(instance, init->isHaltOnError);
mbed_official 146:f64d43ff0c18 50 if (init->isEnableRoundrobinArbitration)
mbed_official 146:f64d43ff0c18 51 {
mbed_official 146:f64d43ff0c18 52 edma_hal_set_roundrobin_channel_arbitration(instance);
mbed_official 146:f64d43ff0c18 53 }
mbed_official 146:f64d43ff0c18 54 else
mbed_official 146:f64d43ff0c18 55 {
mbed_official 146:f64d43ff0c18 56 edma_hal_set_fixed_priority_channel_arbitration(instance);
mbed_official 146:f64d43ff0c18 57 }
mbed_official 146:f64d43ff0c18 58 edma_hal_set_debug_mode(instance, init->isEnableDebug);
mbed_official 146:f64d43ff0c18 59
mbed_official 146:f64d43ff0c18 60 #if (FSL_FEATURE_DMA_CHANNEL_GROUP_COUNT > 0x1U)
mbed_official 146:f64d43ff0c18 61 edma_hal_set_group_priority(instance, init->groupPriority);
mbed_official 146:f64d43ff0c18 62 if (init->isEnableGroupRoundrobinArbitration)
mbed_official 146:f64d43ff0c18 63 {
mbed_official 146:f64d43ff0c18 64 edma_hal_set_roundrobin_group_arbitration(instance);
mbed_official 146:f64d43ff0c18 65 }
mbed_official 146:f64d43ff0c18 66 else
mbed_official 146:f64d43ff0c18 67 {
mbed_official 146:f64d43ff0c18 68 edma_hal_set_fixed_priority_group_arbitration(instance);
mbed_official 146:f64d43ff0c18 69 }
mbed_official 146:f64d43ff0c18 70 #endif
mbed_official 146:f64d43ff0c18 71 }
mbed_official 146:f64d43ff0c18 72
mbed_official 146:f64d43ff0c18 73 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 74 *
mbed_official 146:f64d43ff0c18 75 * Function Name : edma_hal_stcd_push_to_htcd
mbed_official 146:f64d43ff0c18 76 * Description : Copy the configuration data from the software TCD to hardware TCD.
mbed_official 146:f64d43ff0c18 77 *
mbed_official 146:f64d43ff0c18 78 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 79 void edma_hal_stcd_push_to_htcd(uint32_t instance, uint32_t channel, edma_software_tcd_t *stcd)
mbed_official 146:f64d43ff0c18 80 {
mbed_official 146:f64d43ff0c18 81 assert(instance < HW_DMA_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 82 assert(channel < FSL_FEATURE_DMA_MODULE_CHANNEL);
mbed_official 146:f64d43ff0c18 83 assert(stcd);
mbed_official 146:f64d43ff0c18 84
mbed_official 146:f64d43ff0c18 85 HW_DMA_TCDn_SADDR_WR(instance, channel, stcd->SADDR);
mbed_official 146:f64d43ff0c18 86 HW_DMA_TCDn_SOFF_WR(instance, channel, stcd->SOFF);
mbed_official 146:f64d43ff0c18 87 HW_DMA_TCDn_ATTR_WR(instance, channel, stcd->ATTR);
mbed_official 146:f64d43ff0c18 88 HW_DMA_TCDn_NBYTES_MLNO_WR(instance, channel, stcd->NBYTES_MLNO);
mbed_official 146:f64d43ff0c18 89 HW_DMA_TCDn_SLAST_WR(instance, channel, stcd->SLAST);
mbed_official 146:f64d43ff0c18 90 HW_DMA_TCDn_DADDR_WR(instance, channel, stcd->DADDR);
mbed_official 146:f64d43ff0c18 91 HW_DMA_TCDn_DOFF_WR(instance, channel, stcd->DOFF);
mbed_official 146:f64d43ff0c18 92 HW_DMA_TCDn_CITER_ELINKYES_WR(instance, channel, stcd->CITER_ELINKYES);
mbed_official 146:f64d43ff0c18 93 HW_DMA_TCDn_DLASTSGA_WR(instance, channel, stcd->DLAST_SGA);
mbed_official 146:f64d43ff0c18 94 HW_DMA_TCDn_CSR_WR(instance, channel, stcd->CSR);
mbed_official 146:f64d43ff0c18 95 HW_DMA_TCDn_BITER_ELINKYES_WR(instance, channel, stcd->BITER_ELINKYES);
mbed_official 146:f64d43ff0c18 96 }
mbed_official 146:f64d43ff0c18 97
mbed_official 146:f64d43ff0c18 98 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 99 *
mbed_official 146:f64d43ff0c18 100 * Function Name : edma_hal_htcd_get_nbytes_configuration.
mbed_official 146:f64d43ff0c18 101 * Description : Get nbytes configuration data.
mbed_official 146:f64d43ff0c18 102 *
mbed_official 146:f64d43ff0c18 103 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 104 uint32_t edma_hal_htcd_get_nbytes_configuration(uint32_t instance, uint32_t channel)
mbed_official 146:f64d43ff0c18 105 {
mbed_official 146:f64d43ff0c18 106 assert(instance < HW_DMA_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 107 assert(channel < FSL_FEATURE_DMA_MODULE_CHANNEL);
mbed_official 146:f64d43ff0c18 108
mbed_official 146:f64d43ff0c18 109 if (BR_DMA_CR_EMLM(instance))
mbed_official 146:f64d43ff0c18 110 {
mbed_official 146:f64d43ff0c18 111 if (BR_DMA_TCDn_NBYTES_MLOFFYES_SMLOE(instance, channel) ||
mbed_official 146:f64d43ff0c18 112 BR_DMA_TCDn_NBYTES_MLOFFYES_SMLOE(instance, channel))
mbed_official 146:f64d43ff0c18 113 {
mbed_official 146:f64d43ff0c18 114 return BR_DMA_TCDn_NBYTES_MLOFFYES_NBYTES(instance, channel);
mbed_official 146:f64d43ff0c18 115 }
mbed_official 146:f64d43ff0c18 116 else
mbed_official 146:f64d43ff0c18 117 {
mbed_official 146:f64d43ff0c18 118 return BR_DMA_TCDn_NBYTES_MLOFFNO_NBYTES(instance, channel);
mbed_official 146:f64d43ff0c18 119 }
mbed_official 146:f64d43ff0c18 120 }
mbed_official 146:f64d43ff0c18 121 else
mbed_official 146:f64d43ff0c18 122 {
mbed_official 146:f64d43ff0c18 123 return BR_DMA_TCDn_NBYTES_MLNO_NBYTES(instance, channel);
mbed_official 146:f64d43ff0c18 124 }
mbed_official 146:f64d43ff0c18 125 }
mbed_official 146:f64d43ff0c18 126
mbed_official 146:f64d43ff0c18 127 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 128 *
mbed_official 146:f64d43ff0c18 129 * Function Name : edma_hal_htcd_get_current_major_count
mbed_official 146:f64d43ff0c18 130 * Description : Get current major loop count.
mbed_official 146:f64d43ff0c18 131 *
mbed_official 146:f64d43ff0c18 132 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 133 uint32_t edma_hal_htcd_get_current_major_count(uint32_t instance, uint32_t channel)
mbed_official 146:f64d43ff0c18 134 {
mbed_official 146:f64d43ff0c18 135 assert(instance < HW_DMA_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 136 assert(channel < FSL_FEATURE_DMA_MODULE_CHANNEL);
mbed_official 146:f64d43ff0c18 137
mbed_official 146:f64d43ff0c18 138 if (BR_DMA_TCDn_CITER_ELINKYES_ELINK(instance, channel))
mbed_official 146:f64d43ff0c18 139 {
mbed_official 146:f64d43ff0c18 140 return BR_DMA_TCDn_CITER_ELINKYES_CITER(instance, channel);
mbed_official 146:f64d43ff0c18 141 }
mbed_official 146:f64d43ff0c18 142 else
mbed_official 146:f64d43ff0c18 143 {
mbed_official 146:f64d43ff0c18 144 return BR_DMA_TCDn_CITER_ELINKNO_CITER(instance, channel);
mbed_official 146:f64d43ff0c18 145 }
mbed_official 146:f64d43ff0c18 146 }
mbed_official 146:f64d43ff0c18 147
mbed_official 146:f64d43ff0c18 148 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 149 *
mbed_official 146:f64d43ff0c18 150 * Function Name : edma_hal_htcd_get_begin_major_count
mbed_official 146:f64d43ff0c18 151 * Description : Get begin major loop count.
mbed_official 146:f64d43ff0c18 152 *
mbed_official 146:f64d43ff0c18 153 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 154 uint32_t edma_hal_htcd_get_begin_major_count(uint32_t instance, uint32_t channel)
mbed_official 146:f64d43ff0c18 155 {
mbed_official 146:f64d43ff0c18 156 assert(instance < HW_DMA_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 157 assert(channel < FSL_FEATURE_DMA_MODULE_CHANNEL);
mbed_official 146:f64d43ff0c18 158
mbed_official 146:f64d43ff0c18 159 if (BR_DMA_TCDn_BITER_ELINKYES_ELINK(instance, channel))
mbed_official 146:f64d43ff0c18 160 {
mbed_official 146:f64d43ff0c18 161 return BR_DMA_TCDn_BITER_ELINKYES_BITER(instance, channel);
mbed_official 146:f64d43ff0c18 162 }
mbed_official 146:f64d43ff0c18 163 else
mbed_official 146:f64d43ff0c18 164 {
mbed_official 146:f64d43ff0c18 165 return BR_DMA_TCDn_BITER_ELINKNO_BITER(instance, channel);
mbed_official 146:f64d43ff0c18 166 }
mbed_official 146:f64d43ff0c18 167 }
mbed_official 146:f64d43ff0c18 168
mbed_official 146:f64d43ff0c18 169 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 170 *
mbed_official 146:f64d43ff0c18 171 * Function Name : edma_hal_htcd_get_unfinished_bytes
mbed_official 146:f64d43ff0c18 172 * Description : Get the bytes number not be transferred for this hardware TCD.
mbed_official 146:f64d43ff0c18 173 *
mbed_official 146:f64d43ff0c18 174 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 175 uint32_t edma_hal_htcd_get_unfinished_bytes(uint32_t instance, uint32_t channel)
mbed_official 146:f64d43ff0c18 176 {
mbed_official 146:f64d43ff0c18 177 assert(instance < HW_DMA_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 178 assert(channel < FSL_FEATURE_DMA_MODULE_CHANNEL);
mbed_official 146:f64d43ff0c18 179
mbed_official 146:f64d43ff0c18 180 return edma_hal_htcd_get_current_major_count(instance, channel) *
mbed_official 146:f64d43ff0c18 181 edma_hal_htcd_get_nbytes_configuration(instance, channel);
mbed_official 146:f64d43ff0c18 182 }
mbed_official 146:f64d43ff0c18 183
mbed_official 146:f64d43ff0c18 184 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 185 *
mbed_official 146:f64d43ff0c18 186 * Function Name : edma_hal_htcd_get_finished_bytes
mbed_official 146:f64d43ff0c18 187 * Description : Get the bytes number already be transferred for this hardware TCD.
mbed_official 146:f64d43ff0c18 188 *
mbed_official 146:f64d43ff0c18 189 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 190 uint32_t edma_hal_htcd_get_finished_bytes(uint32_t instance, uint32_t channel)
mbed_official 146:f64d43ff0c18 191 {
mbed_official 146:f64d43ff0c18 192 assert(instance < HW_DMA_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 193 assert(channel < FSL_FEATURE_DMA_MODULE_CHANNEL);
mbed_official 146:f64d43ff0c18 194
mbed_official 146:f64d43ff0c18 195 return (edma_hal_htcd_get_begin_major_count(instance, channel) -
mbed_official 146:f64d43ff0c18 196 edma_hal_htcd_get_current_major_count(instance, channel)) *
mbed_official 146:f64d43ff0c18 197 edma_hal_htcd_get_nbytes_configuration(instance, channel);
mbed_official 146:f64d43ff0c18 198 }
mbed_official 146:f64d43ff0c18 199 /*******************************************************************************
mbed_official 146:f64d43ff0c18 200 * EOF
mbed_official 146:f64d43ff0c18 201 ******************************************************************************/
mbed_official 146:f64d43ff0c18 202