Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ###################################################################
- ** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
- ** Filename : Cpu.c
- ** Project : ProcessorExpert
- ** Processor : MK60DN512VLQ10
- ** Component : MK60DN512LQ10
- ** Version : Component 01.000, Driver 01.04, CPU db: 3.00.000
- ** Datasheet : K60P144M100SF2V2RM Rev. 2, Jun 2012
- ** Compiler : GNU C Compiler
- ** Date/Time : 2013-06-24, 21:00, # CodeGen: 84
- ** Abstract :
- **
- ** Settings :
- **
- ** Contents :
- ** No public methods
- **
- ** Copyright : 1997 - 2013 Freescale Semiconductor, Inc. All Rights Reserved.
- ** SOURCE DISTRIBUTION PERMISSIBLE as directed in End User License Agreement.
- **
- ** http : www.freescale.com
- ** mail : support@freescale.com
- ** ###################################################################*/
- /*!
- ** @file Cpu.c
- ** @version 01.04
- ** @brief
- **
- */
- /*!
- ** @addtogroup Cpu_module Cpu module documentation
- ** @{
- */
- /* MODULE Cpu. */
- /* {Default RTOS Adapter} No RTOS includes */
- #include "AS1.h"
- #include "PE_Types.h"
- #include "PE_Error.h"
- #include "PE_Const.h"
- #include "IO_Map.h"
- #include "Events.h"
- #include "Cpu.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- /* Global variables */
- volatile uint8_t SR_reg; /* Current value of the FAULTMASK register */
- volatile uint8_t SR_lock = 0x00U; /* Lock */
- /*
- ** ===================================================================
- ** Method : Cpu_SetBASEPRI (component MK60DN512LQ10)
- **
- ** Description :
- ** This method sets the BASEPRI core register.
- ** This method is internal. It is used by Processor Expert only.
- ** ===================================================================
- */
- void Cpu_SetBASEPRI(uint32_t Level);
- /*
- ** ===================================================================
- ** Method : Cpu_INT_NMIInterrupt (component MK60DN512LQ10)
- **
- ** Description :
- ** This ISR services the Non Maskable Interrupt interrupt.
- ** This method is internal. It is used by Processor Expert only.
- ** ===================================================================
- */
- PE_ISR(Cpu_INT_NMIInterrupt)
- {
- Cpu_OnNMIINT0();
- }
- /*
- ** ===================================================================
- ** Method : Cpu_Cpu_Interrupt (component MK60DN512LQ10)
- **
- ** Description :
- ** This ISR services an unused interrupt/exception vector.
- ** This method is internal. It is used by Processor Expert only.
- ** ===================================================================
- */
- PE_ISR(Cpu_Interrupt)
- {
- /* This code can be changed using the CPU component property "Build Options / Unhandled int code" */
- PE_DEBUGHALT();
- }
- /*** !!! Here you can place your own code using property "User data declarations" on the build options tab. !!! ***/
- /*lint -esym(765,__init_hardware) Disable MISRA rule (8.10) checking for symbols (__init_hardware). The function is linked to the EWL library */
- /*lint -esym(765,Cpu_Interrupt) Disable MISRA rule (8.10) checking for symbols (Cpu_Interrupt). */
- void __init_hardware(void)
- {
- /*** !!! Here you can place your own code before PE initialization using property "User code before PE initialization" on the build options tab. !!! ***/
- /*** ### MK60DN512VLQ10 "Cpu" init code ... ***/
- /*** PE initialization code after reset ***/
- SCB_VTOR = (uint32_t)(&__vect_table); /* Set the interrupt vector table position */
- /* Disable the WDOG module */
- /* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */
- WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */
- /* WDOG_UNLOCK: WDOGUNLOCK=0xD928 */
- WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */
- /* WDOG_STCTRLH: ??=0,DISTESTWDOG=0,BYTESEL=0,TESTSEL=0,TESTWDOG=0,??=0,??=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=0,CLKSRC=1,WDOGEN=0 */
- WDOG_STCTRLH = WDOG_STCTRLH_BYTESEL(0x00) |
- WDOG_STCTRLH_WAITEN_MASK |
- WDOG_STCTRLH_STOPEN_MASK |
- WDOG_STCTRLH_ALLOWUPDATE_MASK |
- WDOG_STCTRLH_CLKSRC_MASK |
- 0x0100U;
- /* System clock initialization */
- /* SIM_SCGC5: PORTE=1,PORTA=1 */
- SIM_SCGC5 |= (SIM_SCGC5_PORTE_MASK | SIM_SCGC5_PORTA_MASK); /* Enable clock gate for ports to enable pin routing */
- /* SIM_CLKDIV1: OUTDIV1=0,OUTDIV2=1,OUTDIV3=1,OUTDIV4=3,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
- SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0x00) |
- SIM_CLKDIV1_OUTDIV2(0x01) |
- SIM_CLKDIV1_OUTDIV3(0x01) |
- SIM_CLKDIV1_OUTDIV4(0x03); /* Update system prescalers */
- /* SIM_SOPT2: PLLFLLSEL=1 */
- SIM_SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK; /* Select PLL as a clock source for various peripherals */
- /* SIM_SOPT1: OSC32KSEL=3 */
- SIM_SOPT1 |= SIM_SOPT1_OSC32KSEL(0x03); /* LPO 1kHz oscillator drives 32 kHz clock for various peripherals */
- /* PORTA_PCR18: ISF=0,MUX=0 */
- PORTA_PCR18 &= (uint32_t)~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
- /* Switch to FBE Mode */
- /* MCG_C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=0,LP=0,IRCS=0 */
- MCG_C2 = MCG_C2_RANGE0(0x02);
- /* OSC_CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
- OSC_CR = OSC_CR_ERCLKEN_MASK;
- /* MCG_C7: OSCSEL=0 */
- MCG_C7 &= (uint8_t)~(uint8_t)(MCG_C7_OSCSEL_MASK);
- /* MCG_C1: CLKS=2,FRDIV=5,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
- MCG_C1 = (MCG_C1_CLKS(0x02) | MCG_C1_FRDIV(0x05) | MCG_C1_IRCLKEN_MASK);
- /* MCG_C4: DMX32=0,DRST_DRS=0 */
- MCG_C4 &= (uint8_t)~(uint8_t)((MCG_C4_DMX32_MASK | MCG_C4_DRST_DRS(0x03)));
- /* MCG_C5: ??=0,PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=0x0F */
- MCG_C5 = MCG_C5_PRDIV0(0x0F);
- /* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=8 */
- MCG_C6 = MCG_C6_VDIV0(0x08);
- while((MCG_S & MCG_S_IREFST_MASK) != 0x00U) { /* Check that the source of the FLL reference clock is the external reference clock. */
- }
- while((MCG_S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
- }
- /* Switch to PBE Mode */
- /* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=8 */
- MCG_C6 = (MCG_C6_PLLS_MASK | MCG_C6_VDIV0(0x08));
- while((MCG_S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
- }
- while((MCG_S & MCG_S_LOCK0_MASK) == 0x00U) { /* Wait until locked */
- }
- /* Switch to PEE Mode */
- /* MCG_C1: CLKS=0,FRDIV=5,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
- MCG_C1 = (MCG_C1_CLKS(0x00) | MCG_C1_FRDIV(0x05) | MCG_C1_IRCLKEN_MASK);
- while((MCG_S & 0x0CU) != 0x0CU) { /* Wait until output of the PLL is selected */
- }
- /*** End of PE initialization code after reset ***/
- /*** !!! Here you can place your own code after PE initialization using property "User code after PE initialization" on the build options tab. !!! ***/
- }
- /*
- ** ===================================================================
- ** Method : Cpu_SetBASEPRI (component MK60DN512LQ10)
- **
- ** Description :
- ** This method sets the BASEPRI core register.
- ** This method is internal. It is used by Processor Expert only.
- ** ===================================================================
- */
- /*lint -save -e586 -e950 Disable MISRA rule (2.1,1.1) checking. */
- #ifdef _lint
- #define Cpu_SetBASEPRI(Level) /* empty */
- #else
- void Cpu_SetBASEPRI(uint32_t Level) {
- asm ("msr basepri, %[input]"::[input] "r" (Level):);
- }
- #endif
- /*lint -restore Enable MISRA rule (2.1,1.1) checking. */
- /*
- ** ===================================================================
- ** Method : PE_low_level_init (component MK60DN512LQ10)
- **
- ** Description :
- ** Initializes beans and provides common register initialization.
- ** The method is called automatically as a part of the
- ** application initialization code.
- ** This method is internal. It is used by Processor Expert only.
- ** ===================================================================
- */
- void PE_low_level_init(void)
- {
- #ifdef PEX_RTOS_INIT
- PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
- #endif
- /* Initialization of the SIM module */
- /* PORTA_PCR4: ISF=0,MUX=7 */
- PORTA_PCR4 = (uint32_t)((PORTA_PCR4 & (uint32_t)~(uint32_t)(
- PORT_PCR_ISF_MASK
- )) | (uint32_t)(
- PORT_PCR_MUX(0x07)
- ));
- /* Initialization of the RCM module */
- /* RCM_RPFW: RSTFLTSEL=0 */
- RCM_RPFW &= (uint8_t)~(uint8_t)(RCM_RPFW_RSTFLTSEL(0x1F));
- /* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
- RCM_RPFC &= (uint8_t)~(uint8_t)(
- RCM_RPFC_RSTFLTSS_MASK |
- RCM_RPFC_RSTFLTSRW(0x03)
- );
- /* Initialization of the FTFL_FlashConfig module */
- /* SIM_SCGC7: MPU=1 */
- SIM_SCGC7 |= SIM_SCGC7_MPU_MASK;
- /* Initialization of the MPU module */
- /* MPU_CESR: SPERR=0,VLD=0 */
- MPU_CESR &= (uint32_t)~(uint32_t)((MPU_CESR_SPERR(0x1F) | MPU_CESR_VLD_MASK));
- /* Initialization of the PMC module */
- /* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
- PMC_LVDSC1 = (uint8_t)((PMC_LVDSC1 & (uint8_t)~(uint8_t)(
- PMC_LVDSC1_LVDIE_MASK |
- PMC_LVDSC1_LVDV(0x03)
- )) | (uint8_t)(
- PMC_LVDSC1_LVDACK_MASK |
- PMC_LVDSC1_LVDRE_MASK
- ));
- /* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
- PMC_LVDSC2 = (uint8_t)((PMC_LVDSC2 & (uint8_t)~(uint8_t)(
- PMC_LVDSC2_LVWIE_MASK |
- PMC_LVDSC2_LVWV(0x03)
- )) | (uint8_t)(
- PMC_LVDSC2_LVWACK_MASK
- ));
- /* PMC_REGSC: BGEN=0,ACKISO=0,BGBE=0 */
- PMC_REGSC &= (uint8_t)~(uint8_t)(
- PMC_REGSC_BGEN_MASK |
- PMC_REGSC_ACKISO_MASK |
- PMC_REGSC_BGBE_MASK
- );
- /* SMC_PMPROT: ??=0,??=0,AVLP=0,??=0,ALLS=0,??=0,AVLLS=0,??=0 */
- SMC_PMPROT = 0x00U; /* Setup Power mode protection register */
- /* Common initialization of the CPU registers */
- /* NVICIP20: PRI20=0 */
- NVICIP20 = NVIC_IP_PRI20(0x00);
- /* ### Serial_LDD "AS1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
- (void)AS1_Init(NULL);
- /* Enable interrupts of the given priority level */
- Cpu_SetBASEPRI(16U);
- }
- /* Flash configuration field */
- __attribute__ ((section (".cfmconfig"))) const uint8_t _cfm[0x10] = {
- /* NV_BACKKEY3: KEY=0xFF */
- 0xFFU,
- /* NV_BACKKEY2: KEY=0xFF */
- 0xFFU,
- /* NV_BACKKEY1: KEY=0xFF */
- 0xFFU,
- /* NV_BACKKEY0: KEY=0xFF */
- 0xFFU,
- /* NV_BACKKEY7: KEY=0xFF */
- 0xFFU,
- /* NV_BACKKEY6: KEY=0xFF */
- 0xFFU,
- /* NV_BACKKEY5: KEY=0xFF */
- 0xFFU,
- /* NV_BACKKEY4: KEY=0xFF */
- 0xFFU,
- /* NV_FPROT3: PROT=0xFF */
- 0xFFU,
- /* NV_FPROT2: PROT=0xFF */
- 0xFFU,
- /* NV_FPROT1: PROT=0xFF */
- 0xFFU,
- /* NV_FPROT0: PROT=0xFF */
- 0xFFU,
- /* NV_FSEC: KEYEN=1,MEEN=3,FSLACC=3,SEC=2 */
- 0x7EU,
- /* NV_FOPT: ??=1,??=1,??=1,??=1,??=1,??=1,EZPORT_DIS=1,LPBOOT=1 */
- 0xFFU,
- /* NV_FEPROT: EPROT=0xFF */
- 0xFFU,
- /* NV_FDPROT: DPROT=0xFF */
- 0xFFU
- };
- /* END Cpu. */
- #ifdef __cplusplus
- } /* extern "C" */
- #endif
- /*!
- ** @}
- */
- /*
- ** ###################################################################
- **
- ** This file was created by Processor Expert 10.2 [05.06]
- ** for the Freescale Kinetis series of microcontrollers.
- **
- ** ###################################################################
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement