12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247 |
- /*==================================================================================================
- * Project : RTD AUTOSAR 4.4
- * Platform : CORTEXM
- * Peripheral :
- * Dependencies : none
- *
- * Autosar Version : 4.4.0
- * Autosar Revision : ASR_REL_4_4_REV_0000
- * Autosar Conf.Variant :
- * SW Version : 1.0.0
- * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
- *
- * (c) Copyright 2020-2021 NXP Semiconductors
- * All Rights Reserved.
- *
- * NXP Confidential. This software is owned or controlled by NXP and may only be
- * used strictly in accordance with the applicable license terms. By expressly
- * accepting such terms or by downloading, installing, activating and/or otherwise
- * using the software, you are agreeing that you have read, and that you agree to
- * comply with and are bound by, such license terms. If you do not agree to be
- * bound by the applicable license terms, then you may not retain, install,
- * activate or otherwise use the software.
- ==================================================================================================*/
- /**
- * @file Clock_Ip_Specific.c
- * @version 1.0.0
- *
- * @brief CLOCK driver implementations.
- * @details CLOCK driver implementations.
- *
- * @addtogroup CLOCK_DRIVER Clock Ip Driver
- * @{
- */
-
- #include "Clock_Ip_Private.h"
- #if (defined(CLOCK_IP_ENABLE_USER_MODE_SUPPORT))
- #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
- #define USER_MODE_REG_PROT_ENABLED (STD_ON)
- #include "RegLockMacros.h"
- #endif
- #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
- /*==================================================================================================
- SOURCE FILE VERSION INFORMATION
- ==================================================================================================*/
- #define CLOCK_IP_SPECIFIC_VENDOR_ID_C 43
- #define CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION_C 4
- #define CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION_C 4
- #define CLOCK_IP_SPECIFIC_AR_RELEASE_REVISION_VERSION_C 0
- #define CLOCK_IP_SPECIFIC_SW_MAJOR_VERSION_C 1
- #define CLOCK_IP_SPECIFIC_SW_MINOR_VERSION_C 0
- #define CLOCK_IP_SPECIFIC_SW_PATCH_VERSION_C 0
- /*==================================================================================================
- * FILE VERSION CHECKS
- ==================================================================================================*/
- /* Check if Clock_Ip_Specific.c file and Clock_Ip_Private.h file are of the same vendor */
- #if (CLOCK_IP_SPECIFIC_VENDOR_ID_C != CLOCK_IP_PRIVATE_VENDOR_ID)
- #error "Clock_Ip_Specific.c and Clock_Ip_Private.h have different vendor ids"
- #endif
- /* Check if Clock_Ip_Specific.c file and Clock_Ip_Private.h file are of the same Autosar version */
- #if ((CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION_C != CLOCK_IP_PRIVATE_AR_RELEASE_MAJOR_VERSION) || \
- (CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION_C != CLOCK_IP_PRIVATE_AR_RELEASE_MINOR_VERSION) || \
- (CLOCK_IP_SPECIFIC_AR_RELEASE_REVISION_VERSION_C != CLOCK_IP_PRIVATE_AR_RELEASE_REVISION_VERSION) \
- )
- #error "AutoSar Version Numbers of Clock_Ip_Specific.c and Clock_Ip_Private.h are different"
- #endif
- /* Check if Clock_Ip_Specific.c file and Clock_Ip_Private.h file are of the same Software version */
- #if ((CLOCK_IP_SPECIFIC_SW_MAJOR_VERSION_C != CLOCK_IP_PRIVATE_SW_MAJOR_VERSION) || \
- (CLOCK_IP_SPECIFIC_SW_MINOR_VERSION_C != CLOCK_IP_PRIVATE_SW_MINOR_VERSION) || \
- (CLOCK_IP_SPECIFIC_SW_PATCH_VERSION_C != CLOCK_IP_PRIVATE_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Clock_Ip_Specific.c and Clock_Ip_Private.h are different"
- #endif
- #if (defined(CLOCK_IP_ENABLE_USER_MODE_SUPPORT))
- #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
- #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
- /* Check if Clock_Ip_Specific.c file and RegLockMacros.h file are of the same Autosar version */
- #if ((CLOCK_IP_SPECIFIC_AR_RELEASE_MAJOR_VERSION_C != REGLOCKMACROS_AR_RELEASE_MAJOR_VERSION) || \
- (CLOCK_IP_SPECIFIC_AR_RELEASE_MINOR_VERSION_C != REGLOCKMACROS_AR_RELEASE_MINOR_VERSION))
- #error "AutoSar Version Numbers of Clock_Ip_Specific.c and RegLockMacros.h are different"
- #endif
- #endif
- #endif
- #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
- /*==================================================================================================
- LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
- ==================================================================================================*/
- /*==================================================================================================
- * LOCAL MACROS
- ==================================================================================================*/
- #define SCS_SELECTOR_HARDWARE_VALUES_NO 7U
- #define RUN_POWER_MODE_STATUS 1U
- #if (defined (CLOCK_IP_S32K118) || defined(CLOCK_IP_S32K116))
- #define SYS_OSC 1U
- #define CMU 1U
- #define SCS_RUN 4U
- #define FIRCOSC 4U
- #define DIVCORE_RUN 5U
- #define DIVBUS_RUN 7U
- #define DIVSLOW_RUN 9U
- #elif (defined (CLOCK_IP_S32K142W) || defined(CLOCK_IP_S32K144W))
- #define SYS_OSC 1U
- #define SYS_PLL 1U
- #define FIRCOSC 4U
- #define SCS_RUN 5U
- #define DIVCORE_RUN 6U
- #define DIVBUS_RUN 8U
- #define DIVSLOW_RUN 10U
- #elif (defined (CLOCK_IP_S32K142) || defined(CLOCK_IP_S32K144) || defined(CLOCK_IP_S32K146) || defined(CLOCK_IP_S32K148))
- #define SYS_OSC 1U
- #define SYS_PLL 1U
- #define FIRCOSC 4U
- #define SCS_RUN 5U
- #define DIVCORE_RUN 6U
- #define SCS_HSRUN 7U
- #define DIVCORE_HSRUN 8U
- #define DIVBUS_RUN 9U
- #define DIVBUS_HSRUN 11U
- #define DIVSLOW_RUN 12U
- #define DIVSLOW_HSRUN 14U
- #endif
- /*==================================================================================================
- LOCAL CONSTANTS
- ==================================================================================================*/
- /*==================================================================================================
- LOCAL VARIABLES
- ==================================================================================================*/
- /*==================================================================================================
- GLOBAL CONSTANTS
- ==================================================================================================*/
- /*==================================================================================================
- GLOBAL VARIABLES
- ==================================================================================================*/
- #ifdef FEATURE_CLOCK_IP_HAS_FLASH_WAIT_STATES
- /* Clock start ram section code */
- #define MCU_START_SEC_RAMCODE
- #include "Mcu_MemMap.h"
- static void CodeInRam_SetFlashWaitStates(void);
- /* Clock start ram section code */
- #define MCU_STOP_SEC_RAMCODE
- #include "Mcu_MemMap.h"
- #endif /* FEATURE_CLOCK_IP_HAS_FLASH_WAIT_STATES */
- /* Clock start initialized section data */
- #define MCU_START_SEC_VAR_CLEARED_BOOLEAN
- #include "Mcu_MemMap.h"
- static boolean fircWasEnabledBeforeMcuInit; /* Firc clock was enabled before MCU initialization */
- /* Clock stop initialized section data */
- #define MCU_STOP_SEC_VAR_CLEARED_BOOLEAN
- #include "Mcu_MemMap.h"
- /* Clock start initialized section data */
- #define MCU_START_SEC_VAR_CLEARED_UNSPECIFIED
- #include "Mcu_MemMap.h"
- static const Clock_Ip_ClockConfigType *config_clock;
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- static const pllCallback * spllClock;
- #endif
- static const extOscCallback *soscClock;
- static const intOscCallback *fircClock;
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- static const clockMonitorCallback *cmuFircMonitor;
- #endif
- static const selectorCallback *scsRunClockSelector;
- static const dividerCallback *coreRunClockDivider;
- static const dividerCallback *busRunClockDivider;
- static const dividerCallback *slowRunClockDivider;
- static const Clock_Ip_IrcoscConfigType *fircConfig;
- static const Clock_Ip_XoscConfigType *soscConfig;
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- static const Clock_Ip_PllConfigType *spllConfig;
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- const Clock_Ip_CmuConfigType *cmuFircMon1Config,*cmuFircMon2Config;
- #endif
- static const Clock_Ip_SelectorConfigType *scsConfig_Run_Mode, *scsConfig_Vlpr_Mode;
- static const Clock_Ip_DividerConfigType *coreConfig_Run_Mode, *coreConfig_Vlpr_Mode, *busConfig_Run_Mode, *busConfig_Vlpr_Mode, *slowConfig_Run_Mode, *slowConfig_Vlpr_Mode;
- #if defined(FEATURE_CLOCK_IP_HAS_SLOW_HSRUN_CLK)
- static const selectorCallback *scsHsrunClockSelector;
- static const dividerCallback *coreHsrunClockDivider;
- static const dividerCallback *busHsrunClockDivider;
- static const dividerCallback *slowHsrunClockDivider;
- static const Clock_Ip_SelectorConfigType *scsConfig_Hsrun_Mode;
- static const Clock_Ip_DividerConfigType *coreConfig_Hsrun_Mode, *busConfig_Hsrun_Mode, *slowConfig_Hsrun_Mode;
- #endif
- /* Clock stop initialized section data */
- #define MCU_STOP_SEC_VAR_CLEARED_UNSPECIFIED
- #include "Mcu_MemMap.h"
- /*==================================================================================================
- * LOCAL FUNCTION PROTOTYPES
- ==================================================================================================*/
- #define MCU_START_SEC_CODE
- #include "Mcu_MemMap.h"
- static const Clock_Ip_IrcoscConfigType *getFircConfig(void);
- static const Clock_Ip_XoscConfigType *getSoscConfig(void);
- static const Clock_Ip_XoscConfigType *getSoscConfig(void);
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- static const Clock_Ip_PllConfigType *getSpllConfig(void);
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- static const Clock_Ip_CmuConfigType *getCmuFircConfig(Clock_Ip_NameType name);
- #endif
- static const Clock_Ip_SelectorConfigType *getSelectorConfig(Clock_Ip_NameType name);
- static const Clock_Ip_DividerConfigType *getCoreDividerConfig(Clock_Ip_NameType name);
- static const Clock_Ip_DividerConfigType *getBusDividerConfig(Clock_Ip_NameType name);
- static const Clock_Ip_DividerConfigType *getSlowDividerConfig(Clock_Ip_NameType name);
- static void SetSimLpoclksRegister_TrustedCall(Clock_Ip_ClockConfigType const *config);
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- static void EnableCmuGate_TrustedCall(void);
- #endif
- #define MCU_STOP_SEC_CODE
- #include "Mcu_MemMap.h"
- /*==================================================================================================
- * LOCAL FUNCTIONS
- ==================================================================================================*/
- /*==================================================================================================
- * GLOBAL FUNCTIONS
- ==================================================================================================*/
- #ifdef FEATURE_CLOCK_IP_HAS_RAM_WAIT_STATES
- #define MCU_START_SEC_CODE_AC
- #include "Mcu_MemMap.h"
- static void PRAMC_SetRamIWS(void);
- #define MCU_STOP_SEC_CODE_AC
- #include "Mcu_MemMap.h"
- #endif
- #define MCU_START_SEC_CODE
- #include "Mcu_MemMap.h"
- #ifdef FEATURE_CLOCK_IP_HAS_RAM_WAIT_STATES
- void SetRamWaitStates(void)
- {
- #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
- #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
- OsIf_Trusted_Call(PRAMC_SetRamIWS);
- #else
- PRAMC_SetRamIWS();
- #endif
- #else
- PRAMC_SetRamIWS();
- #endif
- }
- #endif
- #ifdef FEATURE_CLOCK_IP_HAS_FLASH_WAIT_STATES
- void FLASH_SetFlashIWS(void);
- void SetFlashWaitStates(void)
- {
- FLASH_SetFlashIWS();
- }
- #endif
- /* Configure the specific modules like eMios */
- void SpecificPeripheralClockInitialization(Clock_IP_SpecificPeriphConfigType const * config)
- {
- (void)config;
- }
- void DisableSafeClock(Clock_Ip_ClockConfigType const * config)
- {
- uint32 i;
- boolean fircConfigFound = FALSE;
-
- if (config != NULL_PTR)
- {
- for (i = 0U; i < config_clock->ircoscsCount; i++)
- {
- if (config_clock->ircoscs[i].name == FIRC_CLK)
- {
- fircConfigFound = TRUE;
- if (config_clock->ircoscs[i].enable == FALSE)
- {
- /* Disable FIRC according to configuration */
- intOscCallbacks[ircoscCallbackIndex[FIRCOSC]].Disable(FIRC_CLK);
- }
- break;
- }
- }
- }
- if ((fircConfigFound == FALSE) && (fircWasEnabledBeforeMcuInit == FALSE))
- {
- /* Disable FIRC according to configuration */
- intOscCallbacks[ircoscCallbackIndex[FIRCOSC]].Disable(FIRC_CLK);
- }
- }
- static void SetFircToResetValue_TrustedCall(void)
- {
- /* Range is 48Mhz. */
- IP_SCG->FIRCCFG = SCG_FIRCCFG_RANGE(0U);
-
- /* Enable clock, regulator is enabled. */
- IP_SCG->FIRCCSR |= (SCG_FIRCCSR_FIRCEN(1U) | SCG_FIRCCSR_FIRCREGOFF(0U));
- }
- static void SetSimLpoclksRegister_TrustedCall(Clock_Ip_ClockConfigType const *config)
- {
- uint32 SimLpoValue = 3U; /* Reset value of SIM_LPOCLKS register */
- uint32 i;
- /* The LPOCLKS register is a write-once register so configuration will be written here*/
- for (i = 0U; i < config->selectorsCount; i++)
- {
- /* Selector for RTC_CLK */
- if (RTC_CLK == config->selectors[i].name)
- {
- SimLpoValue |= ((uint32)(selectorEntry_hardwareValue[config->selectors[i].value]) << SIM_LPOCLKS_RTCCLKSEL_SHIFT);
- }
- /* Selector for LPO_CLK */
- if (LPO_CLK == config->selectors[i].name)
- {
- SimLpoValue |= ((uint32)(selectorEntryPCS_hardwareValue[config->selectors[i].value]) << SIM_LPOCLKS_LPOCLKSEL_SHIFT);
- }
- }
-
- for (i = 0U; i < config->gatesCount; i++) /* Set clock gates that are under clock control. */
- {
- /* Gate for LPO_32K_CLK */
- if (LPO_32K_CLK == config->gates[i].name)
- {
- SimLpoValue |= ((uint32)(config->gates[i].enable) << SIM_LPOCLKS_LPO32KCLKEN_SHIFT);
- }
- /* Gate for LPO_1K_CLK */
- if (LPO_1K_CLK == config->gates[i].name)
- {
- SimLpoValue |= ((uint32)(config->gates[i].enable) << SIM_LPOCLKS_LPO1KCLKEN_SHIFT);
- }
- }
- IP_SIM->LPOCLKS = SimLpoValue;
- }
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- static void EnableCmuGate_TrustedCall(void)
- {
- uint32 regValue;
- regValue = IP_PCC->PCCn[clockFeatures[CMU0_CLK][GATE_INDEX]];
- regValue &= ~PCC_PCCn_CGC_MASK;
- regValue |= PCC_PCCn_CGC_MASK;
- IP_PCC->PCCn[clockFeatures[CMU0_CLK][GATE_INDEX]] = regValue;
- regValue = IP_PCC->PCCn[clockFeatures[CMU1_CLK][GATE_INDEX]];
- regValue &= ~PCC_PCCn_CGC_MASK;
- regValue |= PCC_PCCn_CGC_MASK;
- IP_PCC->PCCn[clockFeatures[CMU1_CLK][GATE_INDEX]] = regValue;
- }
- #endif
- void SpecificPlatformInitClock(Clock_Ip_ClockConfigType const * config)
- {
- boolean TimeoutOccurred = FALSE;
- uint32 StartTime;
- uint32 ElapsedTime;
- uint32 TimeoutTicks;
- uint32 IrcoscStatus;
- config_clock = config;
-
- (void)RUN_POWER_MODE_STATUS;
-
- /* Clocks cannot be configured while the chip is in other mode than RUN_MODE */
- CLOCK_DEV_ASSERT(RUN_POWER_MODE_STATUS == ((IP_SMC->PMSTAT & SMC_PMSTAT_PMSTAT_MASK) >> SMC_PMSTAT_PMSTAT_SHIFT));
-
- /* Check whether FIRC is disabled, enable it in this case. */
- if ((IP_SCG->FIRCCSR & SCG_FIRCCSR_FIRCEN_MASK) == 0U)
- {
- fircWasEnabledBeforeMcuInit = FALSE;
-
- #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
- #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
- OsIf_Trusted_Call(SetFircToResetValue_TrustedCall);
- #else
- SetFircToResetValue_TrustedCall();
- #endif
- #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
- ClockStartTimeout(&StartTime, &ElapsedTime, &TimeoutTicks, CLOCK_TIMEOUT_VALUE_US);
- /* Wait until ircosc is locked */
- do
- {
- IrcoscStatus = (((IP_SCG->FIRCCSR & SCG_FIRCCSR_FIRCVLD_MASK) >> SCG_FIRCCSR_FIRCVLD_SHIFT));
- TimeoutOccurred = ClockTimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks);
- }
- while ((IrcoscStatus == 0U) && (FALSE == TimeoutOccurred));
- if (FALSE != TimeoutOccurred)
- {
- /* Report timeout error */
- ReportClockErrors(CLOCK_IP_REPORT_TIMEOUT_ERROR, FIRC_CLK);
- }
- }
- else
- {
- fircWasEnabledBeforeMcuInit = TRUE;
- }
-
- #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
- #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
- OsIf_Trusted_Call1param(SetSimLpoclksRegister_TrustedCall,(config));
- #else
- SetSimLpoclksRegister_TrustedCall(config);
- #endif
- #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- #ifdef CLOCK_IP_ENABLE_USER_MODE_SUPPORT
- #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
- OsIf_Trusted_Call(EnableCmuGate_TrustedCall);
- #else
- EnableCmuGate_TrustedCall();
- #endif
- #endif /* CLOCK_IP_ENABLE_USER_MODE_SUPPORT */
- #endif
- }
- /**
- * @brief This function will get current configuration of FIRC.
- */
- static const Clock_Ip_IrcoscConfigType *getFircConfig(void)
- {
- uint32 i;
- const Clock_Ip_IrcoscConfigType *returnValue = NULL_PTR;
- static Clock_Ip_IrcoscConfigType fircConfiguration;
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->ircoscsCount; i++)
- {
- if (config_clock->ircoscs[i].name == FIRC_CLK)
- {
- returnValue = &config_clock->ircoscs[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = &fircConfiguration;
- fircConfiguration.name = FIRC_CLK;
- fircConfiguration.enable = (uint16)(IP_SCG->FIRCCSR & SCG_FIRCCSR_FIRCEN_MASK) >> SCG_FIRCCSR_FIRCEN_SHIFT;
- fircConfiguration.range = (uint8)(IP_SCG->FIRCCFG & SCG_FIRCCFG_RANGE_MASK) >> SCG_FIRCCFG_RANGE_SHIFT;
- fircConfiguration.regulator = (uint8)(IP_SCG->FIRCCSR & SCG_FIRCCSR_FIRCREGOFF_MASK) >> SCG_FIRCCSR_FIRCREGOFF_SHIFT;
- }
- return returnValue;
- }
- /**
- * @brief This function will get current configuration of SOSC.
- */
- static const Clock_Ip_XoscConfigType *getSoscConfig(void)
- {
- uint32 i;
- const Clock_Ip_XoscConfigType *returnValue = NULL_PTR;
- static Clock_Ip_XoscConfigType soscConfiguration;
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->xoscsCount; i++)
- {
- if (config_clock->xoscs[i].name == SOSC_CLK)
- {
- returnValue = &config_clock->xoscs[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = &soscConfiguration;
- soscConfiguration.name = SOSC_CLK;
- soscConfiguration.enable = (uint16)(IP_SCG->SOSCCSR & SCG_SOSCCSR_SOSCEN_MASK) >> SCG_SOSCCSR_SOSCEN_SHIFT;
- soscConfiguration.freq = FEATURE_CLOCK_IP_DEFAULT_SOSC_FREQUENCY;
- }
- return returnValue;
- }
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- /**
- * @brief This function will get current configuration of SPLL.
- */
- static const Clock_Ip_PllConfigType *getSpllConfig(void)
- {
- uint32 i;
- const Clock_Ip_PllConfigType *returnValue = NULL_PTR;
- static Clock_Ip_PllConfigType spllConfiguration;
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->pllsCount; i++)
- {
- if (config_clock->plls[i].name == SPLL_CLK)
- {
- returnValue = &config_clock->plls[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = &spllConfiguration;
- spllConfiguration.name = SPLL_CLK;
- spllConfiguration.enable = (uint16)(IP_SCG->SPLLCSR & SCG_SPLLCSR_SPLLEN_MASK) >> SCG_SPLLCSR_SPLLEN_SHIFT;
- spllConfiguration.predivider = (uint8)((IP_SCG->SPLLCFG & SCG_SPLLCFG_PREDIV_MASK) >> SCG_SPLLCFG_PREDIV_SHIFT);
- spllConfiguration.mulFactorDiv = (uint8)((IP_SCG->SPLLCFG & SCG_SPLLCFG_MULT_MASK) >> SCG_SPLLCFG_MULT_SHIFT);
- }
- return returnValue;
- }
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- static const Clock_Ip_CmuConfigType *getCmuFircConfig(Clock_Ip_NameType name)
- {
- uint32 i;
- const Clock_Ip_CmuConfigType *returnValue = NULL_PTR;
- static Clock_Ip_CmuConfigType cmuConfiguration;
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->cmusCount; i++)
- {
- if (config_clock->cmus[i].name == name)
- {
- returnValue = &config_clock->cmus[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = &cmuConfiguration;
- cmuConfiguration.name = FIRC_CLK;
- cmuConfiguration.enable = (cmu[0U]->GCR & CMU_FC_GCR_FCE_MASK) >> CMU_FC_GCR_FCE_SHIFT;
- }
- return returnValue;
- }
- #endif
- static const Clock_Ip_SelectorConfigType *getSelectorConfig(Clock_Ip_NameType name)
- {
- const Clock_Ip_SelectorConfigType *returnValue = NULL_PTR;
- static Clock_Ip_SelectorConfigType selectorConfigurations[3U];
- uint32 selectorConfigIndex, i;
- static const Clock_Ip_NameType clockSource[SCS_SELECTOR_HARDWARE_VALUES_NO] = {
- CLOCK_IS_OFF, /* clock name for 0 hardware value */
- SOSC_CLK, /* clock name for 1 hardware value */
- SIRC_CLK, /* clock name for 2 hardware value */
- FIRC_CLK, /* clock name for 3 hardware value */
- CLOCK_IS_OFF, /* clock name for 4 hardware value */
- CLOCK_IS_OFF, /* clock name for 5 hardware value */
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- SPLL_CLK, /* clock name for 6 hardware value */
- #else
- CLOCK_IS_OFF, /* clock name for 6 hardware value */
- #endif
- };
- switch(name)
- {
- case SCS_RUN_CLK:
- selectorConfigIndex = 0U;
- break;
- case SCS_VLPR_CLK:
- selectorConfigIndex = 1U;
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_SCS_HSRUN_CLK)
- case SCS_HSRUN_CLK:
- selectorConfigIndex = 2U;
- break;
- #endif
- default:
- selectorConfigIndex = 0U;
- break;
- }
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->selectorsCount; i++)
- {
- if (config_clock->selectors[i].name == name)
- {
- returnValue = &config_clock->selectors[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = &selectorConfigurations[selectorConfigIndex];
- selectorConfigurations[selectorConfigIndex].name = name;
- switch(name)
- {
- case SCS_RUN_CLK:
- selectorConfigurations[selectorConfigIndex].value = clockSource[(IP_SCG->RCCR & SCG_RCCR_SCS_MASK) >> SCG_RCCR_SCS_SHIFT];
- break;
- case SCS_VLPR_CLK:
- selectorConfigurations[selectorConfigIndex].value = clockSource[(IP_SCG->VCCR & SCG_VCCR_SCS_MASK) >> SCG_VCCR_SCS_SHIFT];
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_SCS_HSRUN_CLK)
- case SCS_HSRUN_CLK:
- selectorConfigurations[selectorConfigIndex].value = clockSource[(IP_SCG->HCCR & SCG_HCCR_SCS_MASK) >> SCG_HCCR_SCS_SHIFT];
- break;
- #endif
- default:
- /* Invalid clock name */
- break;
- }
- }
- return returnValue;
- }
- static const Clock_Ip_DividerConfigType *getCoreDividerConfig(Clock_Ip_NameType name)
- {
- const Clock_Ip_DividerConfigType *returnValue = NULL_PTR;
- static Clock_Ip_DividerConfigType dividerConfigurations[3U];
- uint32 dividerConfigIndex = 0U;
- uint32 i;
- switch(name)
- {
- case CORE_RUN_CLK:
- dividerConfigIndex = 0U;
- break;
- case CORE_VLPR_CLK:
- dividerConfigIndex = 1U;
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_CORE_HSRUN_CLK)
- case CORE_HSRUN_CLK:
- dividerConfigIndex = 2U;
- break;
- #endif
- default:
- /* Invalid clock name */
- break;
- }
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->dividersCount; i++)
- {
- if (config_clock->dividers[i].name == name)
- {
- returnValue = &config_clock->dividers[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = ÷rConfigurations[dividerConfigIndex];
- dividerConfigurations[dividerConfigIndex].name = name;
- switch(name)
- {
- case CORE_RUN_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->RCCR & SCG_RCCR_DIVCORE_MASK) >> SCG_RCCR_DIVCORE_SHIFT) + 1U;
- break;
- case CORE_VLPR_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->VCCR & SCG_VCCR_DIVCORE_MASK) >> SCG_VCCR_DIVCORE_SHIFT) + 1U;
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_CORE_HSRUN_CLK)
- case CORE_HSRUN_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->HCCR & SCG_HCCR_DIVCORE_MASK) >> SCG_HCCR_DIVCORE_SHIFT) + 1U;
- break;
- #endif
- default:
- /* Invalid clock name */
- break;
- }
- }
- return returnValue;
- }
- static const Clock_Ip_DividerConfigType *getBusDividerConfig(Clock_Ip_NameType name)
- {
- const Clock_Ip_DividerConfigType *returnValue = NULL_PTR;
- static Clock_Ip_DividerConfigType dividerConfigurations[3U];
- uint32 dividerConfigIndex = 0U;
- uint32 i;
- switch(name)
- {
- case BUS_RUN_CLK:
- dividerConfigIndex = 0U;
- break;
- case BUS_VLPR_CLK:
- dividerConfigIndex = 1U;
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_BUS_HSRUN_CLK)
- case BUS_HSRUN_CLK:
- dividerConfigIndex = 2U;
- break;
- #endif
- default:
- /* Invalid clock name */
- break;
- }
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->dividersCount; i++)
- {
- if (config_clock->dividers[i].name == name)
- {
- returnValue = &config_clock->dividers[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = ÷rConfigurations[dividerConfigIndex];
- dividerConfigurations[dividerConfigIndex].name = name;
- switch(name)
- {
- case BUS_RUN_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->RCCR & SCG_RCCR_DIVBUS_MASK) >> SCG_RCCR_DIVBUS_SHIFT) + 1U;
- break;
- case BUS_VLPR_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->VCCR & SCG_VCCR_DIVBUS_MASK) >> SCG_VCCR_DIVBUS_SHIFT) + 1U;
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_BUS_HSRUN_CLK)
- case BUS_HSRUN_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->HCCR & SCG_HCCR_DIVBUS_MASK) >> SCG_HCCR_DIVBUS_SHIFT) + 1U;
- break;
- #endif
- default:
- /* Invalid clock name */
- break;
- }
- }
- return returnValue;
- }
- static const Clock_Ip_DividerConfigType *getSlowDividerConfig(Clock_Ip_NameType name)
- {
- const Clock_Ip_DividerConfigType *returnValue = NULL_PTR;
- static Clock_Ip_DividerConfigType dividerConfigurations[3U];
- uint32 dividerConfigIndex = 0U;
- uint32 i;
- switch(name)
- {
- case SLOW_RUN_CLK:
- dividerConfigIndex = 0U;
- break;
- case SLOW_VLPR_CLK:
- dividerConfigIndex = 1U;
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_SLOW_HSRUN_CLK)
- case SLOW_HSRUN_CLK:
- dividerConfigIndex = 2U;
- break;
- #endif
- default:
- /* Invalid clock name */
- break;
- }
- if (config_clock != NULL_PTR)
- {
- for (i = 0U; i < config_clock->dividersCount; i++)
- {
- if (config_clock->dividers[i].name == name)
- {
- returnValue = &config_clock->dividers[i];
- break;
- }
- }
- }
- /* Element is not under mcu control */
- if (returnValue == NULL_PTR)
- {
- returnValue = ÷rConfigurations[dividerConfigIndex];
- dividerConfigurations[dividerConfigIndex].name = name;
- switch(name)
- {
- case SLOW_RUN_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->RCCR & SCG_RCCR_DIVSLOW_MASK) >> SCG_RCCR_DIVSLOW_SHIFT) + 1U;
- break;
- case SLOW_VLPR_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->VCCR & SCG_VCCR_DIVSLOW_MASK) >> SCG_VCCR_DIVSLOW_SHIFT) + 1U;
- break;
- #if defined(FEATURE_CLOCK_IP_HAS_SLOW_HSRUN_CLK)
- case SLOW_HSRUN_CLK:
- dividerConfigurations[dividerConfigIndex].value = ((IP_SCG->HCCR & SCG_HCCR_DIVSLOW_MASK) >> SCG_HCCR_DIVSLOW_SHIFT) + 1U;
- break;
- #endif
- default:
- /* Invalid clock name */
- break;
- }
- }
- return returnValue;
- }
- /* Initialize objects for clock */
- void ClockInitializeObjects(void)
- {
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- spllClock = &pllCallbacks[pllCallbackIndex[SYS_PLL]];
- #endif
- soscClock = &extOscCallbacks[xoscCallbackIndex[SYS_OSC]];
- fircClock = &intOscCallbacks[ircoscCallbackIndex[FIRCOSC]];
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK) || defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- cmuFircMonitor = &cmuCallbacks[cmuCallbackIndex[CMU]];
- #endif
- scsRunClockSelector = &selectorCallbacks[selectorCallbackIndex[SCS_RUN]];
- #if defined(FEATURE_CLOCK_IP_HAS_SCS_HSRUN_CLK)
- scsHsrunClockSelector = &selectorCallbacks[selectorCallbackIndex[SCS_HSRUN]];
- #endif
- coreRunClockDivider = ÷rCallbacks[dividerCallbackIndex[DIVCORE_RUN]];
- #if defined(FEATURE_CLOCK_IP_HAS_CORE_HSRUN_CLK)
- coreHsrunClockDivider = ÷rCallbacks[dividerCallbackIndex[DIVCORE_HSRUN]];
- #endif
-
- busRunClockDivider = ÷rCallbacks[dividerCallbackIndex[DIVBUS_RUN]];
- #if defined(FEATURE_CLOCK_IP_HAS_BUS_HSRUN_CLK)
- busHsrunClockDivider = ÷rCallbacks[dividerCallbackIndex[DIVBUS_HSRUN]];
- #endif
- slowRunClockDivider = ÷rCallbacks[dividerCallbackIndex[DIVSLOW_RUN]];
- #if defined(FEATURE_CLOCK_IP_HAS_SLOW_HSRUN_CLK)
- slowHsrunClockDivider = ÷rCallbacks[dividerCallbackIndex[DIVSLOW_HSRUN]];
- #endif
- fircConfig = getFircConfig();
- soscConfig = getSoscConfig();
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- spllConfig = getSpllConfig();
- #endif
-
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK)
- cmuFircMon1Config = getCmuFircConfig(FIRC_MON1_CLK);
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- cmuFircMon2Config = getCmuFircConfig(FIRC_MON2_CLK);
- #endif
- scsConfig_Run_Mode = getSelectorConfig(SCS_RUN_CLK);
- scsConfig_Vlpr_Mode = getSelectorConfig(SCS_VLPR_CLK);
- #if defined(FEATURE_CLOCK_IP_HAS_SCS_HSRUN_CLK)
- scsConfig_Hsrun_Mode = getSelectorConfig(SCS_HSRUN_CLK);
- #endif
- coreConfig_Run_Mode = getCoreDividerConfig(CORE_RUN_CLK);
- coreConfig_Vlpr_Mode = getCoreDividerConfig(CORE_VLPR_CLK);
- #if defined(FEATURE_CLOCK_IP_HAS_CORE_HSRUN_CLK)
- coreConfig_Hsrun_Mode = getCoreDividerConfig(CORE_HSRUN_CLK);
- #endif
- busConfig_Run_Mode = getBusDividerConfig(BUS_RUN_CLK);
- busConfig_Vlpr_Mode = getBusDividerConfig(BUS_VLPR_CLK);
- #if defined(FEATURE_CLOCK_IP_HAS_BUS_HSRUN_CLK)
- busConfig_Hsrun_Mode = getBusDividerConfig(BUS_HSRUN_CLK);
- #endif
- slowConfig_Run_Mode = getSlowDividerConfig(SLOW_RUN_CLK);
- slowConfig_Vlpr_Mode = getSlowDividerConfig(SLOW_VLPR_CLK);
- #if defined(FEATURE_CLOCK_IP_HAS_SLOW_HSRUN_CLK)
- slowConfig_Hsrun_Mode = getSlowDividerConfig(SLOW_HSRUN_CLK);
- #endif
- }
- void ClockPowerModeChangeNotification(power_modes_t powerMode, power_notification_t notification)
- {
- switch(powerMode)
- {
- case VLPR_MODE:
- case VLPS_MODE:
- {
- if(BEFORE_POWER_MODE_CHANGE == notification)
- {
- /* Disable all cmus */
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK)
- /* Check enable clock gate for CMU0 */
- if(((IP_PCC->PCCn[62] & PCC_PCCn_CGC_MASK) >> PCC_PCCn_CGC_SHIFT) == 1U)
- {
- cmuFircMonitor->Disable(FIRC_MON1_CLK);
- }
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- /* Check enable clock gate for CMU1 */
- if(((IP_PCC->PCCn[63] & PCC_PCCn_CGC_MASK) >> PCC_PCCn_CGC_SHIFT) == 1U)
- {
- cmuFircMonitor->Disable(FIRC_MON2_CLK);
- }
- #endif
- /* Load system clock settings for VLPR mode */
- scsRunClockSelector->Set(scsConfig_Vlpr_Mode);
- coreRunClockDivider->Set(coreConfig_Vlpr_Mode);
- busRunClockDivider->Set(busConfig_Vlpr_Mode);
- slowRunClockDivider->Set(slowConfig_Vlpr_Mode);
- /* Disable all clock sources except SIRC */
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- spllClock->Disable(spllConfig->name);
- #endif
- soscClock->Disable(soscConfig->name);
- fircClock->Disable(fircConfig->name);
- }
- }
- break;
- case RUN_MODE:
- {
- if(POWER_MODE_CHANGED == notification)
- {
- /* Restore clock source settings */
- fircClock->Enable(fircConfig);
- soscClock->Enable(soscConfig); /* Enable */
- soscClock->Complete(soscConfig); /* Wait to lock */
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- spllClock->Enable(spllConfig); /* Enable */
- (void)(spllClock->Complete(spllConfig->name)); /* Wait to lock */
- #endif
- /* Restore system clock settings */
- scsRunClockSelector->Set(scsConfig_Run_Mode);
- coreRunClockDivider->Set(coreConfig_Run_Mode);
- busRunClockDivider->Set(busConfig_Run_Mode);
- slowRunClockDivider->Set(slowConfig_Run_Mode);
- /* Restore all cmus */
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK)
- /* Check enable clock gate for CMU0 */
- if(((IP_PCC->PCCn[62] & PCC_PCCn_CGC_MASK) >> PCC_PCCn_CGC_SHIFT) == 1U)
- {
- cmuFircMonitor->Enable(cmuFircMon1Config);
- }
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- /* Check enable clock gate for CMU1 */
- if(((IP_PCC->PCCn[63] & PCC_PCCn_CGC_MASK) >> PCC_PCCn_CGC_SHIFT) == 1U)
- {
- cmuFircMonitor->Enable(cmuFircMon2Config);
- }
- #endif
- }
- }
- break;
- case HSRUN_MODE:
- {
- if(POWER_MODE_CHANGED == notification)
- {
- /* Restore clock source settings */
- fircClock->Enable(fircConfig);
- soscClock->Enable(soscConfig); /* Enable */
- soscClock->Complete(soscConfig); /* Wait to lock */
- #if defined(FEATURE_CLOCK_IP_HAS_SPLL_CLK)
- spllClock->Enable(spllConfig); /* Enable */
- (void)(spllClock->Complete(spllConfig->name)); /* Wait to lock */
- #endif
- /* Restore system clock settings */
- #if defined(FEATURE_CLOCK_IP_HAS_SCS_HSRUN_CLK)
- scsHsrunClockSelector->Set(scsConfig_Hsrun_Mode);
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_CORE_HSRUN_CLK)
- coreHsrunClockDivider->Set(coreConfig_Hsrun_Mode);
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_BUS_HSRUN_CLK)
- busHsrunClockDivider->Set(busConfig_Hsrun_Mode);
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_SLOW_HSRUN_CLK)
- slowHsrunClockDivider->Set(slowConfig_Hsrun_Mode);
- #endif
- /* Restore all cmus */
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON1_CLK)
- /* Check enable clock gate for CMU0 */
- if(((IP_PCC->PCCn[62] & PCC_PCCn_CGC_MASK) >> PCC_PCCn_CGC_SHIFT) == 1U)
- {
- cmuFircMonitor->Enable(cmuFircMon1Config);
- }
- #endif
- #if defined(FEATURE_CLOCK_IP_HAS_FIRC_MON2_CLK)
- /* Check enable clock gate for CMU1 */
- if(((IP_PCC->PCCn[63] & PCC_PCCn_CGC_MASK) >> PCC_PCCn_CGC_SHIFT) == 1U)
- {
- cmuFircMonitor->Enable(cmuFircMon2Config);
- }
- #endif
- }
- }
- break;
- default:
- {
- /* Invalid power mode */
- }
- break;
- }
- }
- /* Clock stop section code */
- #define MCU_STOP_SEC_CODE
- #include "Mcu_MemMap.h"
- #ifdef FEATURE_CLOCK_IP_HAS_RAM_WAIT_STATES
- /* Clock start rom section code */
- #define MCU_START_SEC_CODE_AC
- #include "Mcu_MemMap.h"
- static void PRAMC_SetRamIWS(void)
- {
- /* CORE_CLK frequency is greater than 80MHz or CORE_CLK and AIPS_PLAT_CLK have the same frequency */
- if ((configuredCoreClock > 80000000U) || (configuredCoreClock == configuredAipsPlatClock))
- {
- /* Enable RAM WS */
- PRAMC_0->PRCR1 |= PRAMC_PRCR1_FT_DIS_MASK;
- PRAMC_1->PRCR1 |= PRAMC_PRCR1_FT_DIS_MASK;
- }
- else
- {
- /* Disable RAM WS */
- PRAMC_0->PRCR1 &= ~PRAMC_PRCR1_FT_DIS_MASK;
- PRAMC_1->PRCR1 &= ~PRAMC_PRCR1_FT_DIS_MASK;
- }
- }
- /* Clock stop rom section code */
- #define MCU_STOP_SEC_CODE_AC
- #include "Mcu_MemMap.h"
- #endif
- #ifdef FEATURE_CLOCK_IP_HAS_FLASH_WAIT_STATES
- /* Clock start ram section code */
- #define MCU_START_SEC_RAMCODE
- #include "Mcu_MemMap.h"
- static void CodeInRam_SetFlashWaitStates(void)
- {
- uint32 rwsc_setting = 0U;
- if (configuredCoreClock <= 167000000U)
- {
- if (configuredCoreClock <= 66000000U)
- {
- rwsc_setting = 1U;
- }
- else if (configuredCoreClock <= 100000000U)
- {
- rwsc_setting = 2U;
- }
- else if (configuredCoreClock <= 133000000U)
- {
- rwsc_setting = 3U;
- }
- else
- {
- rwsc_setting = 4U;
- }
- }
- else
- {
- if (configuredCoreClock <= 200000000U)
- {
- rwsc_setting = 5U;
- }
- else if (configuredCoreClock <= 233000000U)
- {
- rwsc_setting = 6U;
- }
- else if (configuredCoreClock <= 250000000U)
- {
- rwsc_setting = 7U;
- }
- else
- {
- rwsc_setting = 7U;
- }
- }
- FLASH->CTL &= ~FLASH_CTL_RWSL_MASK;
- FLASH->CTL &= ~FLASH_CTL_RWSC_MASK;
- FLASH->CTL |= FLASH_CTL_RWSC(rwsc_setting);
- }
- /* Clock stop ram section code */
- #define MCU_STOP_SEC_RAMCODE
- #include "Mcu_MemMap.h"
- /* Clock start initialized section data */
- #define MCU_START_SEC_VAR_INIT_UNSPECIFIED
- #include "Mcu_MemMap.h"
- typedef void (*SetFlashWaitStatesCallbackType)(void);
- SetFlashWaitStatesCallbackType SetFlashWaitStatesCallback = CodeInRam_SetFlashWaitStates; /* Set Flash Wait States callback */
- /* Clock stop initialized section data */
- #define MCU_STOP_SEC_VAR_INIT_UNSPECIFIED
- #include "Mcu_MemMap.h"
- /* Clock start section code */
- #define MCU_START_SEC_CODE
- #include "Mcu_MemMap.h"
- void FLASH_SetFlashIWS(void)
- {
- SetFlashWaitStatesCallback();
- }
- /* Clock stop section code */
- #define MCU_STOP_SEC_CODE
- #include "Mcu_MemMap.h"
- #endif
- /*! @}*/
- /*******************************************************************************
- * EOF
- ******************************************************************************/
|