mirror of https://github.com/ARMmbed/mbed-os.git
Added CMSIS files for Freescale KL43Z ARM
parent
29fc31ec88
commit
94581919bd
|
|
@ -63,3 +63,6 @@ debug.log
|
||||||
|
|
||||||
# Orig diff files
|
# Orig diff files
|
||||||
*.orig
|
*.orig
|
||||||
|
|
||||||
|
# PyCharm project files
|
||||||
|
.idea
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
LR_IROM1 0x00000000 0x40000 { ; load region size_region (256k)
|
||||||
|
ER_IROM1 0x00000000 0x40000 { ; load address = execution address
|
||||||
|
*.o (RESET, +First)
|
||||||
|
*(InRoot$$Sections)
|
||||||
|
.ANY (+RO)
|
||||||
|
}
|
||||||
|
; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0
|
||||||
|
; 0x8000 - 0xC0 = 0x7F40
|
||||||
|
RW_IRAM1 0x1FFFE0C0 0x7F40 {
|
||||||
|
.ANY (+RW +ZI)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,362 @@
|
||||||
|
; * ---------------------------------------------------------------------------------------
|
||||||
|
; * @file: startup_MKL43Z4.s
|
||||||
|
; * @purpose: CMSIS Cortex-M0P Core Device Startup File
|
||||||
|
; * MKL43Z4
|
||||||
|
; * @version: 1.3
|
||||||
|
; * @date: 2014-8-21
|
||||||
|
; * @build: b140821
|
||||||
|
; * ---------------------------------------------------------------------------------------
|
||||||
|
; *
|
||||||
|
; * Copyright (c) 1997 - 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.
|
||||||
|
; *
|
||||||
|
; *------- <<< Use Configuration Wizard in Context Menu >>> ------------------
|
||||||
|
; *
|
||||||
|
; *****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
__initial_sp EQU 0x20006000 ; Top of RAM
|
||||||
|
|
||||||
|
PRESERVE8
|
||||||
|
THUMB
|
||||||
|
|
||||||
|
|
||||||
|
; Vector Table Mapped to Address 0 at Reset
|
||||||
|
|
||||||
|
AREA RESET, DATA, READONLY
|
||||||
|
EXPORT __Vectors
|
||||||
|
EXPORT __Vectors_End
|
||||||
|
EXPORT __Vectors_Size
|
||||||
|
|
||||||
|
__Vectors DCD __initial_sp ; Top of Stack
|
||||||
|
DCD Reset_Handler ; Reset Handler
|
||||||
|
DCD NMI_Handler ;NMI Handler
|
||||||
|
DCD HardFault_Handler ;Hard Fault Handler
|
||||||
|
DCD 0 ;Reserved
|
||||||
|
DCD 0 ;Reserved
|
||||||
|
DCD 0 ;Reserved
|
||||||
|
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 DMA0_IRQHandler ;DMA channel 0 transfer complete
|
||||||
|
DCD DMA1_IRQHandler ;DMA channel 1 transfer complete
|
||||||
|
DCD DMA2_IRQHandler ;DMA channel 2 transfer complete
|
||||||
|
DCD DMA3_IRQHandler ;DMA channel 3 transfer complete
|
||||||
|
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 I2C1_IRQHandler ;I2C1 interrupt
|
||||||
|
DCD SPI0_IRQHandler ;SPI0 single interrupt vector for all sources
|
||||||
|
DCD SPI1_IRQHandler ;SPI1 single interrupt vector for all sources
|
||||||
|
DCD LPUART0_IRQHandler ;LPUART0 status and error
|
||||||
|
DCD LPUART1_IRQHandler ;LPUART1 status and error
|
||||||
|
DCD UART2_FLEXIO_IRQHandler ;UART2 or FLEXIO
|
||||||
|
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 TPM2_IRQHandler ;TPM2 single interrupt vector for all sources
|
||||||
|
DCD RTC_IRQHandler ;RTC alarm
|
||||||
|
DCD RTC_Seconds_IRQHandler ;RTC seconds
|
||||||
|
DCD PIT_IRQHandler ;PIT interrupt
|
||||||
|
DCD I2S0_IRQHandler ;I2S0 interrupt
|
||||||
|
DCD USB0_IRQHandler ;USB0 interrupt
|
||||||
|
DCD DAC0_IRQHandler ;DAC0 interrupt
|
||||||
|
DCD Reserved42_IRQHandler ;Reserved interrupt
|
||||||
|
DCD Reserved43_IRQHandler ;Reserved interrupt
|
||||||
|
DCD LPTMR0_IRQHandler ;LPTMR0 interrupt
|
||||||
|
DCD LCD_IRQHandler ;LCD interrupt
|
||||||
|
DCD PORTA_IRQHandler ;PORTA Pin detect
|
||||||
|
DCD PORTCD_IRQHandler ;Single interrupt vector for PORTC; PORTD Pin detect
|
||||||
|
__Vectors_End
|
||||||
|
|
||||||
|
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||||
|
|
||||||
|
; <h> Flash Configuration
|
||||||
|
; <i> 16-byte flash configuration field that stores default protection settings (loaded on reset)
|
||||||
|
; <i> and security information that allows the MCU to restrict access to the FTFL module.
|
||||||
|
; <h> Backdoor Comparison Key
|
||||||
|
; <o0> Backdoor Comparison Key 0. <0x0-0xFF:2>
|
||||||
|
; <o1> Backdoor Comparison Key 1. <0x0-0xFF:2>
|
||||||
|
; <o2> Backdoor Comparison Key 2. <0x0-0xFF:2>
|
||||||
|
; <o3> Backdoor Comparison Key 3. <0x0-0xFF:2>
|
||||||
|
; <o4> Backdoor Comparison Key 4. <0x0-0xFF:2>
|
||||||
|
; <o5> Backdoor Comparison Key 5. <0x0-0xFF:2>
|
||||||
|
; <o6> Backdoor Comparison Key 6. <0x0-0xFF:2>
|
||||||
|
; <o7> Backdoor Comparison Key 7. <0x0-0xFF:2>
|
||||||
|
BackDoorK0 EQU 0xFF
|
||||||
|
BackDoorK1 EQU 0xFF
|
||||||
|
BackDoorK2 EQU 0xFF
|
||||||
|
BackDoorK3 EQU 0xFF
|
||||||
|
BackDoorK4 EQU 0xFF
|
||||||
|
BackDoorK5 EQU 0xFF
|
||||||
|
BackDoorK6 EQU 0xFF
|
||||||
|
BackDoorK7 EQU 0xFF
|
||||||
|
; </h>
|
||||||
|
; <h> Program flash protection bytes (FPROT)
|
||||||
|
; <i> Each program flash region can be protected from program and erase operation by setting the associated PROT bit.
|
||||||
|
; <i> Each bit protects a 1/32 region of the program flash memory.
|
||||||
|
; <h> FPROT0
|
||||||
|
; <i> Program Flash Region Protect Register 0
|
||||||
|
; <i> 1/32 - 8/32 region
|
||||||
|
; <o.0> FPROT0.0
|
||||||
|
; <o.1> FPROT0.1
|
||||||
|
; <o.2> FPROT0.2
|
||||||
|
; <o.3> FPROT0.3
|
||||||
|
; <o.4> FPROT0.4
|
||||||
|
; <o.5> FPROT0.5
|
||||||
|
; <o.6> FPROT0.6
|
||||||
|
; <o.7> FPROT0.7
|
||||||
|
nFPROT0 EQU 0x00
|
||||||
|
FPROT0 EQU nFPROT0:EOR:0xFF
|
||||||
|
; </h>
|
||||||
|
; <h> FPROT1
|
||||||
|
; <i> Program Flash Region Protect Register 1
|
||||||
|
; <i> 9/32 - 16/32 region
|
||||||
|
; <o.0> FPROT1.0
|
||||||
|
; <o.1> FPROT1.1
|
||||||
|
; <o.2> FPROT1.2
|
||||||
|
; <o.3> FPROT1.3
|
||||||
|
; <o.4> FPROT1.4
|
||||||
|
; <o.5> FPROT1.5
|
||||||
|
; <o.6> FPROT1.6
|
||||||
|
; <o.7> FPROT1.7
|
||||||
|
nFPROT1 EQU 0x00
|
||||||
|
FPROT1 EQU nFPROT1:EOR:0xFF
|
||||||
|
; </h>
|
||||||
|
; <h> FPROT2
|
||||||
|
; <i> Program Flash Region Protect Register 2
|
||||||
|
; <i> 17/32 - 24/32 region
|
||||||
|
; <o.0> FPROT2.0
|
||||||
|
; <o.1> FPROT2.1
|
||||||
|
; <o.2> FPROT2.2
|
||||||
|
; <o.3> FPROT2.3
|
||||||
|
; <o.4> FPROT2.4
|
||||||
|
; <o.5> FPROT2.5
|
||||||
|
; <o.6> FPROT2.6
|
||||||
|
; <o.7> FPROT2.7
|
||||||
|
nFPROT2 EQU 0x00
|
||||||
|
FPROT2 EQU nFPROT2:EOR:0xFF
|
||||||
|
; </h>
|
||||||
|
; <h> FPROT3
|
||||||
|
; <i> Program Flash Region Protect Register 3
|
||||||
|
; <i> 25/32 - 32/32 region
|
||||||
|
; <o.0> FPROT3.0
|
||||||
|
; <o.1> FPROT3.1
|
||||||
|
; <o.2> FPROT3.2
|
||||||
|
; <o.3> FPROT3.3
|
||||||
|
; <o.4> FPROT3.4
|
||||||
|
; <o.5> FPROT3.5
|
||||||
|
; <o.6> FPROT3.6
|
||||||
|
; <o.7> FPROT3.7
|
||||||
|
nFPROT3 EQU 0x00
|
||||||
|
FPROT3 EQU nFPROT3:EOR:0xFF
|
||||||
|
; </h>
|
||||||
|
; </h>
|
||||||
|
; <h> Flash nonvolatile option byte (FOPT)
|
||||||
|
; <i> Allows the user to customize the operation of the MCU at boot time.
|
||||||
|
; <o.0> LPBOOT0
|
||||||
|
; <0=> Core and system clock divider (OUTDIV1) is 0x7 (divide by 8) when LPBOOT1=0 or 0x1 (divide by 2) when LPBOOT1=1.
|
||||||
|
; <1=> Core and system clock divider (OUTDIV1) is 0x3 (divide by 4) when LPBOOT1=0 or 0x0 (divide by 1) when LPBOOT1=1.
|
||||||
|
; <o.1> BOOTPIN_OPT
|
||||||
|
; <0=> Force Boot from ROM if BOOTCFG0 asserted, where BOOTCFG0 is the boot config function which is muxed with NMI pin
|
||||||
|
; <1=> Boot source configured by FOPT (BOOTSRC_SEL) bits
|
||||||
|
; <o.2> NMI_DIS
|
||||||
|
; <0=> NMI interrupts are always blocked
|
||||||
|
; <1=> NMI_b pin/interrupts reset default to enabled
|
||||||
|
; <o.3> RESET_PIN_CFG
|
||||||
|
; <0=> RESET pin is disabled following a POR and cannot be enabled as reset function
|
||||||
|
; <1=> RESET_b pin is dedicated
|
||||||
|
; <o.4> LPBOOT1
|
||||||
|
; <0=> Core and system clock divider (OUTDIV1) is 0x7 (divide by 8) when LPBOOT0=0 or 0x3 (divide by 4) when LPBOOT0=1.
|
||||||
|
; <1=> Core and system clock divider (OUTDIV1) is 0x1 (divide by 2) when LPBOOT0=0 or 0x0 (divide by 1) when LPBOOT0=1.
|
||||||
|
; <o.5> FAST_INIT
|
||||||
|
; <0=> Slower initialization
|
||||||
|
; <1=> Fast Initialization
|
||||||
|
; <o.6..7> BOOTSRC_SEL
|
||||||
|
; <0=> Boot from Flash
|
||||||
|
; <2=> Boot from ROM
|
||||||
|
; <3=> Boot from ROM
|
||||||
|
; <i> Boot source selection
|
||||||
|
FOPT EQU 0x3F
|
||||||
|
; </h>
|
||||||
|
; <h> Flash security byte (FSEC)
|
||||||
|
; <i> WARNING: If SEC field is configured as "MCU security status is secure" and MEEN field is configured as "Mass erase is disabled",
|
||||||
|
; <i> MCU's security status cannot be set back to unsecure state since Mass erase via the debugger is blocked !!!
|
||||||
|
; <o.0..1> SEC
|
||||||
|
; <2=> MCU security status is unsecure
|
||||||
|
; <3=> MCU security status is secure
|
||||||
|
; <i> Flash Security
|
||||||
|
; <o.2..3> FSLACC
|
||||||
|
; <2=> Freescale factory access denied
|
||||||
|
; <3=> Freescale factory access granted
|
||||||
|
; <i> Freescale Failure Analysis Access Code
|
||||||
|
; <o.4..5> MEEN
|
||||||
|
; <2=> Mass erase is disabled
|
||||||
|
; <3=> Mass erase is enabled
|
||||||
|
; <o.6..7> KEYEN
|
||||||
|
; <2=> Backdoor key access enabled
|
||||||
|
; <3=> Backdoor key access disabled
|
||||||
|
; <i> Backdoor Key Security Enable
|
||||||
|
FSEC EQU 0xFE
|
||||||
|
; </h>
|
||||||
|
; </h>
|
||||||
|
IF :LNOT::DEF:RAM_TARGET
|
||||||
|
AREA |.ARM.__at_0x400|, DATA, READONLY
|
||||||
|
__FlashConfig
|
||||||
|
DCB BackDoorK0, BackDoorK1, BackDoorK2, BackDoorK3
|
||||||
|
DCB BackDoorK4, BackDoorK5, BackDoorK6, BackDoorK7
|
||||||
|
DCB FPROT0 , FPROT1 , FPROT2 , FPROT3
|
||||||
|
DCB FSEC , FOPT , 0xFF , 0xFF
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
AREA |.text|, CODE, READONLY
|
||||||
|
|
||||||
|
; Reset Handler
|
||||||
|
|
||||||
|
Reset_Handler PROC
|
||||||
|
EXPORT Reset_Handler [WEAK]
|
||||||
|
IMPORT SystemInit
|
||||||
|
IMPORT __main
|
||||||
|
LDR R0, =SystemInit
|
||||||
|
BLX R0
|
||||||
|
LDR R0, =__main
|
||||||
|
BX R0
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
|
||||||
|
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||||
|
NMI_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT NMI_Handler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
HardFault_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT HardFault_Handler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
SVC_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT SVC_Handler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
PendSV_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT PendSV_Handler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
SysTick_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT SysTick_Handler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
Default_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT DMA0_IRQHandler [WEAK]
|
||||||
|
EXPORT DMA1_IRQHandler [WEAK]
|
||||||
|
EXPORT DMA2_IRQHandler [WEAK]
|
||||||
|
EXPORT DMA3_IRQHandler [WEAK]
|
||||||
|
EXPORT Reserved20_IRQHandler [WEAK]
|
||||||
|
EXPORT FTFA_IRQHandler [WEAK]
|
||||||
|
EXPORT PMC_IRQHandler [WEAK]
|
||||||
|
EXPORT LLWU_IRQHandler [WEAK]
|
||||||
|
EXPORT I2C0_IRQHandler [WEAK]
|
||||||
|
EXPORT I2C1_IRQHandler [WEAK]
|
||||||
|
EXPORT SPI0_IRQHandler [WEAK]
|
||||||
|
EXPORT SPI1_IRQHandler [WEAK]
|
||||||
|
EXPORT LPUART0_IRQHandler [WEAK]
|
||||||
|
EXPORT LPUART1_IRQHandler [WEAK]
|
||||||
|
EXPORT UART2_FLEXIO_IRQHandler [WEAK]
|
||||||
|
EXPORT ADC0_IRQHandler [WEAK]
|
||||||
|
EXPORT CMP0_IRQHandler [WEAK]
|
||||||
|
EXPORT TPM0_IRQHandler [WEAK]
|
||||||
|
EXPORT TPM1_IRQHandler [WEAK]
|
||||||
|
EXPORT TPM2_IRQHandler [WEAK]
|
||||||
|
EXPORT RTC_IRQHandler [WEAK]
|
||||||
|
EXPORT RTC_Seconds_IRQHandler [WEAK]
|
||||||
|
EXPORT PIT_IRQHandler [WEAK]
|
||||||
|
EXPORT I2S0_IRQHandler [WEAK]
|
||||||
|
EXPORT USB0_IRQHandler [WEAK]
|
||||||
|
EXPORT DAC0_IRQHandler [WEAK]
|
||||||
|
EXPORT Reserved42_IRQHandler [WEAK]
|
||||||
|
EXPORT Reserved43_IRQHandler [WEAK]
|
||||||
|
EXPORT LPTMR0_IRQHandler [WEAK]
|
||||||
|
EXPORT LCD_IRQHandler [WEAK]
|
||||||
|
EXPORT PORTA_IRQHandler [WEAK]
|
||||||
|
EXPORT PORTCD_IRQHandler [WEAK]
|
||||||
|
EXPORT DefaultISR [WEAK]
|
||||||
|
DMA0_IRQHandler
|
||||||
|
DMA1_IRQHandler
|
||||||
|
DMA2_IRQHandler
|
||||||
|
DMA3_IRQHandler
|
||||||
|
Reserved20_IRQHandler
|
||||||
|
FTFA_IRQHandler
|
||||||
|
PMC_IRQHandler
|
||||||
|
LLWU_IRQHandler
|
||||||
|
I2C0_IRQHandler
|
||||||
|
I2C1_IRQHandler
|
||||||
|
SPI0_IRQHandler
|
||||||
|
SPI1_IRQHandler
|
||||||
|
LPUART0_IRQHandler
|
||||||
|
LPUART1_IRQHandler
|
||||||
|
UART2_FLEXIO_IRQHandler
|
||||||
|
ADC0_IRQHandler
|
||||||
|
CMP0_IRQHandler
|
||||||
|
TPM0_IRQHandler
|
||||||
|
TPM1_IRQHandler
|
||||||
|
TPM2_IRQHandler
|
||||||
|
RTC_IRQHandler
|
||||||
|
RTC_Seconds_IRQHandler
|
||||||
|
PIT_IRQHandler
|
||||||
|
I2S0_IRQHandler
|
||||||
|
USB0_IRQHandler
|
||||||
|
DAC0_IRQHandler
|
||||||
|
Reserved42_IRQHandler
|
||||||
|
Reserved43_IRQHandler
|
||||||
|
LPTMR0_IRQHandler
|
||||||
|
LCD_IRQHandler
|
||||||
|
PORTA_IRQHandler
|
||||||
|
PORTCD_IRQHandler
|
||||||
|
DefaultISR
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
ALIGN
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* mbed Microcontroller Library - stackheap
|
||||||
|
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* Setup a fixed single stack/heap memory model,
|
||||||
|
* between the top of the RW/ZI region and the stackpointer
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rt_misc.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern char Image$$RW_IRAM1$$ZI$$Limit[];
|
||||||
|
|
||||||
|
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
|
||||||
|
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
|
||||||
|
uint32_t sp_limit = __current_sp();
|
||||||
|
|
||||||
|
zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned
|
||||||
|
|
||||||
|
struct __initial_stackheap r;
|
||||||
|
r.heap_base = zi_limit;
|
||||||
|
r.heap_limit = sp_limit;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,163 @@
|
||||||
|
/*
|
||||||
|
* KL43Z ARM GCC linker script file
|
||||||
|
*/
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
VECTORS (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000400
|
||||||
|
FLASH_PROTECTION (rx) : ORIGIN = 0x00000400, LENGTH = 0x00000010
|
||||||
|
FLASH (rx) : ORIGIN = 0x00000410, LENGTH = 256K - 0x00000410
|
||||||
|
RAM (rwx) : ORIGIN = 0x1FFFE0C0, LENGTH = 32K - 0xC0
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Linker script to place sections and symbol values. Should be used together
|
||||||
|
* with other linker script that defines memory regions FLASH and RAM.
|
||||||
|
* It references following symbols, which must be defined in code:
|
||||||
|
* _reset_init : Entry of reset handler
|
||||||
|
*
|
||||||
|
* It defines following symbols, which code can use without definition:
|
||||||
|
* __exidx_start
|
||||||
|
* __exidx_end
|
||||||
|
* __etext
|
||||||
|
* __data_start__
|
||||||
|
* __preinit_array_start
|
||||||
|
* __preinit_array_end
|
||||||
|
* __init_array_start
|
||||||
|
* __init_array_end
|
||||||
|
* __fini_array_start
|
||||||
|
* __fini_array_end
|
||||||
|
* __data_end__
|
||||||
|
* __bss_start__
|
||||||
|
* __bss_end__
|
||||||
|
* __end__
|
||||||
|
* end
|
||||||
|
* __HeapLimit
|
||||||
|
* __StackLimit
|
||||||
|
* __StackTop
|
||||||
|
* __stack
|
||||||
|
*/
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.isr_vector :
|
||||||
|
{
|
||||||
|
__vector_table = .;
|
||||||
|
KEEP(*(.vector_table))
|
||||||
|
*(.text.Reset_Handler)
|
||||||
|
*(.text.System_Init)
|
||||||
|
. = ALIGN(4);
|
||||||
|
} > VECTORS
|
||||||
|
|
||||||
|
.flash_protect :
|
||||||
|
{
|
||||||
|
KEEP(*(.kinetis_flash_config_field))
|
||||||
|
. = ALIGN(4);
|
||||||
|
} > FLASH_PROTECTION
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.text*)
|
||||||
|
|
||||||
|
KEEP(*(.init))
|
||||||
|
KEEP(*(.fini))
|
||||||
|
|
||||||
|
/* .ctors */
|
||||||
|
*crtbegin.o(.ctors)
|
||||||
|
*crtbegin?.o(.ctors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||||
|
*(SORT(.ctors.*))
|
||||||
|
*(.ctors)
|
||||||
|
|
||||||
|
/* .dtors */
|
||||||
|
*crtbegin.o(.dtors)
|
||||||
|
*crtbegin?.o(.dtors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||||
|
*(SORT(.dtors.*))
|
||||||
|
*(.dtors)
|
||||||
|
|
||||||
|
*(.rodata*)
|
||||||
|
|
||||||
|
KEEP(*(.eh_frame*))
|
||||||
|
} > FLASH
|
||||||
|
|
||||||
|
.ARM.extab :
|
||||||
|
{
|
||||||
|
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||||
|
} > FLASH
|
||||||
|
|
||||||
|
__exidx_start = .;
|
||||||
|
.ARM.exidx :
|
||||||
|
{
|
||||||
|
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||||
|
} > FLASH
|
||||||
|
__exidx_end = .;
|
||||||
|
|
||||||
|
__etext = .;
|
||||||
|
|
||||||
|
.data : AT (__etext)
|
||||||
|
{
|
||||||
|
__data_start__ = .;
|
||||||
|
*(vtable)
|
||||||
|
*(.data*)
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* preinit data */
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||||
|
KEEP(*(.preinit_array))
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* init data */
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP(*(SORT(.init_array.*)))
|
||||||
|
KEEP(*(.init_array))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* finit data */
|
||||||
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||||
|
KEEP(*(SORT(.fini_array.*)))
|
||||||
|
KEEP(*(.fini_array))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* All data end */
|
||||||
|
__data_end__ = .;
|
||||||
|
|
||||||
|
} > RAM
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
__bss_start__ = .;
|
||||||
|
*(.bss*)
|
||||||
|
*(COMMON)
|
||||||
|
__bss_end__ = .;
|
||||||
|
} > RAM
|
||||||
|
|
||||||
|
.heap :
|
||||||
|
{
|
||||||
|
__end__ = .;
|
||||||
|
end = __end__;
|
||||||
|
*(.heap*)
|
||||||
|
__HeapLimit = .;
|
||||||
|
} > RAM
|
||||||
|
|
||||||
|
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||||
|
* used for linker to calculate size of stack sections, and assign
|
||||||
|
* values to stack symbols later */
|
||||||
|
.stack_dummy :
|
||||||
|
{
|
||||||
|
*(.stack)
|
||||||
|
} > RAM
|
||||||
|
|
||||||
|
/* Set stack top to end of RAM, and stack limit move down by
|
||||||
|
* size of stack_dummy section */
|
||||||
|
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||||
|
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||||
|
PROVIDE(__stack = __StackTop);
|
||||||
|
|
||||||
|
/* Check if data + heap + stack exceeds RAM limit */
|
||||||
|
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,243 @@
|
||||||
|
/* KL43Z startup ARM GCC
|
||||||
|
* Purpose: startup file for Cortex-M0 devices. Should use with
|
||||||
|
* GCC for ARM Embedded Processors
|
||||||
|
* Version: V1.3
|
||||||
|
* Date: 10 Nov 2014
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011, ARM Limited
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* 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.
|
||||||
|
* Neither the name of the ARM Limited 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 ARM LIMITED 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.
|
||||||
|
*/
|
||||||
|
.syntax unified
|
||||||
|
.arch armv6-m
|
||||||
|
|
||||||
|
/* Memory Model
|
||||||
|
The HEAP starts at the end of the DATA section and grows upward.
|
||||||
|
|
||||||
|
The STACK starts at the end of the RAM and grows downward.
|
||||||
|
|
||||||
|
The HEAP and stack STACK are only checked at compile time:
|
||||||
|
(DATA_SIZE + HEAP_SIZE + STACK_SIZE) < RAM_SIZE
|
||||||
|
|
||||||
|
This is just a check for the bare minimum for the Heap+Stack area before
|
||||||
|
aborting compilation, it is not the run time limit:
|
||||||
|
Heap_Size + Stack_Size = 0x200 + 0x400 = 0x600
|
||||||
|
*/
|
||||||
|
.section .stack
|
||||||
|
.align 3
|
||||||
|
#ifdef __STACK_SIZE
|
||||||
|
.equ Stack_Size, __STACK_SIZE
|
||||||
|
#else
|
||||||
|
.equ Stack_Size, 0x400
|
||||||
|
#endif
|
||||||
|
.globl __StackTop
|
||||||
|
.globl __StackLimit
|
||||||
|
__StackLimit:
|
||||||
|
.space Stack_Size
|
||||||
|
.size __StackLimit, . - __StackLimit
|
||||||
|
__StackTop:
|
||||||
|
.size __StackTop, . - __StackTop
|
||||||
|
|
||||||
|
.section .heap
|
||||||
|
.align 3
|
||||||
|
#ifdef __HEAP_SIZE
|
||||||
|
.equ Heap_Size, __HEAP_SIZE
|
||||||
|
#else
|
||||||
|
.equ Heap_Size, 0x200
|
||||||
|
#endif
|
||||||
|
.globl __HeapBase
|
||||||
|
.globl __HeapLimit
|
||||||
|
__HeapBase:
|
||||||
|
.space Heap_Size
|
||||||
|
.size __HeapBase, . - __HeapBase
|
||||||
|
__HeapLimit:
|
||||||
|
.size __HeapLimit, . - __HeapLimit
|
||||||
|
|
||||||
|
.section .vector_table,"a",%progbits
|
||||||
|
.align 2
|
||||||
|
.globl __isr_vector
|
||||||
|
__isr_vector:
|
||||||
|
.long __StackTop /* Top of Stack */
|
||||||
|
.long Reset_Handler /* Reset Handler */
|
||||||
|
.long NMI_Handler /* NMI Handler */
|
||||||
|
.long HardFault_Handler /* Hard Fault Handler */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long SVC_Handler /* SVCall Handler */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long PendSV_Handler /* PendSV Handler */
|
||||||
|
.long SysTick_Handler /* SysTick Handler */
|
||||||
|
|
||||||
|
/* External interrupts */
|
||||||
|
.long DMA0_IRQHandler /* DMA channel 0 transfer complete interrupt */
|
||||||
|
.long DMA1_IRQHandler /* DMA channel 1 transfer complete interrupt */
|
||||||
|
.long DMA2_IRQHandler /* DMA channel 2 transfer complete interrupt */
|
||||||
|
.long DMA3_IRQHandler /* DMA channel 3 transfer complete interrupt */
|
||||||
|
.long Default_Handler /* Reserved interrupt 20 */
|
||||||
|
.long FTFA_IRQHandler /* FTFA interrupt */
|
||||||
|
.long PMC_IRQHandler /* Low-voltage detect, low-voltage warning*/
|
||||||
|
.long LLWU_IRQHandler /* Low leakage wakeup*/
|
||||||
|
.long I2C0_IRQHandler /* I2C0 interrupt*/
|
||||||
|
.long I2C1_IRQHandler /* I2C1 interrupt*/
|
||||||
|
.long SPI0_IRQHandler /* SPI0 single interrupt vector for all sources*/
|
||||||
|
.long SPI1_IRQHandler /* SPI1 single interrupt vector for all sources*/
|
||||||
|
.long LPUART0_IRQHandler /* LPUART0 status and error*/
|
||||||
|
.long LPUART1_IRQHandler /* LPUART1 status and error*/
|
||||||
|
.long UART2_FLEXIO_IRQHandler /* UART2 or FLEXIO*/
|
||||||
|
.long ADC0_IRQHandler /* ADC0 interrupt*/
|
||||||
|
.long CMP0_IRQHandler /* CMP0 interrupt*/
|
||||||
|
.long TPM0_IRQHandler /* TPM0 single interrupt vector for all sources*/
|
||||||
|
.long TPM1_IRQHandler /* TPM1 single interrupt vector for all sources*/
|
||||||
|
.long TPM2_IRQHandler /* TPM2 single interrupt vector for all sources*/
|
||||||
|
.long RTC_IRQHandler /* RTC alarm*/
|
||||||
|
.long RTC_Seconds_IRQHandler /* RTC seconds*/
|
||||||
|
.long PIT_IRQHandler /* PIT interrupt*/
|
||||||
|
.long I2S0_IRQHandler /* I2S0 interrupt*/
|
||||||
|
.long USB0_IRQHandler /* USB0 interrupt*/
|
||||||
|
.long DAC0_IRQHandler /* DAC0 interrupt*/
|
||||||
|
.long Reserved42_IRQHandler /* Reserved interrupt*/
|
||||||
|
.long Reserved43_IRQHandler /* Reserved interrupt*/
|
||||||
|
.long LPTMR0_IRQHandler /* LPTMR0 interrupt*/
|
||||||
|
.long LCD_IRQHandler /* LCD interrupt*/
|
||||||
|
.long PORTA_IRQHandler /* PORTA Pin detect*/
|
||||||
|
.long PORTCD_IRQHandler /* Single interrupt vector for PORTC; PORTD Pin detect*/
|
||||||
|
|
||||||
|
.size __isr_vector, . - __isr_vector
|
||||||
|
|
||||||
|
/* Reset Handler */
|
||||||
|
.section .text.Reset_Handler
|
||||||
|
.thumb
|
||||||
|
.thumb_func
|
||||||
|
.align 2
|
||||||
|
.globl Reset_Handler
|
||||||
|
.type Reset_Handler, %function
|
||||||
|
Reset_Handler:
|
||||||
|
/* Loop to copy data from read only memory to RAM. The ranges
|
||||||
|
* of copy from/to are specified by following symbols evaluated in
|
||||||
|
* linker script.
|
||||||
|
* __etext: End of code section, i.e., begin of data sections to copy from.
|
||||||
|
* __data_start__/__data_end__: RAM address range that data should be
|
||||||
|
* copied to. Both must be aligned to 4 bytes boundary. */
|
||||||
|
ldr r1, =__etext
|
||||||
|
ldr r2, =__data_start__
|
||||||
|
ldr r3, =__data_end__
|
||||||
|
|
||||||
|
subs r3, r2
|
||||||
|
ble .Lflash_to_ram_loop_end
|
||||||
|
|
||||||
|
movs r4, 0
|
||||||
|
.Lflash_to_ram_loop:
|
||||||
|
ldr r0, [r1,r4]
|
||||||
|
str r0, [r2,r4]
|
||||||
|
adds r4, 4
|
||||||
|
cmp r4, r3
|
||||||
|
blt .Lflash_to_ram_loop
|
||||||
|
.Lflash_to_ram_loop_end:
|
||||||
|
|
||||||
|
ldr r0, =SystemInit
|
||||||
|
blx r0
|
||||||
|
ldr r0, =_start
|
||||||
|
bx r0
|
||||||
|
.pool
|
||||||
|
.size Reset_Handler, . - Reset_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.text
|
||||||
|
/* Macro to define default handlers. Default handler
|
||||||
|
* will be weak symbol and just dead loops. They can be
|
||||||
|
* overwritten by other handlers */
|
||||||
|
.macro def_default_handler handler_name
|
||||||
|
.align 1
|
||||||
|
.thumb_func
|
||||||
|
.weak \handler_name
|
||||||
|
.type \handler_name, %function
|
||||||
|
\handler_name :
|
||||||
|
b .
|
||||||
|
.size \handler_name, . - \handler_name
|
||||||
|
.endm
|
||||||
|
|
||||||
|
def_default_handler NMI_Handler
|
||||||
|
def_default_handler HardFault_Handler
|
||||||
|
def_default_handler SVC_Handler
|
||||||
|
def_default_handler PendSV_Handler
|
||||||
|
def_default_handler SysTick_Handler
|
||||||
|
def_default_handler Default_Handler
|
||||||
|
|
||||||
|
.macro def_irq_default_handler handler_name
|
||||||
|
.weak \handler_name
|
||||||
|
.set \handler_name, Default_Handler
|
||||||
|
.endm
|
||||||
|
|
||||||
|
def_irq_default_handler DMA0_IRQHandler
|
||||||
|
def_irq_default_handler DMA1_IRQHandler
|
||||||
|
def_irq_default_handler DMA2_IRQHandler
|
||||||
|
def_irq_default_handler DMA3_IRQHandler
|
||||||
|
def_irq_default_handler Reserved20_IRQHandler
|
||||||
|
def_irq_default_handler FTFA_IRQHandler
|
||||||
|
def_irq_default_handler PMC_IRQHandler
|
||||||
|
def_irq_default_handler LLWU_IRQHandler
|
||||||
|
def_irq_default_handler I2C0_IRQHandler
|
||||||
|
def_irq_default_handler I2C1_IRQHandler
|
||||||
|
def_irq_default_handler SPI0_IRQHandler
|
||||||
|
def_irq_default_handler SPI1_IRQHandler
|
||||||
|
def_irq_default_handler LPUART0_IRQHandler
|
||||||
|
def_irq_default_handler LPUART1_IRQHandler
|
||||||
|
def_irq_default_handler UART2_FLEXIO_IRQHandler
|
||||||
|
def_irq_default_handler ADC0_IRQHandler
|
||||||
|
def_irq_default_handler CMP0_IRQHandler
|
||||||
|
def_irq_default_handler TPM0_IRQHandler
|
||||||
|
def_irq_default_handler TPM1_IRQHandler
|
||||||
|
def_irq_default_handler TPM2_IRQHandler
|
||||||
|
def_irq_default_handler RTC_IRQHandler
|
||||||
|
def_irq_default_handler RTC_Seconds_IRQHandler
|
||||||
|
def_irq_default_handler PIT_IRQHandler
|
||||||
|
def_irq_default_handler I2S0_IRQHandler
|
||||||
|
def_irq_default_handler USB0_IRQHandler
|
||||||
|
def_irq_default_handler DAC0_IRQHandler
|
||||||
|
def_irq_default_handler Reserved42_IRQHandler
|
||||||
|
def_irq_default_handler Reserved43_IRQHandler
|
||||||
|
def_irq_default_handler LPTMR0_IRQHandler
|
||||||
|
def_irq_default_handler LCD_IRQHandler
|
||||||
|
def_irq_default_handler PORTA_IRQHandler
|
||||||
|
def_irq_default_handler PORTCD_IRQHandler
|
||||||
|
def_irq_default_handler DefaultISR
|
||||||
|
|
||||||
|
/* Flash protection region, placed at 0x400 */
|
||||||
|
.text
|
||||||
|
.thumb
|
||||||
|
.align 2
|
||||||
|
.section .kinetis_flash_config_field,"a",%progbits
|
||||||
|
kinetis_flash_config:
|
||||||
|
.long 0xFFFFFFFF
|
||||||
|
.long 0xFFFFFFFF
|
||||||
|
.long 0xFFFFFFFF
|
||||||
|
.long 0xFFFF3FFE
|
||||||
|
|
||||||
|
.end
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* mbed Microcontroller Library - CMSIS
|
||||||
|
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* A generic CMSIS include header, pulling in LPC11U24 specifics
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MBED_CMSIS_H
|
||||||
|
#define MBED_CMSIS_H
|
||||||
|
|
||||||
|
#include "MKL43Z4.h"
|
||||||
|
#include "cmsis_nvic.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* mbed Microcontroller Library - cmsis_nvic for LPC11U24
|
||||||
|
* Copyright (c) 2011 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* CMSIS-style functionality to support dynamic vectors
|
||||||
|
*/
|
||||||
|
#include "cmsis_nvic.h"
|
||||||
|
|
||||||
|
#define NVIC_RAM_VECTOR_ADDRESS (0x1FFFE000) // Vectors positioned at start of RAM
|
||||||
|
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||||
|
|
||||||
|
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||||
|
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
// Copy and switch to dynamic vectors if the first time called
|
||||||
|
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||||
|
uint32_t *old_vectors = vectors;
|
||||||
|
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||||
|
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||||
|
vectors[i] = old_vectors[i];
|
||||||
|
}
|
||||||
|
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||||
|
}
|
||||||
|
vectors[IRQn + 16] = vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t NVIC_GetVector(IRQn_Type IRQn) {
|
||||||
|
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||||
|
return vectors[IRQn + 16];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* mbed Microcontroller Library - cmsis_nvic
|
||||||
|
* Copyright (c) 2009-2011 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* CMSIS-style functionality to support dynamic vectors
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MBED_CMSIS_NVIC_H
|
||||||
|
#define MBED_CMSIS_NVIC_H
|
||||||
|
|
||||||
|
#define NVIC_NUM_VECTORS (16 + 32) // CORE + MCU Peripherals
|
||||||
|
#define NVIC_USER_IRQ_OFFSET 16
|
||||||
|
|
||||||
|
#include "cmsis.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
|
||||||
|
uint32_t NVIC_GetVector(IRQn_Type IRQn);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,224 @@
|
||||||
|
/*
|
||||||
|
** ###################################################################
|
||||||
|
** Processors: MKL43Z256VLH4
|
||||||
|
** MKL43Z128VLH4
|
||||||
|
** MKL43Z64VLH4
|
||||||
|
** MKL43Z256VMP4
|
||||||
|
** MKL43Z128VMP4
|
||||||
|
** MKL43Z64VMP4
|
||||||
|
**
|
||||||
|
** 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: KL43P64M48SF6RM, Rev.3, Aug 2014
|
||||||
|
** Version: rev. 1.4, 2014-09-01
|
||||||
|
** Build: b140904
|
||||||
|
**
|
||||||
|
** 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 (2014-03-27)
|
||||||
|
** Initial version.
|
||||||
|
** - rev. 1.1 (2014-05-26)
|
||||||
|
** I2S registers TCR2/RCR2 and others were changed.
|
||||||
|
** FLEXIO register FLEXIO_VERID has now bitfields: FEATURE, MINOR, MAJOR.
|
||||||
|
** Names of the bitfields of the FLEXIO_SHIFTBUF have been changed to the appropriate register name e.g.: FLEXIO_SHIFTBUFBBS_SHIFTBUFBBS.
|
||||||
|
** Peripheral_BASES macros has been changed to Peripheral_BASE_PTRS, e.g.: ADC_BASES to ADC_BASE_PTRS.
|
||||||
|
** Clock configuration for high range external oscillator has been added.
|
||||||
|
** RFSYS module access has been added.
|
||||||
|
** - rev. 1.2 (2014-07-10)
|
||||||
|
** GPIO - Renamed modules PTA,PTB,PTC,PTD,PTE to GPIOA,GPIOB,GPIOC,GPIOD,GPIOE.
|
||||||
|
** UART0 - UART0 module renamed to UART2.
|
||||||
|
** I2S - removed MDR register.
|
||||||
|
** - rev. 1.3 (2014-08-21)
|
||||||
|
** UART2 - Removed ED register.
|
||||||
|
** UART2 - Removed MODEM register.
|
||||||
|
** UART2 - Removed IR register.
|
||||||
|
** UART2 - Removed PFIFO register.
|
||||||
|
** UART2 - Removed CFIFO register.
|
||||||
|
** UART2 - Removed SFIFO register.
|
||||||
|
** UART2 - Removed TWFIFO register.
|
||||||
|
** UART2 - Removed TCFIFO register.
|
||||||
|
** UART2 - Removed RWFIFO register.
|
||||||
|
** UART2 - Removed RCFIFO register.
|
||||||
|
** USB - Removed bitfield REG_EN in CLK_RECOVER_IRC_EN register.
|
||||||
|
** SIM - Changed bitfield value MCGIRCLK to LIRC_CLK of bitfield CLKOUTSEL in SOPT2 register.
|
||||||
|
** SIM - Removed bitfield DIEID in SDID register.
|
||||||
|
** - rev. 1.4 (2014-09-01)
|
||||||
|
** USB - USB0_CTL0 was renamed to USB0_OTGCTL register.
|
||||||
|
** USB - USB0_CTL1 was renamed to USB0_CTL register.
|
||||||
|
**
|
||||||
|
** ###################################################################
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @file MKL43Z4
|
||||||
|
* @version 1.4
|
||||||
|
* @date 2014-09-01
|
||||||
|
* @brief Device specific configuration file for MKL43Z4 (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 "device/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) */
|
||||||
|
|
||||||
|
/* Power mode protection initialization */
|
||||||
|
#ifdef SMC_PMPROT_VALUE
|
||||||
|
SMC->PMPROT = 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) */
|
||||||
|
#define SOPT2_WRITE_MASK ((SIM_SOPT2_USBSRC_MASK) | (SIM_SOPT2_TPMSRC_MASK) | (SIM_SOPT2_LPUART0SRC_MASK) | (SIM_SOPT2_LPUART1SRC_MASK)) /* define mask of written bits. */
|
||||||
|
SIM->SOPT2 = ((SIM->SOPT2) & (uint32_t)(~SOPT2_WRITE_MASK)) | ((SYSTEM_SIM_SOPT2_VALUE) & SOPT2_WRITE_MASK); /* Selects the clock source for the TPM counter clock. */
|
||||||
|
#if (MCG_MODE == MCG_MODE_LIRC_2M || MCG_MODE == MCG_MODE_LIRC_8M || MCG_MODE == MCG_MODE_HIRC)
|
||||||
|
/* Set MCG and OSC0 */
|
||||||
|
#if (((OSC0_CR_VALUE) & OSC_CR_ERCLKEN_MASK) != 0x00U)
|
||||||
|
/* SIM_SCGC5: PORTA=1 */
|
||||||
|
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;
|
||||||
|
/* PORTA_PCR3: ISF=0,MUX=0 */
|
||||||
|
PORTA_PCR18 &= (uint32_t)~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
|
||||||
|
if (((MCG_C2_VALUE) & MCG_C2_EREFS0_MASK) != 0x00U) {
|
||||||
|
PORTA_PCR19 &= (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) */
|
||||||
|
OSC0->CR = OSC0_CR_VALUE; /* Set OSC0_CR (OSCERCLK enable, oscillator capacitor load) */
|
||||||
|
|
||||||
|
#else /* MCG_MODE */
|
||||||
|
/* Set MCG and OSC0 */
|
||||||
|
/* SIM_SCGC5: PORTA=1 */
|
||||||
|
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;
|
||||||
|
/* PORTA_PCR3: ISF=0,MUX=0 */
|
||||||
|
PORTA_PCR18 &= (uint32_t)~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
|
||||||
|
if (((MCG_C2_VALUE) & MCG_C2_EREFS0_MASK) != 0x00U) {
|
||||||
|
PORTA_PCR19 &= (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) */
|
||||||
|
OSC0->CR = OSC0_CR_VALUE; /* Set OSC0_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 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
-- 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)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,335 @@
|
||||||
|
/*
|
||||||
|
** ###################################################################
|
||||||
|
** Processors: MKL43Z256VLH4
|
||||||
|
** MKL43Z128VLH4
|
||||||
|
** MKL43Z64VLH4
|
||||||
|
** MKL43Z256VMP4
|
||||||
|
** MKL43Z128VMP4
|
||||||
|
** MKL43Z64VMP4
|
||||||
|
**
|
||||||
|
** 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: KL43P64M48SF6RM, Rev.3, Aug 2014
|
||||||
|
** Version: rev. 1.4, 2014-09-01
|
||||||
|
** Build: b140904
|
||||||
|
**
|
||||||
|
** 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 (2014-03-27)
|
||||||
|
** Initial version.
|
||||||
|
** - rev. 1.1 (2014-05-26)
|
||||||
|
** I2S registers TCR2/RCR2 and others were changed.
|
||||||
|
** FLEXIO register FLEXIO_VERID has now bitfields: FEATURE, MINOR, MAJOR.
|
||||||
|
** Names of the bitfields of the FLEXIO_SHIFTBUF have been changed to the appropriate register name e.g.: FLEXIO_SHIFTBUFBBS_SHIFTBUFBBS.
|
||||||
|
** Peripheral_BASES macros has been changed to Peripheral_BASE_PTRS, e.g.: ADC_BASES to ADC_BASE_PTRS.
|
||||||
|
** Clock configuration for high range external oscillator has been added.
|
||||||
|
** RFSYS module access has been added.
|
||||||
|
** - rev. 1.2 (2014-07-10)
|
||||||
|
** GPIO - Renamed modules PTA,PTB,PTC,PTD,PTE to GPIOA,GPIOB,GPIOC,GPIOD,GPIOE.
|
||||||
|
** UART0 - UART0 module renamed to UART2.
|
||||||
|
** I2S - removed MDR register.
|
||||||
|
** - rev. 1.3 (2014-08-21)
|
||||||
|
** UART2 - Removed ED register.
|
||||||
|
** UART2 - Removed MODEM register.
|
||||||
|
** UART2 - Removed IR register.
|
||||||
|
** UART2 - Removed PFIFO register.
|
||||||
|
** UART2 - Removed CFIFO register.
|
||||||
|
** UART2 - Removed SFIFO register.
|
||||||
|
** UART2 - Removed TWFIFO register.
|
||||||
|
** UART2 - Removed TCFIFO register.
|
||||||
|
** UART2 - Removed RWFIFO register.
|
||||||
|
** UART2 - Removed RCFIFO register.
|
||||||
|
** USB - Removed bitfield REG_EN in CLK_RECOVER_IRC_EN register.
|
||||||
|
** SIM - Changed bitfield value MCGIRCLK to LIRC_CLK of bitfield CLKOUTSEL in SOPT2 register.
|
||||||
|
** SIM - Removed bitfield DIEID in SDID register.
|
||||||
|
** - rev. 1.4 (2014-09-01)
|
||||||
|
** USB - USB0_CTL0 was renamed to USB0_OTGCTL register.
|
||||||
|
** USB - USB0_CTL1 was renamed to USB0_CTL register.
|
||||||
|
**
|
||||||
|
** ###################################################################
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @file MKL43Z4
|
||||||
|
* @version 1.4
|
||||||
|
* @date 2014-09-01
|
||||||
|
* @brief Device specific configuration file for MKL43Z4 (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_MKL43Z4_H_
|
||||||
|
#define SYSTEM_MKL43Z4_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
|
||||||
|
|
||||||
|
#ifndef CLOCK_SETUP
|
||||||
|
#define CLOCK_SETUP 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 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, USB FS clock derived from external clock USB_CLKIN (applicable only for derivatived with USB)
|
||||||
|
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, USB FS clock derived from external clock USB_CLKIN (applicable only for derivatived with USB)
|
||||||
|
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, USB FS clock derived from external clock USB_CLKIN (applicable only for derivatived with USB)
|
||||||
|
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, USB FS clock derived from external clock USB_CLKIN (applicable only for derivatived with USB)
|
||||||
|
4 ... Multipurpose Clock Generator Lite (MCG_Lite) in High-frequency Internal Reference Clock (HIRC) mode
|
||||||
|
USB clock setup - for USB to receive internal 48MHz clock derived from HIRC.
|
||||||
|
Core clock/Bus clock derived from the internal clock source 48MHz
|
||||||
|
Core clock = 48MHz, BusClock = 24MHz, USB FS clock derived from HIRC (MCGPCLK)
|
||||||
|
5 ... Multipurpose Clock Generator Lite (MCG_Lite) in External Oscillator (EXT) mode
|
||||||
|
Core clock/Bus clock derived directly from the external crystal 8 MHz
|
||||||
|
Core clock = 8MHz, BusClock = 4MHz, USB FS clock derived from external clock USB_CLKIN (applicable only for derivatived with USB)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 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 SMC_PMPROT_VALUE 0x22u /* SMC_PMPROT */
|
||||||
|
|
||||||
|
#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: RANGE0=0,HGO0=0,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 */
|
||||||
|
/* OSC0_CR: ERCLKEN=0,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||||
|
#define OSC0_CR_VALUE 0x00u /* OSC0_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: LPUART1SRC=0,LPUART0SRC=0,TPMSRC=3,FLEXIOSRC=0,USBSRC=0,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: RANGE0=0,HGO0=0,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 */
|
||||||
|
/* OSC0_CR: ERCLKEN=0,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||||
|
#define OSC0_CR_VALUE 0x00u /* OSC0_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: LPUART1SRC=0,LPUART0SRC=0,TPMSRC=3,FLEXIOSRC=0,USBSRC=0,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: RANGE0=0,HGO0=0,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 */
|
||||||
|
/* OSC0_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||||
|
#define OSC0_CR_VALUE 0x80u /* OSC0_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: LPUART1SRC=0,LPUART0SRC=0,TPMSRC=2,FLEXIOSRC=0,USBSRC=0,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: RANGE0=0,HGO0=0,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 */
|
||||||
|
/* OSC0_CR: ERCLKEN=0,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||||
|
#define OSC0_CR_VALUE 0x00u /* OSC0_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: LPUART1SRC=0,LPUART0SRC=0,TPMSRC=3,FLEXIOSRC=0,USBSRC=0,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
|
||||||
|
#define SYSTEM_SIM_SOPT2_VALUE 0x03000000u /* SIM_SOPT2 */
|
||||||
|
#elif (CLOCK_SETUP == 4)
|
||||||
|
#define DEFAULT_SYSTEM_CLOCK 2000000u /* 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_2M /* Clock generator mode */
|
||||||
|
/* MCG_C1: CLKS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||||
|
#define MCG_C1_VALUE 0x02u /* MCG_C1 */
|
||||||
|
/* MCG_C2: RANGE0=0,HGO0=0,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 */
|
||||||
|
/* OSC0_CR: ERCLKEN=0,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||||
|
#define OSC0_CR_VALUE 0x00u /* OSC0_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: LPUART1SRC=0,LPUART0SRC=0,TPMSRC=3,FLEXIOSRC=0,USBSRC=1,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
|
||||||
|
#define SYSTEM_SIM_SOPT2_VALUE 0x03040000u /* SIM_SOPT2 */
|
||||||
|
#elif (CLOCK_SETUP == 5)
|
||||||
|
#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=2,IRCLKEN=0,IREFSTEN=0 */
|
||||||
|
#define MCG_C1_VALUE 0x80u /* MCG_C1 */
|
||||||
|
/* MCG_C2: RANGE0=1,HGO0=0,EREFS0=1,IRCS=1 */
|
||||||
|
#define MCG_C2_VALUE 0x15u /* 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 */
|
||||||
|
/* OSC0_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||||
|
#define OSC0_CR_VALUE 0x80u /* OSC0_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: LPUART1SRC=0,LPUART0SRC=0,TPMSRC=3,FLEXIOSRC=0,USBSRC=0,CLKOUTSEL=0,RTCCLKOUTSEL=0 */
|
||||||
|
#define SYSTEM_SIM_SOPT2_VALUE 0x03000000u /* SIM_SOPT2 */
|
||||||
|
#else
|
||||||
|
#error The selected clock setup is not supported.
|
||||||
|
#endif /* (CLOCK_SETUP == 5) */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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_MKL43Z4_H_) */
|
||||||
Loading…
Reference in New Issue