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 #include "fsl_ftm_hal.h"
mbed_official 146:f64d43ff0c18 31
mbed_official 146:f64d43ff0c18 32 /*******************************************************************************
mbed_official 146:f64d43ff0c18 33 * Definitions
mbed_official 146:f64d43ff0c18 34 ******************************************************************************/
mbed_official 324:406fd2029f23 35 void FTM_HAL_Init(uint32_t ftmBaseAddr)
mbed_official 146:f64d43ff0c18 36 {
mbed_official 324:406fd2029f23 37
mbed_official 146:f64d43ff0c18 38 }
mbed_official 146:f64d43ff0c18 39
mbed_official 324:406fd2029f23 40 void FTM_HAL_EnablePwmMode(uint32_t ftmBaseAddr, ftm_pwm_param_t *config, uint8_t channel)
mbed_official 146:f64d43ff0c18 41 {
mbed_official 324:406fd2029f23 42 FTM_HAL_SetDualEdgeCaptureCmd(ftmBaseAddr, channel, false);
mbed_official 324:406fd2029f23 43 FTM_HAL_SetChnEdgeLevel(ftmBaseAddr, channel, config->edgeMode ? 1 : 2);
mbed_official 324:406fd2029f23 44 switch(config->mode)
mbed_official 324:406fd2029f23 45 {
mbed_official 324:406fd2029f23 46 case kFtmEdgeAlignedPWM:
mbed_official 324:406fd2029f23 47 FTM_HAL_SetDualChnCombineCmd(ftmBaseAddr, channel, false);
mbed_official 324:406fd2029f23 48 FTM_HAL_SetCpwms(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 49 FTM_HAL_SetChnMSnBAMode(ftmBaseAddr, channel, 2);
mbed_official 324:406fd2029f23 50 break;
mbed_official 324:406fd2029f23 51 case kFtmCenterAlignedPWM:
mbed_official 324:406fd2029f23 52 FTM_HAL_SetDualChnCombineCmd(ftmBaseAddr, channel, false);
mbed_official 324:406fd2029f23 53 FTM_HAL_SetCpwms(ftmBaseAddr, 1);
mbed_official 324:406fd2029f23 54 break;
mbed_official 324:406fd2029f23 55 case kFtmCombinedPWM:
mbed_official 324:406fd2029f23 56 FTM_HAL_SetCpwms(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 57 FTM_HAL_SetDualChnCombineCmd(ftmBaseAddr, channel, true);
mbed_official 324:406fd2029f23 58 break;
mbed_official 324:406fd2029f23 59 default:
mbed_official 324:406fd2029f23 60 assert(0);
mbed_official 324:406fd2029f23 61 break;
mbed_official 324:406fd2029f23 62 }
mbed_official 146:f64d43ff0c18 63 }
mbed_official 146:f64d43ff0c18 64
mbed_official 324:406fd2029f23 65 void FTM_HAL_DisablePwmMode(uint32_t ftmBaseAddr, ftm_pwm_param_t *config, uint8_t channel)
mbed_official 146:f64d43ff0c18 66 {
mbed_official 146:f64d43ff0c18 67
mbed_official 324:406fd2029f23 68 FTM_HAL_SetChnCountVal(ftmBaseAddr, channel, 0);
mbed_official 324:406fd2029f23 69 FTM_HAL_SetChnEdgeLevel(ftmBaseAddr, channel, 0);
mbed_official 324:406fd2029f23 70 FTM_HAL_SetChnMSnBAMode(ftmBaseAddr, channel, 0);
mbed_official 324:406fd2029f23 71 FTM_HAL_SetCpwms(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 72 FTM_HAL_SetDualChnCombineCmd(ftmBaseAddr, channel, false);
mbed_official 146:f64d43ff0c18 73 }
mbed_official 324:406fd2029f23 74
mbed_official 324:406fd2029f23 75 void FTM_HAL_Reset(uint32_t ftmBaseAddr, uint32_t instance)
mbed_official 146:f64d43ff0c18 76 {
mbed_official 324:406fd2029f23 77 uint8_t chan = FSL_FEATURE_FTM_CHANNEL_COUNTn(instance);
mbed_official 324:406fd2029f23 78
mbed_official 324:406fd2029f23 79 HW_FTM_SC_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 80 HW_FTM_CNT_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 81 HW_FTM_MOD_WR(ftmBaseAddr, 0);
mbed_official 146:f64d43ff0c18 82
mbed_official 324:406fd2029f23 83 for(int i = 0; i < chan; i++)
mbed_official 324:406fd2029f23 84 {
mbed_official 324:406fd2029f23 85 HW_FTM_CnSC_WR(ftmBaseAddr, i, 0);
mbed_official 324:406fd2029f23 86 HW_FTM_CnV_WR(ftmBaseAddr, i, 0);
mbed_official 324:406fd2029f23 87 }
mbed_official 324:406fd2029f23 88 HW_FTM_CNTIN_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 89 HW_FTM_STATUS_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 90 HW_FTM_MODE_WR(ftmBaseAddr, 0x00000004);
mbed_official 324:406fd2029f23 91 HW_FTM_SYNC_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 92 HW_FTM_OUTINIT_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 93 HW_FTM_OUTMASK_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 94 HW_FTM_COMBINE_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 95 HW_FTM_DEADTIME_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 96 HW_FTM_EXTTRIG_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 97 HW_FTM_POL_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 98 HW_FTM_FMS_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 99 HW_FTM_FILTER_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 100 HW_FTM_FLTCTRL_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 101 /*HW_FTM_QDCTRL_WR(instance, 0);*/
mbed_official 324:406fd2029f23 102 HW_FTM_CONF_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 103 HW_FTM_FLTPOL_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 104 HW_FTM_SYNCONF_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 105 HW_FTM_INVCTRL_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 106 HW_FTM_SWOCTRL_WR(ftmBaseAddr, 0);
mbed_official 324:406fd2029f23 107 HW_FTM_PWMLOAD_WR(ftmBaseAddr, 0);
mbed_official 146:f64d43ff0c18 108 }
mbed_official 146:f64d43ff0c18 109
mbed_official 324:406fd2029f23 110 void FTM_HAL_SetHardwareTriggerCmd(uint32_t ftmBaseAddr, uint8_t trigger_num, bool enable)
mbed_official 146:f64d43ff0c18 111 {
mbed_official 324:406fd2029f23 112 switch(trigger_num)
mbed_official 324:406fd2029f23 113 {
mbed_official 324:406fd2029f23 114 case 0:
mbed_official 324:406fd2029f23 115 BW_FTM_SYNC_TRIG0(ftmBaseAddr, enable ? 1 : 0);
mbed_official 324:406fd2029f23 116 break;
mbed_official 324:406fd2029f23 117 case 1:
mbed_official 324:406fd2029f23 118 BW_FTM_SYNC_TRIG1(ftmBaseAddr, enable ? 1 : 0);
mbed_official 324:406fd2029f23 119 break;
mbed_official 324:406fd2029f23 120 case 2:
mbed_official 324:406fd2029f23 121 BW_FTM_SYNC_TRIG2(ftmBaseAddr, enable ? 1 : 0);
mbed_official 324:406fd2029f23 122 break;
mbed_official 324:406fd2029f23 123 default:
mbed_official 324:406fd2029f23 124 assert(0);
mbed_official 324:406fd2029f23 125 break;
mbed_official 324:406fd2029f23 126 }
mbed_official 324:406fd2029f23 127 }
mbed_official 324:406fd2029f23 128
mbed_official 324:406fd2029f23 129 void FTM_HAL_SetChnTriggerCmd(uint32_t ftmBaseAddr, uint8_t channel, bool val)
mbed_official 324:406fd2029f23 130 {
mbed_official 324:406fd2029f23 131 assert(channel < HW_CHAN6);
mbed_official 324:406fd2029f23 132
mbed_official 324:406fd2029f23 133 uint8_t bit = val ? 1 : 0;
mbed_official 324:406fd2029f23 134 uint32_t value = (channel > 1U) ? (uint8_t)(bit << (channel - 2U)) : (uint8_t)(bit << (channel + 4U));
mbed_official 324:406fd2029f23 135
mbed_official 324:406fd2029f23 136 val ? HW_FTM_EXTTRIG_SET(ftmBaseAddr, value) : HW_FTM_EXTTRIG_CLR(ftmBaseAddr, value);
mbed_official 146:f64d43ff0c18 137 }
mbed_official 146:f64d43ff0c18 138
mbed_official 324:406fd2029f23 139 void FTM_HAL_SetChnInputCaptureFilter(uint32_t ftmBaseAddr, uint8_t channel, uint8_t val)
mbed_official 146:f64d43ff0c18 140 {
mbed_official 324:406fd2029f23 141 assert(channel < HW_CHAN4);
mbed_official 146:f64d43ff0c18 142
mbed_official 324:406fd2029f23 143 switch(channel)
mbed_official 324:406fd2029f23 144 {
mbed_official 324:406fd2029f23 145 case HW_CHAN0:
mbed_official 324:406fd2029f23 146 BW_FTM_FILTER_CH0FVAL(ftmBaseAddr, val);
mbed_official 324:406fd2029f23 147 break;
mbed_official 324:406fd2029f23 148 case HW_CHAN1:
mbed_official 324:406fd2029f23 149 BW_FTM_FILTER_CH1FVAL(ftmBaseAddr, val);
mbed_official 324:406fd2029f23 150 break;
mbed_official 324:406fd2029f23 151 case HW_CHAN2:
mbed_official 324:406fd2029f23 152 BW_FTM_FILTER_CH2FVAL(ftmBaseAddr, val);
mbed_official 324:406fd2029f23 153 break;
mbed_official 324:406fd2029f23 154 case HW_CHAN3:
mbed_official 324:406fd2029f23 155 BW_FTM_FILTER_CH3FVAL(ftmBaseAddr, val);
mbed_official 324:406fd2029f23 156 break;
mbed_official 324:406fd2029f23 157 default:
mbed_official 324:406fd2029f23 158 assert(0);
mbed_official 324:406fd2029f23 159 break;
mbed_official 324:406fd2029f23 160 }
mbed_official 146:f64d43ff0c18 161 }
mbed_official 146:f64d43ff0c18 162
mbed_official 324:406fd2029f23 163 uint32_t FTM_HAL_GetChnPairIndex(uint8_t channel)
mbed_official 324:406fd2029f23 164 {
mbed_official 324:406fd2029f23 165 if((channel == HW_CHAN0) || (channel == HW_CHAN1))
mbed_official 324:406fd2029f23 166 {
mbed_official 324:406fd2029f23 167 return 0;
mbed_official 324:406fd2029f23 168 }
mbed_official 324:406fd2029f23 169 else if((channel == HW_CHAN2) || (channel == HW_CHAN3))
mbed_official 324:406fd2029f23 170 {
mbed_official 324:406fd2029f23 171 return 1;
mbed_official 324:406fd2029f23 172 }
mbed_official 324:406fd2029f23 173 else if((channel == HW_CHAN4) || (channel == HW_CHAN5))
mbed_official 324:406fd2029f23 174 {
mbed_official 324:406fd2029f23 175 return 2;
mbed_official 324:406fd2029f23 176 }
mbed_official 324:406fd2029f23 177 else
mbed_official 324:406fd2029f23 178 {
mbed_official 324:406fd2029f23 179 return 3;
mbed_official 324:406fd2029f23 180 }
mbed_official 324:406fd2029f23 181 }
mbed_official 324:406fd2029f23 182
mbed_official 324:406fd2029f23 183 /*******************************************************************************
mbed_official 324:406fd2029f23 184 * EOF
mbed_official 324:406fd2029f23 185 ******************************************************************************/
mbed_official 324:406fd2029f23 186