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/sim/fsl_sim_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
mbed_official 146:f64d43ff0c18 31 #include "fsl_sim_hal.h"
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 /*******************************************************************************
mbed_official 146:f64d43ff0c18 34 * Definitions
mbed_official 146:f64d43ff0c18 35 ******************************************************************************/
mbed_official 146:f64d43ff0c18 36
mbed_official 146:f64d43ff0c18 37 /*******************************************************************************
mbed_official 146:f64d43ff0c18 38 * Code
mbed_official 146:f64d43ff0c18 39 ******************************************************************************/
mbed_official 146:f64d43ff0c18 40
mbed_official 146:f64d43ff0c18 41 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 42 *
mbed_official 146:f64d43ff0c18 43 * Function Name : clock_manager_find_module
mbed_official 146:f64d43ff0c18 44 * Description : An internal function to find the specified clock module
mbed_official 146:f64d43ff0c18 45 * table pointer for specified clock gate module name with instance.
mbed_official 146:f64d43ff0c18 46 * If the clock module with instance is supported, it will return an valid
mbed_official 146:f64d43ff0c18 47 * pointer. Otherwise it will return a null pointer.
mbed_official 146:f64d43ff0c18 48 *
mbed_official 146:f64d43ff0c18 49 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 50 const sim_clock_gate_module_config_t *clock_manager_find_module(
mbed_official 146:f64d43ff0c18 51 sim_clock_gate_module_names_t clockModule,
mbed_official 146:f64d43ff0c18 52 uint8_t instance)
mbed_official 146:f64d43ff0c18 53 {
mbed_official 146:f64d43ff0c18 54 uint32_t i = 0;
mbed_official 146:f64d43ff0c18 55
mbed_official 146:f64d43ff0c18 56 /* search through whole name table*/
mbed_official 146:f64d43ff0c18 57 while (kSimClockGateModuleConfigTable[i].clockGateModuleName != kSimClockModuleMax)
mbed_official 146:f64d43ff0c18 58 {
mbed_official 146:f64d43ff0c18 59 /* find only the match with both name and instance*/
mbed_official 146:f64d43ff0c18 60 if ( (kSimClockGateModuleConfigTable[i].clockGateModuleName == clockModule) &&
mbed_official 146:f64d43ff0c18 61 (kSimClockGateModuleConfigTable[i].deviceInstance == instance) )
mbed_official 146:f64d43ff0c18 62 {
mbed_official 146:f64d43ff0c18 63 /* return the table pointer*/
mbed_official 146:f64d43ff0c18 64 return &kSimClockGateModuleConfigTable[i];
mbed_official 146:f64d43ff0c18 65 }
mbed_official 146:f64d43ff0c18 66 i++;
mbed_official 146:f64d43ff0c18 67 }
mbed_official 146:f64d43ff0c18 68 return NULL;
mbed_official 146:f64d43ff0c18 69 }
mbed_official 146:f64d43ff0c18 70
mbed_official 146:f64d43ff0c18 71 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 72 *
mbed_official 146:f64d43ff0c18 73 * Function Name : clock_hal_set_gate
mbed_official 146:f64d43ff0c18 74 * Description : Enable or disable the clock for specified clock module
mbed_official 146:f64d43ff0c18 75 * This function will enable/disable the clock for specified clock module and
mbed_official 146:f64d43ff0c18 76 * instance.
mbed_official 146:f64d43ff0c18 77 *
mbed_official 146:f64d43ff0c18 78 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 79 sim_hal_status_t clock_hal_set_gate(sim_clock_gate_module_names_t clockModule,
mbed_official 146:f64d43ff0c18 80 uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 81 {
mbed_official 146:f64d43ff0c18 82 const sim_clock_gate_module_config_t *table = NULL;
mbed_official 146:f64d43ff0c18 83 /* check clock module name*/
mbed_official 146:f64d43ff0c18 84 assert(clockModule < kSimClockModuleMax);
mbed_official 146:f64d43ff0c18 85
mbed_official 146:f64d43ff0c18 86 /* find out the content matches with name and instance*/
mbed_official 146:f64d43ff0c18 87 table = clock_manager_find_module(clockModule, instance);
mbed_official 146:f64d43ff0c18 88
mbed_official 146:f64d43ff0c18 89 if (table != NULL)
mbed_official 146:f64d43ff0c18 90 {
mbed_official 146:f64d43ff0c18 91 if (enable)
mbed_official 146:f64d43ff0c18 92 {
mbed_official 146:f64d43ff0c18 93 /* if matches, execute the set(Enable/Disable) the clock gate*/
mbed_official 146:f64d43ff0c18 94 *(uint32_t *)table->scgcRegAddress |= table->deviceMask;
mbed_official 146:f64d43ff0c18 95 }
mbed_official 146:f64d43ff0c18 96 else
mbed_official 146:f64d43ff0c18 97 {
mbed_official 146:f64d43ff0c18 98 /* if matches, execute the set(Enable/Disable) the clock gate*/
mbed_official 146:f64d43ff0c18 99 *(uint32_t *)table->scgcRegAddress &= ~table->deviceMask;
mbed_official 146:f64d43ff0c18 100 }
mbed_official 146:f64d43ff0c18 101 return kSimHalSuccess;
mbed_official 146:f64d43ff0c18 102 }
mbed_official 146:f64d43ff0c18 103 else
mbed_official 146:f64d43ff0c18 104 {
mbed_official 146:f64d43ff0c18 105 return kSimHalNoSuchModule;
mbed_official 146:f64d43ff0c18 106 }
mbed_official 146:f64d43ff0c18 107 }
mbed_official 146:f64d43ff0c18 108
mbed_official 146:f64d43ff0c18 109 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 110 *
mbed_official 146:f64d43ff0c18 111 * Function Name : clock_hal_get_gate
mbed_official 146:f64d43ff0c18 112 * Description : Get the clock enable or disable state
mbed_official 146:f64d43ff0c18 113 * This function will get the current clock gate status of the specified clock
mbed_official 146:f64d43ff0c18 114 * moudle and instance.
mbed_official 146:f64d43ff0c18 115 *
mbed_official 146:f64d43ff0c18 116 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 117 sim_hal_status_t clock_hal_get_gate(sim_clock_gate_module_names_t clockModule,
mbed_official 146:f64d43ff0c18 118 uint8_t instance, bool *isEnabled)
mbed_official 146:f64d43ff0c18 119 {
mbed_official 146:f64d43ff0c18 120 const sim_clock_gate_module_config_t *table = NULL;
mbed_official 146:f64d43ff0c18 121 /* check clock module name*/
mbed_official 146:f64d43ff0c18 122 assert(clockModule < kSimClockModuleMax);
mbed_official 146:f64d43ff0c18 123
mbed_official 146:f64d43ff0c18 124 /* find out the content matches with name and instance*/
mbed_official 146:f64d43ff0c18 125 table = clock_manager_find_module(clockModule, instance);
mbed_official 146:f64d43ff0c18 126
mbed_official 146:f64d43ff0c18 127 if (table != NULL)
mbed_official 146:f64d43ff0c18 128 {
mbed_official 146:f64d43ff0c18 129 if ((*(uint32_t *)table->scgcRegAddress) & table->deviceMask)
mbed_official 146:f64d43ff0c18 130 {
mbed_official 146:f64d43ff0c18 131 *isEnabled = true;
mbed_official 146:f64d43ff0c18 132 }
mbed_official 146:f64d43ff0c18 133 else
mbed_official 146:f64d43ff0c18 134 {
mbed_official 146:f64d43ff0c18 135 *isEnabled = false;
mbed_official 146:f64d43ff0c18 136 }
mbed_official 146:f64d43ff0c18 137 return kSimHalSuccess;
mbed_official 146:f64d43ff0c18 138 }
mbed_official 146:f64d43ff0c18 139 else
mbed_official 146:f64d43ff0c18 140 {
mbed_official 146:f64d43ff0c18 141 return kSimHalNoSuchModule;
mbed_official 146:f64d43ff0c18 142 }
mbed_official 146:f64d43ff0c18 143 }
mbed_official 146:f64d43ff0c18 144
mbed_official 146:f64d43ff0c18 145 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 146 *
mbed_official 146:f64d43ff0c18 147 * Function Name : clock_hal_set_clock_source
mbed_official 146:f64d43ff0c18 148 * Description : Set clock source setting
mbed_official 146:f64d43ff0c18 149 * This function will set the settings for specified clock source. Each clock
mbed_official 146:f64d43ff0c18 150 * source has its clock selection settings. Refer to reference manual for
mbed_official 146:f64d43ff0c18 151 * details of settings for each clock source. Refer to sim_clock_source_names_t
mbed_official 146:f64d43ff0c18 152 * for clock sources.
mbed_official 146:f64d43ff0c18 153 *
mbed_official 146:f64d43ff0c18 154 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 155 sim_hal_status_t clock_hal_set_clock_source(sim_clock_source_names_t clockSource, uint8_t setting)
mbed_official 146:f64d43ff0c18 156 {
mbed_official 146:f64d43ff0c18 157 sim_hal_status_t status = kSimHalSuccess;
mbed_official 146:f64d43ff0c18 158 assert(clockSource < kSimClockSourceMax);
mbed_official 146:f64d43ff0c18 159
mbed_official 146:f64d43ff0c18 160 switch (clockSource)
mbed_official 146:f64d43ff0c18 161 {
mbed_official 146:f64d43ff0c18 162 #if FSL_FEATURE_SIM_OPT_HAS_NFCSRC
mbed_official 146:f64d43ff0c18 163 case kSimClockNfcSrc: /* NFCSRC*/
mbed_official 146:f64d43ff0c18 164 BW_SIM_SOPT2_NFCSRC(setting);
mbed_official 146:f64d43ff0c18 165 break;
mbed_official 146:f64d43ff0c18 166 case kSimClockNfcSel: /* NFC_CLKSEL*/
mbed_official 146:f64d43ff0c18 167 BW_SIM_SOPT2_NFC_CLKSEL(setting);
mbed_official 146:f64d43ff0c18 168 break;
mbed_official 146:f64d43ff0c18 169 #endif
mbed_official 146:f64d43ff0c18 170
mbed_official 146:f64d43ff0c18 171 #if FSL_FEATURE_SIM_OPT_HAS_ESDHCSRC
mbed_official 146:f64d43ff0c18 172 case kSimClockEsdhcSrc: /* ESDHCSRC*/
mbed_official 146:f64d43ff0c18 173 BW_SIM_SOPT2_ESDHCSRC(setting);
mbed_official 146:f64d43ff0c18 174 break;
mbed_official 146:f64d43ff0c18 175 #endif
mbed_official 146:f64d43ff0c18 176
mbed_official 146:f64d43ff0c18 177 #if FSL_FEATURE_SIM_OPT_HAS_SDHCSRC
mbed_official 146:f64d43ff0c18 178 case kSimClockSdhcSrc: /* SDHCSRC*/
mbed_official 146:f64d43ff0c18 179 BW_SIM_SOPT2_SDHCSRC(setting);
mbed_official 146:f64d43ff0c18 180 break;
mbed_official 146:f64d43ff0c18 181 #endif
mbed_official 146:f64d43ff0c18 182
mbed_official 146:f64d43ff0c18 183 #if FSL_FEATURE_SIM_OPT_HAS_LCDCSRC
mbed_official 146:f64d43ff0c18 184 case kSimClockLcdcSrc: /* LCDCSRC*/
mbed_official 146:f64d43ff0c18 185 BW_SIM_SOPT2_LCDCSRC(setting);
mbed_official 146:f64d43ff0c18 186 break;
mbed_official 146:f64d43ff0c18 187 case kSimClockLcdcSel: /* LCDC_CLKSEL*/
mbed_official 146:f64d43ff0c18 188 BW_SIM_SOPT2_LCDC_CLKSEL(setting);
mbed_official 146:f64d43ff0c18 189 break;
mbed_official 146:f64d43ff0c18 190 #endif
mbed_official 146:f64d43ff0c18 191
mbed_official 146:f64d43ff0c18 192 #if FSL_FEATURE_SIM_OPT_HAS_TIMESRC
mbed_official 146:f64d43ff0c18 193 case kSimClockTimeSrc: /* TIMESRC*/
mbed_official 146:f64d43ff0c18 194 BW_SIM_SOPT2_TIMESRC(setting);
mbed_official 146:f64d43ff0c18 195 break;
mbed_official 146:f64d43ff0c18 196 #endif
mbed_official 146:f64d43ff0c18 197
mbed_official 146:f64d43ff0c18 198 #if FSL_FEATURE_SIM_OPT_HAS_RMIISRC
mbed_official 146:f64d43ff0c18 199 case kSimClockRmiiSrc: /* RMIISRC*/
mbed_official 146:f64d43ff0c18 200 BW_SIM_SOPT2_RMIISRC(setting);
mbed_official 146:f64d43ff0c18 201 break;
mbed_official 146:f64d43ff0c18 202 #endif
mbed_official 146:f64d43ff0c18 203
mbed_official 146:f64d43ff0c18 204 #if FSL_FEATURE_SIM_OPT_HAS_USBSRC
mbed_official 146:f64d43ff0c18 205 case kSimClockUsbSrc: /* USBSRC*/
mbed_official 146:f64d43ff0c18 206 BW_SIM_SOPT2_USBSRC(setting);
mbed_official 146:f64d43ff0c18 207 break;
mbed_official 146:f64d43ff0c18 208 #endif
mbed_official 146:f64d43ff0c18 209
mbed_official 146:f64d43ff0c18 210 #if FSL_FEATURE_SIM_OPT_HAS_USBFSRC
mbed_official 146:f64d43ff0c18 211 case kSimClockUsbfSrc: /* USBFSRC*/
mbed_official 146:f64d43ff0c18 212 BW_SIM_SOPT2_USBFSRC(setting);
mbed_official 146:f64d43ff0c18 213 break;
mbed_official 146:f64d43ff0c18 214 case kSimClockUsbfSel: /* USBF_CLKSEL*/
mbed_official 146:f64d43ff0c18 215 BW_SIM_SOPT2_USBF_CLKSEL(setting);
mbed_official 146:f64d43ff0c18 216 break;
mbed_official 146:f64d43ff0c18 217 #endif
mbed_official 146:f64d43ff0c18 218
mbed_official 146:f64d43ff0c18 219 #if FSL_FEATURE_SIM_OPT_HAS_USBHSRC
mbed_official 146:f64d43ff0c18 220 case kSimClockUsbhSrc: /* USBHSRC*/
mbed_official 146:f64d43ff0c18 221 BW_SIM_SOPT2_USBHSRC(setting);
mbed_official 146:f64d43ff0c18 222 break;
mbed_official 146:f64d43ff0c18 223 #endif
mbed_official 146:f64d43ff0c18 224
mbed_official 146:f64d43ff0c18 225 #if FSL_FEATURE_SIM_OPT_HAS_UART0SRC
mbed_official 146:f64d43ff0c18 226 case kSimClockUart0Src: /* UART0SRC*/
mbed_official 146:f64d43ff0c18 227 BW_SIM_SOPT2_UART0SRC(setting);
mbed_official 146:f64d43ff0c18 228 break;
mbed_official 146:f64d43ff0c18 229 #endif
mbed_official 146:f64d43ff0c18 230
mbed_official 146:f64d43ff0c18 231 #if FSL_FEATURE_SIM_OPT_HAS_TPMSRC
mbed_official 146:f64d43ff0c18 232 case kSimClockTpmSrc: /* TPMSRC*/
mbed_official 146:f64d43ff0c18 233 BW_SIM_SOPT2_TPMSRC(setting);
mbed_official 146:f64d43ff0c18 234 break;
mbed_official 146:f64d43ff0c18 235 #endif
mbed_official 146:f64d43ff0c18 236
mbed_official 146:f64d43ff0c18 237 case kSimClockOsc32kSel: /* OSC32KSEL*/
mbed_official 146:f64d43ff0c18 238 BW_SIM_SOPT1_OSC32KSEL(setting);
mbed_official 146:f64d43ff0c18 239 break;
mbed_official 146:f64d43ff0c18 240
mbed_official 146:f64d43ff0c18 241 case kSimClockPllfllSel: /* PLLFLLSEL*/
mbed_official 146:f64d43ff0c18 242 BW_SIM_SOPT2_PLLFLLSEL(setting);
mbed_official 146:f64d43ff0c18 243 break;
mbed_official 146:f64d43ff0c18 244
mbed_official 146:f64d43ff0c18 245 #if FSL_FEATURE_SIM_OPT_HAS_TRACE_CLKSEL
mbed_official 146:f64d43ff0c18 246 case kSimClockTraceSel: /* TRACE_CLKSEL*/
mbed_official 146:f64d43ff0c18 247 BW_SIM_SOPT2_TRACECLKSEL(setting);
mbed_official 146:f64d43ff0c18 248 break;
mbed_official 146:f64d43ff0c18 249 #endif
mbed_official 146:f64d43ff0c18 250
mbed_official 146:f64d43ff0c18 251 case kSimClockClkoutSel: /* CLKOUTSEL*/
mbed_official 146:f64d43ff0c18 252 BW_SIM_SOPT2_CLKOUTSEL(setting);
mbed_official 146:f64d43ff0c18 253 break;
mbed_official 146:f64d43ff0c18 254
mbed_official 146:f64d43ff0c18 255 case kSimClockRtcClkoutSel: /* RTCCLKOUTSEL*/
mbed_official 146:f64d43ff0c18 256 BW_SIM_SOPT2_RTCCLKOUTSEL(setting);
mbed_official 146:f64d43ff0c18 257 break;
mbed_official 146:f64d43ff0c18 258
mbed_official 146:f64d43ff0c18 259 default:
mbed_official 146:f64d43ff0c18 260 status = kSimHalNoSuchClockSrc;
mbed_official 146:f64d43ff0c18 261 break;
mbed_official 146:f64d43ff0c18 262 }
mbed_official 146:f64d43ff0c18 263
mbed_official 146:f64d43ff0c18 264 return status;
mbed_official 146:f64d43ff0c18 265 }
mbed_official 146:f64d43ff0c18 266
mbed_official 146:f64d43ff0c18 267 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 268 *
mbed_official 146:f64d43ff0c18 269 * Function Name : clock_hal_get_clock_source
mbed_official 146:f64d43ff0c18 270 * Description : Get clock source setting
mbed_official 146:f64d43ff0c18 271 * This function will get the settings for specified clock source. Each clock
mbed_official 146:f64d43ff0c18 272 * source has its clock selection settings. Refer to reference manual for
mbed_official 146:f64d43ff0c18 273 * details of settings for each clock source. Refer to sim_clock_source_names_t
mbed_official 146:f64d43ff0c18 274 * for clock sources.
mbed_official 146:f64d43ff0c18 275 *
mbed_official 146:f64d43ff0c18 276 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 277 sim_hal_status_t clock_hal_get_clock_source(sim_clock_source_names_t clockSource, uint8_t *setting)
mbed_official 146:f64d43ff0c18 278 {
mbed_official 146:f64d43ff0c18 279 sim_hal_status_t status = kSimHalSuccess;
mbed_official 146:f64d43ff0c18 280 assert(clockSource < kSimClockSourceMax);
mbed_official 146:f64d43ff0c18 281
mbed_official 146:f64d43ff0c18 282 switch (clockSource)
mbed_official 146:f64d43ff0c18 283 {
mbed_official 146:f64d43ff0c18 284 #if FSL_FEATURE_SIM_OPT_HAS_NFCSRC
mbed_official 146:f64d43ff0c18 285 case kSimClockNfcSrc: /* NFCSRC*/
mbed_official 146:f64d43ff0c18 286 *setting = BR_SIM_SOPT2_NFCSRC;
mbed_official 146:f64d43ff0c18 287 break;
mbed_official 146:f64d43ff0c18 288 case kSimClockNfcSel: /* NFC_CLKSEL*/
mbed_official 146:f64d43ff0c18 289 *setting = BR_SIM_SOPT2_NFC_CLKSEL;
mbed_official 146:f64d43ff0c18 290 break;
mbed_official 146:f64d43ff0c18 291 #endif
mbed_official 146:f64d43ff0c18 292
mbed_official 146:f64d43ff0c18 293 #if FSL_FEATURE_SIM_OPT_HAS_ESDHCSRC
mbed_official 146:f64d43ff0c18 294 case kSimClockEsdhcSrc: /* ESDHCSRC*/
mbed_official 146:f64d43ff0c18 295 *setting = BR_SIM_SOPT2_ESDHCSRC;
mbed_official 146:f64d43ff0c18 296 break;
mbed_official 146:f64d43ff0c18 297 #endif
mbed_official 146:f64d43ff0c18 298
mbed_official 146:f64d43ff0c18 299 #if FSL_FEATURE_SIM_OPT_HAS_SDHCSRC
mbed_official 146:f64d43ff0c18 300 case kSimClockSdhcSrc: /* SDHCSRC*/
mbed_official 146:f64d43ff0c18 301 *setting = BR_SIM_SOPT2_SDHCSRC;
mbed_official 146:f64d43ff0c18 302 break;
mbed_official 146:f64d43ff0c18 303 #endif
mbed_official 146:f64d43ff0c18 304
mbed_official 146:f64d43ff0c18 305 #if FSL_FEATURE_SIM_OPT_HAS_LCDCSRC
mbed_official 146:f64d43ff0c18 306 case kSimClockLcdcSrc: /* LCDCSRC*/
mbed_official 146:f64d43ff0c18 307 *setting = BR_SIM_SOPT2_LCDCSRC;
mbed_official 146:f64d43ff0c18 308 break;
mbed_official 146:f64d43ff0c18 309 case kSimClockLcdcSel: /* LCDC_CLKSEL*/
mbed_official 146:f64d43ff0c18 310 *setting = BR_SIM_SOPT2_LCDC_CLKSEL;
mbed_official 146:f64d43ff0c18 311 break;
mbed_official 146:f64d43ff0c18 312 #endif
mbed_official 146:f64d43ff0c18 313
mbed_official 146:f64d43ff0c18 314 #if FSL_FEATURE_SIM_OPT_HAS_TIMESRC
mbed_official 146:f64d43ff0c18 315 case kSimClockTimeSrc: /* TIMESRC*/
mbed_official 146:f64d43ff0c18 316 *setting = BR_SIM_SOPT2_TIMESRC;
mbed_official 146:f64d43ff0c18 317 break;
mbed_official 146:f64d43ff0c18 318 #endif
mbed_official 146:f64d43ff0c18 319
mbed_official 146:f64d43ff0c18 320 #if FSL_FEATURE_SIM_OPT_HAS_RMIISRC
mbed_official 146:f64d43ff0c18 321 case kSimClockRmiiSrc: /* RMIISRC*/
mbed_official 146:f64d43ff0c18 322 *setting = BR_SIM_SOPT2_RMIISRC;
mbed_official 146:f64d43ff0c18 323 break;
mbed_official 146:f64d43ff0c18 324 #endif
mbed_official 146:f64d43ff0c18 325
mbed_official 146:f64d43ff0c18 326 #if FSL_FEATURE_SIM_OPT_HAS_USBSRC
mbed_official 146:f64d43ff0c18 327 case kSimClockUsbSrc: /* USBSRC*/
mbed_official 146:f64d43ff0c18 328 *setting = BR_SIM_SOPT2_USBSRC;
mbed_official 146:f64d43ff0c18 329 break;
mbed_official 146:f64d43ff0c18 330 #endif
mbed_official 146:f64d43ff0c18 331
mbed_official 146:f64d43ff0c18 332 #if FSL_FEATURE_SIM_OPT_HAS_USBFSRC
mbed_official 146:f64d43ff0c18 333 case kSimClockUsbfSrc: /* USBFSRC*/
mbed_official 146:f64d43ff0c18 334 *setting = BR_SIM_SOPT2_USBFSRC;
mbed_official 146:f64d43ff0c18 335 break;
mbed_official 146:f64d43ff0c18 336 case kSimClockUsbfSel: /* USBF_CLKSEL*/
mbed_official 146:f64d43ff0c18 337 *setting = BR_SIM_SOPT2_USBF_CLKSEL;
mbed_official 146:f64d43ff0c18 338 break;
mbed_official 146:f64d43ff0c18 339 #endif
mbed_official 146:f64d43ff0c18 340
mbed_official 146:f64d43ff0c18 341 #if FSL_FEATURE_SIM_OPT_HAS_USBHSRC
mbed_official 146:f64d43ff0c18 342 case kSimClockUsbhSrc: /* USBHSRC*/
mbed_official 146:f64d43ff0c18 343 *setting = BR_SIM_SOPT2_USBHSRC;
mbed_official 146:f64d43ff0c18 344 break;
mbed_official 146:f64d43ff0c18 345 #endif
mbed_official 146:f64d43ff0c18 346
mbed_official 146:f64d43ff0c18 347 #if FSL_FEATURE_SIM_OPT_HAS_UART0SRC
mbed_official 146:f64d43ff0c18 348 case kSimClockUart0Src: /* UART0SRC*/
mbed_official 146:f64d43ff0c18 349 *setting = BR_SIM_SOPT2_UART0SRC;
mbed_official 146:f64d43ff0c18 350 break;
mbed_official 146:f64d43ff0c18 351 #endif
mbed_official 146:f64d43ff0c18 352
mbed_official 146:f64d43ff0c18 353 #if FSL_FEATURE_SIM_OPT_HAS_TPMSRC
mbed_official 146:f64d43ff0c18 354 case kSimClockTpmSrc: /* TPMSRC*/
mbed_official 146:f64d43ff0c18 355 *setting = BR_SIM_SOPT2_TPMSRC;
mbed_official 146:f64d43ff0c18 356 break;
mbed_official 146:f64d43ff0c18 357 #endif
mbed_official 146:f64d43ff0c18 358
mbed_official 146:f64d43ff0c18 359 case kSimClockOsc32kSel: /* OSC32KSEL*/
mbed_official 146:f64d43ff0c18 360 *setting = BR_SIM_SOPT1_OSC32KSEL;
mbed_official 146:f64d43ff0c18 361 break;
mbed_official 146:f64d43ff0c18 362
mbed_official 146:f64d43ff0c18 363 case kSimClockPllfllSel: /* PLLFLLSEL*/
mbed_official 146:f64d43ff0c18 364 *setting = BR_SIM_SOPT2_PLLFLLSEL;
mbed_official 146:f64d43ff0c18 365 break;
mbed_official 146:f64d43ff0c18 366
mbed_official 146:f64d43ff0c18 367 #if FSL_FEATURE_SIM_OPT_HAS_TRACE_CLKSEL
mbed_official 146:f64d43ff0c18 368 case kSimClockTraceSel: /* TRACE_CLKSEL*/
mbed_official 146:f64d43ff0c18 369 *setting = BR_SIM_SOPT2_TRACECLKSEL;
mbed_official 146:f64d43ff0c18 370 break;
mbed_official 146:f64d43ff0c18 371 #endif
mbed_official 146:f64d43ff0c18 372
mbed_official 146:f64d43ff0c18 373 case kSimClockClkoutSel: /* CLKOUTSEL */
mbed_official 146:f64d43ff0c18 374 *setting = BR_SIM_SOPT2_CLKOUTSEL;
mbed_official 146:f64d43ff0c18 375 break;
mbed_official 146:f64d43ff0c18 376
mbed_official 146:f64d43ff0c18 377 case kSimClockRtcClkoutSel: /* RTCCLKOUTSEL */
mbed_official 146:f64d43ff0c18 378 *setting = BR_SIM_SOPT2_RTCCLKOUTSEL;
mbed_official 146:f64d43ff0c18 379 break;
mbed_official 146:f64d43ff0c18 380
mbed_official 146:f64d43ff0c18 381 default:
mbed_official 146:f64d43ff0c18 382 status = kSimHalNoSuchClockSrc;
mbed_official 146:f64d43ff0c18 383 break;
mbed_official 146:f64d43ff0c18 384 }
mbed_official 146:f64d43ff0c18 385
mbed_official 146:f64d43ff0c18 386 return status;
mbed_official 146:f64d43ff0c18 387 }
mbed_official 146:f64d43ff0c18 388
mbed_official 146:f64d43ff0c18 389 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 390 *
mbed_official 146:f64d43ff0c18 391 * Function Name : clock_hal_set_clock_divider
mbed_official 146:f64d43ff0c18 392 * Description : Set clock divider setting
mbed_official 146:f64d43ff0c18 393 * This function will set the setting for specified clock divider. Refer to
mbed_official 146:f64d43ff0c18 394 * reference manual for supported clock divider and value range. Refer to
mbed_official 146:f64d43ff0c18 395 * sim_clock_divider_names_t for dividers.
mbed_official 146:f64d43ff0c18 396 *
mbed_official 146:f64d43ff0c18 397 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 398 sim_hal_status_t clock_hal_set_clock_divider(sim_clock_divider_names_t clockDivider,
mbed_official 146:f64d43ff0c18 399 uint32_t setting)
mbed_official 146:f64d43ff0c18 400 {
mbed_official 146:f64d43ff0c18 401 sim_hal_status_t status = kSimHalSuccess;
mbed_official 146:f64d43ff0c18 402 assert(clockDivider < kSimClockDividerMax);
mbed_official 146:f64d43ff0c18 403
mbed_official 146:f64d43ff0c18 404 switch (clockDivider)
mbed_official 146:f64d43ff0c18 405 {
mbed_official 146:f64d43ff0c18 406 case kSimClockDividerOutdiv1: /* OUTDIV1*/
mbed_official 146:f64d43ff0c18 407 BW_SIM_CLKDIV1_OUTDIV1(setting);
mbed_official 146:f64d43ff0c18 408 break;
mbed_official 146:f64d43ff0c18 409
mbed_official 146:f64d43ff0c18 410 #if FSL_FEATURE_SIM_DIVIDER_HAS_OUTDIV2
mbed_official 146:f64d43ff0c18 411 case kSimClockDividerOutdiv2: /* OUTDIV2*/
mbed_official 146:f64d43ff0c18 412 BW_SIM_CLKDIV1_OUTDIV2(setting);
mbed_official 146:f64d43ff0c18 413 break;
mbed_official 146:f64d43ff0c18 414 #endif
mbed_official 146:f64d43ff0c18 415
mbed_official 146:f64d43ff0c18 416 #if FSL_FEATURE_SIM_DIVIDER_HAS_OUTDIV3
mbed_official 146:f64d43ff0c18 417 case kSimClockDividerOutdiv3: /* OUTDIV3*/
mbed_official 146:f64d43ff0c18 418 BW_SIM_CLKDIV1_OUTDIV3(setting);
mbed_official 146:f64d43ff0c18 419 break;
mbed_official 146:f64d43ff0c18 420 #endif
mbed_official 146:f64d43ff0c18 421
mbed_official 146:f64d43ff0c18 422 case kSimClockDividerOutdiv4: /* OUTDIV4*/
mbed_official 146:f64d43ff0c18 423 BW_SIM_CLKDIV1_OUTDIV4(setting);
mbed_official 146:f64d43ff0c18 424 break;
mbed_official 146:f64d43ff0c18 425
mbed_official 146:f64d43ff0c18 426 #if FSL_FEATURE_SIM_DIVIDER_HAS_USBDIV
mbed_official 146:f64d43ff0c18 427 case kSimClockDividerUsbFrac: /* USBFRAC*/
mbed_official 146:f64d43ff0c18 428 BW_SIM_CLKDIV2_USBFRAC(setting);
mbed_official 146:f64d43ff0c18 429 break;
mbed_official 146:f64d43ff0c18 430 case kSimClockDividerUsbDiv: /* USBDIV*/
mbed_official 146:f64d43ff0c18 431 BW_SIM_CLKDIV2_USBDIV(setting);
mbed_official 146:f64d43ff0c18 432 break;
mbed_official 146:f64d43ff0c18 433 #endif
mbed_official 146:f64d43ff0c18 434
mbed_official 146:f64d43ff0c18 435 #if FSL_FEATURE_SIM_DIVIDER_HAS_USBFSDIV
mbed_official 146:f64d43ff0c18 436 case kSimClockDividerUsbfsFrac: /* USBFSFRAC*/
mbed_official 146:f64d43ff0c18 437 BW_SIM_CLKDIV2_USBFSFRAC(setting);
mbed_official 146:f64d43ff0c18 438 break;
mbed_official 146:f64d43ff0c18 439 case kSimClockDividerUsbfsDiv: /* USBFSDIV*/
mbed_official 146:f64d43ff0c18 440 BW_SIM_CLKDIV2_USBFSDIV(setting);
mbed_official 146:f64d43ff0c18 441 break;
mbed_official 146:f64d43ff0c18 442 #endif
mbed_official 146:f64d43ff0c18 443
mbed_official 146:f64d43ff0c18 444 #if FSL_FEATURE_SIM_DIVIDER_HAS_USBHSDIV
mbed_official 146:f64d43ff0c18 445 case kSimClockDividerUsbhsFrac: /* USBHSFRAC*/
mbed_official 146:f64d43ff0c18 446 BW_SIM_CLKDIV2_USBHSFRAC(setting);
mbed_official 146:f64d43ff0c18 447 break;
mbed_official 146:f64d43ff0c18 448 case kSimClockDividerUsbhsDiv: /* USBHSDIV*/
mbed_official 146:f64d43ff0c18 449 BW_SIM_CLKDIV2_USBHSDIV(setting);
mbed_official 146:f64d43ff0c18 450 break;
mbed_official 146:f64d43ff0c18 451 #endif
mbed_official 146:f64d43ff0c18 452
mbed_official 146:f64d43ff0c18 453 #if FSL_FEATURE_SIM_OPT_HAS_LCDCSRC
mbed_official 146:f64d43ff0c18 454 case kSimClockDividerLcdcFrac: /* LCDCFRAC*/
mbed_official 146:f64d43ff0c18 455 BW_SIM_CLKDIV3_LCDCFRAC(setting);
mbed_official 146:f64d43ff0c18 456 break;
mbed_official 146:f64d43ff0c18 457 case kSimClockDividerLcdcDiv: /* LCDCDIV*/
mbed_official 146:f64d43ff0c18 458 BW_SIM_CLKDIV3_LCDCDIV(setting);
mbed_official 146:f64d43ff0c18 459 break;
mbed_official 146:f64d43ff0c18 460 #endif
mbed_official 146:f64d43ff0c18 461
mbed_official 146:f64d43ff0c18 462 #if FSL_FEATURE_SIM_OPT_HAS_NFCSRC
mbed_official 146:f64d43ff0c18 463 case kSimClockDividerNfcFrac: /* NFCFRAC*/
mbed_official 146:f64d43ff0c18 464 BW_SIM_CLKDIV4_NFCFRAC(setting);
mbed_official 146:f64d43ff0c18 465 break;
mbed_official 146:f64d43ff0c18 466 case kSimClockDividerNfcDiv: /* NFCDIV*/
mbed_official 146:f64d43ff0c18 467 BW_SIM_CLKDIV4_NFCDIV(setting);
mbed_official 146:f64d43ff0c18 468 break;
mbed_official 146:f64d43ff0c18 469 #endif
mbed_official 146:f64d43ff0c18 470
mbed_official 146:f64d43ff0c18 471 case kSimClockDividerSpecial1: /* special divider 1 */
mbed_official 146:f64d43ff0c18 472 break;
mbed_official 146:f64d43ff0c18 473
mbed_official 146:f64d43ff0c18 474 default:
mbed_official 146:f64d43ff0c18 475 status = kSimHalNoSuchDivider;
mbed_official 146:f64d43ff0c18 476 break;
mbed_official 146:f64d43ff0c18 477 }
mbed_official 146:f64d43ff0c18 478
mbed_official 146:f64d43ff0c18 479 return status;
mbed_official 146:f64d43ff0c18 480 }
mbed_official 146:f64d43ff0c18 481
mbed_official 146:f64d43ff0c18 482 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 483 *
mbed_official 146:f64d43ff0c18 484 * Function Name : clock_hal_set_clock_out_dividers
mbed_official 146:f64d43ff0c18 485 * Description : Set all clock out dividers setting at the same time
mbed_official 146:f64d43ff0c18 486 * This function will set the setting for all clock out dividers. Refer to
mbed_official 146:f64d43ff0c18 487 * reference manual for supported clock divider and value range. Refer to
mbed_official 146:f64d43ff0c18 488 * sim_clock_divider_names_t for dividers.
mbed_official 146:f64d43ff0c18 489 *
mbed_official 146:f64d43ff0c18 490 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 491 void clock_hal_set_clock_out_dividers(uint32_t outdiv1, uint32_t outdiv2,
mbed_official 146:f64d43ff0c18 492 uint32_t outdiv3, uint32_t outdiv4)
mbed_official 146:f64d43ff0c18 493 {
mbed_official 146:f64d43ff0c18 494 uint32_t clkdiv1 = 0;
mbed_official 146:f64d43ff0c18 495
mbed_official 146:f64d43ff0c18 496 clkdiv1 |= BF_SIM_CLKDIV1_OUTDIV1(outdiv1);
mbed_official 146:f64d43ff0c18 497 #if FSL_FEATURE_SIM_DIVIDER_HAS_OUTDIV2
mbed_official 146:f64d43ff0c18 498 clkdiv1 |= BF_SIM_CLKDIV1_OUTDIV2(outdiv2);
mbed_official 146:f64d43ff0c18 499 #endif
mbed_official 146:f64d43ff0c18 500 #if FSL_FEATURE_SIM_DIVIDER_HAS_OUTDIV3
mbed_official 146:f64d43ff0c18 501 clkdiv1 |= BF_SIM_CLKDIV1_OUTDIV3(outdiv3);
mbed_official 146:f64d43ff0c18 502 #endif
mbed_official 146:f64d43ff0c18 503 clkdiv1 |= BF_SIM_CLKDIV1_OUTDIV4(outdiv4);
mbed_official 146:f64d43ff0c18 504
mbed_official 146:f64d43ff0c18 505 HW_SIM_CLKDIV1_WR(clkdiv1);
mbed_official 146:f64d43ff0c18 506 }
mbed_official 146:f64d43ff0c18 507
mbed_official 146:f64d43ff0c18 508 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 509 *
mbed_official 146:f64d43ff0c18 510 * Function Name : clock_hal_get_clock_divider
mbed_official 146:f64d43ff0c18 511 * Description : Get clock divider setting
mbed_official 146:f64d43ff0c18 512 * This function will get the setting for specified clock divider. Refer to
mbed_official 146:f64d43ff0c18 513 * reference manual for supported clock divider and value range. Refer to
mbed_official 146:f64d43ff0c18 514 * sim_clock_divider_names_t for dividers.
mbed_official 146:f64d43ff0c18 515 *
mbed_official 146:f64d43ff0c18 516 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 517 sim_hal_status_t clock_hal_get_clock_divider(sim_clock_divider_names_t clockDivider, uint32_t *setting)
mbed_official 146:f64d43ff0c18 518 {
mbed_official 146:f64d43ff0c18 519 sim_hal_status_t status = kSimHalSuccess;
mbed_official 146:f64d43ff0c18 520 assert(clockDivider < kSimClockDividerMax);
mbed_official 146:f64d43ff0c18 521
mbed_official 146:f64d43ff0c18 522 *setting = 0;
mbed_official 146:f64d43ff0c18 523
mbed_official 146:f64d43ff0c18 524 switch (clockDivider)
mbed_official 146:f64d43ff0c18 525 {
mbed_official 146:f64d43ff0c18 526 case kSimClockDividerOutdiv1: /* OUTDIV1*/
mbed_official 146:f64d43ff0c18 527 *setting = BR_SIM_CLKDIV1_OUTDIV1;
mbed_official 146:f64d43ff0c18 528 break;
mbed_official 146:f64d43ff0c18 529
mbed_official 146:f64d43ff0c18 530 #if FSL_FEATURE_SIM_DIVIDER_HAS_OUTDIV2
mbed_official 146:f64d43ff0c18 531 case kSimClockDividerOutdiv2: /* OUTDIV2*/
mbed_official 146:f64d43ff0c18 532 *setting = BR_SIM_CLKDIV1_OUTDIV2;
mbed_official 146:f64d43ff0c18 533 break;
mbed_official 146:f64d43ff0c18 534 #endif
mbed_official 146:f64d43ff0c18 535
mbed_official 146:f64d43ff0c18 536 #if FSL_FEATURE_SIM_DIVIDER_HAS_OUTDIV3
mbed_official 146:f64d43ff0c18 537 case kSimClockDividerOutdiv3: /* OUTDIV3*/
mbed_official 146:f64d43ff0c18 538 *setting = BR_SIM_CLKDIV1_OUTDIV3;
mbed_official 146:f64d43ff0c18 539 break;
mbed_official 146:f64d43ff0c18 540 #endif
mbed_official 146:f64d43ff0c18 541
mbed_official 146:f64d43ff0c18 542 case kSimClockDividerOutdiv4: /* OUTDIV4*/
mbed_official 146:f64d43ff0c18 543 *setting = BR_SIM_CLKDIV1_OUTDIV4;
mbed_official 146:f64d43ff0c18 544 break;
mbed_official 146:f64d43ff0c18 545
mbed_official 146:f64d43ff0c18 546 #if FSL_FEATURE_SIM_DIVIDER_HAS_USBDIV
mbed_official 146:f64d43ff0c18 547 case kSimClockDividerUsbFrac: /* USBFRAC*/
mbed_official 146:f64d43ff0c18 548 *setting = BR_SIM_CLKDIV2_USBFRAC;
mbed_official 146:f64d43ff0c18 549 break;
mbed_official 146:f64d43ff0c18 550 case kSimClockDividerUsbDiv: /* USBDIV*/
mbed_official 146:f64d43ff0c18 551 *setting = BR_SIM_CLKDIV2_USBDIV;
mbed_official 146:f64d43ff0c18 552 break;
mbed_official 146:f64d43ff0c18 553 #endif
mbed_official 146:f64d43ff0c18 554
mbed_official 146:f64d43ff0c18 555 #if FSL_FEATURE_SIM_DIVIDER_HAS_USBFSDIV
mbed_official 146:f64d43ff0c18 556 case kSimClockDividerUsbfsFrac: /* USBFSFRAC*/
mbed_official 146:f64d43ff0c18 557 *setting = BR_SIM_CLKDIV2_USBFSFRAC;
mbed_official 146:f64d43ff0c18 558 break;
mbed_official 146:f64d43ff0c18 559 case kSimClockDividerUsbfsDiv: /* USBFSDIV*/
mbed_official 146:f64d43ff0c18 560 *setting = BR_SIM_CLKDIV2_USBFSDIV;
mbed_official 146:f64d43ff0c18 561 break;
mbed_official 146:f64d43ff0c18 562 #endif
mbed_official 146:f64d43ff0c18 563
mbed_official 146:f64d43ff0c18 564 #if FSL_FEATURE_SIM_DIVIDER_HAS_USBHSDIV
mbed_official 146:f64d43ff0c18 565 case kSimClockDividerUsbhsFrac: /* USBHSFRAC*/
mbed_official 146:f64d43ff0c18 566 *setting = BR_SIM_CLKDIV2_USBHSFRAC;
mbed_official 146:f64d43ff0c18 567 break;
mbed_official 146:f64d43ff0c18 568 case kSimClockDividerUsbhsDiv: /* USBHSDIV*/
mbed_official 146:f64d43ff0c18 569 *setting = BR_SIM_CLKDIV2_USBHSDIV;
mbed_official 146:f64d43ff0c18 570 break;
mbed_official 146:f64d43ff0c18 571 #endif
mbed_official 146:f64d43ff0c18 572
mbed_official 146:f64d43ff0c18 573 #if FSL_FEATURE_SIM_OPT_HAS_LCDCSRC
mbed_official 146:f64d43ff0c18 574 case kSimClockDividerLcdcFrac: /* LCDCFRAC*/
mbed_official 146:f64d43ff0c18 575 *setting = BR_SIM_CLKDIV3_LCDCFRAC;
mbed_official 146:f64d43ff0c18 576 break;
mbed_official 146:f64d43ff0c18 577 case kSimClockDividerLcdcDiv: /* LCDCDIV*/
mbed_official 146:f64d43ff0c18 578 *setting = BR_SIM_CLKDIV3_LCDCDIV;
mbed_official 146:f64d43ff0c18 579 break;
mbed_official 146:f64d43ff0c18 580 #endif
mbed_official 146:f64d43ff0c18 581
mbed_official 146:f64d43ff0c18 582 #if FSL_FEATURE_SIM_OPT_HAS_NFCSRC
mbed_official 146:f64d43ff0c18 583 case kSimClockDividerNfcFrac: /* NFCFRAC*/
mbed_official 146:f64d43ff0c18 584 *setting = BR_SIM_CLKDIV4_NFCFRAC;
mbed_official 146:f64d43ff0c18 585 break;
mbed_official 146:f64d43ff0c18 586 case kSimClockDividerNfcDiv: /* NFCDIV*/
mbed_official 146:f64d43ff0c18 587 *setting = BR_SIM_CLKDIV4_NFCDIV;
mbed_official 146:f64d43ff0c18 588 break;
mbed_official 146:f64d43ff0c18 589 #endif
mbed_official 146:f64d43ff0c18 590
mbed_official 146:f64d43ff0c18 591 case kSimClockDividerSpecial1: /* special divider 1 */
mbed_official 146:f64d43ff0c18 592 *setting = 1;
mbed_official 146:f64d43ff0c18 593 break;
mbed_official 146:f64d43ff0c18 594
mbed_official 146:f64d43ff0c18 595 default:
mbed_official 146:f64d43ff0c18 596 status = kSimHalNoSuchDivider;
mbed_official 146:f64d43ff0c18 597 break;
mbed_official 146:f64d43ff0c18 598 }
mbed_official 146:f64d43ff0c18 599
mbed_official 146:f64d43ff0c18 600 return status;
mbed_official 146:f64d43ff0c18 601 }
mbed_official 146:f64d43ff0c18 602
mbed_official 146:f64d43ff0c18 603 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 604 *
mbed_official 146:f64d43ff0c18 605 * Function Name : sim_set_alttrgen
mbed_official 146:f64d43ff0c18 606 * Description : Set ADCx alternate trigger enable setting
mbed_official 146:f64d43ff0c18 607 * This function will enable/disable alternative conversion triggers for ADCx.
mbed_official 146:f64d43ff0c18 608 *
mbed_official 146:f64d43ff0c18 609 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 610 void sim_set_alttrgen(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 611 {
mbed_official 146:f64d43ff0c18 612 assert(instance < HW_ADC_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 613
mbed_official 146:f64d43ff0c18 614 switch (instance)
mbed_official 146:f64d43ff0c18 615 {
mbed_official 146:f64d43ff0c18 616 case 0:
mbed_official 146:f64d43ff0c18 617 BW_SIM_SOPT7_ADC0ALTTRGEN(enable ? 1 : 0);
mbed_official 146:f64d43ff0c18 618 break;
mbed_official 146:f64d43ff0c18 619 #if (HW_ADC_INSTANCE_COUNT > 1)
mbed_official 146:f64d43ff0c18 620 case 1:
mbed_official 146:f64d43ff0c18 621 BW_SIM_SOPT7_ADC1ALTTRGEN(enable ? 1 : 0);
mbed_official 146:f64d43ff0c18 622 break;
mbed_official 146:f64d43ff0c18 623 #if (HW_ADC_INSTANCE_COUNT > 2)
mbed_official 146:f64d43ff0c18 624 case 2:
mbed_official 146:f64d43ff0c18 625 BW_SIM_SOPT7_ADC2ALTTRGEN(enable ? 1 : 0);
mbed_official 146:f64d43ff0c18 626 break;
mbed_official 146:f64d43ff0c18 627 case 3:
mbed_official 146:f64d43ff0c18 628 BW_SIM_SOPT7_ADC3ALTTRGEN(enable ? 1 : 0);
mbed_official 146:f64d43ff0c18 629 break;
mbed_official 146:f64d43ff0c18 630 #endif
mbed_official 146:f64d43ff0c18 631 #endif
mbed_official 146:f64d43ff0c18 632 default:
mbed_official 146:f64d43ff0c18 633 break;
mbed_official 146:f64d43ff0c18 634 }
mbed_official 146:f64d43ff0c18 635 }
mbed_official 146:f64d43ff0c18 636
mbed_official 146:f64d43ff0c18 637 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 638 *
mbed_official 146:f64d43ff0c18 639 * Function Name : sim_get_alttrgen
mbed_official 146:f64d43ff0c18 640 * Description : Get ADCx alternate trigger enable settingg
mbed_official 146:f64d43ff0c18 641 * This function will get ADCx alternate trigger enable setting.
mbed_official 146:f64d43ff0c18 642 *
mbed_official 146:f64d43ff0c18 643 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 644 bool sim_get_alttrgen(uint8_t instance)
mbed_official 146:f64d43ff0c18 645 {
mbed_official 146:f64d43ff0c18 646 assert(instance < HW_ADC_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 647
mbed_official 146:f64d43ff0c18 648 switch (instance)
mbed_official 146:f64d43ff0c18 649 {
mbed_official 146:f64d43ff0c18 650 case 0:
mbed_official 146:f64d43ff0c18 651 return BR_SIM_SOPT7_ADC0ALTTRGEN;
mbed_official 146:f64d43ff0c18 652 #if (HW_ADC_INSTANCE_COUNT > 1)
mbed_official 146:f64d43ff0c18 653 case 1:
mbed_official 146:f64d43ff0c18 654 return BR_SIM_SOPT7_ADC1ALTTRGEN;
mbed_official 146:f64d43ff0c18 655 #if (HW_ADC_INSTANCE_COUNT > 2)
mbed_official 146:f64d43ff0c18 656 case 2:
mbed_official 146:f64d43ff0c18 657 return BR_SIM_SOPT7_ADC2ALTTRGEN;
mbed_official 146:f64d43ff0c18 658 case 3:
mbed_official 146:f64d43ff0c18 659 return BR_SIM_SOPT7_ADC3ALTTRGEN;
mbed_official 146:f64d43ff0c18 660 #endif
mbed_official 146:f64d43ff0c18 661 #endif
mbed_official 146:f64d43ff0c18 662 default:
mbed_official 146:f64d43ff0c18 663 return false;
mbed_official 146:f64d43ff0c18 664 }
mbed_official 146:f64d43ff0c18 665 }
mbed_official 146:f64d43ff0c18 666
mbed_official 146:f64d43ff0c18 667 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 668 *
mbed_official 146:f64d43ff0c18 669 * Function Name : sim_set_pretrgsel
mbed_official 146:f64d43ff0c18 670 * Description : Set ADCx pre-trigger select setting
mbed_official 146:f64d43ff0c18 671 * This function will select the ADCx pre-trigger source when alternative
mbed_official 146:f64d43ff0c18 672 * triggers are enabled through ADCxALTTRGEN
mbed_official 146:f64d43ff0c18 673 *
mbed_official 146:f64d43ff0c18 674 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 675 void sim_set_pretrgsel(uint8_t instance, sim_pretrgsel_t select)
mbed_official 146:f64d43ff0c18 676 {
mbed_official 146:f64d43ff0c18 677 assert(instance < HW_ADC_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 678
mbed_official 146:f64d43ff0c18 679 switch (instance)
mbed_official 146:f64d43ff0c18 680 {
mbed_official 146:f64d43ff0c18 681 case 0:
mbed_official 146:f64d43ff0c18 682 BW_SIM_SOPT7_ADC0PRETRGSEL(select);
mbed_official 146:f64d43ff0c18 683 break;
mbed_official 146:f64d43ff0c18 684 #if (HW_ADC_INSTANCE_COUNT > 1)
mbed_official 146:f64d43ff0c18 685 case 1:
mbed_official 146:f64d43ff0c18 686 BW_SIM_SOPT7_ADC1PRETRGSEL(select);
mbed_official 146:f64d43ff0c18 687 break;
mbed_official 146:f64d43ff0c18 688 #if (HW_ADC_INSTANCE_COUNT > 2)
mbed_official 146:f64d43ff0c18 689 case 2:
mbed_official 146:f64d43ff0c18 690 BW_SIM_SOPT7_ADC2PRETRGSEL(select);
mbed_official 146:f64d43ff0c18 691 break;
mbed_official 146:f64d43ff0c18 692 case 3:
mbed_official 146:f64d43ff0c18 693 BW_SIM_SOPT7_ADC3PRETRGSEL(select);
mbed_official 146:f64d43ff0c18 694 break;
mbed_official 146:f64d43ff0c18 695 #endif
mbed_official 146:f64d43ff0c18 696 #endif
mbed_official 146:f64d43ff0c18 697 default:
mbed_official 146:f64d43ff0c18 698 break;
mbed_official 146:f64d43ff0c18 699 }
mbed_official 146:f64d43ff0c18 700 }
mbed_official 146:f64d43ff0c18 701
mbed_official 146:f64d43ff0c18 702 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 703 *
mbed_official 146:f64d43ff0c18 704 * Function Name : sim_get_pretrgsel
mbed_official 146:f64d43ff0c18 705 * Description : Get ADCx pre-trigger select setting
mbed_official 146:f64d43ff0c18 706 * This function will get ADCx pre-trigger select setting.
mbed_official 146:f64d43ff0c18 707 *
mbed_official 146:f64d43ff0c18 708 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 709 sim_pretrgsel_t sim_get_pretrgsel(uint8_t instance)
mbed_official 146:f64d43ff0c18 710 {
mbed_official 146:f64d43ff0c18 711 assert(instance < HW_ADC_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 712
mbed_official 146:f64d43ff0c18 713 switch (instance)
mbed_official 146:f64d43ff0c18 714 {
mbed_official 146:f64d43ff0c18 715 case 0:
mbed_official 146:f64d43ff0c18 716 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC0PRETRGSEL;
mbed_official 146:f64d43ff0c18 717 #if (HW_ADC_INSTANCE_COUNT > 1)
mbed_official 146:f64d43ff0c18 718 case 1:
mbed_official 146:f64d43ff0c18 719 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC1PRETRGSEL;
mbed_official 146:f64d43ff0c18 720 #if (HW_ADC_INSTANCE_COUNT > 2)
mbed_official 146:f64d43ff0c18 721 case 2:
mbed_official 146:f64d43ff0c18 722 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC2PRETRGSEL;
mbed_official 146:f64d43ff0c18 723 case 3:
mbed_official 146:f64d43ff0c18 724 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC3PRETRGSEL;
mbed_official 146:f64d43ff0c18 725 #endif
mbed_official 146:f64d43ff0c18 726 #endif
mbed_official 146:f64d43ff0c18 727 default:
mbed_official 146:f64d43ff0c18 728 return (sim_pretrgsel_t)false;
mbed_official 146:f64d43ff0c18 729 }
mbed_official 146:f64d43ff0c18 730 }
mbed_official 146:f64d43ff0c18 731
mbed_official 146:f64d43ff0c18 732 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 733 *
mbed_official 146:f64d43ff0c18 734 * Function Name : sim_set_trgsel
mbed_official 146:f64d43ff0c18 735 * Description : Set ADCx trigger select setting
mbed_official 146:f64d43ff0c18 736 * This function will select the ADCx trigger source when alternative triggers
mbed_official 146:f64d43ff0c18 737 * are enabled through ADCxALTTRGEN
mbed_official 146:f64d43ff0c18 738 *
mbed_official 146:f64d43ff0c18 739 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 740 void sim_set_trgsel(uint8_t instance, sim_trgsel_t select)
mbed_official 146:f64d43ff0c18 741 {
mbed_official 146:f64d43ff0c18 742 assert(instance < HW_ADC_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 743
mbed_official 146:f64d43ff0c18 744 switch (instance)
mbed_official 146:f64d43ff0c18 745 {
mbed_official 146:f64d43ff0c18 746 case 0:
mbed_official 146:f64d43ff0c18 747 BW_SIM_SOPT7_ADC0TRGSEL(select);
mbed_official 146:f64d43ff0c18 748 break;
mbed_official 146:f64d43ff0c18 749 #if (HW_ADC_INSTANCE_COUNT > 1)
mbed_official 146:f64d43ff0c18 750 case 1:
mbed_official 146:f64d43ff0c18 751 BW_SIM_SOPT7_ADC1TRGSEL(select);
mbed_official 146:f64d43ff0c18 752 break;
mbed_official 146:f64d43ff0c18 753 #if (HW_ADC_INSTANCE_COUNT > 2)
mbed_official 146:f64d43ff0c18 754 case 2:
mbed_official 146:f64d43ff0c18 755 BW_SIM_SOPT7_ADC2TRGSEL(select);
mbed_official 146:f64d43ff0c18 756 break;
mbed_official 146:f64d43ff0c18 757 case 3:
mbed_official 146:f64d43ff0c18 758 BW_SIM_SOPT7_ADC3TRGSEL(select);
mbed_official 146:f64d43ff0c18 759 break;
mbed_official 146:f64d43ff0c18 760 #endif
mbed_official 146:f64d43ff0c18 761 #endif
mbed_official 146:f64d43ff0c18 762 default:
mbed_official 146:f64d43ff0c18 763 break;
mbed_official 146:f64d43ff0c18 764 }
mbed_official 146:f64d43ff0c18 765 }
mbed_official 146:f64d43ff0c18 766
mbed_official 146:f64d43ff0c18 767 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 768 *
mbed_official 146:f64d43ff0c18 769 * Function Name : sim_get_trgsel
mbed_official 146:f64d43ff0c18 770 * Description : Get ADCx trigger select setting
mbed_official 146:f64d43ff0c18 771 * This function will get ADCx trigger select setting.
mbed_official 146:f64d43ff0c18 772 *
mbed_official 146:f64d43ff0c18 773 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 774 sim_pretrgsel_t sim_get_trgsel(uint8_t instance)
mbed_official 146:f64d43ff0c18 775 {
mbed_official 146:f64d43ff0c18 776 assert(instance < HW_ADC_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 777
mbed_official 146:f64d43ff0c18 778 switch (instance)
mbed_official 146:f64d43ff0c18 779 {
mbed_official 146:f64d43ff0c18 780 case 0:
mbed_official 146:f64d43ff0c18 781 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC0TRGSEL;
mbed_official 146:f64d43ff0c18 782 #if (HW_ADC_INSTANCE_COUNT > 1)
mbed_official 146:f64d43ff0c18 783 case 1:
mbed_official 146:f64d43ff0c18 784 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC1TRGSEL;
mbed_official 146:f64d43ff0c18 785 #if (HW_ADC_INSTANCE_COUNT > 2)
mbed_official 146:f64d43ff0c18 786 case 2:
mbed_official 146:f64d43ff0c18 787 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC2TRGSEL;
mbed_official 146:f64d43ff0c18 788 case 3:
mbed_official 146:f64d43ff0c18 789 return (sim_pretrgsel_t)BR_SIM_SOPT7_ADC3TRGSEL;
mbed_official 146:f64d43ff0c18 790 #endif
mbed_official 146:f64d43ff0c18 791 #endif
mbed_official 146:f64d43ff0c18 792 default:
mbed_official 146:f64d43ff0c18 793 return (sim_pretrgsel_t)false;
mbed_official 146:f64d43ff0c18 794 }
mbed_official 146:f64d43ff0c18 795 }
mbed_official 146:f64d43ff0c18 796
mbed_official 146:f64d43ff0c18 797 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 798 *
mbed_official 146:f64d43ff0c18 799 * Function Name : sim_set_uart_rxsrc
mbed_official 146:f64d43ff0c18 800 * Description : Set UARTx receive data source select setting
mbed_official 146:f64d43ff0c18 801 * This function will select the source for the UART1 receive data.
mbed_official 146:f64d43ff0c18 802 *
mbed_official 146:f64d43ff0c18 803 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 804 void sim_set_uart_rxsrc(uint8_t instance, sim_uart_rxsrc_t select)
mbed_official 146:f64d43ff0c18 805 {
mbed_official 146:f64d43ff0c18 806 assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT);
mbed_official 146:f64d43ff0c18 807
mbed_official 146:f64d43ff0c18 808 switch (instance)
mbed_official 146:f64d43ff0c18 809 {
mbed_official 146:f64d43ff0c18 810 case 0:
mbed_official 146:f64d43ff0c18 811 BW_SIM_SOPT5_UART0RXSRC(select);
mbed_official 146:f64d43ff0c18 812 break;
mbed_official 146:f64d43ff0c18 813 case 1:
mbed_official 146:f64d43ff0c18 814 BW_SIM_SOPT5_UART1RXSRC(select);
mbed_official 146:f64d43ff0c18 815 break;
mbed_official 146:f64d43ff0c18 816 default:
mbed_official 146:f64d43ff0c18 817 break;
mbed_official 146:f64d43ff0c18 818 }
mbed_official 146:f64d43ff0c18 819 }
mbed_official 146:f64d43ff0c18 820
mbed_official 146:f64d43ff0c18 821 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 822 *
mbed_official 146:f64d43ff0c18 823 * Function Name : sim_get_pretrgsel
mbed_official 146:f64d43ff0c18 824 * Description : Get UARTx receive data source select setting
mbed_official 146:f64d43ff0c18 825 * This function will get UARTx receive data source select setting.
mbed_official 146:f64d43ff0c18 826 *
mbed_official 146:f64d43ff0c18 827 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 828 sim_uart_rxsrc_t sim_get_uart_rxsrc(uint8_t instance)
mbed_official 146:f64d43ff0c18 829 {
mbed_official 146:f64d43ff0c18 830 assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT);
mbed_official 146:f64d43ff0c18 831
mbed_official 146:f64d43ff0c18 832 switch (instance)
mbed_official 146:f64d43ff0c18 833 {
mbed_official 146:f64d43ff0c18 834 case 0:
mbed_official 146:f64d43ff0c18 835 return (sim_uart_rxsrc_t)BR_SIM_SOPT5_UART0RXSRC;
mbed_official 146:f64d43ff0c18 836 case 1:
mbed_official 146:f64d43ff0c18 837 return (sim_uart_rxsrc_t)BR_SIM_SOPT5_UART1RXSRC;
mbed_official 146:f64d43ff0c18 838 default:
mbed_official 146:f64d43ff0c18 839 return (sim_uart_rxsrc_t)0;
mbed_official 146:f64d43ff0c18 840 }
mbed_official 146:f64d43ff0c18 841 }
mbed_official 146:f64d43ff0c18 842
mbed_official 146:f64d43ff0c18 843 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 844 *
mbed_official 146:f64d43ff0c18 845 * Function Name : sim_set_uart_txsrc
mbed_official 146:f64d43ff0c18 846 * Description : Set UARTx transmit data source select setting
mbed_official 146:f64d43ff0c18 847 * This function will select the source for the UARTx transmit data.
mbed_official 146:f64d43ff0c18 848 *
mbed_official 146:f64d43ff0c18 849 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 850 void sim_set_uart_txsrc(uint8_t instance, sim_uart_txsrc_t select)
mbed_official 146:f64d43ff0c18 851 {
mbed_official 146:f64d43ff0c18 852 assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT);
mbed_official 146:f64d43ff0c18 853
mbed_official 146:f64d43ff0c18 854 switch (instance)
mbed_official 146:f64d43ff0c18 855 {
mbed_official 146:f64d43ff0c18 856 case 0:
mbed_official 146:f64d43ff0c18 857 BW_SIM_SOPT5_UART0TXSRC(select);
mbed_official 146:f64d43ff0c18 858 break;
mbed_official 146:f64d43ff0c18 859 case 1:
mbed_official 146:f64d43ff0c18 860 BW_SIM_SOPT5_UART1TXSRC(select);
mbed_official 146:f64d43ff0c18 861 break;
mbed_official 146:f64d43ff0c18 862 default:
mbed_official 146:f64d43ff0c18 863 break;
mbed_official 146:f64d43ff0c18 864 }
mbed_official 146:f64d43ff0c18 865 }
mbed_official 146:f64d43ff0c18 866
mbed_official 146:f64d43ff0c18 867 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 868 *
mbed_official 146:f64d43ff0c18 869 * Function Name : sim_get_uart_txsrc
mbed_official 146:f64d43ff0c18 870 * Description : Get UARTx transmit data source select setting
mbed_official 146:f64d43ff0c18 871 * This function will get UARTx transmit data source select setting.
mbed_official 146:f64d43ff0c18 872 *
mbed_official 146:f64d43ff0c18 873 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 874 sim_uart_txsrc_t sim_get_uart_txsrc(uint8_t instance)
mbed_official 146:f64d43ff0c18 875 {
mbed_official 146:f64d43ff0c18 876 assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT);
mbed_official 146:f64d43ff0c18 877
mbed_official 146:f64d43ff0c18 878 switch (instance)
mbed_official 146:f64d43ff0c18 879 {
mbed_official 146:f64d43ff0c18 880 case 0:
mbed_official 146:f64d43ff0c18 881 return (sim_uart_txsrc_t)BR_SIM_SOPT5_UART0TXSRC;
mbed_official 146:f64d43ff0c18 882 case 1:
mbed_official 146:f64d43ff0c18 883 return (sim_uart_txsrc_t)BR_SIM_SOPT5_UART1TXSRC;
mbed_official 146:f64d43ff0c18 884 default:
mbed_official 146:f64d43ff0c18 885 return (sim_uart_txsrc_t)0;
mbed_official 146:f64d43ff0c18 886 }
mbed_official 146:f64d43ff0c18 887 }
mbed_official 146:f64d43ff0c18 888
mbed_official 146:f64d43ff0c18 889 #if FSL_FEATURE_SIM_OPT_HAS_ODE
mbed_official 146:f64d43ff0c18 890 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 891 *
mbed_official 146:f64d43ff0c18 892 * Function Name : sim_set_uart_ode
mbed_official 146:f64d43ff0c18 893 * Description : Set UARTx Open Drain Enable setting
mbed_official 146:f64d43ff0c18 894 * This function will enable/disable the UARTx Open Drain.
mbed_official 146:f64d43ff0c18 895 *
mbed_official 146:f64d43ff0c18 896 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 897 void sim_set_uart_ode(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 898 {
mbed_official 146:f64d43ff0c18 899 assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT);
mbed_official 146:f64d43ff0c18 900
mbed_official 146:f64d43ff0c18 901 switch (instance)
mbed_official 146:f64d43ff0c18 902 {
mbed_official 146:f64d43ff0c18 903 case 0:
mbed_official 146:f64d43ff0c18 904 BW_SIM_SOPT5_UART0ODE(enable ? 1 : 0);
mbed_official 146:f64d43ff0c18 905 break;
mbed_official 146:f64d43ff0c18 906 case 1:
mbed_official 146:f64d43ff0c18 907 BW_SIM_SOPT5_UART1ODE(enable ? 1 : 0);
mbed_official 146:f64d43ff0c18 908 break;
mbed_official 146:f64d43ff0c18 909 case 2:
mbed_official 146:f64d43ff0c18 910 BW_SIM_SOPT5_UART2ODE(enable ? 1 : 0);
mbed_official 146:f64d43ff0c18 911 break;
mbed_official 146:f64d43ff0c18 912 default:
mbed_official 146:f64d43ff0c18 913 break;
mbed_official 146:f64d43ff0c18 914 }
mbed_official 146:f64d43ff0c18 915 }
mbed_official 146:f64d43ff0c18 916
mbed_official 146:f64d43ff0c18 917 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 918 *
mbed_official 146:f64d43ff0c18 919 * Function Name : sim_get_uart_ode
mbed_official 146:f64d43ff0c18 920 * Description : Get UARTx Open Drain Enable setting
mbed_official 146:f64d43ff0c18 921 * This function will get UARTx Open Drain Enable setting.
mbed_official 146:f64d43ff0c18 922 *
mbed_official 146:f64d43ff0c18 923 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 924 bool sim_get_uart_ode(uint8_t instance)
mbed_official 146:f64d43ff0c18 925 {
mbed_official 146:f64d43ff0c18 926 assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT);
mbed_official 146:f64d43ff0c18 927
mbed_official 146:f64d43ff0c18 928 switch (instance)
mbed_official 146:f64d43ff0c18 929 {
mbed_official 146:f64d43ff0c18 930 case 0:
mbed_official 146:f64d43ff0c18 931 return BR_SIM_SOPT5_UART0ODE;
mbed_official 146:f64d43ff0c18 932 case 1:
mbed_official 146:f64d43ff0c18 933 return BR_SIM_SOPT5_UART1ODE;
mbed_official 146:f64d43ff0c18 934 case 2:
mbed_official 146:f64d43ff0c18 935 return BR_SIM_SOPT5_UART2ODE;
mbed_official 146:f64d43ff0c18 936 default:
mbed_official 146:f64d43ff0c18 937 return (sim_uart_txsrc_t)0;
mbed_official 146:f64d43ff0c18 938 }
mbed_official 146:f64d43ff0c18 939 }
mbed_official 146:f64d43ff0c18 940 #endif
mbed_official 146:f64d43ff0c18 941
mbed_official 146:f64d43ff0c18 942 #if FSL_FEATURE_SIM_OPT_HAS_FTM
mbed_official 146:f64d43ff0c18 943 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 944 *
mbed_official 146:f64d43ff0c18 945 * Function Name : sim_set_ftm_trg_src
mbed_official 146:f64d43ff0c18 946 * Description : Set FlexTimer x hardware trigger y source select setting
mbed_official 146:f64d43ff0c18 947 * This function will select the source of FTMx hardware trigger y.
mbed_official 146:f64d43ff0c18 948 *
mbed_official 146:f64d43ff0c18 949 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 950 void sim_set_ftm_trg_src(uint8_t instance, uint8_t trigger, sim_ftm_trg_src_t select)
mbed_official 146:f64d43ff0c18 951 {
mbed_official 146:f64d43ff0c18 952 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 953 assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT);
mbed_official 146:f64d43ff0c18 954
mbed_official 146:f64d43ff0c18 955 switch (instance)
mbed_official 146:f64d43ff0c18 956 {
mbed_official 146:f64d43ff0c18 957 #if FSL_FEATURE_SIM_OPT_HAS_FTM0_TRIGGER
mbed_official 146:f64d43ff0c18 958 case 0:
mbed_official 146:f64d43ff0c18 959 switch (trigger)
mbed_official 146:f64d43ff0c18 960 {
mbed_official 146:f64d43ff0c18 961 case 0:
mbed_official 146:f64d43ff0c18 962 BW_SIM_SOPT4_FTM0TRG0SRC(select);
mbed_official 146:f64d43ff0c18 963 break;
mbed_official 146:f64d43ff0c18 964 case 1:
mbed_official 146:f64d43ff0c18 965 BW_SIM_SOPT4_FTM0TRG1SRC(select);
mbed_official 146:f64d43ff0c18 966 break;
mbed_official 146:f64d43ff0c18 967 default:
mbed_official 146:f64d43ff0c18 968 break;
mbed_official 146:f64d43ff0c18 969 }
mbed_official 146:f64d43ff0c18 970 break;
mbed_official 146:f64d43ff0c18 971 #endif
mbed_official 146:f64d43ff0c18 972 #if FSL_FEATURE_SIM_OPT_HAS_FTM3_TRIGGER
mbed_official 146:f64d43ff0c18 973 case 3:
mbed_official 146:f64d43ff0c18 974 switch (trigger)
mbed_official 146:f64d43ff0c18 975 {
mbed_official 146:f64d43ff0c18 976 case 0:
mbed_official 146:f64d43ff0c18 977 BW_SIM_SOPT4_FTM3TRG0SRC(select);
mbed_official 146:f64d43ff0c18 978 break;
mbed_official 146:f64d43ff0c18 979 case 1:
mbed_official 146:f64d43ff0c18 980 BW_SIM_SOPT4_FTM3TRG1SRC(select);
mbed_official 146:f64d43ff0c18 981 break;
mbed_official 146:f64d43ff0c18 982 default:
mbed_official 146:f64d43ff0c18 983 break;
mbed_official 146:f64d43ff0c18 984 }
mbed_official 146:f64d43ff0c18 985 break;
mbed_official 146:f64d43ff0c18 986 #endif
mbed_official 146:f64d43ff0c18 987 default:
mbed_official 146:f64d43ff0c18 988 break;
mbed_official 146:f64d43ff0c18 989 }
mbed_official 146:f64d43ff0c18 990 }
mbed_official 146:f64d43ff0c18 991
mbed_official 146:f64d43ff0c18 992 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 993 *
mbed_official 146:f64d43ff0c18 994 * Function Name : sim_get_ftm_trg_src
mbed_official 146:f64d43ff0c18 995 * Description : Get FlexTimer x hardware trigger y source select setting
mbed_official 146:f64d43ff0c18 996 * This function will get FlexTimer x hardware trigger y source select setting.
mbed_official 146:f64d43ff0c18 997 *
mbed_official 146:f64d43ff0c18 998 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 999 sim_ftm_trg_src_t sim_get_ftm_trg_src(uint8_t instance, uint8_t trigger)
mbed_official 146:f64d43ff0c18 1000 {
mbed_official 146:f64d43ff0c18 1001 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1002 assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT);
mbed_official 146:f64d43ff0c18 1003
mbed_official 146:f64d43ff0c18 1004 switch (instance)
mbed_official 146:f64d43ff0c18 1005 {
mbed_official 146:f64d43ff0c18 1006 #if FSL_FEATURE_SIM_OPT_HAS_FTM0_TRIGGER
mbed_official 146:f64d43ff0c18 1007 case 0:
mbed_official 146:f64d43ff0c18 1008 switch (trigger)
mbed_official 146:f64d43ff0c18 1009 {
mbed_official 146:f64d43ff0c18 1010 case 0:
mbed_official 146:f64d43ff0c18 1011 return (sim_ftm_trg_src_t)BR_SIM_SOPT4_FTM0TRG0SRC;
mbed_official 146:f64d43ff0c18 1012 case 1:
mbed_official 146:f64d43ff0c18 1013 return (sim_ftm_trg_src_t)BR_SIM_SOPT4_FTM0TRG1SRC;
mbed_official 146:f64d43ff0c18 1014 default:
mbed_official 146:f64d43ff0c18 1015 break;
mbed_official 146:f64d43ff0c18 1016 }
mbed_official 146:f64d43ff0c18 1017 break;
mbed_official 146:f64d43ff0c18 1018 #endif
mbed_official 146:f64d43ff0c18 1019 #if FSL_FEATURE_SIM_OPT_HAS_FTM3_TRIGGER
mbed_official 146:f64d43ff0c18 1020 case 3:
mbed_official 146:f64d43ff0c18 1021 switch (trigger)
mbed_official 146:f64d43ff0c18 1022 {
mbed_official 146:f64d43ff0c18 1023 case 0:
mbed_official 146:f64d43ff0c18 1024 return (sim_ftm_trg_src_t)BR_SIM_SOPT4_FTM3TRG0SRC;
mbed_official 146:f64d43ff0c18 1025 case 1:
mbed_official 146:f64d43ff0c18 1026 return (sim_ftm_trg_src_t)BR_SIM_SOPT4_FTM3TRG1SRC;
mbed_official 146:f64d43ff0c18 1027 default:
mbed_official 146:f64d43ff0c18 1028 break;
mbed_official 146:f64d43ff0c18 1029 }
mbed_official 146:f64d43ff0c18 1030 break;
mbed_official 146:f64d43ff0c18 1031 #endif
mbed_official 146:f64d43ff0c18 1032 default:
mbed_official 146:f64d43ff0c18 1033 break;
mbed_official 146:f64d43ff0c18 1034 }
mbed_official 146:f64d43ff0c18 1035
mbed_official 146:f64d43ff0c18 1036 return (sim_ftm_trg_src_t)0;
mbed_official 146:f64d43ff0c18 1037 }
mbed_official 146:f64d43ff0c18 1038
mbed_official 146:f64d43ff0c18 1039 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1040 *
mbed_official 146:f64d43ff0c18 1041 * Function Name : sim_set_ftm_clk_sel
mbed_official 146:f64d43ff0c18 1042 * Description : Set FlexTimer x external clock pin select setting
mbed_official 146:f64d43ff0c18 1043 * This function will select the source of FTMx external clock pin select
mbed_official 146:f64d43ff0c18 1044 *
mbed_official 146:f64d43ff0c18 1045 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1046 void sim_set_ftm_clk_sel(uint8_t instance, sim_ftm_clk_sel_t select)
mbed_official 146:f64d43ff0c18 1047 {
mbed_official 146:f64d43ff0c18 1048 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1049
mbed_official 146:f64d43ff0c18 1050 switch (instance)
mbed_official 146:f64d43ff0c18 1051 {
mbed_official 146:f64d43ff0c18 1052 case 0:
mbed_official 146:f64d43ff0c18 1053 BW_SIM_SOPT4_FTM0CLKSEL(select);
mbed_official 146:f64d43ff0c18 1054 break;
mbed_official 146:f64d43ff0c18 1055 case 1:
mbed_official 146:f64d43ff0c18 1056 BW_SIM_SOPT4_FTM1CLKSEL(select);
mbed_official 146:f64d43ff0c18 1057 break;
mbed_official 146:f64d43ff0c18 1058 case 2:
mbed_official 146:f64d43ff0c18 1059 BW_SIM_SOPT4_FTM2CLKSEL(select);
mbed_official 146:f64d43ff0c18 1060 break;
mbed_official 146:f64d43ff0c18 1061 case 3:
mbed_official 146:f64d43ff0c18 1062 BW_SIM_SOPT4_FTM3CLKSEL(select);
mbed_official 146:f64d43ff0c18 1063 break;
mbed_official 146:f64d43ff0c18 1064 default:
mbed_official 146:f64d43ff0c18 1065 break;
mbed_official 146:f64d43ff0c18 1066 }
mbed_official 146:f64d43ff0c18 1067 }
mbed_official 146:f64d43ff0c18 1068
mbed_official 146:f64d43ff0c18 1069 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1070 *
mbed_official 146:f64d43ff0c18 1071 * Function Name : sim_get_ftm_clk_sel
mbed_official 146:f64d43ff0c18 1072 * Description : Get FlexTimer x external clock pin select setting
mbed_official 146:f64d43ff0c18 1073 * This function will get FlexTimer x external clock pin select setting.
mbed_official 146:f64d43ff0c18 1074 *
mbed_official 146:f64d43ff0c18 1075 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1076 sim_ftm_clk_sel_t sim_get_ftm_clk_sel(uint8_t instance)
mbed_official 146:f64d43ff0c18 1077 {
mbed_official 146:f64d43ff0c18 1078 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1079
mbed_official 146:f64d43ff0c18 1080 switch (instance)
mbed_official 146:f64d43ff0c18 1081 {
mbed_official 146:f64d43ff0c18 1082 case 0:
mbed_official 146:f64d43ff0c18 1083 return (sim_ftm_clk_sel_t)BR_SIM_SOPT4_FTM0CLKSEL;
mbed_official 146:f64d43ff0c18 1084 case 1:
mbed_official 146:f64d43ff0c18 1085 return (sim_ftm_clk_sel_t)BR_SIM_SOPT4_FTM1CLKSEL;
mbed_official 146:f64d43ff0c18 1086 case 2:
mbed_official 146:f64d43ff0c18 1087 return (sim_ftm_clk_sel_t)BR_SIM_SOPT4_FTM2CLKSEL;
mbed_official 146:f64d43ff0c18 1088 case 3:
mbed_official 146:f64d43ff0c18 1089 return (sim_ftm_clk_sel_t)BR_SIM_SOPT4_FTM3CLKSEL;
mbed_official 146:f64d43ff0c18 1090 default:
mbed_official 146:f64d43ff0c18 1091 break;
mbed_official 146:f64d43ff0c18 1092 }
mbed_official 146:f64d43ff0c18 1093
mbed_official 146:f64d43ff0c18 1094 return (sim_ftm_clk_sel_t)0;
mbed_official 146:f64d43ff0c18 1095 }
mbed_official 146:f64d43ff0c18 1096
mbed_official 146:f64d43ff0c18 1097 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1098 *
mbed_official 146:f64d43ff0c18 1099 * Function Name : sim_set_ftm_ch_src
mbed_official 146:f64d43ff0c18 1100 * Description : FlexTimer x channel y input capture source select setting
mbed_official 146:f64d43ff0c18 1101 * This function will select FlexTimer x channel y input capture source
mbed_official 146:f64d43ff0c18 1102 *
mbed_official 146:f64d43ff0c18 1103 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1104 void sim_set_ftm_ch_src(uint8_t instance, uint8_t channel, sim_ftm_ch_src_t select)
mbed_official 146:f64d43ff0c18 1105 {
mbed_official 146:f64d43ff0c18 1106 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1107
mbed_official 146:f64d43ff0c18 1108 switch (instance)
mbed_official 146:f64d43ff0c18 1109 {
mbed_official 146:f64d43ff0c18 1110 #if FSL_FEATURE_SIM_OPT_HAS_FTM1_CHANNELS
mbed_official 146:f64d43ff0c18 1111 case 1:
mbed_official 146:f64d43ff0c18 1112 switch (channel)
mbed_official 146:f64d43ff0c18 1113 {
mbed_official 146:f64d43ff0c18 1114 case 0:
mbed_official 146:f64d43ff0c18 1115 BW_SIM_SOPT4_FTM1CH0SRC(select);
mbed_official 146:f64d43ff0c18 1116 break;
mbed_official 146:f64d43ff0c18 1117 default:
mbed_official 146:f64d43ff0c18 1118 break;
mbed_official 146:f64d43ff0c18 1119 }
mbed_official 146:f64d43ff0c18 1120 break;
mbed_official 146:f64d43ff0c18 1121 #endif
mbed_official 146:f64d43ff0c18 1122 #if FSL_FEATURE_SIM_OPT_HAS_FTM2_CHANNELS
mbed_official 146:f64d43ff0c18 1123 case 2:
mbed_official 146:f64d43ff0c18 1124 switch (channel)
mbed_official 146:f64d43ff0c18 1125 {
mbed_official 146:f64d43ff0c18 1126 case 0:
mbed_official 146:f64d43ff0c18 1127 BW_SIM_SOPT4_FTM2CH0SRC(select);
mbed_official 146:f64d43ff0c18 1128 break;
mbed_official 146:f64d43ff0c18 1129 #if FSL_FEATURE_SIM_OPT_HAS_FTM2_CHANNEL1
mbed_official 146:f64d43ff0c18 1130 case 1:
mbed_official 146:f64d43ff0c18 1131 BW_SIM_SOPT4_FTM2CH1SRC(select);
mbed_official 146:f64d43ff0c18 1132 break;
mbed_official 146:f64d43ff0c18 1133 #endif
mbed_official 146:f64d43ff0c18 1134 default:
mbed_official 146:f64d43ff0c18 1135 break;
mbed_official 146:f64d43ff0c18 1136 }
mbed_official 146:f64d43ff0c18 1137 break;
mbed_official 146:f64d43ff0c18 1138 #endif
mbed_official 146:f64d43ff0c18 1139 #if FSL_FEATURE_SIM_OPT_HAS_FTM3_CHANNELS
mbed_official 146:f64d43ff0c18 1140 case 3:
mbed_official 146:f64d43ff0c18 1141 switch (channel)
mbed_official 146:f64d43ff0c18 1142 {
mbed_official 146:f64d43ff0c18 1143 case 0:
mbed_official 146:f64d43ff0c18 1144 BW_SIM_SOPT4_FTM3CH0SRC(select);
mbed_official 146:f64d43ff0c18 1145 break;
mbed_official 146:f64d43ff0c18 1146 default:
mbed_official 146:f64d43ff0c18 1147 break;
mbed_official 146:f64d43ff0c18 1148 }
mbed_official 146:f64d43ff0c18 1149 break;
mbed_official 146:f64d43ff0c18 1150 #endif
mbed_official 146:f64d43ff0c18 1151 default:
mbed_official 146:f64d43ff0c18 1152 break;
mbed_official 146:f64d43ff0c18 1153 }
mbed_official 146:f64d43ff0c18 1154 }
mbed_official 146:f64d43ff0c18 1155
mbed_official 146:f64d43ff0c18 1156 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1157 *
mbed_official 146:f64d43ff0c18 1158 * Function Name : sim_get_ftm_ch_src
mbed_official 146:f64d43ff0c18 1159 * Description : Get FlexTimer x channel y input capture source select setting
mbed_official 146:f64d43ff0c18 1160 * This function will get FlexTimer x channel y input capture source select
mbed_official 146:f64d43ff0c18 1161 * setting.
mbed_official 146:f64d43ff0c18 1162 *
mbed_official 146:f64d43ff0c18 1163 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1164 sim_ftm_ch_src_t sim_get_ftm_ch_src(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 1165 {
mbed_official 146:f64d43ff0c18 1166 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1167
mbed_official 146:f64d43ff0c18 1168 switch (instance)
mbed_official 146:f64d43ff0c18 1169 {
mbed_official 146:f64d43ff0c18 1170 #if FSL_FEATURE_SIM_OPT_HAS_FTM1_CHANNELS
mbed_official 146:f64d43ff0c18 1171 case 1:
mbed_official 146:f64d43ff0c18 1172 switch (channel)
mbed_official 146:f64d43ff0c18 1173 {
mbed_official 146:f64d43ff0c18 1174 case 0:
mbed_official 146:f64d43ff0c18 1175 return (sim_ftm_ch_src_t)BR_SIM_SOPT4_FTM1CH0SRC;
mbed_official 146:f64d43ff0c18 1176 default:
mbed_official 146:f64d43ff0c18 1177 break;
mbed_official 146:f64d43ff0c18 1178 }
mbed_official 146:f64d43ff0c18 1179 break;
mbed_official 146:f64d43ff0c18 1180 #endif
mbed_official 146:f64d43ff0c18 1181 #if FSL_FEATURE_SIM_OPT_HAS_FTM2_CHANNELS
mbed_official 146:f64d43ff0c18 1182 case 2:
mbed_official 146:f64d43ff0c18 1183 switch (channel)
mbed_official 146:f64d43ff0c18 1184 {
mbed_official 146:f64d43ff0c18 1185 case 0:
mbed_official 146:f64d43ff0c18 1186 return (sim_ftm_ch_src_t)BR_SIM_SOPT4_FTM2CH0SRC;
mbed_official 146:f64d43ff0c18 1187 #if FSL_FEATURE_SIM_OPT_HAS_FTM2_CHANNEL1
mbed_official 146:f64d43ff0c18 1188 case 1:
mbed_official 146:f64d43ff0c18 1189 return (sim_ftm_ch_src_t)BR_SIM_SOPT4_FTM2CH1SRC;
mbed_official 146:f64d43ff0c18 1190 #endif
mbed_official 146:f64d43ff0c18 1191 default:
mbed_official 146:f64d43ff0c18 1192 break;
mbed_official 146:f64d43ff0c18 1193 }
mbed_official 146:f64d43ff0c18 1194 break;
mbed_official 146:f64d43ff0c18 1195 #endif
mbed_official 146:f64d43ff0c18 1196 #if FSL_FEATURE_SIM_OPT_HAS_FTM3_CHANNELS
mbed_official 146:f64d43ff0c18 1197 case 3:
mbed_official 146:f64d43ff0c18 1198 switch (channel)
mbed_official 146:f64d43ff0c18 1199 {
mbed_official 146:f64d43ff0c18 1200 case 0:
mbed_official 146:f64d43ff0c18 1201 return (sim_ftm_ch_src_t)BR_SIM_SOPT4_FTM3CH0SRC;
mbed_official 146:f64d43ff0c18 1202 default:
mbed_official 146:f64d43ff0c18 1203 break;
mbed_official 146:f64d43ff0c18 1204 }
mbed_official 146:f64d43ff0c18 1205 break;
mbed_official 146:f64d43ff0c18 1206 #endif
mbed_official 146:f64d43ff0c18 1207 default:
mbed_official 146:f64d43ff0c18 1208 break;
mbed_official 146:f64d43ff0c18 1209 }
mbed_official 146:f64d43ff0c18 1210
mbed_official 146:f64d43ff0c18 1211 return (sim_ftm_ch_src_t)0;
mbed_official 146:f64d43ff0c18 1212 }
mbed_official 146:f64d43ff0c18 1213
mbed_official 146:f64d43ff0c18 1214 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1215 *
mbed_official 146:f64d43ff0c18 1216 * Function Name : sim_set_ftm_flt_sel
mbed_official 146:f64d43ff0c18 1217 * Description : Set FlexTimer x fault y select setting
mbed_official 146:f64d43ff0c18 1218 * This function will set the FlexTimer x fault y select setting.
mbed_official 146:f64d43ff0c18 1219 *
mbed_official 146:f64d43ff0c18 1220 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1221 void sim_set_ftm_flt_sel(uint8_t instance, uint8_t fault, sim_ftm_flt_sel_t select)
mbed_official 146:f64d43ff0c18 1222 {
mbed_official 146:f64d43ff0c18 1223 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1224
mbed_official 146:f64d43ff0c18 1225 switch (instance)
mbed_official 146:f64d43ff0c18 1226 {
mbed_official 146:f64d43ff0c18 1227 case 0:
mbed_official 146:f64d43ff0c18 1228 switch (fault)
mbed_official 146:f64d43ff0c18 1229 {
mbed_official 146:f64d43ff0c18 1230 case 0:
mbed_official 146:f64d43ff0c18 1231 BW_SIM_SOPT4_FTM0FLT0(select);
mbed_official 146:f64d43ff0c18 1232 break;
mbed_official 146:f64d43ff0c18 1233 case 1:
mbed_official 146:f64d43ff0c18 1234 BW_SIM_SOPT4_FTM0FLT1(select);
mbed_official 146:f64d43ff0c18 1235 break;
mbed_official 146:f64d43ff0c18 1236 #if (FSL_FEATURE_SIM_OPT_FTM0_FAULT_COUNT > 2)
mbed_official 146:f64d43ff0c18 1237 case 2:
mbed_official 146:f64d43ff0c18 1238 BW_SIM_SOPT4_FTM0FLT2(select);
mbed_official 146:f64d43ff0c18 1239 break;
mbed_official 146:f64d43ff0c18 1240 #if (FSL_FEATURE_SIM_OPT_FTM0_FAULT_COUNT > 3)
mbed_official 146:f64d43ff0c18 1241 case 3:
mbed_official 146:f64d43ff0c18 1242 BW_SIM_SOPT4_FTM0FLT3(select);
mbed_official 146:f64d43ff0c18 1243 break;
mbed_official 146:f64d43ff0c18 1244 #endif
mbed_official 146:f64d43ff0c18 1245 #endif
mbed_official 146:f64d43ff0c18 1246 default:
mbed_official 146:f64d43ff0c18 1247 break;
mbed_official 146:f64d43ff0c18 1248 }
mbed_official 146:f64d43ff0c18 1249 break;
mbed_official 146:f64d43ff0c18 1250 case 1:
mbed_official 146:f64d43ff0c18 1251 BW_SIM_SOPT4_FTM1FLT0(select);
mbed_official 146:f64d43ff0c18 1252 break;
mbed_official 146:f64d43ff0c18 1253 case 2:
mbed_official 146:f64d43ff0c18 1254 BW_SIM_SOPT4_FTM2FLT0(select);
mbed_official 146:f64d43ff0c18 1255 break;
mbed_official 146:f64d43ff0c18 1256 case 3:
mbed_official 146:f64d43ff0c18 1257 BW_SIM_SOPT4_FTM3FLT0(select);
mbed_official 146:f64d43ff0c18 1258 break;
mbed_official 146:f64d43ff0c18 1259 default:
mbed_official 146:f64d43ff0c18 1260 break;
mbed_official 146:f64d43ff0c18 1261 }
mbed_official 146:f64d43ff0c18 1262 }
mbed_official 146:f64d43ff0c18 1263
mbed_official 146:f64d43ff0c18 1264 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1265 *
mbed_official 146:f64d43ff0c18 1266 * Function Name : sim_get_ftm_flt_sel
mbed_official 146:f64d43ff0c18 1267 * Description : Get FlexTimer x fault y select setting
mbed_official 146:f64d43ff0c18 1268 * This function will get FlexTimer x fault y select setting.
mbed_official 146:f64d43ff0c18 1269 *
mbed_official 146:f64d43ff0c18 1270 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1271 sim_ftm_flt_sel_t sim_get_ftm_flt_sel(uint8_t instance, uint8_t fault)
mbed_official 146:f64d43ff0c18 1272 {
mbed_official 146:f64d43ff0c18 1273 assert (instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1274
mbed_official 146:f64d43ff0c18 1275 switch (instance)
mbed_official 146:f64d43ff0c18 1276 {
mbed_official 146:f64d43ff0c18 1277 case 0:
mbed_official 146:f64d43ff0c18 1278 switch (fault)
mbed_official 146:f64d43ff0c18 1279 {
mbed_official 146:f64d43ff0c18 1280 case 0:
mbed_official 146:f64d43ff0c18 1281 return (sim_ftm_flt_sel_t)BR_SIM_SOPT4_FTM0FLT0;
mbed_official 146:f64d43ff0c18 1282 case 1:
mbed_official 146:f64d43ff0c18 1283 return (sim_ftm_flt_sel_t)BR_SIM_SOPT4_FTM0FLT1;
mbed_official 146:f64d43ff0c18 1284 #if (FSL_FEATURE_SIM_OPT_FTM0_FAULT_COUNT > 2)
mbed_official 146:f64d43ff0c18 1285 case 2:
mbed_official 146:f64d43ff0c18 1286 return (sim_ftm_flt_sel_t)BR_SIM_SOPT4_FTM0FLT2;
mbed_official 146:f64d43ff0c18 1287 #if (FSL_FEATURE_SIM_OPT_FTM0_FAULT_COUNT > 3)
mbed_official 146:f64d43ff0c18 1288 case 3:
mbed_official 146:f64d43ff0c18 1289 return (sim_ftm_flt_sel_t)BR_SIM_SOPT4_FTM0FLT3;
mbed_official 146:f64d43ff0c18 1290 #endif
mbed_official 146:f64d43ff0c18 1291 #endif
mbed_official 146:f64d43ff0c18 1292 default:
mbed_official 146:f64d43ff0c18 1293 break;
mbed_official 146:f64d43ff0c18 1294 }
mbed_official 146:f64d43ff0c18 1295 break;
mbed_official 146:f64d43ff0c18 1296 case 1:
mbed_official 146:f64d43ff0c18 1297 return (sim_ftm_flt_sel_t)BR_SIM_SOPT4_FTM1FLT0;
mbed_official 146:f64d43ff0c18 1298 case 2:
mbed_official 146:f64d43ff0c18 1299 return (sim_ftm_flt_sel_t)BR_SIM_SOPT4_FTM2FLT0;
mbed_official 146:f64d43ff0c18 1300 case 3:
mbed_official 146:f64d43ff0c18 1301 return (sim_ftm_flt_sel_t)BR_SIM_SOPT4_FTM3FLT0;
mbed_official 146:f64d43ff0c18 1302 default:
mbed_official 146:f64d43ff0c18 1303 break;
mbed_official 146:f64d43ff0c18 1304 }
mbed_official 146:f64d43ff0c18 1305
mbed_official 146:f64d43ff0c18 1306 return (sim_ftm_flt_sel_t)0;
mbed_official 146:f64d43ff0c18 1307 }
mbed_official 146:f64d43ff0c18 1308 #endif
mbed_official 146:f64d43ff0c18 1309
mbed_official 146:f64d43ff0c18 1310 #if FSL_FEATURE_SIM_OPT_HAS_TPM
mbed_official 146:f64d43ff0c18 1311 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1312 *
mbed_official 146:f64d43ff0c18 1313 * Function Name : sim_set_tpm_clk_sel
mbed_official 146:f64d43ff0c18 1314 * Description : Set Timer/PWM x external clock pin select setting
mbed_official 146:f64d43ff0c18 1315 * This function will select the source of Timer/PWM x external clock pin select
mbed_official 146:f64d43ff0c18 1316 *
mbed_official 146:f64d43ff0c18 1317 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1318 void sim_set_tpm_clk_sel(uint8_t instance, sim_tpm_clk_sel_t select)
mbed_official 146:f64d43ff0c18 1319 {
mbed_official 146:f64d43ff0c18 1320 assert (instance < HW_TPM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1321
mbed_official 146:f64d43ff0c18 1322 switch (instance)
mbed_official 146:f64d43ff0c18 1323 {
mbed_official 146:f64d43ff0c18 1324 case 0:
mbed_official 146:f64d43ff0c18 1325 BW_SIM_SOPT4_TPM0CLKSEL(select);
mbed_official 146:f64d43ff0c18 1326 break;
mbed_official 146:f64d43ff0c18 1327 case 1:
mbed_official 146:f64d43ff0c18 1328 BW_SIM_SOPT4_TPM1CLKSEL(select);
mbed_official 146:f64d43ff0c18 1329 break;
mbed_official 146:f64d43ff0c18 1330 case 2:
mbed_official 146:f64d43ff0c18 1331 BW_SIM_SOPT4_TPM2CLKSEL(select);
mbed_official 146:f64d43ff0c18 1332 break;
mbed_official 146:f64d43ff0c18 1333 default:
mbed_official 146:f64d43ff0c18 1334 break;
mbed_official 146:f64d43ff0c18 1335 }
mbed_official 146:f64d43ff0c18 1336 }
mbed_official 146:f64d43ff0c18 1337
mbed_official 146:f64d43ff0c18 1338 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1339 *
mbed_official 146:f64d43ff0c18 1340 * Function Name : sim_get_tpm_clk_sel
mbed_official 146:f64d43ff0c18 1341 * Description : Get Timer/PWM x external clock pin select setting
mbed_official 146:f64d43ff0c18 1342 * This function will get Timer/PWM x external clock pin select setting.
mbed_official 146:f64d43ff0c18 1343 *
mbed_official 146:f64d43ff0c18 1344 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1345 sim_tpm_clk_sel_t sim_get_tpm_clk_sel(uint8_t instance)
mbed_official 146:f64d43ff0c18 1346 {
mbed_official 146:f64d43ff0c18 1347 assert (instance < HW_TPM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1348
mbed_official 146:f64d43ff0c18 1349 switch (instance)
mbed_official 146:f64d43ff0c18 1350 {
mbed_official 146:f64d43ff0c18 1351 case 0:
mbed_official 146:f64d43ff0c18 1352 return (sim_tpm_clk_sel_t)BR_SIM_SOPT4_TPM0CLKSEL;
mbed_official 146:f64d43ff0c18 1353 case 1:
mbed_official 146:f64d43ff0c18 1354 return (sim_tpm_clk_sel_t)BR_SIM_SOPT4_TPM1CLKSEL;
mbed_official 146:f64d43ff0c18 1355 case 2:
mbed_official 146:f64d43ff0c18 1356 return (sim_tpm_clk_sel_t)BR_SIM_SOPT4_TPM2CLKSEL;
mbed_official 146:f64d43ff0c18 1357 default:
mbed_official 146:f64d43ff0c18 1358 break;
mbed_official 146:f64d43ff0c18 1359 }
mbed_official 146:f64d43ff0c18 1360
mbed_official 146:f64d43ff0c18 1361 return (sim_tpm_clk_sel_t)0;
mbed_official 146:f64d43ff0c18 1362 }
mbed_official 146:f64d43ff0c18 1363
mbed_official 146:f64d43ff0c18 1364 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1365 *
mbed_official 146:f64d43ff0c18 1366 * Function Name : sim_set_tpm_ch_src
mbed_official 146:f64d43ff0c18 1367 * Description : Timer/PWM x channel y input capture source select setting
mbed_official 146:f64d43ff0c18 1368 * This function will select Timer/PWM x channel y input capture source
mbed_official 146:f64d43ff0c18 1369 *
mbed_official 146:f64d43ff0c18 1370 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1371 void sim_set_tpm_ch_src(uint8_t instance, uint8_t channel, sim_tpm_ch_src_t select)
mbed_official 146:f64d43ff0c18 1372 {
mbed_official 146:f64d43ff0c18 1373 assert (instance < HW_TPM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1374
mbed_official 146:f64d43ff0c18 1375 switch (instance)
mbed_official 146:f64d43ff0c18 1376 {
mbed_official 146:f64d43ff0c18 1377 case 1:
mbed_official 146:f64d43ff0c18 1378 switch (channel)
mbed_official 146:f64d43ff0c18 1379 {
mbed_official 146:f64d43ff0c18 1380 case 0:
mbed_official 146:f64d43ff0c18 1381 BW_SIM_SOPT4_TPM1CH0SRC(select);
mbed_official 146:f64d43ff0c18 1382 break;
mbed_official 146:f64d43ff0c18 1383 default:
mbed_official 146:f64d43ff0c18 1384 break;
mbed_official 146:f64d43ff0c18 1385 }
mbed_official 146:f64d43ff0c18 1386 break;
mbed_official 146:f64d43ff0c18 1387 case 2:
mbed_official 146:f64d43ff0c18 1388 switch (channel)
mbed_official 146:f64d43ff0c18 1389 {
mbed_official 146:f64d43ff0c18 1390 case 0:
mbed_official 146:f64d43ff0c18 1391 BW_SIM_SOPT4_TPM2CH0SRC(select);
mbed_official 146:f64d43ff0c18 1392 break;
mbed_official 146:f64d43ff0c18 1393 default:
mbed_official 146:f64d43ff0c18 1394 break;
mbed_official 146:f64d43ff0c18 1395 }
mbed_official 146:f64d43ff0c18 1396 break;
mbed_official 146:f64d43ff0c18 1397 default:
mbed_official 146:f64d43ff0c18 1398 break;
mbed_official 146:f64d43ff0c18 1399 }
mbed_official 146:f64d43ff0c18 1400 }
mbed_official 146:f64d43ff0c18 1401
mbed_official 146:f64d43ff0c18 1402 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 1403 *
mbed_official 146:f64d43ff0c18 1404 * Function Name : sim_get_tpm_ch_src
mbed_official 146:f64d43ff0c18 1405 * Description : Get Timer/PWM x channel y input capture source select setting
mbed_official 146:f64d43ff0c18 1406 * This function will get Timer/PWM x channel y input capture source select
mbed_official 146:f64d43ff0c18 1407 * setting.
mbed_official 146:f64d43ff0c18 1408 *
mbed_official 146:f64d43ff0c18 1409 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 1410 sim_tpm_ch_src_t sim_get_tpm_ch_src(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 1411 {
mbed_official 146:f64d43ff0c18 1412 assert (instance < HW_TPM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1413
mbed_official 146:f64d43ff0c18 1414 switch (instance)
mbed_official 146:f64d43ff0c18 1415 {
mbed_official 146:f64d43ff0c18 1416 case 1:
mbed_official 146:f64d43ff0c18 1417 switch (channel)
mbed_official 146:f64d43ff0c18 1418 {
mbed_official 146:f64d43ff0c18 1419 case 0:
mbed_official 146:f64d43ff0c18 1420 return (sim_tpm_ch_src_t)BR_SIM_SOPT4_TPM1CH0SRC;
mbed_official 146:f64d43ff0c18 1421 default:
mbed_official 146:f64d43ff0c18 1422 break;
mbed_official 146:f64d43ff0c18 1423 }
mbed_official 146:f64d43ff0c18 1424 break;
mbed_official 146:f64d43ff0c18 1425 case 2:
mbed_official 146:f64d43ff0c18 1426 switch (channel)
mbed_official 146:f64d43ff0c18 1427 {
mbed_official 146:f64d43ff0c18 1428 case 0:
mbed_official 146:f64d43ff0c18 1429 return (sim_tpm_ch_src_t)BR_SIM_SOPT4_TPM2CH0SRC;
mbed_official 146:f64d43ff0c18 1430 default:
mbed_official 146:f64d43ff0c18 1431 break;
mbed_official 146:f64d43ff0c18 1432 }
mbed_official 146:f64d43ff0c18 1433 break;
mbed_official 146:f64d43ff0c18 1434 default:
mbed_official 146:f64d43ff0c18 1435 break;
mbed_official 146:f64d43ff0c18 1436 }
mbed_official 146:f64d43ff0c18 1437
mbed_official 146:f64d43ff0c18 1438 return (sim_tpm_ch_src_t)0;
mbed_official 146:f64d43ff0c18 1439 }
mbed_official 146:f64d43ff0c18 1440 #endif
mbed_official 146:f64d43ff0c18 1441
mbed_official 146:f64d43ff0c18 1442 /*******************************************************************************
mbed_official 146:f64d43ff0c18 1443 * EOF
mbed_official 146:f64d43ff0c18 1444 ******************************************************************************/
mbed_official 146:f64d43ff0c18 1445