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/osc/fsl_osc_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_osc_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 /*******************************************************************************
mbed_official 146:f64d43ff0c18 39 * Code
mbed_official 146:f64d43ff0c18 40 ******************************************************************************/
mbed_official 146:f64d43ff0c18 41
mbed_official 146:f64d43ff0c18 42 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 43 *
mbed_official 146:f64d43ff0c18 44 * Function Name : osc_hal_enable_external_reference_clock
mbed_official 146:f64d43ff0c18 45 * Description : Enable the external reference clock for oscillator
mbed_official 146:f64d43ff0c18 46 * This function will enable the external reference clock output
mbed_official 146:f64d43ff0c18 47 * for oscillator - that is the OSCERCLK. This clock will be used
mbed_official 146:f64d43ff0c18 48 * by many peripherals. It should be enabled at early system init
mbed_official 146:f64d43ff0c18 49 * stage to ensure the peripherals could select it and use it.
mbed_official 146:f64d43ff0c18 50 *
mbed_official 146:f64d43ff0c18 51 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 52 void osc_hal_enable_external_reference_clock(osc_instance_t instance)
mbed_official 146:f64d43ff0c18 53 {
mbed_official 146:f64d43ff0c18 54 /* check instance range */
mbed_official 146:f64d43ff0c18 55 assert(instance < FSL_FEATURE_OSC_COUNT);
mbed_official 146:f64d43ff0c18 56
mbed_official 146:f64d43ff0c18 57 /* branch according to instance */
mbed_official 146:f64d43ff0c18 58 switch (instance)
mbed_official 146:f64d43ff0c18 59 {
mbed_official 146:f64d43ff0c18 60 #if FSL_FEATURE_OSC_HAS_OSC0
mbed_official 146:f64d43ff0c18 61 case 0:
mbed_official 146:f64d43ff0c18 62 OSC0->CR |= OSC_CR_ERCLKEN_MASK;
mbed_official 146:f64d43ff0c18 63 break;
mbed_official 146:f64d43ff0c18 64 #endif
mbed_official 146:f64d43ff0c18 65 #if FSL_FEATURE_OSC_HAS_OSC1
mbed_official 146:f64d43ff0c18 66 case 1:
mbed_official 146:f64d43ff0c18 67 OSC1->CR |= OSC_CR_ERCLKEN_MASK;
mbed_official 146:f64d43ff0c18 68 break;
mbed_official 146:f64d43ff0c18 69 #endif
mbed_official 146:f64d43ff0c18 70 #if FSL_FEATURE_OSC_HAS_OSC
mbed_official 146:f64d43ff0c18 71 case 0:
mbed_official 146:f64d43ff0c18 72 OSC->CR |= OSC_CR_ERCLKEN_MASK;
mbed_official 146:f64d43ff0c18 73 break;
mbed_official 146:f64d43ff0c18 74 #endif
mbed_official 146:f64d43ff0c18 75 default:
mbed_official 146:f64d43ff0c18 76 break;
mbed_official 146:f64d43ff0c18 77 }
mbed_official 146:f64d43ff0c18 78 }
mbed_official 146:f64d43ff0c18 79
mbed_official 146:f64d43ff0c18 80 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 81 *
mbed_official 146:f64d43ff0c18 82 * Function Name : osc_hal_disable_external_reference_clock
mbed_official 146:f64d43ff0c18 83 * Description : Disable the external reference clock for oscillator
mbed_official 146:f64d43ff0c18 84 * This function will disable the external reference clock output
mbed_official 146:f64d43ff0c18 85 * for oscillator - that is the OSCERCLK. This clock will be used
mbed_official 146:f64d43ff0c18 86 * by many peripherals. It should be enabled at early system init
mbed_official 146:f64d43ff0c18 87 * stage to ensure the peripherals could select it and use it.
mbed_official 146:f64d43ff0c18 88 *
mbed_official 146:f64d43ff0c18 89 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 90 void osc_hal_disable_external_reference_clock(osc_instance_t instance)
mbed_official 146:f64d43ff0c18 91 {
mbed_official 146:f64d43ff0c18 92 /* check instance range */
mbed_official 146:f64d43ff0c18 93 assert(instance < FSL_FEATURE_OSC_COUNT);
mbed_official 146:f64d43ff0c18 94
mbed_official 146:f64d43ff0c18 95 /* branch according to instance */
mbed_official 146:f64d43ff0c18 96 switch (instance)
mbed_official 146:f64d43ff0c18 97 {
mbed_official 146:f64d43ff0c18 98 #if FSL_FEATURE_OSC_HAS_OSC0
mbed_official 146:f64d43ff0c18 99 case 0:
mbed_official 146:f64d43ff0c18 100 OSC0->CR &= ~OSC_CR_ERCLKEN_MASK;
mbed_official 146:f64d43ff0c18 101 break;
mbed_official 146:f64d43ff0c18 102 #endif
mbed_official 146:f64d43ff0c18 103 #if FSL_FEATURE_OSC_HAS_OSC1
mbed_official 146:f64d43ff0c18 104 case 1:
mbed_official 146:f64d43ff0c18 105 OSC1->CR &= ~OSC_CR_ERCLKEN_MASK;
mbed_official 146:f64d43ff0c18 106 break;
mbed_official 146:f64d43ff0c18 107 #endif
mbed_official 146:f64d43ff0c18 108 #if FSL_FEATURE_OSC_HAS_OSC
mbed_official 146:f64d43ff0c18 109 case 0:
mbed_official 146:f64d43ff0c18 110 OSC->CR &= ~OSC_CR_ERCLKEN_MASK;
mbed_official 146:f64d43ff0c18 111 break;
mbed_official 146:f64d43ff0c18 112 #endif
mbed_official 146:f64d43ff0c18 113 default:
mbed_official 146:f64d43ff0c18 114 break;
mbed_official 146:f64d43ff0c18 115 }
mbed_official 146:f64d43ff0c18 116 }
mbed_official 146:f64d43ff0c18 117
mbed_official 146:f64d43ff0c18 118 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 119 *
mbed_official 146:f64d43ff0c18 120 * Function Name : osc_hal_enable_external_reference_clock_in_stop_mode
mbed_official 146:f64d43ff0c18 121 * Description : Enable the external reference clock in stop mode
mbed_official 146:f64d43ff0c18 122 * This function will enable the external reference clock (OSCERCLK) when
mbed_official 146:f64d43ff0c18 123 * MCU enters Stop mode.
mbed_official 146:f64d43ff0c18 124 *
mbed_official 146:f64d43ff0c18 125 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 126 void osc_hal_enable_external_reference_clock_in_stop_mode(osc_instance_t instance)
mbed_official 146:f64d43ff0c18 127 {
mbed_official 146:f64d43ff0c18 128 /* check instance range */
mbed_official 146:f64d43ff0c18 129 assert(instance < FSL_FEATURE_OSC_COUNT);
mbed_official 146:f64d43ff0c18 130
mbed_official 146:f64d43ff0c18 131 /* branch according to instance */
mbed_official 146:f64d43ff0c18 132 switch (instance)
mbed_official 146:f64d43ff0c18 133 {
mbed_official 146:f64d43ff0c18 134 #if FSL_FEATURE_OSC_HAS_OSC0
mbed_official 146:f64d43ff0c18 135 case 0:
mbed_official 146:f64d43ff0c18 136 OSC0->CR |= OSC_CR_EREFSTEN_MASK;
mbed_official 146:f64d43ff0c18 137 break;
mbed_official 146:f64d43ff0c18 138 #endif
mbed_official 146:f64d43ff0c18 139 #if FSL_FEATURE_OSC_HAS_OSC1
mbed_official 146:f64d43ff0c18 140 case 1:
mbed_official 146:f64d43ff0c18 141 OSC1->CR |= OSC_CR_EREFSTEN_MASK;
mbed_official 146:f64d43ff0c18 142 break;
mbed_official 146:f64d43ff0c18 143 #endif
mbed_official 146:f64d43ff0c18 144 #if FSL_FEATURE_OSC_HAS_OSC
mbed_official 146:f64d43ff0c18 145 case 0:
mbed_official 146:f64d43ff0c18 146 OSC->CR |= OSC_CR_EREFSTEN_MASK;
mbed_official 146:f64d43ff0c18 147 break;
mbed_official 146:f64d43ff0c18 148 #endif
mbed_official 146:f64d43ff0c18 149 default:
mbed_official 146:f64d43ff0c18 150 break;
mbed_official 146:f64d43ff0c18 151 }
mbed_official 146:f64d43ff0c18 152 }
mbed_official 146:f64d43ff0c18 153
mbed_official 146:f64d43ff0c18 154 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 155 *
mbed_official 146:f64d43ff0c18 156 * Function Name : osc_hal_disable_external_reference_clock_in_stop_mode
mbed_official 146:f64d43ff0c18 157 * Description : Disable the external reference clock for in stop mode
mbed_official 146:f64d43ff0c18 158 * This function will disable the external reference clock (OSCERCLK) when
mbed_official 146:f64d43ff0c18 159 * MCU enters Stop mode.
mbed_official 146:f64d43ff0c18 160 *
mbed_official 146:f64d43ff0c18 161 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 162 void osc_hal_disable_external_reference_clock_in_stop_mode(osc_instance_t instance)
mbed_official 146:f64d43ff0c18 163 {
mbed_official 146:f64d43ff0c18 164 /* check instance range */
mbed_official 146:f64d43ff0c18 165 assert(instance < FSL_FEATURE_OSC_COUNT);
mbed_official 146:f64d43ff0c18 166
mbed_official 146:f64d43ff0c18 167 /* branch according to instance */
mbed_official 146:f64d43ff0c18 168 switch (instance)
mbed_official 146:f64d43ff0c18 169 {
mbed_official 146:f64d43ff0c18 170 #if FSL_FEATURE_OSC_HAS_OSC0
mbed_official 146:f64d43ff0c18 171 case 0:
mbed_official 146:f64d43ff0c18 172 OSC0->CR &= ~OSC_CR_EREFSTEN_MASK;
mbed_official 146:f64d43ff0c18 173 break;
mbed_official 146:f64d43ff0c18 174 #endif
mbed_official 146:f64d43ff0c18 175 #if FSL_FEATURE_OSC_HAS_OSC1
mbed_official 146:f64d43ff0c18 176 case 1:
mbed_official 146:f64d43ff0c18 177 OSC1->CR &= ~OSC_CR_EREFSTEN_MASK;
mbed_official 146:f64d43ff0c18 178 break;
mbed_official 146:f64d43ff0c18 179 #endif
mbed_official 146:f64d43ff0c18 180 #if FSL_FEATURE_OSC_HAS_OSC
mbed_official 146:f64d43ff0c18 181 case 0:
mbed_official 146:f64d43ff0c18 182 OSC->CR &= ~OSC_CR_EREFSTEN_MASK;
mbed_official 146:f64d43ff0c18 183 break;
mbed_official 146:f64d43ff0c18 184 #endif
mbed_official 146:f64d43ff0c18 185 default:
mbed_official 146:f64d43ff0c18 186 break;
mbed_official 146:f64d43ff0c18 187 }
mbed_official 146:f64d43ff0c18 188 }
mbed_official 146:f64d43ff0c18 189
mbed_official 146:f64d43ff0c18 190 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 191 *
mbed_official 146:f64d43ff0c18 192 * Function Name : osc_hal_enable_capacitor_config
mbed_official 146:f64d43ff0c18 193 * Description : Enable the capacitor configuration for oscillator
mbed_official 146:f64d43ff0c18 194 * This function will enable the specified capacitors configuration for the
mbed_official 146:f64d43ff0c18 195 * oscillator. This should be done in early system level init function call
mbed_official 146:f64d43ff0c18 196 * based on system configuration.
mbed_official 146:f64d43ff0c18 197 *
mbed_official 146:f64d43ff0c18 198 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 199 void osc_hal_enable_capacitor_config(osc_instance_t instance, uint32_t capacitorConfigs)
mbed_official 146:f64d43ff0c18 200 {
mbed_official 146:f64d43ff0c18 201 /* check instance range */
mbed_official 146:f64d43ff0c18 202 assert(instance < FSL_FEATURE_OSC_COUNT);
mbed_official 146:f64d43ff0c18 203
mbed_official 146:f64d43ff0c18 204 /* branch according to instance */
mbed_official 146:f64d43ff0c18 205 switch (instance)
mbed_official 146:f64d43ff0c18 206 {
mbed_official 146:f64d43ff0c18 207 #if FSL_FEATURE_OSC_HAS_OSC0
mbed_official 146:f64d43ff0c18 208 case 0:
mbed_official 146:f64d43ff0c18 209 OSC0->CR |= (capacitorConfigs & kOscCapacitorMask);
mbed_official 146:f64d43ff0c18 210 break;
mbed_official 146:f64d43ff0c18 211 #endif
mbed_official 146:f64d43ff0c18 212 #if FSL_FEATURE_OSC_HAS_OSC1
mbed_official 146:f64d43ff0c18 213 case 1:
mbed_official 146:f64d43ff0c18 214 OSC1->CR |= (capacitorConfigs & kOscCapacitorMask);
mbed_official 146:f64d43ff0c18 215 break;
mbed_official 146:f64d43ff0c18 216 #endif
mbed_official 146:f64d43ff0c18 217 #if FSL_FEATURE_OSC_HAS_OSC
mbed_official 146:f64d43ff0c18 218 case 0:
mbed_official 146:f64d43ff0c18 219 OSC->CR |= (capacitorConfigs & kOscCapacitorMask);
mbed_official 146:f64d43ff0c18 220 break;
mbed_official 146:f64d43ff0c18 221 #endif
mbed_official 146:f64d43ff0c18 222 default:
mbed_official 146:f64d43ff0c18 223 break;
mbed_official 146:f64d43ff0c18 224 }
mbed_official 146:f64d43ff0c18 225 }
mbed_official 146:f64d43ff0c18 226
mbed_official 146:f64d43ff0c18 227 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 228 *
mbed_official 146:f64d43ff0c18 229 * Function Name : osc_hal_disable_capacitor_config
mbed_official 146:f64d43ff0c18 230 * Description : Disable the capacitor configuration for specific oscillator
mbed_official 146:f64d43ff0c18 231 * This function will enable the specified capacitors configuration for the
mbed_official 146:f64d43ff0c18 232 * oscillator.
mbed_official 146:f64d43ff0c18 233 *
mbed_official 146:f64d43ff0c18 234 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 235 void osc_hal_disable_capacitor_config(osc_instance_t instance, uint32_t capacitorConfigs)
mbed_official 146:f64d43ff0c18 236 {
mbed_official 146:f64d43ff0c18 237 /* check instance range */
mbed_official 146:f64d43ff0c18 238 assert(instance < FSL_FEATURE_OSC_COUNT);
mbed_official 146:f64d43ff0c18 239
mbed_official 146:f64d43ff0c18 240 /* branch according to instance */
mbed_official 146:f64d43ff0c18 241 switch (instance)
mbed_official 146:f64d43ff0c18 242 {
mbed_official 146:f64d43ff0c18 243 #if FSL_FEATURE_OSC_HAS_OSC0
mbed_official 146:f64d43ff0c18 244 case 0:
mbed_official 146:f64d43ff0c18 245 OSC0->CR &= ~(capacitorConfigs & kOscCapacitorMask);
mbed_official 146:f64d43ff0c18 246 break;
mbed_official 146:f64d43ff0c18 247 #endif
mbed_official 146:f64d43ff0c18 248 #if FSL_FEATURE_OSC_HAS_OSC1
mbed_official 146:f64d43ff0c18 249 case 1:
mbed_official 146:f64d43ff0c18 250 OSC1->CR &= ~(capacitorConfigs & kOscCapacitorMask);
mbed_official 146:f64d43ff0c18 251 break;
mbed_official 146:f64d43ff0c18 252 #endif
mbed_official 146:f64d43ff0c18 253 #if FSL_FEATURE_OSC_HAS_OSC
mbed_official 146:f64d43ff0c18 254 case 0:
mbed_official 146:f64d43ff0c18 255 OSC->CR &= ~(capacitorConfigs & kOscCapacitorMask);
mbed_official 146:f64d43ff0c18 256 break;
mbed_official 146:f64d43ff0c18 257 #endif
mbed_official 146:f64d43ff0c18 258 default:
mbed_official 146:f64d43ff0c18 259 break;
mbed_official 146:f64d43ff0c18 260 }
mbed_official 146:f64d43ff0c18 261 }
mbed_official 146:f64d43ff0c18 262
mbed_official 146:f64d43ff0c18 263 /*******************************************************************************
mbed_official 146:f64d43ff0c18 264 * EOF
mbed_official 146:f64d43ff0c18 265 ******************************************************************************/
mbed_official 146:f64d43ff0c18 266