Add KBOOT.
This commit is contained in:
59
apps/flash_driver_api/MKL03Z4/src/application_common.h
Normal file
59
apps/flash_driver_api/MKL03Z4/src/application_common.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Freescale Semiconductor, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __APPLICATION_COMMON_H__
|
||||
#define __APPLICATION_COMMON_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "application_config.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Prototypes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! @brief Initialize the hardware such as pinmux.
|
||||
void init_hardware(void);
|
||||
|
||||
void init_term_uart(void);
|
||||
|
||||
//! @brief Returns the value in MHz of the UART clock based on the instance.
|
||||
uint32_t get_uart_clock(uint32_t instance);
|
||||
|
||||
#endif // __APPLICATION_COMMON_H__
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// EOF
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
65
apps/flash_driver_api/MKL03Z4/src/application_config.h
Normal file
65
apps/flash_driver_api/MKL03Z4/src/application_config.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Freescale Semiconductor, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __APPLICATION_CONFIG_H__
|
||||
#define __APPLICATION_CONFIG_H__
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Serial Port Info */
|
||||
|
||||
/**************************************************************************
|
||||
* Note:
|
||||
*
|
||||
* Because of the changes to the UART modules, we can no longer define
|
||||
* the TERM_PORT as a base pointer. The uart functions have been modified
|
||||
* accommodate this change. Now, TERM_PORT_NUM must be defined as the
|
||||
* number of the UART port desired to use
|
||||
*
|
||||
* TERM_PORT_NUM = 0 -- This allows you to use UART0; default pins are
|
||||
* PTA14 and PTA15
|
||||
*
|
||||
* TERM_PORT_NUM = 1 -- This allows you to use UART1; default pins are
|
||||
* PTC3 and PTC4
|
||||
*
|
||||
* TERM_PORT_NUM = 2 -- This allows you to use UART2; default pins are
|
||||
* PTD2 and PTD3
|
||||
*
|
||||
*************************************************************************/
|
||||
#define TERM_PORT_NUM 0
|
||||
|
||||
#define TERMINAL_BAUD 19200
|
||||
#undef HW_FLOW_CONTROL
|
||||
|
||||
#endif // __APPLICATION_CONFIG_H__
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// EOF
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
98
apps/flash_driver_api/MKL03Z4/src/hardware_init_MKL03Z4.c
Normal file
98
apps/flash_driver_api/MKL03Z4/src/hardware_init_MKL03Z4.c
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Freescale Semiconductor, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "application_common.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "lpuart/fsl_lpuart.h"
|
||||
#include "target_config.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Variables
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Code
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void init_hardware(void)
|
||||
{
|
||||
// Enable clocks to ports.
|
||||
SIM->SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK);
|
||||
|
||||
// Select the MCGIRCLK as UART0 clock source.
|
||||
SIM->SOPT2 |= SIM_SOPT2_LPUART0SRC_MASK;
|
||||
|
||||
// Update SystemCoreClock. Out of reset, the LIRC is enabled. FOPT bits set the OUTDIV1 value.
|
||||
uint32_t lirc = (((MCG->C2 & MCG_C2_IRCS_MASK) >> MCG_C2_IRCS_SHIFT) == 1) ? kLIRC8M : kLIRC2M;
|
||||
SystemCoreClock = lirc / (((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV1_MASK) >> SIM_CLKDIV1_OUTDIV1_SHIFT) + 1);
|
||||
}
|
||||
|
||||
uint32_t get_uart_clock(uint32_t instance)
|
||||
{
|
||||
uint32_t lirc = (((MCG->C2 & MCG_C2_IRCS_MASK) >> MCG_C2_IRCS_SHIFT) == 1) ? kLIRC8M : kLIRC2M;
|
||||
return lirc >> ((MCG->SC & MCG_SC_FCRDIV_MASK) >> MCG_SC_FCRDIV_SHIFT);
|
||||
}
|
||||
|
||||
void init_term_uart(void)
|
||||
{
|
||||
// Init pin mux for term uart.
|
||||
PORTB->PCR[2] = PORT_PCR_MUX(2); // UART0_RX is ALT2 for pin PTB2
|
||||
PORTB->PCR[1] = PORT_PCR_MUX(2); // UART0_TX is ALT2 for pin PTB1
|
||||
|
||||
// Ungate the LPUART clock.
|
||||
SIM->SCGC5 |= SIM_SCGC5_LPUART0_MASK;
|
||||
|
||||
lpuart_config_t lpuartCfg;
|
||||
LPUART_GetDefaultConfig(&lpuartCfg);
|
||||
|
||||
lpuartCfg.baudRate_Bps = TERMINAL_BAUD;
|
||||
lpuartCfg.enableTx = true;
|
||||
lpuartCfg.parityMode = kLPUART_ParityDisabled;
|
||||
lpuartCfg.stopBitCount = kLPUART_OneStopBit;
|
||||
|
||||
LPUART_Init(LPUART0, &lpuartCfg, get_uart_clock(0));
|
||||
}
|
||||
|
||||
int fputc(int ch, FILE *fp)
|
||||
{
|
||||
LPUART_WriteBlocking(LPUART0, (const uint8_t *)&ch, 1);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// EOF
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
251
apps/flash_driver_api/MKL03Z4/src/startup/iar/startup_MKL03Z4.s
Normal file
251
apps/flash_driver_api/MKL03Z4/src/startup/iar/startup_MKL03Z4.s
Normal file
@@ -0,0 +1,251 @@
|
||||
; ---------------------------------------------------------------------------------------
|
||||
; @file: startup_MKL03Z4.s
|
||||
; @purpose: CMSIS Cortex-M0P Core Device Startup File
|
||||
; MKL03Z4
|
||||
; @version: 1.4
|
||||
; @date: 2014-8-28
|
||||
; @build: b150126
|
||||
; ---------------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 1997 - 2015 , Freescale Semiconductor, Inc.
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without modification,
|
||||
; are permitted provided that the following conditions are met:
|
||||
;
|
||||
; o Redistributions of source code must retain the above copyright notice, this list
|
||||
; of conditions and the following disclaimer.
|
||||
;
|
||||
; o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
; list of conditions and the following disclaimer in the documentation and/or
|
||||
; other materials provided with the distribution.
|
||||
;
|
||||
; o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
; contributors may be used to endorse or promote products derived from this
|
||||
; software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
; ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;
|
||||
; The modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; The vector table is normally located at address 0.
|
||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||
; The name "__vector_table" has special meaning for C-SPY:
|
||||
; it is where the SP start value is found, and the NVIC vector
|
||||
; table register (VTOR) is initialized to this address if != 0.
|
||||
;
|
||||
; Cortex-M version
|
||||
;
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
EXTERN init_data_bss
|
||||
PUBLIC __vector_table
|
||||
PUBLIC __vector_table_0x1c
|
||||
PUBLIC __Vectors
|
||||
PUBLIC __Vectors_End
|
||||
PUBLIC __Vectors_Size
|
||||
|
||||
DATA
|
||||
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler
|
||||
|
||||
DCD NMI_Handler ;NMI Handler
|
||||
DCD HardFault_Handler ;Hard Fault Handler
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
__vector_table_0x1c
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD SVC_Handler ;SVCall Handler
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD PendSV_Handler ;PendSV Handler
|
||||
DCD SysTick_Handler ;SysTick Handler
|
||||
|
||||
;External Interrupts
|
||||
DCD Reserved16_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved17_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved18_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved19_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved20_IRQHandler ;Reserved interrupt
|
||||
DCD FTFA_IRQHandler ;Command complete and read collision
|
||||
DCD PMC_IRQHandler ;Low-voltage detect, low-voltage warning
|
||||
DCD LLWU_IRQHandler ;Low leakage wakeup
|
||||
DCD I2C0_IRQHandler ;I2C0 interrupt
|
||||
DCD Reserved25_IRQHandler ;Reserved interrupt
|
||||
DCD SPI0_IRQHandler ;SPI0 single interrupt vector for all sources
|
||||
DCD Reserved27_IRQHandler ;Reserved interrupt
|
||||
DCD LPUART0_IRQHandler ;LPUART0 status and error
|
||||
DCD Reserved29_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved30_IRQHandler ;Reserved interrupt
|
||||
DCD ADC0_IRQHandler ;ADC0 interrupt
|
||||
DCD CMP0_IRQHandler ;CMP0 interrupt
|
||||
DCD TPM0_IRQHandler ;TPM0 single interrupt vector for all sources
|
||||
DCD TPM1_IRQHandler ;TPM1 single interrupt vector for all sources
|
||||
DCD Reserved35_IRQHandler ;Reserved interrupt
|
||||
DCD RTC_IRQHandler ;RTC alarm
|
||||
DCD RTC_Seconds_IRQHandler ;RTC seconds
|
||||
DCD Reserved38_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved39_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved40_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved41_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved42_IRQHandler ;Reserved interrupt
|
||||
DCD Reserved43_IRQHandler ;Reserved interrupt
|
||||
DCD LPTMR0_IRQHandler ;LPTMR0 interrupt
|
||||
DCD Reserved45_IRQHandler ;Reserved interrupt
|
||||
DCD PORTA_IRQHandler ;PORTA Pin detect
|
||||
DCD PORTB_IRQHandler ;PORTB Pin detect
|
||||
__Vectors_End
|
||||
|
||||
SECTION FlashConfig:CODE
|
||||
__FlashConfig
|
||||
DCD 0xFFFFFFFF
|
||||
DCD 0xFFFFFFFF
|
||||
DCD 0xFFFFFFFF
|
||||
DCD 0xFFFF3DFE
|
||||
__FlashConfig_End
|
||||
|
||||
__Vectors EQU __vector_table
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Default interrupt handlers.
|
||||
;;
|
||||
THUMB
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||
Reset_Handler
|
||||
CPSID I ; Mask interrupts
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =init_data_bss
|
||||
BLX R0
|
||||
CPSIE I ; Unmask interrupts
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
NMI_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SVC_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK Reserved16_IRQHandler
|
||||
PUBWEAK Reserved17_IRQHandler
|
||||
PUBWEAK Reserved18_IRQHandler
|
||||
PUBWEAK Reserved19_IRQHandler
|
||||
PUBWEAK Reserved20_IRQHandler
|
||||
PUBWEAK FTFA_IRQHandler
|
||||
PUBWEAK PMC_IRQHandler
|
||||
PUBWEAK LLWU_IRQHandler
|
||||
PUBWEAK I2C0_IRQHandler
|
||||
PUBWEAK Reserved25_IRQHandler
|
||||
PUBWEAK SPI0_IRQHandler
|
||||
PUBWEAK Reserved27_IRQHandler
|
||||
PUBWEAK LPUART0_IRQHandler
|
||||
PUBWEAK Reserved29_IRQHandler
|
||||
PUBWEAK Reserved30_IRQHandler
|
||||
PUBWEAK ADC0_IRQHandler
|
||||
PUBWEAK CMP0_IRQHandler
|
||||
PUBWEAK TPM0_IRQHandler
|
||||
PUBWEAK TPM1_IRQHandler
|
||||
PUBWEAK Reserved35_IRQHandler
|
||||
PUBWEAK RTC_IRQHandler
|
||||
PUBWEAK RTC_Seconds_IRQHandler
|
||||
PUBWEAK Reserved38_IRQHandler
|
||||
PUBWEAK Reserved39_IRQHandler
|
||||
PUBWEAK Reserved40_IRQHandler
|
||||
PUBWEAK Reserved41_IRQHandler
|
||||
PUBWEAK Reserved42_IRQHandler
|
||||
PUBWEAK Reserved43_IRQHandler
|
||||
PUBWEAK LPTMR0_IRQHandler
|
||||
PUBWEAK Reserved45_IRQHandler
|
||||
PUBWEAK PORTA_IRQHandler
|
||||
PUBWEAK PORTB_IRQHandler
|
||||
PUBWEAK DefaultISR
|
||||
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||
Reserved16_IRQHandler
|
||||
Reserved17_IRQHandler
|
||||
Reserved18_IRQHandler
|
||||
Reserved19_IRQHandler
|
||||
Reserved20_IRQHandler
|
||||
FTFA_IRQHandler
|
||||
PMC_IRQHandler
|
||||
LLWU_IRQHandler
|
||||
I2C0_IRQHandler
|
||||
Reserved25_IRQHandler
|
||||
SPI0_IRQHandler
|
||||
Reserved27_IRQHandler
|
||||
LPUART0_IRQHandler
|
||||
Reserved29_IRQHandler
|
||||
Reserved30_IRQHandler
|
||||
ADC0_IRQHandler
|
||||
CMP0_IRQHandler
|
||||
TPM0_IRQHandler
|
||||
TPM1_IRQHandler
|
||||
Reserved35_IRQHandler
|
||||
RTC_IRQHandler
|
||||
RTC_Seconds_IRQHandler
|
||||
Reserved38_IRQHandler
|
||||
Reserved39_IRQHandler
|
||||
Reserved40_IRQHandler
|
||||
Reserved41_IRQHandler
|
||||
Reserved42_IRQHandler
|
||||
Reserved43_IRQHandler
|
||||
LPTMR0_IRQHandler
|
||||
Reserved45_IRQHandler
|
||||
PORTA_IRQHandler
|
||||
PORTB_IRQHandler
|
||||
DefaultISR
|
||||
LDR R0, =DefaultISR
|
||||
BX R0
|
||||
|
||||
END
|
||||
227
apps/flash_driver_api/MKL03Z4/src/startup/system_MKL03Z4.c
Normal file
227
apps/flash_driver_api/MKL03Z4/src/startup/system_MKL03Z4.c
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: MKL03Z32CAF4
|
||||
** MKL03Z32VFG4
|
||||
** MKL03Z16VFG4
|
||||
** MKL03Z8VFG4
|
||||
** MKL03Z32VFK4
|
||||
** MKL03Z16VFK4
|
||||
** MKL03Z8VFK4
|
||||
**
|
||||
** Compilers: Keil ARM C/C++ Compiler
|
||||
** Freescale C/C++ for Embedded ARM
|
||||
** GNU C Compiler
|
||||
** GNU C Compiler - CodeSourcery Sourcery G++
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
**
|
||||
** Reference manual: KL03P24M48SF0RM, Rev 2, Apr 2014
|
||||
** Version: rev. 1.4, 2014-08-28
|
||||
** Build: b141218
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright (c) 2014 Freescale Semiconductor, Inc.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2013-12-11)
|
||||
** Initial version.
|
||||
** - rev. 1.1 (2014-04-16)
|
||||
** Update of the I2C module (SMBUS feature).
|
||||
** Update of the MCG_Light module.
|
||||
** Added register file system (RFSYS).
|
||||
** - rev. 1.2 (2014-04-30)
|
||||
** PEx compatibility macros has been added.
|
||||
** - rev. 1.3 (2014-06-27)
|
||||
** I2C_S1 register was renamed.
|
||||
** GPIO - Modules PTA,PTB renamed to GPIOA,GPIOB.
|
||||
** - rev. 1.4 (2014-08-28)
|
||||
** Update of system files - default clock configuration changed.
|
||||
** Update of startup files - possibility to override DefaultISR added.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file MKL03Z4
|
||||
* @version 1.4
|
||||
* @date 2014-08-28
|
||||
* @brief Device specific configuration file for MKL03Z4 (implementation file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "system_MKL03Z4.h"
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Core clock
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInit()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
#if (ACK_ISOLATION)
|
||||
if (PMC->REGSC & PMC_REGSC_ACKISO_MASK)
|
||||
{
|
||||
PMC->REGSC |= PMC_REGSC_ACKISO_MASK; /* VLLSx recovery */
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (DISABLE_WDOG)
|
||||
/* SIM->COPC: ?=0,COPCLKSEL=0,COPDBGEN=0,COPSTPEN=0,COPT=0,COPCLKS=0,COPW=0 */
|
||||
SIM->COPC = (uint32_t)0x00u;
|
||||
#endif /* (DISABLE_WDOG) */
|
||||
#ifdef CLOCK_SETUP
|
||||
/* Power mode protection initialization */
|
||||
#ifdef SYSTEM_SMC_PMPROT_VALUE
|
||||
SMC->PMPROT = SYSTEM_SMC_PMPROT_VALUE;
|
||||
#endif
|
||||
|
||||
/* System clock initialization */
|
||||
|
||||
/* Set system prescalers and clock sources */
|
||||
SIM->CLKDIV1 = SYSTEM_SIM_CLKDIV1_VALUE; /* Set system prescalers */
|
||||
SIM->SOPT1 = ((SIM->SOPT1) & (uint32_t)(~(SIM_SOPT1_OSC32KSEL_MASK))) |
|
||||
((SYSTEM_SIM_SOPT1_VALUE) & (SIM_SOPT1_OSC32KSEL_MASK)); /* Set 32 kHz clock source (ERCLK32K) */
|
||||
SIM->SOPT2 = ((SIM->SOPT2) & (uint32_t)(~(SIM_SOPT2_TPMSRC_MASK | SIM_SOPT2_LPUART0SRC_MASK))) |
|
||||
((SYSTEM_SIM_SOPT2_VALUE) &
|
||||
(SIM_SOPT2_TPMSRC_MASK | SIM_SOPT2_LPUART0SRC_MASK)); /* Select TPM and LPUART0 clock sources. */
|
||||
#if (MCG_MODE == MCG_MODE_LIRC_2M || MCG_MODE == MCG_MODE_LIRC_8M || MCG_MODE == MCG_MODE_HIRC)
|
||||
/* Set MCG and OSC */
|
||||
#if (((OSC_CR_VALUE)&OSC_CR_ERCLKEN_MASK) != 0x00U)
|
||||
/* SIM_SCGC5: PORTA=1 */
|
||||
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;
|
||||
/* PORTA_PCR3: ISF=0,MUX=0 */
|
||||
PORTA_PCR3 &= (uint32_t) ~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
|
||||
if (((MCG_C2_VALUE)&MCG_C2_EREFS0_MASK) != 0x00U)
|
||||
{
|
||||
PORTA_PCR4 &= (uint32_t) ~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
|
||||
}
|
||||
#endif
|
||||
MCG->SC = MCG_SC_VALUE; /* Set SC (internal reference clock divider) */
|
||||
MCG->MC = MCG_MC_VALUE; /* Set MC (high-frequency IRC enable, second LIRC divider) */
|
||||
MCG->C1 = MCG_C1_VALUE; /* Set C1 (clock source selection, int. reference enable etc.) */
|
||||
MCG->C2 = MCG_C2_VALUE; /* Set C2 (ext. and int. reference clock selection) */
|
||||
OSC->CR = OSC_CR_VALUE; /* Set OSC_CR (OSCERCLK enable, oscillator capacitor load) */
|
||||
|
||||
#else /* MCG_MODE */
|
||||
/* Set MCG and OSC */
|
||||
/* SIM_SCGC5: PORTA=1 */
|
||||
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;
|
||||
/* PORTA_PCR3: ISF=0,MUX=0 */
|
||||
PORTA_PCR3 &= (uint32_t) ~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
|
||||
if (((MCG_C2_VALUE)&MCG_C2_EREFS0_MASK) != 0x00U)
|
||||
{
|
||||
PORTA_PCR4 &= (uint32_t) ~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
|
||||
}
|
||||
MCG->SC = MCG_SC_VALUE; /* Set SC (internal reference clock divider) */
|
||||
MCG->C2 = MCG_C2_VALUE; /* Set C2 (ext. and int. reference clock selection) */
|
||||
OSC->CR = OSC_CR_VALUE; /* Set OSC_CR (OSCERCLK enable, oscillator capacitor load) */
|
||||
MCG->C1 = MCG_C1_VALUE; /* Set C1 (clock source selection, int. reference enable etc.) */
|
||||
MCG->MC = MCG_MC_VALUE; /* Set MC (high-frequency IRC enable, second LIRC divider) */
|
||||
if (((MCG_C2_VALUE)&MCG_C2_EREFS0_MASK) != 0U)
|
||||
{
|
||||
while ((MCG->S & MCG_S_OSCINIT0_MASK) == 0x00U)
|
||||
{ /* Check that the oscillator is running */
|
||||
}
|
||||
}
|
||||
#endif /* MCG_MODE */
|
||||
|
||||
/* Common for all MCG modes */
|
||||
|
||||
#if (MCG_MODE == MCG_MODE_HIRC)
|
||||
while ((MCG->S & MCG_S_CLKST_MASK) != 0x00U)
|
||||
{ /* Wait until high internal reference clock is selected as MCG_Lite output */
|
||||
}
|
||||
#elif(MCG_MODE == MCG_MODE_LIRC_2M || MCG_MODE == MCG_MODE_LIRC_8M)
|
||||
while ((MCG->S & MCG_S_CLKST_MASK) != 0x04U)
|
||||
{ /* Wait until low internal reference clock is selected as MCG_Lite output */
|
||||
}
|
||||
#elif(MCG_MODE == MCG_MODE_EXT)
|
||||
while ((MCG->S & MCG_S_CLKST_MASK) != 0x08U)
|
||||
{ /* Wait until external reference clock is selected as MCG_Lite output */
|
||||
}
|
||||
#endif
|
||||
if (((SMC_PMCTRL_VALUE)&SMC_PMCTRL_RUNM_MASK) == SMC_PMCTRL_RUNM(0x02U))
|
||||
{
|
||||
SMC->PMCTRL = (uint8_t)((SMC_PMCTRL_VALUE) & (SMC_PMCTRL_RUNM_MASK)); /* Enable VLPR mode */
|
||||
while (SMC->PMSTAT != 0x04U)
|
||||
{ /* Wait until the system is in VLPR mode */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemCoreClockUpdate()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
uint32_t MCGOUTClock; /* Variable to store output clock frequency of the MCG module */
|
||||
uint16_t Divider;
|
||||
|
||||
if ((MCG->S & MCG_S_CLKST_MASK) == 0x00U)
|
||||
{
|
||||
/* High internal reference clock is selected */
|
||||
MCGOUTClock = CPU_INT_FAST_CLK_HZ; /* Fast internal reference clock selected */
|
||||
}
|
||||
else if ((MCG->S & MCG_S_CLKST_MASK) == 0x04U)
|
||||
{
|
||||
/* Internal reference clock is selected */
|
||||
Divider = (uint16_t)(0x01LU << ((MCG->SC & MCG_SC_FCRDIV_MASK) >> MCG_SC_FCRDIV_SHIFT));
|
||||
MCGOUTClock = (uint32_t)(CPU_INT_SLOW_CLK_HZ / Divider); /* Slow internal reference clock 8MHz selected */
|
||||
}
|
||||
else if ((MCG->S & MCG_S_CLKST_MASK) == 0x08U)
|
||||
{
|
||||
/* External reference clock is selected */
|
||||
MCGOUTClock = CPU_XTAL_CLK_HZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Reserved value */
|
||||
return;
|
||||
} /* (!((MCG->S & MCG_S_CLKST_MASK) == 0x08U)) */
|
||||
SystemCoreClock =
|
||||
(MCGOUTClock / (0x01U + ((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV1_MASK) >> SIM_CLKDIV1_OUTDIV1_SHIFT)));
|
||||
}
|
||||
268
apps/flash_driver_api/MKL03Z4/src/startup/system_MKL03Z4.h
Normal file
268
apps/flash_driver_api/MKL03Z4/src/startup/system_MKL03Z4.h
Normal file
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: MKL03Z32CAF4
|
||||
** MKL03Z32VFG4
|
||||
** MKL03Z16VFG4
|
||||
** MKL03Z8VFG4
|
||||
** MKL03Z32VFK4
|
||||
** MKL03Z16VFK4
|
||||
** MKL03Z8VFK4
|
||||
**
|
||||
** Compilers: Keil ARM C/C++ Compiler
|
||||
** Freescale C/C++ for Embedded ARM
|
||||
** GNU C Compiler
|
||||
** GNU C Compiler - CodeSourcery Sourcery G++
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
**
|
||||
** Reference manual: KL03P24M48SF0RM, Rev 2, Apr 2014
|
||||
** Version: rev. 1.4, 2014-08-28
|
||||
** Build: b150126
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright (c) 2014 Freescale Semiconductor, Inc.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2013-12-11)
|
||||
** Initial version.
|
||||
** - rev. 1.1 (2014-04-16)
|
||||
** Update of the I2C module (SMBUS feature).
|
||||
** Update of the MCG_Light module.
|
||||
** Added register file system (RFSYS).
|
||||
** - rev. 1.2 (2014-04-30)
|
||||
** PEx compatibility macros has been added.
|
||||
** - rev. 1.3 (2014-06-27)
|
||||
** I2C_S1 register was renamed.
|
||||
** GPIO - Modules PTA,PTB renamed to GPIOA,GPIOB.
|
||||
** - rev. 1.4 (2014-08-28)
|
||||
** Update of system files - default clock configuration changed.
|
||||
** Update of startup files - possibility to override DefaultISR added.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file MKL03Z4
|
||||
* @version 1.4
|
||||
* @date 2014-08-28
|
||||
* @brief Device specific configuration file for MKL03Z4 (header file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#ifndef _SYSTEM_MKL03Z4_H_
|
||||
#define _SYSTEM_MKL03Z4_H_ /**< Symbol preventing repeated inclusion */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef DISABLE_WDOG
|
||||
#define DISABLE_WDOG 1
|
||||
#endif
|
||||
|
||||
#define ACK_ISOLATION 1
|
||||
|
||||
/* MCG_Lite mode constants */
|
||||
|
||||
#define MCG_MODE_LIRC_8M 0U
|
||||
#define MCG_MODE_HIRC 1U
|
||||
#define MCG_MODE_LIRC_2M 2U
|
||||
#define MCG_MODE_EXT 3U
|
||||
|
||||
/* Predefined clock setups
|
||||
0 ... Multipurpose Clock Generator Lite (MCG_Lite) in Low-frequency Internal Reference Clock 8 MHz (LIRC 8 MHz) mode
|
||||
Default part configuration.
|
||||
Core clock/Bus clock derived from the internal clock source 8 MHz
|
||||
Core clock = 4MHz, BusClock = 2MHz
|
||||
1 ... Multipurpose Clock Generator Lite (MCG_Lite) in High-frequency Internal Reference Clock (HIRC) mode
|
||||
Maximum achievable clock frequency configuration using internal clock.
|
||||
Core clock/Bus clock derived from the internal clock source 48MHz
|
||||
Core clock = 48MHz, BusClock = 24MHz
|
||||
2 ... Multipurpose Clock Generator Lite (MCG_Lite) in External Oscillator (EXT) mode
|
||||
Core clock/Bus clock derived directly from the external crystal 32.768kHz
|
||||
The clock settings is ready for Very Low Power Run mode.
|
||||
Core clock = 32.768kHz, BusClock = 32.768kHz
|
||||
3 ... Multipurpose Clock Generator Lite (MCG_Lite) in Low-frequency Internal Reference Clock 2 MHz (LIRC 2 MHz) mode
|
||||
Core clock/Bus clock derived from the internal clock source 2 MHz
|
||||
The clock settings is ready for Very Low Power Run mode.
|
||||
Core clock = 2MHz, BusClock = 1MHz
|
||||
*/
|
||||
|
||||
/* Define clock source values */
|
||||
|
||||
#define CPU_XTAL_CLK_HZ 32768u /* Value of the external crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_INT_FAST_CLK_HZ 48000000u /* Value of the fast internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_IRC_CLK_HZ 48000000u /* Value of the 48M internal oscillator clock frequency in Hz */
|
||||
|
||||
/* Low power mode enable */
|
||||
/* SMC_PMPROT: AVLP=1,AVLLS=1 */
|
||||
#define SYSTEM_SMC_PMPROT_VALUE 0x22u /* SMC_PMPROT */
|
||||
|
||||
#ifdef CLOCK_SETUP
|
||||
#if (CLOCK_SETUP == 0)
|
||||
#define DEFAULT_SYSTEM_CLOCK 4000000u /* Default System clock value */
|
||||
#define CPU_INT_SLOW_CLK_HZ 8000000u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define MCG_MODE MCG_MODE_LIRC_8M /* Clock generator mode */
|
||||
/* MCG_C1: CLKS=1,IRCLKEN=1,IREFSTEN=0 */
|
||||
#define MCG_C1_VALUE 0x42u /* MCG_C1 */
|
||||
/* MCG_C2: EREFS0=0,IRCS=1 */
|
||||
#define MCG_C2_VALUE 0x01u /* MCG_C2 */
|
||||
/* MCG_SC: FCRDIV=0 */
|
||||
#define MCG_SC_VALUE 0x00u /* MCG_SC */
|
||||
/* MCG_MC: HIRCEN=0 LIRC_DIV2=0 */
|
||||
#define MCG_MC_VALUE 0x00u /* MCG_MC */
|
||||
/* OSC_CR: ERCLKEN=0,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
#define OSC_CR_VALUE 0x00u /* OSC_CR */
|
||||
/* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
|
||||
#define SMC_PMCTRL_VALUE 0x00u /* SMC_PMCTRL */
|
||||
/* SIM_CLKDIV1: OUTDIV1=1,OUTDIV4=1 */
|
||||
#define SYSTEM_SIM_CLKDIV1_VALUE 0x10010000u /* SIM_CLKDIV1 */
|
||||
/* SIM_SOPT1: OSC32KSEL=0,OSC32KOUT=0 */
|
||||
#define SYSTEM_SIM_SOPT1_VALUE 0x00000000U /* SIM_SOPT1 */
|
||||
/* SIM_SOPT2: LPUART0SRC=0,TPMSRC=3,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
|
||||
#define SYSTEM_SIM_SOPT2_VALUE 0x03000000u /* SIM_SOPT2 */
|
||||
#elif(CLOCK_SETUP == 1)
|
||||
#define DEFAULT_SYSTEM_CLOCK 48000000u /* Default System clock value */
|
||||
#define CPU_INT_SLOW_CLK_HZ 8000000u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define MCG_MODE MCG_MODE_HIRC /* Clock generator mode */
|
||||
/* MCG_C1: CLKS=0,IRCLKEN=0,IREFSTEN=0 */
|
||||
#define MCG_C1_VALUE 0x00u /* MCG_C1 */
|
||||
/* MCG_C2: EREFS0=0,IRCS=1 */
|
||||
#define MCG_C2_VALUE 0x01u /* MCG_C2 */
|
||||
/* MCG_SC: FCRDIV=0 */
|
||||
#define MCG_SC_VALUE 0x00u /* MCG_SC */
|
||||
/* MCG_MC: HIRCEN=1 LIRC_DIV2=0 */
|
||||
#define MCG_MC_VALUE 0x80u /* MCG_MC */
|
||||
/* OSC_CR: ERCLKEN=0,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
#define OSC_CR_VALUE 0x00u /* OSC_CR */
|
||||
/* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
|
||||
#define SMC_PMCTRL_VALUE 0x00u /* SMC_PMCTRL */
|
||||
/* SIM_CLKDIV1: OUTDIV1=0,OUTDIV4=1 */
|
||||
#define SYSTEM_SIM_CLKDIV1_VALUE 0x10000u /* SIM_CLKDIV1 */
|
||||
/* SIM_SOPT1: OSC32KSEL=0,OSC32KOUT=0 */
|
||||
#define SYSTEM_SIM_SOPT1_VALUE 0x00000000u /* SIM_SOPT1 */
|
||||
/* SIM_SOPT2: LPUART0SRC=0,TPMSRC=3,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
|
||||
#define SYSTEM_SIM_SOPT2_VALUE 0x03000000U /* SIM_SOPT2 */
|
||||
#elif(CLOCK_SETUP == 2)
|
||||
#define DEFAULT_SYSTEM_CLOCK 32768u /* Default System clock value */
|
||||
#define CPU_INT_SLOW_CLK_HZ 8000000u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define MCG_MODE MCG_MODE_EXT /* Clock generator mode */
|
||||
/* MCG_C1: CLKS=2,IRCLKEN=1,IREFSTEN=0 */
|
||||
#define MCG_C1_VALUE 0x82u /* MCG_C1 */
|
||||
/* MCG_C2: EREFS0=1,IRCS=1 */
|
||||
#define MCG_C2_VALUE 0x05u /* MCG_C2 */
|
||||
/* MCG_SC: FCRDIV=0 */
|
||||
#define MCG_SC_VALUE 0x00u /* MCG_SC */
|
||||
/* MCG_MC: HIRCEN=0 LIRC_DIV2=0 */
|
||||
#define MCG_MC_VALUE 0x00u /* MCG_MC */
|
||||
/* OSC_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
#define OSC_CR_VALUE 0x80u /* OSC_CR */
|
||||
/* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
|
||||
#define SMC_PMCTRL_VALUE 0x00u /* SMC_PMCTRL */
|
||||
/* SIM_CLKDIV1: OUTDIV1=0,OUTDIV4=0 */
|
||||
#define SYSTEM_SIM_CLKDIV1_VALUE 0x00u /* SIM_CLKDIV1 */
|
||||
/* SIM_SOPT1: OSC32KSEL=0,OSC32KOUT=0 */
|
||||
#define SYSTEM_SIM_SOPT1_VALUE 0x00000000u /* SIM_SOPT1 */
|
||||
/* SIM_SOPT2: LPUART0SRC=0,TPMSRC=2,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
|
||||
#define SYSTEM_SIM_SOPT2_VALUE 0x02000000u /* SIM_SOPT2 */
|
||||
#elif(CLOCK_SETUP == 3)
|
||||
#define DEFAULT_SYSTEM_CLOCK 2000000u /* Default System clock value */
|
||||
#define CPU_INT_SLOW_CLK_HZ 2000000u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define MCG_MODE MCG_MODE_LIRC_2M /* Clock generator mode */
|
||||
/* MCG_C1: CLKS=1,IRCLKEN=1,IREFSTEN=0 */
|
||||
#define MCG_C1_VALUE 0x42u /* MCG_C1 */
|
||||
/* MCG_C2: EREFS0=0,IRCS=0 */
|
||||
#define MCG_C2_VALUE 0x00u /* MCG_C2 */
|
||||
/* MCG_SC: FCRDIV=0 */
|
||||
#define MCG_SC_VALUE 0x00u /* MCG_SC */
|
||||
/* MCG_MC: HIRCEN=0 LIRC_DIV2=0 */
|
||||
#define MCG_MC_VALUE 0x00u /* MCG_MC */
|
||||
/* OSC_CR: ERCLKEN=0,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
#define OSC_CR_VALUE 0x00u /* OSC_CR */
|
||||
/* SMC_PMCTRL: RUNM=0,STOPA=0,STOPM=0 */
|
||||
#define SMC_PMCTRL_VALUE 0x00u /* SMC_PMCTRL */
|
||||
/* SIM_CLKDIV1: OUTDIV1=0,OUTDIV4=1 */
|
||||
#define SYSTEM_SIM_CLKDIV1_VALUE 0x10000u /* SIM_CLKDIV1 */
|
||||
/* SIM_SOPT1: OSC32KSEL=0,OSC32KOUT=0 */
|
||||
#define SYSTEM_SIM_SOPT1_VALUE 0x00000000U /* SIM_SOPT1 */
|
||||
/* SIM_SOPT2: LPUART0SRC=0,TPMSRC=3,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
|
||||
#define SYSTEM_SIM_SOPT2_VALUE 0x03000000u /* SIM_SOPT2 */
|
||||
#else
|
||||
#error The selected clock setup is not supported.
|
||||
#endif
|
||||
#else
|
||||
#define DEFAULT_SYSTEM_CLOCK 4000000u /* Default System clock value */
|
||||
#define CPU_INT_SLOW_CLK_HZ 8000000u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief System clock frequency (core clock)
|
||||
*
|
||||
* The system clock frequency supplied to the SysTick timer and the processor
|
||||
* core clock. This variable can be used by the user application to setup the
|
||||
* SysTick timer or configure other parameters. It may also be used by debugger to
|
||||
* query the frequency of the debug timer or configure the trace clock speed
|
||||
* SystemCoreClock is initialized with a correct predefined value.
|
||||
*/
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system.
|
||||
*
|
||||
* Typically this function configures the oscillator (PLL) that is part of the
|
||||
* microcontroller device. For systems with variable clock speed it also updates
|
||||
* the variable SystemCoreClock. SystemInit is called from startup_device file.
|
||||
*/
|
||||
void SystemInit(void);
|
||||
|
||||
/**
|
||||
* @brief Updates the SystemCoreClock variable.
|
||||
*
|
||||
* It must be called whenever the core clock is changed during program
|
||||
* execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
|
||||
* the current core clock.
|
||||
*/
|
||||
void SystemCoreClockUpdate(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #if !defined(_SYSTEM_MKL03Z4_H_) */
|
||||
56
apps/flash_driver_api/MKL03Z4/src/target_config.h
Normal file
56
apps/flash_driver_api/MKL03Z4/src/target_config.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Freescale Semiconductor, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#if !defined(__TARGET_CLOCKS_H__)
|
||||
#define __TARGET_CLOCKS_H__
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! @brief Constants for clock frequencies.
|
||||
enum _target_clocks
|
||||
{
|
||||
//! Frequency of the HIRC.
|
||||
kHIRC = 48000000,
|
||||
|
||||
//! 8MHz low frequency IRC.
|
||||
kLIRC8M = 8000000,
|
||||
|
||||
//! 2MHz low frequency IRC.
|
||||
kLIRC2M = 2000000,
|
||||
|
||||
//! The bus clock cannot go above 24MHz.
|
||||
kMaxBusClock = 24000000
|
||||
};
|
||||
|
||||
#endif // __TARGET_CLOCKS_H__
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// EOF
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Reference in New Issue
Block a user