Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of target-freescale-ksdk by
TARGET_KPSDK_CODE/drivers/clock/fsl_clock_manager.c@0:e4d670b91a9a, 2016-03-23 (annotated)
- Committer:
- screamer
- Date:
- Wed Mar 23 21:26:50 2016 +0000
- Revision:
- 0:e4d670b91a9a
Initial revision
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:e4d670b91a9a | 1 | /* |
screamer | 0:e4d670b91a9a | 2 | * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. |
screamer | 0:e4d670b91a9a | 3 | * All rights reserved. |
screamer | 0:e4d670b91a9a | 4 | * |
screamer | 0:e4d670b91a9a | 5 | * Redistribution and use in source and binary forms, with or without modification, |
screamer | 0:e4d670b91a9a | 6 | * are permitted provided that the following conditions are met: |
screamer | 0:e4d670b91a9a | 7 | * |
screamer | 0:e4d670b91a9a | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
screamer | 0:e4d670b91a9a | 9 | * of conditions and the following disclaimer. |
screamer | 0:e4d670b91a9a | 10 | * |
screamer | 0:e4d670b91a9a | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
screamer | 0:e4d670b91a9a | 12 | * list of conditions and the following disclaimer in the documentation and/or |
screamer | 0:e4d670b91a9a | 13 | * other materials provided with the distribution. |
screamer | 0:e4d670b91a9a | 14 | * |
screamer | 0:e4d670b91a9a | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
screamer | 0:e4d670b91a9a | 16 | * contributors may be used to endorse or promote products derived from this |
screamer | 0:e4d670b91a9a | 17 | * software without specific prior written permission. |
screamer | 0:e4d670b91a9a | 18 | * |
screamer | 0:e4d670b91a9a | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
screamer | 0:e4d670b91a9a | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
screamer | 0:e4d670b91a9a | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
screamer | 0:e4d670b91a9a | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
screamer | 0:e4d670b91a9a | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
screamer | 0:e4d670b91a9a | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
screamer | 0:e4d670b91a9a | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
screamer | 0:e4d670b91a9a | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
screamer | 0:e4d670b91a9a | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
screamer | 0:e4d670b91a9a | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
screamer | 0:e4d670b91a9a | 29 | */ |
screamer | 0:e4d670b91a9a | 30 | |
screamer | 0:e4d670b91a9a | 31 | #include "fsl_device_registers.h" |
screamer | 0:e4d670b91a9a | 32 | #include "fsl_clock_manager.h" |
screamer | 0:e4d670b91a9a | 33 | |
screamer | 0:e4d670b91a9a | 34 | /******************************************************************************* |
screamer | 0:e4d670b91a9a | 35 | * Definitions |
screamer | 0:e4d670b91a9a | 36 | ******************************************************************************/ |
screamer | 0:e4d670b91a9a | 37 | /* Table of base addresses for instances. */ |
screamer | 0:e4d670b91a9a | 38 | const uint32_t g_simBaseAddr[] = SIM_BASE_ADDRS; |
screamer | 0:e4d670b91a9a | 39 | const uint32_t g_mcgBaseAddr[] = MCG_BASE_ADDRS; |
screamer | 0:e4d670b91a9a | 40 | |
screamer | 0:e4d670b91a9a | 41 | |
screamer | 0:e4d670b91a9a | 42 | /******************************************************************************* |
screamer | 0:e4d670b91a9a | 43 | * Code |
screamer | 0:e4d670b91a9a | 44 | ******************************************************************************/ |
screamer | 0:e4d670b91a9a | 45 | |
screamer | 0:e4d670b91a9a | 46 | /*FUNCTION********************************************************************** |
screamer | 0:e4d670b91a9a | 47 | * |
screamer | 0:e4d670b91a9a | 48 | * Function Name : CLOCK_SYS_GetSysClkFreq |
screamer | 0:e4d670b91a9a | 49 | * Description : Internal function to get the system clock frequency |
screamer | 0:e4d670b91a9a | 50 | * This function will check the clock name configuration table for specific |
screamer | 0:e4d670b91a9a | 51 | * chip family and find out the supported clock name for that chip family |
screamer | 0:e4d670b91a9a | 52 | * then it will call the mcg hal function to get the basic system clock, |
screamer | 0:e4d670b91a9a | 53 | * calculate the clock frequency for specified clock name. |
screamer | 0:e4d670b91a9a | 54 | * |
screamer | 0:e4d670b91a9a | 55 | *END**************************************************************************/ |
screamer | 0:e4d670b91a9a | 56 | clock_manager_error_code_t CLOCK_SYS_GetSysClkFreq(clock_names_t clockName, |
screamer | 0:e4d670b91a9a | 57 | uint32_t *frequency) |
screamer | 0:e4d670b91a9a | 58 | { |
screamer | 0:e4d670b91a9a | 59 | /* system clock out divider*/ |
screamer | 0:e4d670b91a9a | 60 | uint32_t divider; |
screamer | 0:e4d670b91a9a | 61 | |
screamer | 0:e4d670b91a9a | 62 | const clock_name_config_t *table = &kClockNameConfigTable[clockName]; |
screamer | 0:e4d670b91a9a | 63 | |
screamer | 0:e4d670b91a9a | 64 | /* check if we need to use a reference clock*/ |
screamer | 0:e4d670b91a9a | 65 | if (table->useOtherRefClock) |
screamer | 0:e4d670b91a9a | 66 | { |
screamer | 0:e4d670b91a9a | 67 | /* get other specified ref clock*/ |
screamer | 0:e4d670b91a9a | 68 | if ( kClockManagerSuccess != CLOCK_SYS_GetFreq(table->otherRefClockName, |
screamer | 0:e4d670b91a9a | 69 | frequency) ) |
screamer | 0:e4d670b91a9a | 70 | { |
screamer | 0:e4d670b91a9a | 71 | return kClockManagerNoSuchClockName; |
screamer | 0:e4d670b91a9a | 72 | } |
screamer | 0:e4d670b91a9a | 73 | } |
screamer | 0:e4d670b91a9a | 74 | else |
screamer | 0:e4d670b91a9a | 75 | { |
screamer | 0:e4d670b91a9a | 76 | /* get default ref clock */ |
screamer | 0:e4d670b91a9a | 77 | *frequency = CLOCK_HAL_GetOutClk(g_mcgBaseAddr[0]); |
screamer | 0:e4d670b91a9a | 78 | } |
screamer | 0:e4d670b91a9a | 79 | |
screamer | 0:e4d670b91a9a | 80 | /* get system clock divider*/ |
screamer | 0:e4d670b91a9a | 81 | if ( CLOCK_HAL_GetDivider(g_simBaseAddr[0], table->dividerName, ÷r) == kSimHalSuccess) |
screamer | 0:e4d670b91a9a | 82 | { |
screamer | 0:e4d670b91a9a | 83 | /* get the frequency for the specified clock*/ |
screamer | 0:e4d670b91a9a | 84 | *frequency = (*frequency) / (divider + 1); |
screamer | 0:e4d670b91a9a | 85 | return kClockManagerSuccess; |
screamer | 0:e4d670b91a9a | 86 | } |
screamer | 0:e4d670b91a9a | 87 | else |
screamer | 0:e4d670b91a9a | 88 | { |
screamer | 0:e4d670b91a9a | 89 | return kClockManagerNoSuchDivider; |
screamer | 0:e4d670b91a9a | 90 | } |
screamer | 0:e4d670b91a9a | 91 | } |
screamer | 0:e4d670b91a9a | 92 | |
screamer | 0:e4d670b91a9a | 93 | /*FUNCTION********************************************************************** |
screamer | 0:e4d670b91a9a | 94 | * |
screamer | 0:e4d670b91a9a | 95 | * Function Name : CLOCK_SYS_GetFreq |
screamer | 0:e4d670b91a9a | 96 | * Description : Internal function to get the frequency by clock name |
screamer | 0:e4d670b91a9a | 97 | * This function will get/calculate the clock frequency based on clock name |
screamer | 0:e4d670b91a9a | 98 | * and current configuration of clock generator. |
screamer | 0:e4d670b91a9a | 99 | * |
screamer | 0:e4d670b91a9a | 100 | *END**************************************************************************/ |
screamer | 0:e4d670b91a9a | 101 | clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, |
screamer | 0:e4d670b91a9a | 102 | uint32_t *frequency) |
screamer | 0:e4d670b91a9a | 103 | { |
screamer | 0:e4d670b91a9a | 104 | clock_manager_error_code_t returnCode = kClockManagerSuccess; |
screamer | 0:e4d670b91a9a | 105 | |
screamer | 0:e4d670b91a9a | 106 | /* branch according to clock name */ |
screamer | 0:e4d670b91a9a | 107 | switch(clockName) |
screamer | 0:e4d670b91a9a | 108 | { |
screamer | 0:e4d670b91a9a | 109 | /* osc clock*/ |
screamer | 0:e4d670b91a9a | 110 | case kOsc32kClock: |
screamer | 0:e4d670b91a9a | 111 | *frequency = CPU_XTAL32k_CLK_HZ; |
screamer | 0:e4d670b91a9a | 112 | break; |
screamer | 0:e4d670b91a9a | 113 | case kOsc0ErClock: |
screamer | 0:e4d670b91a9a | 114 | #if FSL_FEATURE_MCG_HAS_OSC1 |
screamer | 0:e4d670b91a9a | 115 | /* System oscillator 0 drives MCG clock */ |
screamer | 0:e4d670b91a9a | 116 | *frequency = CPU_XTAL0_CLK_HZ; |
screamer | 0:e4d670b91a9a | 117 | #else |
screamer | 0:e4d670b91a9a | 118 | /* System oscillator 0 drives MCG clock */ |
screamer | 0:e4d670b91a9a | 119 | *frequency = CPU_XTAL_CLK_HZ; |
screamer | 0:e4d670b91a9a | 120 | #endif |
screamer | 0:e4d670b91a9a | 121 | break; |
screamer | 0:e4d670b91a9a | 122 | |
screamer | 0:e4d670b91a9a | 123 | #if FSL_FEATURE_MCG_HAS_OSC1 |
screamer | 0:e4d670b91a9a | 124 | case kOsc1ErClock: |
screamer | 0:e4d670b91a9a | 125 | *frequency = CPU_XTAL1_CLK_HZ; |
screamer | 0:e4d670b91a9a | 126 | break; |
screamer | 0:e4d670b91a9a | 127 | #endif |
screamer | 0:e4d670b91a9a | 128 | |
screamer | 0:e4d670b91a9a | 129 | #if FSL_FEATURE_MCG_HAS_IRC_48M |
screamer | 0:e4d670b91a9a | 130 | /* irc clock*/ |
screamer | 0:e4d670b91a9a | 131 | case kIrc48mClock: |
screamer | 0:e4d670b91a9a | 132 | *frequency = CPU_INT_IRC_CLK_HZ; |
screamer | 0:e4d670b91a9a | 133 | break; |
screamer | 0:e4d670b91a9a | 134 | #endif |
screamer | 0:e4d670b91a9a | 135 | |
screamer | 0:e4d670b91a9a | 136 | /* rtc clock*/ |
screamer | 0:e4d670b91a9a | 137 | case kRtc32kClock: |
screamer | 0:e4d670b91a9a | 138 | *frequency = CPU_XTAL32k_CLK_HZ; |
screamer | 0:e4d670b91a9a | 139 | break; |
screamer | 0:e4d670b91a9a | 140 | |
screamer | 0:e4d670b91a9a | 141 | case kRtc1hzClock: |
screamer | 0:e4d670b91a9a | 142 | *frequency = CPU_XTAL1hz_CLK_HZ; // defined in fsl_clock_manager.h for now |
screamer | 0:e4d670b91a9a | 143 | break; |
screamer | 0:e4d670b91a9a | 144 | |
screamer | 0:e4d670b91a9a | 145 | /* lpo clcok*/ |
screamer | 0:e4d670b91a9a | 146 | case kLpoClock: |
screamer | 0:e4d670b91a9a | 147 | *frequency = CPU_LPO_CLK_HZ; // defined in fsl_clock_manager.h for now |
screamer | 0:e4d670b91a9a | 148 | break; |
screamer | 0:e4d670b91a9a | 149 | |
screamer | 0:e4d670b91a9a | 150 | /* mcg clocks, calling mcg clock functions */ |
screamer | 0:e4d670b91a9a | 151 | case kMcgFfClock: |
screamer | 0:e4d670b91a9a | 152 | *frequency = CLOCK_HAL_GetFllRefClk(g_mcgBaseAddr[0]); |
screamer | 0:e4d670b91a9a | 153 | break; |
screamer | 0:e4d670b91a9a | 154 | case kMcgFllClock: |
screamer | 0:e4d670b91a9a | 155 | *frequency = CLOCK_HAL_GetFllClk(g_mcgBaseAddr[0]); |
screamer | 0:e4d670b91a9a | 156 | break; |
screamer | 0:e4d670b91a9a | 157 | #if FSL_FEATURE_MCG_HAS_PLL |
screamer | 0:e4d670b91a9a | 158 | case kMcgPll0Clock: |
screamer | 0:e4d670b91a9a | 159 | *frequency = CLOCK_HAL_GetPll0Clk(g_mcgBaseAddr[0]); |
screamer | 0:e4d670b91a9a | 160 | break; |
screamer | 0:e4d670b91a9a | 161 | #endif |
screamer | 0:e4d670b91a9a | 162 | case kMcgOutClock: |
screamer | 0:e4d670b91a9a | 163 | *frequency = CLOCK_HAL_GetOutClk(g_mcgBaseAddr[0]); |
screamer | 0:e4d670b91a9a | 164 | break; |
screamer | 0:e4d670b91a9a | 165 | case kMcgIrClock: |
screamer | 0:e4d670b91a9a | 166 | *frequency = CLOCK_HAL_GetInternalRefClk(g_mcgBaseAddr[0]); |
screamer | 0:e4d670b91a9a | 167 | break; |
screamer | 0:e4d670b91a9a | 168 | |
screamer | 0:e4d670b91a9a | 169 | case kSDHC0_CLKIN: |
screamer | 0:e4d670b91a9a | 170 | *frequency = SDHC0_CLKIN; // defined in fsl_clock_manager.h for now |
screamer | 0:e4d670b91a9a | 171 | break; |
screamer | 0:e4d670b91a9a | 172 | case kENET_1588_CLKIN: |
screamer | 0:e4d670b91a9a | 173 | *frequency = ENET_1588_CLKIN; // defined in fsl_clock_manager.h for now |
screamer | 0:e4d670b91a9a | 174 | break; |
screamer | 0:e4d670b91a9a | 175 | case kEXTAL_Clock: |
screamer | 0:e4d670b91a9a | 176 | *frequency = EXTAL_Clock; // defined in fsl_clock_manager.h for now |
screamer | 0:e4d670b91a9a | 177 | break; |
screamer | 0:e4d670b91a9a | 178 | case kEXTAL1_Clock: |
screamer | 0:e4d670b91a9a | 179 | *frequency = EXTAL1_Clock; // defined in fsl_clock_manager.h for now |
screamer | 0:e4d670b91a9a | 180 | break; |
screamer | 0:e4d670b91a9a | 181 | case kUSB_CLKIN: |
screamer | 0:e4d670b91a9a | 182 | *frequency = USB_CLKIN; // defined in fsl_clock_manager.h for now |
screamer | 0:e4d670b91a9a | 183 | break; |
screamer | 0:e4d670b91a9a | 184 | |
screamer | 0:e4d670b91a9a | 185 | /* system clocks */ |
screamer | 0:e4d670b91a9a | 186 | case kCoreClock: |
screamer | 0:e4d670b91a9a | 187 | case kSystemClock: |
screamer | 0:e4d670b91a9a | 188 | case kPlatformClock: |
screamer | 0:e4d670b91a9a | 189 | case kBusClock: |
screamer | 0:e4d670b91a9a | 190 | case kFlexBusClock: |
screamer | 0:e4d670b91a9a | 191 | case kFlashClock: |
screamer | 0:e4d670b91a9a | 192 | returnCode = CLOCK_SYS_GetSysClkFreq(clockName, frequency); |
screamer | 0:e4d670b91a9a | 193 | break; |
screamer | 0:e4d670b91a9a | 194 | /* reserved value*/ |
screamer | 0:e4d670b91a9a | 195 | case kReserved: |
screamer | 0:e4d670b91a9a | 196 | default: |
screamer | 0:e4d670b91a9a | 197 | *frequency = 55555; /* for testing use purpose*/ |
screamer | 0:e4d670b91a9a | 198 | returnCode = kClockManagerNoSuchClockName; |
screamer | 0:e4d670b91a9a | 199 | break; |
screamer | 0:e4d670b91a9a | 200 | } |
screamer | 0:e4d670b91a9a | 201 | |
screamer | 0:e4d670b91a9a | 202 | return returnCode; |
screamer | 0:e4d670b91a9a | 203 | } |
screamer | 0:e4d670b91a9a | 204 | |
screamer | 0:e4d670b91a9a | 205 | |
screamer | 0:e4d670b91a9a | 206 | /*FUNCTION********************************************************************** |
screamer | 0:e4d670b91a9a | 207 | * |
screamer | 0:e4d670b91a9a | 208 | * Function Name : CLOCK_SYS_SetSource |
screamer | 0:e4d670b91a9a | 209 | * Description : Set clock source setting |
screamer | 0:e4d670b91a9a | 210 | * This function will set the settings for specified clock source. Each clock |
screamer | 0:e4d670b91a9a | 211 | * source has its clock selection settings. Refer to reference manual for |
screamer | 0:e4d670b91a9a | 212 | * details of settings for each clock source. Refer to clock_source_names_t |
screamer | 0:e4d670b91a9a | 213 | * for clock sources. |
screamer | 0:e4d670b91a9a | 214 | * |
screamer | 0:e4d670b91a9a | 215 | *END**************************************************************************/ |
screamer | 0:e4d670b91a9a | 216 | clock_manager_error_code_t CLOCK_SYS_SetSource(clock_source_names_t clockSource, |
screamer | 0:e4d670b91a9a | 217 | uint8_t setting) |
screamer | 0:e4d670b91a9a | 218 | { |
screamer | 0:e4d670b91a9a | 219 | clock_manager_error_code_t returnCode = kClockManagerSuccess; |
screamer | 0:e4d670b91a9a | 220 | |
screamer | 0:e4d670b91a9a | 221 | if (CLOCK_HAL_SetSource(g_simBaseAddr[0], clockSource, setting) != kSimHalSuccess) |
screamer | 0:e4d670b91a9a | 222 | { |
screamer | 0:e4d670b91a9a | 223 | returnCode = kClockManagerNoSuchClockSource; |
screamer | 0:e4d670b91a9a | 224 | } |
screamer | 0:e4d670b91a9a | 225 | |
screamer | 0:e4d670b91a9a | 226 | return returnCode; |
screamer | 0:e4d670b91a9a | 227 | } |
screamer | 0:e4d670b91a9a | 228 | |
screamer | 0:e4d670b91a9a | 229 | /*FUNCTION********************************************************************** |
screamer | 0:e4d670b91a9a | 230 | * |
screamer | 0:e4d670b91a9a | 231 | * Function Name : CLOCK_SYS_GetSource |
screamer | 0:e4d670b91a9a | 232 | * Description : Get clock source setting |
screamer | 0:e4d670b91a9a | 233 | * This function will get the settings for specified clock source. Each clock |
screamer | 0:e4d670b91a9a | 234 | * source has its clock selection settings. Refer to reference manual for |
screamer | 0:e4d670b91a9a | 235 | * details of settings for each clock source. Refer to clock_source_names_t |
screamer | 0:e4d670b91a9a | 236 | * for clock sources. |
screamer | 0:e4d670b91a9a | 237 | * |
screamer | 0:e4d670b91a9a | 238 | *END**************************************************************************/ |
screamer | 0:e4d670b91a9a | 239 | clock_manager_error_code_t CLOCK_SYS_GetSource(clock_source_names_t clockSource, |
screamer | 0:e4d670b91a9a | 240 | uint8_t *setting) |
screamer | 0:e4d670b91a9a | 241 | { |
screamer | 0:e4d670b91a9a | 242 | clock_manager_error_code_t returnCode = kClockManagerSuccess; |
screamer | 0:e4d670b91a9a | 243 | |
screamer | 0:e4d670b91a9a | 244 | if (CLOCK_HAL_GetSource(g_simBaseAddr[0], clockSource, setting) != kSimHalSuccess) |
screamer | 0:e4d670b91a9a | 245 | { |
screamer | 0:e4d670b91a9a | 246 | returnCode = kClockManagerNoSuchClockSource; |
screamer | 0:e4d670b91a9a | 247 | } |
screamer | 0:e4d670b91a9a | 248 | |
screamer | 0:e4d670b91a9a | 249 | return returnCode; |
screamer | 0:e4d670b91a9a | 250 | } |
screamer | 0:e4d670b91a9a | 251 | |
screamer | 0:e4d670b91a9a | 252 | /*FUNCTION********************************************************************** |
screamer | 0:e4d670b91a9a | 253 | * |
screamer | 0:e4d670b91a9a | 254 | * Function Name : CLOCK_SYS_SetDivider |
screamer | 0:e4d670b91a9a | 255 | * Description : Set clock divider setting |
screamer | 0:e4d670b91a9a | 256 | * This function will set the setting for specified clock divider. Refer to |
screamer | 0:e4d670b91a9a | 257 | * reference manual for supported clock divider and value range. Refer to |
screamer | 0:e4d670b91a9a | 258 | * clock_divider_names_t for dividers. |
screamer | 0:e4d670b91a9a | 259 | * |
screamer | 0:e4d670b91a9a | 260 | *END**************************************************************************/ |
screamer | 0:e4d670b91a9a | 261 | clock_manager_error_code_t CLOCK_SYS_SetDivider(clock_divider_names_t clockDivider, |
screamer | 0:e4d670b91a9a | 262 | uint32_t setting) |
screamer | 0:e4d670b91a9a | 263 | { |
screamer | 0:e4d670b91a9a | 264 | clock_manager_error_code_t returnCode = kClockManagerSuccess; |
screamer | 0:e4d670b91a9a | 265 | |
screamer | 0:e4d670b91a9a | 266 | if (CLOCK_HAL_SetDivider(g_simBaseAddr[0], clockDivider, setting) != kSimHalSuccess) |
screamer | 0:e4d670b91a9a | 267 | { |
screamer | 0:e4d670b91a9a | 268 | returnCode = kClockManagerNoSuchDivider; |
screamer | 0:e4d670b91a9a | 269 | } |
screamer | 0:e4d670b91a9a | 270 | |
screamer | 0:e4d670b91a9a | 271 | return returnCode; |
screamer | 0:e4d670b91a9a | 272 | } |
screamer | 0:e4d670b91a9a | 273 | |
screamer | 0:e4d670b91a9a | 274 | /*FUNCTION********************************************************************** |
screamer | 0:e4d670b91a9a | 275 | * |
screamer | 0:e4d670b91a9a | 276 | * Function Name : CLOCK_SYS_GetDivider |
screamer | 0:e4d670b91a9a | 277 | * Description : Get clock divider setting |
screamer | 0:e4d670b91a9a | 278 | * This function will get the setting for specified clock divider. Refer to |
screamer | 0:e4d670b91a9a | 279 | * reference manual for supported clock divider and value range. Refer to |
screamer | 0:e4d670b91a9a | 280 | * clock_divider_names_t for dividers. |
screamer | 0:e4d670b91a9a | 281 | * |
screamer | 0:e4d670b91a9a | 282 | *END**************************************************************************/ |
screamer | 0:e4d670b91a9a | 283 | clock_manager_error_code_t CLOCK_SYS_GetDivider(clock_divider_names_t clockDivider, |
screamer | 0:e4d670b91a9a | 284 | uint32_t *setting) |
screamer | 0:e4d670b91a9a | 285 | { |
screamer | 0:e4d670b91a9a | 286 | clock_manager_error_code_t returnCode = kClockManagerSuccess; |
screamer | 0:e4d670b91a9a | 287 | |
screamer | 0:e4d670b91a9a | 288 | if (CLOCK_HAL_GetDivider(g_simBaseAddr[0], clockDivider, setting) != kSimHalSuccess) |
screamer | 0:e4d670b91a9a | 289 | { |
screamer | 0:e4d670b91a9a | 290 | returnCode = kClockManagerNoSuchDivider; |
screamer | 0:e4d670b91a9a | 291 | } |
screamer | 0:e4d670b91a9a | 292 | |
screamer | 0:e4d670b91a9a | 293 | return returnCode; |
screamer | 0:e4d670b91a9a | 294 | } |
screamer | 0:e4d670b91a9a | 295 | |
screamer | 0:e4d670b91a9a | 296 | /******************************************************************************* |
screamer | 0:e4d670b91a9a | 297 | * EOF |
screamer | 0:e4d670b91a9a | 298 | ******************************************************************************/ |
screamer | 0:e4d670b91a9a | 299 |