forked from xuos/xiuos
52 changed files with 59492 additions and 1 deletions
@ -0,0 +1,3 @@ |
|||
SRC_FILES := boot.S interrupt.c interrupt_vector.S |
|||
|
|||
include $(KERNEL_ROOT)/compiler.mk |
@ -0,0 +1,29 @@ |
|||
/*
|
|||
* Copyright (c) 2020 AIIT XUOS Lab |
|||
* XiUOS is licensed under Mulan PSL v2. |
|||
* You can use this software according to the terms and conditions of the Mulan PSL v2. |
|||
* You may obtain a copy of Mulan PSL v2 at: |
|||
* http://license.coscl.org.cn/MulanPSL2
|
|||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, |
|||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, |
|||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. |
|||
* See the Mulan PSL v2 for more details. |
|||
*/ |
|||
|
|||
#ifndef ARCH_INTERRUPT_H__ |
|||
#define ARCH_INTERRUPT_H__ |
|||
|
|||
#include <xs_base.h> |
|||
|
|||
#define ARCH_MAX_IRQ_NUM (256) |
|||
|
|||
#define ARCH_IRQ_NUM_OFFSET 0 |
|||
|
|||
#define SYSTICK_IRQN 15 |
|||
#define UART1_IRQn 36 |
|||
#define UART2_IRQn 37 |
|||
|
|||
int32 ArchEnableHwIrq(uint32 irq_num); |
|||
int32 ArchDisableHwIrq(uint32 irq_num); |
|||
|
|||
#endif |
@ -0,0 +1,148 @@ |
|||
/* ------------------------------------------------------------------------- */ |
|||
/* @file: startup_MIMXRT1052.s */ |
|||
/* @purpose: CMSIS Cortex-M7 Core Device Startup File */ |
|||
/* MIMXRT1052 */ |
|||
/* @version: 1.0 */ |
|||
/* @date: 2018-9-21 */ |
|||
/* @build: b180921 */ |
|||
/* ------------------------------------------------------------------------- */ |
|||
/* */ |
|||
/* Copyright 1997-2016 Freescale Semiconductor, Inc. */ |
|||
/* Copyright 2016-2018 NXP */ |
|||
/* All rights reserved. */ |
|||
/* */ |
|||
/* SPDX-License-Identifier: BSD-3-Clause */ |
|||
/*****************************************************************************/ |
|||
/* Version: GCC for ARM Embedded Processors */ |
|||
/*****************************************************************************/ |
|||
|
|||
|
|||
/** |
|||
* @file boot.S |
|||
* @brief Contex-M7 start function |
|||
* @version 1.0 |
|||
* @author AIIT XUOS Lab |
|||
* @date 2021-05-28 |
|||
*/ |
|||
|
|||
/************************************************* |
|||
File name: boot.S |
|||
Description: Contex-M7 start function function |
|||
Others: take startup_MIMXRT1052.s for references |
|||
History: |
|||
1. Date: 2021-05-28 |
|||
Author: AIIT XUOS Lab |
|||
Modification: |
|||
1. add OS entry function |
|||
*************************************************/ |
|||
|
|||
.syntax unified |
|||
.arch armv7-m |
|||
.text |
|||
.thumb |
|||
|
|||
/* Reset Handler */ |
|||
|
|||
.thumb_func |
|||
.align 2 |
|||
.globl Reset_Handler |
|||
.weak Reset_Handler |
|||
.type Reset_Handler, %function |
|||
Reset_Handler: |
|||
cpsid i /* Mask interrupts */ |
|||
.equ VTOR, 0xE000ED08 |
|||
ldr r0, =VTOR |
|||
ldr r1, =__isr_vector |
|||
str r1, [r0] |
|||
ldr r2, [r1] |
|||
msr msp, r2 |
|||
#ifndef __NO_SYSTEM_INIT |
|||
ldr r0,=SystemInit |
|||
blx r0 |
|||
#endif |
|||
/* 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 |
|||
* __noncachedata_start__/__noncachedata_end__ : none cachable region |
|||
* copied to. Both must be aligned to 4 bytes boundary. */ |
|||
|
|||
ldr r1, =__etext |
|||
ldr r2, =__data_start__ |
|||
ldr r3, =__data_end__ |
|||
|
|||
#if 1 |
|||
/* Here are two copies of loop implemenations. First one favors code size |
|||
* and the second one favors performance. Default uses the first one. |
|||
* Change to "#if 0" to use the second one */ |
|||
.LC0: |
|||
cmp r2, r3 |
|||
ittt lt |
|||
ldrlt r0, [r1], #4 |
|||
strlt r0, [r2], #4 |
|||
blt .LC0 |
|||
#else |
|||
subs r3, r2 |
|||
ble .LC1 |
|||
.LC0: |
|||
subs r3, #4 |
|||
ldr r0, [r1, r3] |
|||
str r0, [r2, r3] |
|||
bgt .LC0 |
|||
.LC1: |
|||
#endif |
|||
#ifdef __STARTUP_INITIALIZE_NONCACHEDATA |
|||
ldr r2, =__noncachedata_start__ |
|||
ldr r3, =__noncachedata_init_end__ |
|||
#if 1 |
|||
.LC2: |
|||
cmp r2, r3 |
|||
ittt lt |
|||
ldrlt r0, [r1], #4 |
|||
strlt r0, [r2], #4 |
|||
blt .LC2 |
|||
#else |
|||
subs r3, r2 |
|||
ble .LC3 |
|||
.LC2: |
|||
subs r3, #4 |
|||
ldr r0, [r1, r3] |
|||
str r0, [r2, r3] |
|||
bgt .LC2 |
|||
.LC3: |
|||
#endif |
|||
/* zero inited ncache section initialization */ |
|||
ldr r3, =__noncachedata_end__ |
|||
movs r0,0 |
|||
.LC4: |
|||
cmp r2,r3 |
|||
itt lt |
|||
strlt r0,[r2],#4 |
|||
blt .LC4 |
|||
#endif /* __STARTUP_INITIALIZE_NONCACHEDATA */ |
|||
|
|||
#ifdef __STARTUP_CLEAR_BSS |
|||
/* This part of work usually is done in C library startup code. Otherwise, |
|||
* define this macro to enable it in this startup. |
|||
* |
|||
* Loop to zero out BSS section, which uses following symbols |
|||
* in linker script: |
|||
* __bss_start__: start of BSS section. Must align to 4 |
|||
* __bss_end__: end of BSS section. Must align to 4 |
|||
*/ |
|||
ldr r1, =__bss_start__ |
|||
ldr r2, =__bss_end__ |
|||
|
|||
movs r0, 0 |
|||
.LC5: |
|||
cmp r1, r2 |
|||
itt lt |
|||
strlt r0, [r1], #4 |
|||
blt .LC5 |
|||
#endif /* __STARTUP_CLEAR_BSS */ |
|||
|
|||
ldr r0,=entry |
|||
blx r0 |
|||
|
|||
.size Reset_Handler, . - Reset_Handler |
@ -0,0 +1,83 @@ |
|||
/*
|
|||
* Copyright (c) 2020 AIIT XUOS Lab |
|||
* XiUOS is licensed under Mulan PSL v2. |
|||
* You can use this software according to the terms and conditions of the Mulan PSL v2. |
|||
* You may obtain a copy of Mulan PSL v2 at: |
|||
* http://license.coscl.org.cn/MulanPSL2
|
|||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, |
|||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, |
|||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. |
|||
* See the Mulan PSL v2 for more details. |
|||
*/ |
|||
|
|||
/**
|
|||
* @file interrupt.c |
|||
* @brief support arm cortex-m4 interrupt function |
|||
* @version 1.0 |
|||
* @author AIIT XUOS Lab |
|||
* @date 2021-05-28 |
|||
*/ |
|||
|
|||
#include <xs_base.h> |
|||
#include <xs_isr.h> |
|||
|
|||
|
|||
x_base __attribute__((naked)) DisableLocalInterrupt() |
|||
{ |
|||
asm volatile ("MRS r0, PRIMASK"); |
|||
asm volatile ("CPSID I"); |
|||
asm volatile ("BX LR "); |
|||
} |
|||
|
|||
void __attribute__((naked)) EnableLocalInterrupt(x_base level) |
|||
{ |
|||
asm volatile ("MSR PRIMASK, r0"); |
|||
asm volatile ("BX LR"); |
|||
} |
|||
|
|||
int32 ArchEnableHwIrq(uint32 irq_num) |
|||
{ |
|||
return EOK; |
|||
} |
|||
|
|||
int32 ArchDisableHwIrq(uint32 irq_num) |
|||
{ |
|||
return EOK; |
|||
} |
|||
|
|||
extern void KTaskOsAssignAfterIrq(void *context); |
|||
|
|||
void IsrEntry() |
|||
{ |
|||
uint32 ipsr; |
|||
|
|||
__asm__ volatile("MRS %0, IPSR" : "=r"(ipsr)); |
|||
isrManager.done->incCounter(); |
|||
isrManager.done->handleIrq(ipsr); |
|||
KTaskOsAssignAfterIrq(NONE); |
|||
isrManager.done->decCounter(); |
|||
|
|||
} |
|||
|
|||
void UsageFault_Handler(int irqn, void *arg) |
|||
{ |
|||
/* Go to infinite loop when Usage Fault exception occurs */ |
|||
while (1) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
void BusFault_Handler(int irqn, void *arg) |
|||
{ |
|||
/* Go to infinite loop when Bus Fault exception occurs */ |
|||
while (1) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
void NMI_Handler(int irqn, void *arg) |
|||
{ |
|||
while (1) |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,308 @@ |
|||
/* ------------------------------------------------------------------------- */ |
|||
/* @file: startup_MIMXRT1052.s */ |
|||
/* @purpose: CMSIS Cortex-M7 Core Device Startup File */ |
|||
/* MIMXRT1052 */ |
|||
/* @version: 1.0 */ |
|||
/* @date: 2018-9-21 */ |
|||
/* @build: b180921 */ |
|||
/* ------------------------------------------------------------------------- */ |
|||
/* */ |
|||
/* Copyright 1997-2016 Freescale Semiconductor, Inc. */ |
|||
/* Copyright 2016-2018 NXP */ |
|||
/* All rights reserved. */ |
|||
/* */ |
|||
/* SPDX-License-Identifier: BSD-3-Clause */ |
|||
/*****************************************************************************/ |
|||
/* Version: GCC for ARM Embedded Processors */ |
|||
/*****************************************************************************/ |
|||
|
|||
|
|||
/** |
|||
* @file interrupt_vector.S |
|||
* @brief vector table for Cortex M7 |
|||
* @version 1.0 |
|||
* @author AIIT XUOS Lab |
|||
* @date 2021-05-28 |
|||
*/ |
|||
|
|||
/************************************************* |
|||
File name: interrupt_vector.S |
|||
Description: vector table for a Cortex M7 |
|||
Others: |
|||
History: |
|||
1. Date: 2021-05-28 |
|||
Author: AIIT XUOS Lab |
|||
Modification: |
|||
1. add IsrEntry as default isr function |
|||
*************************************************/ |
|||
|
|||
.syntax unified |
|||
.arch armv7-m |
|||
|
|||
.section .isr_vector, "a" |
|||
.align 2 |
|||
.globl __isr_vector |
|||
__isr_vector: |
|||
.long __StackTop /* Top of Stack */ |
|||
.long Reset_Handler /* Reset Handler */ |
|||
.long NMI_Handler /* NMI Handler*/ |
|||
.long HardFaultHandler /* Hard Fault Handler*/ |
|||
.long MemFaultHandler /* MPU Fault Handler*/ |
|||
.long BusFault_Handler /* Bus Fault Handler*/ |
|||
.long UsageFault_Handler /* Usage Fault Handler*/ |
|||
.long 0 /* Reserved*/ |
|||
.long 0 /* Reserved*/ |
|||
.long 0 /* Reserved*/ |
|||
.long 0 /* Reserved*/ |
|||
.long IsrEntry /* SVCall Handler*/ |
|||
.long IsrEntry /* Debug Monitor Handler*/ |
|||
.long 0 /* Reserved*/ |
|||
.long PendSV_Handler /* PendSV Handler*/ |
|||
.long IsrEntry /* SysTick Handler*/ |
|||
|
|||
/* External Interrupts*/ |
|||
.long IsrEntry /* DMA channel 0/16 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 1/17 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 2/18 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 3/19 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 4/20 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 5/21 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 6/22 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 7/23 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 8/24 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 9/25 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 10/26 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 11/27 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 12/28 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 13/29 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 14/30 transfer complete*/ |
|||
.long IsrEntry /* DMA channel 15/31 transfer complete*/ |
|||
.long IsrEntry /* DMA error interrupt channels 0-15 / 16-31*/ |
|||
.long IsrEntry /* CTI0_Error*/ |
|||
.long IsrEntry /* CTI1_Error*/ |
|||
.long IsrEntry /* CorePlatform exception IRQ*/ |
|||
.long IsrEntry /* LPUART1 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPUART2 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPUART3 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPUART4 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPUART5 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPUART6 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPUART7 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPUART8 TX interrupt and RX interrupt*/ |
|||
.long IsrEntry /* LPI2C1 interrupt*/ |
|||
.long IsrEntry /* LPI2C2 interrupt*/ |
|||
.long IsrEntry /* LPI2C3 interrupt*/ |
|||
.long IsrEntry /* LPI2C4 interrupt*/ |
|||
.long IsrEntry /* LPSPI1 single interrupt vector for all sources*/ |
|||
.long IsrEntry /* LPSPI2 single interrupt vector for all sources*/ |
|||
.long IsrEntry /* LPSPI3 single interrupt vector for all sources*/ |
|||
.long IsrEntry /* LPSPI4 single interrupt vector for all sources*/ |
|||
.long IsrEntry /* CAN1 interrupt*/ |
|||
.long IsrEntry /* CAN2 interrupt*/ |
|||
.long IsrEntry /* FlexRAM address out of range Or access hit IRQ*/ |
|||
.long IsrEntry /* Keypad nterrupt*/ |
|||
.long IsrEntry /* TSC interrupt*/ |
|||
.long IsrEntry /* GPR interrupt*/ |
|||
.long IsrEntry /* LCDIF interrupt*/ |
|||
.long IsrEntry /* CSI interrupt*/ |
|||
.long IsrEntry /* PXP interrupt*/ |
|||
.long IsrEntry /* WDOG2 interrupt*/ |
|||
.long IsrEntry /* SRTC Consolidated Interrupt. Non TZ*/ |
|||
.long IsrEntry /* SRTC Security Interrupt. TZ*/ |
|||
.long IsrEntry /* ON-OFF button press shorter than 5 secs (pulse event)*/ |
|||
.long IsrEntry /* CSU interrupt*/ |
|||
.long IsrEntry /* DCP_IRQ interrupt*/ |
|||
.long IsrEntry /* DCP_VMI_IRQ interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* TRNG interrupt*/ |
|||
.long IsrEntry /* SJC interrupt*/ |
|||
.long IsrEntry /* BEE interrupt*/ |
|||
.long IsrEntry /* SAI1 interrupt*/ |
|||
.long IsrEntry /* SAI1 interrupt*/ |
|||
.long IsrEntry /* SAI3 interrupt*/ |
|||
.long IsrEntry /* SAI3 interrupt*/ |
|||
.long IsrEntry /* SPDIF interrupt*/ |
|||
.long IsrEntry /* Brown-out event interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* TempSensor low/high interrupt*/ |
|||
.long IsrEntry /* TempSensor panic interrupt*/ |
|||
.long IsrEntry /* USBPHY (UTMI0), Interrupt*/ |
|||
.long IsrEntry /* USBPHY (UTMI0), Interrupt*/ |
|||
.long IsrEntry /* ADC1 interrupt*/ |
|||
.long IsrEntry /* ADC2 interrupt*/ |
|||
.long IsrEntry /* DCDC interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT0 from GPIO*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT1 from GPIO*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT2 from GPIO*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT3 from GPIO*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT4 from GPIO*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT5 from GPIO*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT6 from GPIO*/ |
|||
.long IsrEntry /* Active HIGH Interrupt from INT7 from GPIO*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO1 signal 0 throughout 15*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO1 signal 16 throughout 31*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO2 signal 0 throughout 15*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO2 signal 16 throughout 31*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO3 signal 0 throughout 15*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO3 signal 16 throughout 31*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO4 signal 0 throughout 15*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO4 signal 16 throughout 31*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO5 signal 0 throughout 15*/ |
|||
.long IsrEntry /* Combined interrupt indication for GPIO5 signal 16 throughout 31*/ |
|||
.long IsrEntry /* FLEXIO1 interrupt*/ |
|||
.long IsrEntry /* FLEXIO2 interrupt*/ |
|||
.long IsrEntry /* WDOG1 interrupt*/ |
|||
.long IsrEntry /* RTWDOG interrupt*/ |
|||
.long IsrEntry /* EWM interrupt*/ |
|||
.long IsrEntry /* CCM IRQ1 interrupt*/ |
|||
.long IsrEntry /* CCM IRQ2 interrupt*/ |
|||
.long IsrEntry /* GPC interrupt*/ |
|||
.long IsrEntry /* SRC interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* GPT1 interrupt*/ |
|||
.long IsrEntry /* GPT2 interrupt*/ |
|||
.long IsrEntry /* PWM1 capture 0, compare 0, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM1 capture 1, compare 1, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM1 capture 2, compare 2, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM1 capture 3, compare 3, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM1 fault or reload error interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* FlexSPI0 interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* USDHC1 interrupt*/ |
|||
.long IsrEntry /* USDHC2 interrupt*/ |
|||
.long IsrEntry /* USBO2 USB OTG2*/ |
|||
.long IsrEntry /* USBO2 USB OTG1*/ |
|||
.long IsrEntry /* ENET interrupt*/ |
|||
.long IsrEntry /* ENET_1588_Timer interrupt*/ |
|||
.long IsrEntry /* XBAR1 interrupt*/ |
|||
.long IsrEntry /* XBAR1 interrupt*/ |
|||
.long IsrEntry /* ADCETC IRQ0 interrupt*/ |
|||
.long IsrEntry /* ADCETC IRQ1 interrupt*/ |
|||
.long IsrEntry /* ADCETC IRQ2 interrupt*/ |
|||
.long IsrEntry /* ADCETC Error IRQ interrupt*/ |
|||
.long IsrEntry /* PIT interrupt*/ |
|||
.long IsrEntry /* ACMP interrupt*/ |
|||
.long IsrEntry /* ACMP interrupt*/ |
|||
.long IsrEntry /* ACMP interrupt*/ |
|||
.long IsrEntry /* ACMP interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* Reserved interrupt*/ |
|||
.long IsrEntry /* ENC1 interrupt*/ |
|||
.long IsrEntry /* ENC2 interrupt*/ |
|||
.long IsrEntry /* ENC3 interrupt*/ |
|||
.long IsrEntry /* ENC4 interrupt*/ |
|||
.long IsrEntry /* TMR1 interrupt*/ |
|||
.long IsrEntry /* TMR2 interrupt*/ |
|||
.long IsrEntry /* TMR3 interrupt*/ |
|||
.long IsrEntry /* TMR4 interrupt*/ |
|||
.long IsrEntry /* PWM2 capture 0, compare 0, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM2 capture 1, compare 1, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM2 capture 2, compare 2, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM2 capture 3, compare 3, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM2 fault or reload error interrupt*/ |
|||
.long IsrEntry /* PWM3 capture 0, compare 0, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM3 capture 1, compare 1, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM3 capture 2, compare 2, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM3 capture 3, compare 3, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM3 fault or reload error interrupt*/ |
|||
.long IsrEntry /* PWM4 capture 0, compare 0, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM4 capture 1, compare 1, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM4 capture 2, compare 2, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM4 capture 3, compare 3, or reload 0 interrupt*/ |
|||
.long IsrEntry /* PWM4 fault or reload error interrupt*/ |
|||
.long IsrEntry /* 168*/ |
|||
.long IsrEntry /* 169*/ |
|||
.long IsrEntry /* 170*/ |
|||
.long IsrEntry /* 171*/ |
|||
.long IsrEntry /* 172*/ |
|||
.long IsrEntry /* 173*/ |
|||
.long IsrEntry /* 174*/ |
|||
.long IsrEntry /* 175*/ |
|||
.long IsrEntry /* 176*/ |
|||
.long IsrEntry /* 177*/ |
|||
.long IsrEntry /* 178*/ |
|||
.long IsrEntry /* 179*/ |
|||
.long IsrEntry /* 180*/ |
|||
.long IsrEntry /* 181*/ |
|||
.long IsrEntry /* 182*/ |
|||
.long IsrEntry /* 183*/ |
|||
.long IsrEntry /* 184*/ |
|||
.long IsrEntry /* 185*/ |
|||
.long IsrEntry /* 186*/ |
|||
.long IsrEntry /* 187*/ |
|||
.long IsrEntry /* 188*/ |
|||
.long IsrEntry /* 189*/ |
|||
.long IsrEntry /* 190*/ |
|||
.long IsrEntry /* 191*/ |
|||
.long IsrEntry /* 192*/ |
|||
.long IsrEntry /* 193*/ |
|||
.long IsrEntry /* 194*/ |
|||
.long IsrEntry /* 195*/ |
|||
.long IsrEntry /* 196*/ |
|||
.long IsrEntry /* 197*/ |
|||
.long IsrEntry /* 198*/ |
|||
.long IsrEntry /* 199*/ |
|||
.long IsrEntry /* 200*/ |
|||
.long IsrEntry /* 201*/ |
|||
.long IsrEntry /* 202*/ |
|||
.long IsrEntry /* 203*/ |
|||
.long IsrEntry /* 204*/ |
|||
.long IsrEntry /* 205*/ |
|||
.long IsrEntry /* 206*/ |
|||
.long IsrEntry /* 207*/ |
|||
.long IsrEntry /* 208*/ |
|||
.long IsrEntry /* 209*/ |
|||
.long IsrEntry /* 210*/ |
|||
.long IsrEntry /* 211*/ |
|||
.long IsrEntry /* 212*/ |
|||
.long IsrEntry /* 213*/ |
|||
.long IsrEntry /* 214*/ |
|||
.long IsrEntry /* 215*/ |
|||
.long IsrEntry /* 216*/ |
|||
.long IsrEntry /* 217*/ |
|||
.long IsrEntry /* 218*/ |
|||
.long IsrEntry /* 219*/ |
|||
.long IsrEntry /* 220*/ |
|||
.long IsrEntry /* 221*/ |
|||
.long IsrEntry /* 222*/ |
|||
.long IsrEntry /* 223*/ |
|||
.long IsrEntry /* 224*/ |
|||
.long IsrEntry /* 225*/ |
|||
.long IsrEntry /* 226*/ |
|||
.long IsrEntry /* 227*/ |
|||
.long IsrEntry /* 228*/ |
|||
.long IsrEntry /* 229*/ |
|||
.long IsrEntry /* 230*/ |
|||
.long IsrEntry /* 231*/ |
|||
.long IsrEntry /* 232*/ |
|||
.long IsrEntry /* 233*/ |
|||
.long IsrEntry /* 234*/ |
|||
.long IsrEntry /* 235*/ |
|||
.long IsrEntry /* 236*/ |
|||
.long IsrEntry /* 237*/ |
|||
.long IsrEntry /* 238*/ |
|||
.long IsrEntry /* 239*/ |
|||
.long IsrEntry /* 240*/ |
|||
.long IsrEntry /* 241*/ |
|||
.long IsrEntry /* 242*/ |
|||
.long IsrEntry /* 243*/ |
|||
.long IsrEntry /* 244*/ |
|||
.long IsrEntry /* 245*/ |
|||
.long IsrEntry /* 246*/ |
|||
.long IsrEntry /* 247*/ |
|||
.long IsrEntry /* 248*/ |
|||
.long IsrEntry /* 249*/ |
|||
.long IsrEntry /* 250*/ |
|||
.long IsrEntry /* 251*/ |
|||
.long IsrEntry /* 252*/ |
|||
.long IsrEntry /* 253*/ |
|||
.long IsrEntry /* 254*/ |
|||
.long 0xFFFFFFFF /* Reserved for user TRIM value*/ |
|||
|
|||
.size __isr_vector, . - __isr_vector |
|||
|
|||
.text |
|||
.thumb |
@ -0,0 +1,52 @@ |
|||
mainmenu "XiUOS Project Configuration" |
|||
|
|||
config BSP_DIR |
|||
string |
|||
option env="BSP_ROOT" |
|||
default "." |
|||
|
|||
config KERNEL_DIR |
|||
string |
|||
option env="KERNEL_ROOT" |
|||
default "../.." |
|||
|
|||
config BOARD_CORTEX_M7_EVB |
|||
bool |
|||
select ARCH_ARM |
|||
default y |
|||
|
|||
|
|||
source "$KERNEL_DIR/arch/Kconfig" |
|||
|
|||
menu "ok1052-c feature" |
|||
source "$BSP_DIR/third_party_driver/Kconfig" |
|||
|
|||
menu "config default board resources" |
|||
menu "config board app name" |
|||
config BOARD_APP_NAME |
|||
string "config board app name" |
|||
default "/XiUOS_ok1052C_app.bin" |
|||
endmenu |
|||
|
|||
menu "config board service table" |
|||
config SERVICE_TABLE_ADDRESS |
|||
hex "board service table address" |
|||
default 0x2007F0000 |
|||
endmenu |
|||
|
|||
endmenu |
|||
|
|||
config __STACKSIZE__ |
|||
int "stack size for interrupt" |
|||
default 4096 |
|||
|
|||
endmenu |
|||
|
|||
|
|||
menu "Hardware feature" |
|||
source "$KERNEL_DIR/resources/Kconfig" |
|||
endmenu |
|||
|
|||
source "$KERNEL_DIR/Kconfig" |
|||
|
|||
|
@ -0,0 +1,5 @@ |
|||
SRC_DIR := third_party_driver |
|||
|
|||
SRC_FILES := board.c clock_config.c pin_mux.c |
|||
|
|||
include $(KERNEL_ROOT)/compiler.mk |
@ -0,0 +1,164 @@ |
|||
# ไป้ถๅผๅงๆๅปบ็ฝ็ๅทฅไธ็ฉ่ๆไฝ็ณป็ป๏ผไฝฟ็จARMๆถๆ็ok1052-c |
|||
|
|||
# ok1052-c |
|||
|
|||
[XiUOS](http://xuos.io/) (X Industrial Ubiquitous Operating System) ็ฝ็XiUOSๆฏไธๆฌพ้ขๅๆบๆ
ง่ฝฆ้ด็ๅทฅไธ็ฉ่็ฝๆไฝ็ณป็ป๏ผไธป่ฆ็ฑไธไธชๆ็ฎ็ๅพฎๅๅฎๆถๆไฝ็ณป็ปๅ
ๆ ธๅๅ
ถไธ็ๅทฅไธ็ฉ่ๆกๆถๆๆ๏ผ้่ฟ้ซๆ็ฎก็ๅทฅไธ็ฉ่็ฝ่ฎพๅคใๆฏๆๅทฅไธ็ฉ่ๅบ็จ๏ผๅจ็ไบง่ฝฆ้ดๅ
ๅฎ็ฐๆบ่ฝๅ็โๆ็ฅ็ฏๅขใ่็ฝไผ ่พใ็ฅๆ่ฏๅซใๆงๅถ่ฐๆดโ๏ผไฟ่ฟไปฅๅทฅไธ่ฎพๅคๅๅทฅไธๆงๅถ็ณป็ปไธบๆ ธๅฟ็ไบบใๆบใ็ฉๆทฑๅบฆไบ่๏ผๅธฎๅฉๆๅ็ไบง็บฟ็ๆฐๅญๅๅๆบ่ฝๅๆฐดๅนณใ |
|||
|
|||
## 1. ็ฎไป |
|||
|
|||
| ็กฌไปถ | ๆ่ฟฐ | |
|||
| -- | -- | |
|||
|่ฏ็ๅๅท| MIMXRT1052DVL6A | |
|||
|ๆถๆ| cortex-m7 | |
|||
|ไธป้ข| 600MHz | |
|||
|็ๅ
SRAM| 512KB shared with TCM | |
|||
|ๅค่ฎพๆฏๆ| UART | |
|||
|
|||
XiUOSๆฟ็บงๅฝๅๆฏๆไฝฟ็จUARTใ |
|||
|
|||
## 2. ๅผๅ็ฏๅขๆญๅปบ |
|||
|
|||
### ๆจ่ไฝฟ็จ๏ผ |
|||
|
|||
**ๆไฝ็ณป็ป๏ผ** ubuntu18.04 [https://ubuntu.com/download/desktop](https://ubuntu.com/download/desktop) |
|||
|
|||
ๆดๆฐ`ubuntu 18.04`ๆบ็ๆนๆณ:๏ผๆ นๆฎ่ช่บซๆ
ๅต่ๅฎ๏ผๅฏไปฅไธๆดๆน๏ผ |
|||
|
|||
็ฌฌไธๆญฅ:ๆๅผsources.listๆไปถ |
|||
|
|||
```c |
|||
sudo vim /etc/apt/sources.list |
|||
``` |
|||
|
|||
็ฌฌไบๆญฅ:ๅฐไปฅไธๅ
ๅฎนๅคๅถๅฐsources.listๆไปถ |
|||
|
|||
```c |
|||
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse |
|||
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse |
|||
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse |
|||
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse |
|||
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse |
|||
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse |
|||
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse |
|||
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse |
|||
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse |
|||
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse |
|||
``` |
|||
|
|||
็ฌฌไธๆญฅ:ๆดๆฐๆบๅ็ณป็ป่ฝฏไปถ |
|||
|
|||
```c |
|||
sudo apt-get update |
|||
sudo apt-get upgrade |
|||
``` |
|||
|
|||
**ๅผๅๅทฅๅ
ทๆจ่ไฝฟ็จ VSCode ๏ผVScodeไธ่ฝฝๅฐๅไธบ๏ผ** VSCode [https://code.visualstudio.com/](https://code.visualstudio.com/)๏ผๆจ่ไธ่ฝฝๅฐๅไธบ [http://vscode.cdn.azure.cn/stable/3c4e3df9e89829dce27b7b5c24508306b151f30d/code_1.55.2-1618307277_amd64.deb](http://vscode.cdn.azure.cn/stable/3c4e3df9e89829dce27b7b5c24508306b151f30d/code_1.55.2-1618307277_amd64.deb) |
|||
|
|||
### ไพ่ตๅ
ๅฎ่ฃ
๏ผ |
|||
|
|||
``` |
|||
$ sudo apt install build-essential pkg-config git |
|||
$ sudo apt install gcc make libncurses5-dev openssl libssl-dev bison flex libelf-dev autoconf libtool gperf libc6-dev |
|||
``` |
|||
|
|||
**XiUOSๆไฝ็ณป็ปๆบ็ ไธ่ฝฝ๏ผ** XiUOS [https://forgeplus.trustie.net/projects/xuos/xiuos](https://forgeplus.trustie.net/projects/xuos/xiuos) |
|||
|
|||
ๆฐๅปบไธไธช็ฉบๆไปถๅคนๅนถ่ฟๅ
ฅๆไปถๅคนไธญ๏ผๅนถไธ่ฝฝๆบ็ ๏ผๅ
ทไฝๅฝไปคๅฆไธ๏ผ |
|||
|
|||
```c |
|||
mkdir test && cd test |
|||
git clone https://git.trustie.net/xuos/xiuos.git |
|||
``` |
|||
|
|||
ๆๅผๆบ็ ๆไปถๅ
ๅฏไปฅ็ๅฐไปฅไธ็ฎๅฝ๏ผ |
|||
| ๅ็งฐ | ่ฏดๆ | |
|||
| -- | -- | |
|||
| application | ๅบ็จไปฃ็ | |
|||
| board | ๆฟ็บงๆฏๆๅ
| |
|||
| framework | ๅบ็จๆกๆถ | |
|||
| fs | ๆไปถ็ณป็ป | |
|||
| kernel | ๅ
ๆ ธๆบ็ | |
|||
| resources | ้ฉฑๅจๆไปถ | |
|||
| tool | ็ณป็ปๅทฅๅ
ท | |
|||
|
|||
ไฝฟ็จVScodeๆๅผไปฃ็ ๏ผๅ
ทไฝๆไฝๆญฅ้ชคไธบ๏ผๅจๆบ็ ๆไปถๅคนไธๆๅผ็ณป็ป็ป็ซฏ๏ผ่พๅ
ฅ`code .`ๅณๅฏๆๅผVScodeๅผๅ็ฏๅข๏ผๅฆไธๅพๆ็คบ๏ผ |
|||
|
|||
<div align= "center"> |
|||
<img src = ./img/vscode.jpg width =1000> |
|||
</div> |
|||
|
|||
### ่ฃๅ้
็ฝฎๅทฅๅ
ท็ไธ่ฝฝ |
|||
|
|||
่ฃๅ้
็ฝฎๅทฅๅ
ท๏ผ |
|||
|
|||
**ๅทฅๅ
ทๅฐๅ๏ผ** kconfig-frontends [https://forgeplus.trustie.net/projects/xuos/kconfig-frontends](https://forgeplus.trustie.net/projects/xuos/kconfig-frontends)๏ผไธ่ฝฝไธๅฎ่ฃ
็ๅ
ทไฝๅฝไปคๅฆไธ๏ผ |
|||
|
|||
```c |
|||
mkdir kfrontends && cd kfrontends |
|||
git clone https://git.trustie.net/xuos/kconfig-frontends.git |
|||
``` |
|||
|
|||
ไธ่ฝฝๆบ็ ๅๆไปฅไธๆญฅ้ชคๆง่ก่ฝฏไปถๅฎ่ฃ
๏ผ |
|||
|
|||
```c |
|||
cd kconfig-frontends |
|||
./xs_build.sh |
|||
``` |
|||
|
|||
### ็ผ่ฏๅทฅๅ
ท้พ๏ผ |
|||
|
|||
ARM๏ผ arm-none-eabi(`gcc version 6.3.1`)๏ผ้ป่ฎคๅฎ่ฃ
ๅฐUbuntu็/usr/bin/arm-none-eabi-๏ผไฝฟ็จๅฆไธๅฝไปค่กไธ่ฝฝๅๅฎ่ฃ
ใ |
|||
|
|||
```shell |
|||
$ sudo apt install gcc-arm-none-eabi |
|||
``` |
|||
|
|||
## ็ผ่ฏ่ฏดๆ |
|||
|
|||
### ็ผ่พ็ฏๅข๏ผ`Ubuntu18.04` |
|||
|
|||
### ็ผ่ฏๅทฅๅ
ท้พ๏ผ`arm-none-eabi-gcc` |
|||
ไฝฟ็จ`VScode`ๆๅผๅทฅ็จ็ๆนๆณๆๅค็ง๏ผๆฌๆไป็ปไธ็งๅฟซๆท้ฎ๏ผๅจ้กน็ฎ็ฎๅฝไธๅฐ`code .`่พๅ
ฅlinux็ณป็ปๅฝไปค็ป็ซฏๅณๅฏๆๅผ็ฎๆ ้กน็ฎ |
|||
|
|||
|
|||
็ผ่ฏๆญฅ้ชค๏ผ |
|||
|
|||
1.ๅจVScodeๅฝไปค็ป็ซฏไธญๆง่กไปฅไธๅฝไปค๏ผ็ๆ้
็ฝฎๆไปถ |
|||
|
|||
```c |
|||
make BOARD=ok1052-c menuconfig |
|||
``` |
|||
|
|||
2.ๅจmenuconfig็้ข้
็ฝฎ้่ฆๅ
ณ้ญๅๅผๅฏ็ๅ่ฝ๏ผๆๅ่ฝฆ้ฎ่ฟๅ
ฅไธ็บง่ๅ๏ผๆY้ฎ้ไธญ้่ฆๅผๅฏ็ๅ่ฝ๏ผๆN้ฎ้ไธญ้่ฆๅ
ณ้ญ็ๅ่ฝ๏ผ้
็ฝฎ็ปๆๅไฟๅญๅนถ้ๅบ๏ผๆฌไพๆจๅจๆผ็คบ็ฎๅ็่พๅบไพ็จ๏ผๆไปฅๆฒกๆ้่ฆ้
็ฝฎ็้้กน๏ผๅๅปๅฟซๆท้ฎESC้ๅบ้
็ฝฎ๏ผ |
|||
|
|||
 |
|||
|
|||
้ๅบๆถ้ๆฉ`yes`ไฟๅญไธ้ขๆ้
็ฝฎ็ๅ
ๅฎน๏ผๅฆไธๅพๆ็คบ๏ผ |
|||
|
|||
 |
|||
|
|||
3.็ปง็ปญๆง่กไปฅไธๅฝไปค๏ผ่ฟ่ก็ผ่ฏ |
|||
|
|||
``` |
|||
make BOARD=ok1052-c |
|||
``` |
|||
|
|||
4.ๅฆๆ็ผ่ฏๆญฃ็กฎๆ ่ฏฏ๏ผไผไบง็XiUOS_ok1052-c.elfใXiUOS_ok1052-c.binๆไปถใ |
|||
|
|||
## 3. ็งๅๅ่ฟ่ก |
|||
|
|||
### 3.1 ็งๅ |
|||
1ใ็งๅๅทฅๅ
ท๏ผNXP MCU Boot Utility๏ผๅฏๅ่[https://github.com/JayHeng/NXP-MCUBootUtility](https://github.com/JayHeng/NXP-MCUBootUtility) |
|||
|
|||
2ใok1052-cๅผๅๆฟๆฏๆmicro usbๅฃ็งๅ็จๅบ๏ผๆๅผNXP MCU Boot Utilityๅ๏ผ้ๆฉๅฅฝ่ฏ็็ฑปๅไธบi.MXRT105x๏ผๅผๅๆฟไธ็ต๏ผไฝฟ็จusb็บฟๅฐๅผๅๆฟๅPC่ฟๆฅ๏ผๆจ็ ๅผๅ
ณ่ฎพ็ฝฎไธบ1 on 2 on 3 off 4 off๏ผๆไธๅคไฝ้ฎK1ๅ๏ผ่ฅ่ฟๆฅๆๅ๏ผๅฏ่งVendor IDๅProduct IDๅๆๆฐๅญๆพ็คบ๏ผ็นๅปreconnect๏ผ็ญๅพ
NXP MCU Boot Utilityไธญ็บข่ฒๆพ็คบๅๆ่่ฒๆพ็คบ๏ผๅ่กจ็คบๅทฒๆญฃ็กฎ่ฏๅซๅนถ่ฟๆฅๅฐไบๅผๅๆฟใๅฆไธๅพๆ็คบ๏ผ |
|||
 |
|||
|
|||
3ใ้ๆฉ็ผ่ฏ็ๆ็XiUOS_ok1052-c.elfๆไปถ่ทฏๅพ๏ผๅนถ้ๆฉ.out(elf) from GCC ARM็งๅ้้กน๏ผๆๅ็นๅปALL-In-One Actionๅณๅฏ็งๅ็จๅบ๏ผ่ฅ็งๅๆ ่ฏฏ๏ผๅไธๅ็ปฟ่ฒ่ฟๅบฆๆกไผๆง่กๅฐๅบใๅฆไธๅพๆ็คบ๏ผ |
|||
 |
|||
|
|||
### 3.2 ่ฟ่ก็ปๆ |
|||
|
|||
1ใๅผๅๆฟๆฏๆrs232ไธฒๅฃ่ฟๆฅ๏ผไฝฟ็จrs232ไธฒๅฃ็บฟๆrs232่ฝฌusb็บฟๅฐๅผๅๆฟๅPC่ฟๆฅ๏ผไฝฟ็จไธฒๅฃ็ป็ซฏๅทฅๅ
ทๅฏ่ฏๅซๅนถ่ฟๆฅๅผๅๆฟ |
|||
|
|||
2ใๆ็
ง3.1็งๅๆญฅ้ชคๆง่กๅ๏ผๅฐๆจ็ ๅผๅ
ณ่ฎพ็ฝฎไธบ1 off 2 off 3 off 4 off๏ผๆไธๅคไฝ้ฎK1ๅ๏ผ่ฅ็จๅบๆญฃๅธธ๏ผๅไธฒๅฃ็ป็ซฏไธไผๆพ็คบๅฏๅจไฟกๆฏๆๅฐ่พๅบใๅฆไธๅพๆ็คบ๏ผ |
|||
 |
@ -0,0 +1,184 @@ |
|||
/*
|
|||
* Copyright 2017 NXP |
|||
* All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
/**
|
|||
* @file board.c |
|||
* @brief support imxrt1052-board init configure and start-up |
|||
* @version 1.0 |
|||
* @author AIIT XUOS Lab |
|||
* @date 2021-05-29 |
|||
*/ |
|||
|
|||
/*************************************************
|
|||
File name: board.c |
|||
Description: support imxrt1052-board init configure and driver/task/... init |
|||
Others: take SDK_2.6.1_MIMXRT1052xxxxB/devices/MIMXRT1052/project_template/board.c |
|||
History: |
|||
1. Date: 2021-05-29 |
|||
Author: AIIT XUOS Lab |
|||
Modification: |
|||
1. support imxrt1052-board InitBoardHardware |
|||
*************************************************/ |
|||
|
|||
#include "board.h" |
|||
#include "pin_mux.h" |
|||
#include "fsl_iomuxc.h" |
|||
#include "fsl_gpio.h" |
|||
#include <connect_uart.h> |
|||
#include "fsl_lpuart.h" |
|||
|
|||
#define NVIC_PRIORITYGROUP_0 0x00000007U /*!< 0 bits for pre-emption priority |
|||
4 bits for subpriority */ |
|||
#define NVIC_PRIORITYGROUP_1 0x00000006U /*!< 1 bits for pre-emption priority |
|||
3 bits for subpriority */ |
|||
#define NVIC_PRIORITYGROUP_2 0x00000005U /*!< 2 bits for pre-emption priority |
|||
2 bits for subpriority */ |
|||
#define NVIC_PRIORITYGROUP_3 0x00000004U /*!< 3 bits for pre-emption priority |
|||
1 bits for subpriority */ |
|||
#define NVIC_PRIORITYGROUP_4 0x00000003U /*!< 4 bits for pre-emption priority |
|||
0 bits for subpriority */ |
|||
|
|||
/* MPU configuration. */ |
|||
static void BOARD_ConfigMPU(void) |
|||
{ |
|||
/* Disable I cache and D cache */ |
|||
SCB_DisableICache(); |
|||
SCB_DisableDCache(); |
|||
|
|||
/* Disable MPU */ |
|||
ARM_MPU_Disable(); |
|||
|
|||
/* Region 0 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(0, 0xC0000000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB); |
|||
|
|||
/* Region 1 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(1, 0x80000000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB); |
|||
|
|||
/* Region 2 setting */ |
|||
// spi flash: normal type, cacheable, no bufferable, no shareable
|
|||
MPU->RBAR = ARM_MPU_RBAR(2, 0x60000000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 0, 0, ARM_MPU_REGION_SIZE_512MB); |
|||
|
|||
/* Region 3 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(3, 0x00000000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB); |
|||
|
|||
/* Region 4 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(4, 0x00000000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB); |
|||
|
|||
/* Region 5 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(5, 0x20000000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB); |
|||
|
|||
/* Region 6 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(6, 0x20200000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB); |
|||
|
|||
#if defined(BSP_USING_SDRAM) |
|||
/* Region 7 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(7, 0x80000000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_32MB); |
|||
|
|||
/* Region 8 setting */ |
|||
MPU->RBAR = ARM_MPU_RBAR(8, 0x81E00000U); |
|||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 1, 1, 0, 0, 0, ARM_MPU_REGION_SIZE_2MB); |
|||
#endif |
|||
|
|||
/* Enable MPU */ |
|||
ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); |
|||
|
|||
/* Enable I cache and D cache */ |
|||
SCB_EnableDCache(); |
|||
SCB_EnableICache(); |
|||
} |
|||
|
|||
|
|||
/* This is the timer interrupt service routine. */ |
|||
void SysTick_Handler(int irqn, void *arg) |
|||
{ |
|||
TickAndTaskTimesliceUpdate(); |
|||
} |
|||
DECLARE_HW_IRQ(SYSTICK_IRQN, SysTick_Handler, NONE); |
|||
|
|||
#ifdef BSP_USING_LPUART |
|||
void imxrt_uart_pins_init(void) |
|||
{ |
|||
#ifdef BSP_USING_LPUART1 |
|||
|
|||
IOMUXC_SetPinMux( |
|||
IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 is configured as LPUART1_TX */ |
|||
0U); /* Software Input On Field: Input Path is determined by functionality */ |
|||
IOMUXC_SetPinMux( |
|||
IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 is configured as LPUART1_RX */ |
|||
0U); /* Software Input On Field: Input Path is determined by functionality */ |
|||
IOMUXC_SetPinConfig( |
|||
IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 PAD functional properties : */ |
|||
0x10B0u); /* Slew Rate Field: Slow Slew Rate
|
|||
Drive Strength Field: R0/6 |
|||
Speed Field: medium(100MHz) |
|||
Open Drain Enable Field: Open Drain Disabled |
|||
Pull / Keep Enable Field: Pull/Keeper Enabled |
|||
Pull / Keep Select Field: Keeper |
|||
Pull Up / Down Config. Field: 100K Ohm Pull Down |
|||
Hyst. Enable Field: Hysteresis Disabled */ |
|||
IOMUXC_SetPinConfig( |
|||
IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 PAD functional properties : */ |
|||
0x10B0u); /* Slew Rate Field: Slow Slew Rate
|
|||
Drive Strength Field: R0/6 |
|||
Speed Field: medium(100MHz) |
|||
Open Drain Enable Field: Open Drain Disabled |
|||
Pull / Keep Enable Field: Pull/Keeper Enabled |
|||
Pull / Keep Select Field: Keeper |
|||
Pull Up / Down Config. Field: 100K Ohm Pull Down |
|||
Hyst. Enable Field: Hysteresis Disabled */ |
|||
#endif |
|||
#ifdef BSP_USING_LPUART2 |
|||
|
|||
IOMUXC_SetPinMux( |
|||
IOMUXC_GPIO_AD_B1_02_LPUART2_TX, |
|||
0U); |
|||
IOMUXC_SetPinMux( |
|||
IOMUXC_GPIO_AD_B1_03_LPUART2_RX, |
|||
0U); |
|||
IOMUXC_SetPinConfig( |
|||
IOMUXC_GPIO_AD_B1_02_LPUART2_TX, |
|||
0x10B0u); |
|||
IOMUXC_SetPinConfig( |
|||
IOMUXC_GPIO_AD_B1_03_LPUART2_RX, |
|||
0x10B0u); |
|||
|
|||
#endif |
|||
|
|||
} |
|||
#endif /* BSP_USING_LPUART */ |
|||
|
|||
/**
|
|||
* This function will initial rt1050 board. |
|||
*/ |
|||
void InitBoardHardware() |
|||
{ |
|||
BOARD_ConfigMPU(); |
|||
BOARD_InitPins(); |
|||
BOARD_BootClockRUN(); |
|||
|
|||
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
|||
SysTick_Config(SystemCoreClock / TICK_PER_SECOND); |
|||
|
|||
#ifdef BSP_USING_LPUART |
|||
imxrt_uart_pins_init(); |
|||
#endif |
|||
|
|||
InitBoardMemory((void *)HEAP_BEGIN, (void *)HEAP_END); |
|||
|
|||
Imrt1052HwUartInit(); |
|||
|
|||
InstallConsole(KERNEL_CONSOLE_BUS_NAME, KERNEL_CONSOLE_DRV_NAME, KERNEL_CONSOLE_DEVICE_NAME); |
|||
} |
|||
|
@ -0,0 +1,52 @@ |
|||
/*
|
|||
* Copyright (c) 2020 AIIT XUOS Lab |
|||
* XiUOS is licensed under Mulan PSL v2. |
|||
* You can use this software according to the terms and conditions of the Mulan PSL v2. |
|||
* You may obtain a copy of Mulan PSL v2 at: |
|||
* http://license.coscl.org.cn/MulanPSL2
|
|||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, |
|||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, |
|||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. |
|||
* See the Mulan PSL v2 for more details. |
|||
*/ |
|||
|
|||
/**
|
|||
* @file board.h |
|||
* @brief define imxrt1052-board init configure and start-up function |
|||
* @version 1.0 |
|||
* @author AIIT XUOS Lab |
|||
* @date 2021-05-28 |
|||
*/ |
|||
|
|||
/*************************************************
|
|||
File name: board.h |
|||
Description: define imxrt1052-board board init function and struct |
|||
Others: |
|||
History: |
|||
1. Date: 2021-05-28 |
|||
Author: AIIT XUOS Lab |
|||
Modification: |
|||
1. define imxrt-board InitBoardHardware |
|||
2. define imxrt-board heap struct |
|||
*************************************************/ |
|||
|
|||
#ifndef __BOARD_H__ |
|||
#define __BOARD_H__ |
|||
|
|||
#include "fsl_common.h" |
|||
#include "clock_config.h" |
|||
#include <xiuos.h> |
|||
#include <arch_interrupt.h> |
|||
|
|||
extern int heap_start; |
|||
extern int heap_end; |
|||
#define HEAP_BEGIN (&heap_start) |
|||
#define HEAP_END (&heap_end) |
|||
|
|||
|
|||
#define HEAP_SIZE ((uint32_t)HEAP_END - (uint32_t)HEAP_BEGIN) |
|||
|
|||
void InitBoardHardware(void); |
|||
|
|||
#endif |
|||
|
@ -0,0 +1,479 @@ |
|||
/*
|
|||
* Copyright 2017-2019 NXP |
|||
* All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
/**
|
|||
* @file clock_config.c |
|||
* @brief support imxrt1052-board clock configure |
|||
* @version 1.0 |
|||
* @author AIIT XUOS Lab |
|||
* @date 2021-05-29 |
|||
*/ |
|||
|
|||
/*
|
|||
* How to setup clock using clock driver functions: |
|||
* |
|||
* 1. Call CLOCK_InitXXXPLL() to configure corresponding PLL clock. |
|||
* |
|||
* 2. Call CLOCK_InitXXXpfd() to configure corresponding PLL pfd clock. |
|||
* |
|||
* 3. Call CLOCK_SetMux() to configure corresponding clock source for target clock out. |
|||
* |
|||
* 4. Call CLOCK_SetDiv() to configure corresponding clock divider for target clock out. |
|||
* |
|||
* 5. Call CLOCK_SetXtalFreq() to set XTAL frequency based on board settings. |
|||
* |
|||
*/ |
|||
|
|||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
|||
!!GlobalInfo |
|||
product: Clocks v5.0 |
|||
processor: MIMXRT1052xxxxB |
|||
package_id: MIMXRT1052DVL6B |
|||
mcu_data: ksdk2_0 |
|||
processor_version: 5.0.2 |
|||
board: IMXRT1050-EVKB |
|||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ |
|||
|
|||
#include "clock_config.h" |
|||
#include "fsl_iomuxc.h" |
|||
|
|||
/*******************************************************************************
|
|||
* Definitions |
|||
******************************************************************************/ |
|||
|
|||
/*******************************************************************************
|
|||
* Variables |
|||
******************************************************************************/ |
|||
/* System clock frequency. */ |
|||
extern uint32_t SystemCoreClock; |
|||
|
|||
/*******************************************************************************
|
|||
************************ BOARD_InitBootClocks function ************************ |
|||
******************************************************************************/ |
|||
void BOARD_InitBootClocks(void) |
|||
{ |
|||
BOARD_BootClockRUN(); |
|||
} |
|||
|
|||
/*******************************************************************************
|
|||
********************** Configuration BOARD_BootClockRUN *********************** |
|||
******************************************************************************/ |
|||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
|||
!!Configuration |
|||
name: BOARD_BootClockRUN |
|||
called_from_default_init: true |
|||
outputs: |
|||
- {id: AHB_CLK_ROOT.outFreq, value: 600 MHz} |
|||
- {id: CAN_CLK_ROOT.outFreq, value: 40 MHz} |
|||
- {id: CKIL_SYNC_CLK_ROOT.outFreq, value: 32.768 kHz} |
|||
- {id: CLK_1M.outFreq, value: 1 MHz} |
|||
- {id: CLK_24M.outFreq, value: 24 MHz} |
|||
- {id: CSI_CLK_ROOT.outFreq, value: 12 MHz} |
|||
- {id: ENET1_TX_CLK.outFreq, value: 2.4 MHz} |
|||
- {id: ENET_125M_CLK.outFreq, value: 2.4 MHz} |
|||
- {id: ENET_25M_REF_CLK.outFreq, value: 1.2 MHz} |
|||
- {id: FLEXIO1_CLK_ROOT.outFreq, value: 30 MHz} |
|||
- {id: FLEXIO2_CLK_ROOT.outFreq, value: 30 MHz} |
|||
- {id: FLEXSPI_CLK_ROOT.outFreq, value: 2880/11 MHz} |
|||
- {id: GPT1_ipg_clk_highfreq.outFreq, value: 75 MHz} |
|||
- {id: GPT2_ipg_clk_highfreq.outFreq, value: 75 MHz} |
|||
- {id: IPG_CLK_ROOT.outFreq, value: 150 MHz} |
|||
- {id: LCDIF_CLK_ROOT.outFreq, value: 67.5/7 MHz} |
|||
- {id: LPI2C_CLK_ROOT.outFreq, value: 60 MHz} |
|||
- {id: LPSPI_CLK_ROOT.outFreq, value: 105.6 MHz} |
|||
- {id: LVDS1_CLK.outFreq, value: 1.2 GHz} |
|||
- {id: MQS_MCLK.outFreq, value: 1080/17 MHz} |
|||
- {id: PERCLK_CLK_ROOT.outFreq, value: 75 MHz} |
|||
- {id: PLL7_MAIN_CLK.outFreq, value: 24 MHz} |
|||
- {id: SAI1_CLK_ROOT.outFreq, value: 1080/17 MHz} |
|||
- {id: SAI1_MCLK1.outFreq, value: 1080/17 MHz} |
|||
- {id: SAI1_MCLK2.outFreq, value: 1080/17 MHz} |
|||
- {id: SAI1_MCLK3.outFreq, value: 30 MHz} |
|||
- {id: SAI2_CLK_ROOT.outFreq, value: 1080/17 MHz} |
|||
- {id: SAI2_MCLK1.outFreq, value: 1080/17 MHz} |
|||
- {id: SAI2_MCLK3.outFreq, value: 30 MHz} |
|||
- {id: SAI3_CLK_ROOT.outFreq, value: 1080/17 MHz} |
|||
- {id: SAI3_MCLK1.outFreq, value: 1080/17 MHz} |
|||
- {id: SAI3_MCLK3.outFreq, value: 30 MHz} |
|||
- {id: SEMC_CLK_ROOT.outFreq, value: 75 MHz} |
|||
- {id: SPDIF0_CLK_ROOT.outFreq, value: 30 MHz} |
|||
- {id: TRACE_CLK_ROOT.outFreq, value: 352/3 MHz} |
|||
- {id: UART_CLK_ROOT.outFreq, value: 80 MHz} |
|||
- {id: USDHC1_CLK_ROOT.outFreq, value: 198 MHz} |
|||
- {id: USDHC2_CLK_ROOT.outFreq, value: 198 MHz} |
|||
settings: |
|||
- {id: CCM.AHB_PODF.scale, value: '1', locked: true} |
|||
- {id: CCM.ARM_PODF.scale, value: '2', locked: true} |
|||
- {id: CCM.FLEXSPI_PODF.scale, value: '1', locked: true} |
|||
- {id: CCM.FLEXSPI_SEL.sel, value: CCM_ANALOG.PLL3_PFD0_CLK} |
|||
- {id: CCM.LCDIF_PODF.scale, value: '8', locked: true} |
|||
- {id: CCM.LCDIF_PRED.scale, value: '7', locked: true} |
|||
- {id: CCM.LPSPI_PODF.scale, value: '5', locked: true} |
|||
- {id: CCM.PERCLK_PODF.scale, value: '2', locked: true} |
|||
- {id: CCM.SEMC_PODF.scale, value: '8'} |
|||
- {id: CCM.TRACE_PODF.scale, value: '3', locked: true} |
|||
- {id: CCM_ANALOG.PLL1_BYPASS.sel, value: CCM_ANALOG.PLL1} |
|||
- {id: CCM_ANALOG.PLL1_PREDIV.scale, value: '1', locked: true} |
|||
- {id: CCM_ANALOG.PLL1_VDIV.scale, value: '50', locked: true} |
|||
- {id: CCM_ANALOG.PLL2.denom, value: '1', locked: true} |
|||
- {id: CCM_ANALOG.PLL2.num, value: '0', locked: true} |
|||
- {id: CCM_ANALOG.PLL2_BYPASS.sel, value: CCM_ANALOG.PLL2_OUT_CLK} |
|||
- {id: CCM_ANALOG.PLL2_PFD0_BYPASS.sel, value: CCM_ANALOG.PLL2_PFD0} |
|||
- {id: CCM_ANALOG.PLL2_PFD1_BYPASS.sel, value: CCM_ANALOG.PLL2_PFD1} |
|||
- {id: CCM_ANALOG.PLL2_PFD2_BYPASS.sel, value: CCM_ANALOG.PLL2_PFD2} |
|||
- {id: CCM_ANALOG.PLL2_PFD3_BYPASS.sel, value: CCM_ANALOG.PLL2_PFD3} |
|||
- {id: CCM_ANALOG.PLL3_BYPASS.sel, value: CCM_ANALOG.PLL3} |
|||
- {id: CCM_ANALOG.PLL3_PFD0_BYPASS.sel, value: CCM_ANALOG.PLL3_PFD0} |
|||
- {id: CCM_ANALOG.PLL3_PFD0_DIV.scale, value: '33', locked: true} |
|||
- {id: CCM_ANALOG.PLL3_PFD0_MUL.scale, value: '18', locked: true} |
|||
- {id: CCM_ANALOG.PLL3_PFD1_BYPASS.sel, value: CCM_ANALOG.PLL3_PFD1} |
|||
- {id: CCM_ANALOG.PLL3_PFD2_BYPASS.sel, value: CCM_ANALOG.PLL3_PFD2} |
|||
- {id: CCM_ANALOG.PLL3_PFD3_BYPASS.sel, value: CCM_ANALOG.PLL3_PFD3} |
|||
- {id: CCM_ANALOG.PLL4.denom, value: '50'} |
|||
- {id: CCM_ANALOG.PLL4.div, value: '47'} |
|||
- {id: CCM_ANALOG.PLL5.denom, value: '1'} |
|||
- {id: CCM_ANALOG.PLL5.div, value: '40'} |
|||
- {id: CCM_ANALOG.PLL5.num, value: '0'} |
|||
- {id: CCM_ANALOG_PLL_ENET_POWERDOWN_CFG, value: 'Yes'} |
|||
- {id: CCM_ANALOG_PLL_USB1_POWER_CFG, value: 'Yes'} |
|||
sources: |
|||
- {id: XTALOSC24M.OSC.outFreq, value: 24 MHz, enabled: true} |
|||
- {id: XTALOSC24M.RTC_OSC.outFreq, value: 32.768 kHz, enabled: true} |
|||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/ |
|||
|
|||
/*******************************************************************************
|
|||
* Variables for BOARD_BootClockRUN configuration |
|||
******************************************************************************/ |
|||
const clock_arm_pll_config_t armPllConfig_BOARD_BootClockRUN = |
|||
{ |
|||
.loopDivider = 100, /* PLL loop divider, Fout = Fin * 50 */ |
|||
.src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ |
|||
}; |
|||
const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN = |
|||
{ |
|||
.loopDivider = 1, /* PLL loop divider, Fout = Fin * ( 20 + loopDivider*2 + numerator / denominator ) */ |
|||
.numerator = 0, /* 30 bit numerator of fractional loop divider */ |
|||
.denominator = 1, /* 30 bit denominator of fractional loop divider */ |
|||
.src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ |
|||
}; |
|||
const clock_usb_pll_config_t usb1PllConfig_BOARD_BootClockRUN = |
|||
{ |
|||
.loopDivider = 0, /* PLL loop divider, Fout = Fin * 20 */ |
|||
.src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */ |
|||
}; |
|||
/*******************************************************************************
|
|||
* Code for BOARD_BootClockRUN configuration |
|||
******************************************************************************/ |
|||
void BOARD_BootClockRUN(void) |
|||
{ |
|||
/* Init RTC OSC clock frequency. */ |
|||
CLOCK_SetRtcXtalFreq(32768U); |
|||
/* Enable 1MHz clock output. */ |
|||
XTALOSC24M->OSC_CONFIG2 |= XTALOSC24M_OSC_CONFIG2_ENABLE_1M_MASK; |
|||
/* Use free 1MHz clock output. */ |
|||
XTALOSC24M->OSC_CONFIG2 &= ~XTALOSC24M_OSC_CONFIG2_MUX_1M_MASK; |
|||
/* Set XTAL 24MHz clock frequency. */ |
|||
CLOCK_SetXtalFreq(24000000U); |
|||
/* Enable XTAL 24MHz clock source. */ |
|||
CLOCK_InitExternalClk(0); |
|||
/* Enable internal RC. */ |
|||
CLOCK_InitRcOsc24M(); |
|||
/* Switch clock source to external OSC. */ |
|||
CLOCK_SwitchOsc(kCLOCK_XtalOsc); |
|||
/* Set Oscillator ready counter value. */ |
|||
CCM->CCR = (CCM->CCR & (~CCM_CCR_OSCNT_MASK)) | CCM_CCR_OSCNT(127); |
|||
/* Setting PeriphClk2Mux and PeriphMux to provide stable clock before PLLs are initialed */ |
|||
CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 1); /* Set PERIPH_CLK2 MUX to OSC */ |
|||
CLOCK_SetMux(kCLOCK_PeriphMux, 1); /* Set PERIPH_CLK MUX to PERIPH_CLK2 */ |
|||
/* Setting the VDD_SOC to 1.275V. It is necessary to config AHB to 600Mhz. */ |
|||
DCDC->REG3 = (DCDC->REG3 & (~DCDC_REG3_TRG_MASK)) | DCDC_REG3_TRG(0x13); |
|||
/* Waiting for DCDC_STS_DC_OK bit is asserted */ |
|||
while (DCDC_REG0_STS_DC_OK_MASK != (DCDC_REG0_STS_DC_OK_MASK & DCDC->REG0)) |
|||
{ |
|||
} |
|||
/* Set AHB_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_AhbDiv, 0); |
|||
/* Disable IPG clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Adc1); |
|||
CLOCK_DisableClock(kCLOCK_Adc2); |
|||
CLOCK_DisableClock(kCLOCK_Xbar1); |
|||
CLOCK_DisableClock(kCLOCK_Xbar2); |
|||
CLOCK_DisableClock(kCLOCK_Xbar3); |
|||
/* Set IPG_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_IpgDiv, 3); |
|||
/* Set ARM_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_ArmDiv, 1); |
|||
/* Set PERIPH_CLK2_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_PeriphClk2Div, 0); |
|||
/* Disable PERCLK clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Gpt1); |
|||
CLOCK_DisableClock(kCLOCK_Gpt1S); |
|||
CLOCK_DisableClock(kCLOCK_Gpt2); |
|||
CLOCK_DisableClock(kCLOCK_Gpt2S); |
|||
CLOCK_DisableClock(kCLOCK_Pit); |
|||
/* Set PERCLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_PerclkDiv, 1); |
|||
/* Disable USDHC1 clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Usdhc1); |
|||
/* Set USDHC1_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Usdhc1Div, 1); |
|||
/* Set Usdhc1 clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Usdhc1Mux, 0); |
|||
/* Disable USDHC2 clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Usdhc2); |
|||
/* Set USDHC2_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Usdhc2Div, 1); |
|||
/* Set Usdhc2 clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Usdhc2Mux, 0); |
|||
/* In SDK projects, SDRAM (configured by SEMC) will be initialized in either debug script or dcd.
|
|||
* With this macro SKIP_SYSCLK_INIT, system pll (selected to be SEMC source clock in SDK projects) will be left unchanged. |
|||
* Note: If another clock source is selected for SEMC, user may want to avoid changing that clock as well.*/ |
|||
#ifndef SKIP_SYSCLK_INIT |
|||
/* Disable Semc clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Semc); |
|||
/* Set SEMC_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_SemcDiv, 7); |
|||
/* Set Semc alt clock source. */ |
|||
CLOCK_SetMux(kCLOCK_SemcAltMux, 0); |
|||
/* Set Semc clock source. */ |
|||
CLOCK_SetMux(kCLOCK_SemcMux, 0); |
|||
#endif |
|||
/* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd.
|
|||
* With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left unchanged. |
|||
* Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as well.*/ |
|||
#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) |
|||
/* Disable Flexspi clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_FlexSpi); |
|||
/* Set FLEXSPI_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_FlexspiDiv, 0); |
|||
/* Set Flexspi clock source. */ |
|||
CLOCK_SetMux(kCLOCK_FlexspiMux, 3); |
|||
#endif |
|||
/* Disable CSI clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Csi); |
|||
/* Set CSI_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_CsiDiv, 1); |
|||
/* Set Csi clock source. */ |
|||
CLOCK_SetMux(kCLOCK_CsiMux, 0); |
|||
/* Disable LPSPI clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Lpspi1); |
|||
CLOCK_DisableClock(kCLOCK_Lpspi2); |
|||
CLOCK_DisableClock(kCLOCK_Lpspi3); |
|||
CLOCK_DisableClock(kCLOCK_Lpspi4); |
|||
/* Set LPSPI_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_LpspiDiv, 4); |
|||
/* Set Lpspi clock source. */ |
|||
CLOCK_SetMux(kCLOCK_LpspiMux, 2); |
|||
/* Disable TRACE clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Trace); |
|||
/* Set TRACE_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_TraceDiv, 2); |
|||
/* Set Trace clock source. */ |
|||
CLOCK_SetMux(kCLOCK_TraceMux, 2); |
|||
/* Disable SAI1 clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Sai1); |
|||
/* Set SAI1_CLK_PRED. */ |
|||
CLOCK_SetDiv(kCLOCK_Sai1PreDiv, 3); |
|||
/* Set SAI1_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Sai1Div, 1); |
|||
/* Set Sai1 clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Sai1Mux, 0); |
|||
/* Disable SAI2 clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Sai2); |
|||
/* Set SAI2_CLK_PRED. */ |
|||
CLOCK_SetDiv(kCLOCK_Sai2PreDiv, 3); |
|||
/* Set SAI2_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Sai2Div, 1); |
|||
/* Set Sai2 clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Sai2Mux, 0); |
|||
/* Disable SAI3 clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Sai3); |
|||
/* Set SAI3_CLK_PRED. */ |
|||
CLOCK_SetDiv(kCLOCK_Sai3PreDiv, 3); |
|||
/* Set SAI3_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Sai3Div, 1); |
|||
/* Set Sai3 clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Sai3Mux, 0); |
|||
/* Disable Lpi2c clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Lpi2c1); |
|||
CLOCK_DisableClock(kCLOCK_Lpi2c2); |
|||
CLOCK_DisableClock(kCLOCK_Lpi2c3); |
|||
/* Set LPI2C_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Lpi2cDiv, 0); |
|||
/* Set Lpi2c clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Lpi2cMux, 0); |
|||
/* Disable CAN clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Can1); |
|||
CLOCK_DisableClock(kCLOCK_Can2); |
|||
CLOCK_DisableClock(kCLOCK_Can1S); |
|||
CLOCK_DisableClock(kCLOCK_Can2S); |
|||
/* Set CAN_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_CanDiv, 1); |
|||
/* Set Can clock source. */ |
|||
CLOCK_SetMux(kCLOCK_CanMux, 2); |
|||
/* Disable UART clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Lpuart1); |
|||
CLOCK_DisableClock(kCLOCK_Lpuart2); |
|||
CLOCK_DisableClock(kCLOCK_Lpuart3); |
|||
CLOCK_DisableClock(kCLOCK_Lpuart4); |
|||
CLOCK_DisableClock(kCLOCK_Lpuart5); |
|||
CLOCK_DisableClock(kCLOCK_Lpuart6); |
|||
CLOCK_DisableClock(kCLOCK_Lpuart7); |
|||
CLOCK_DisableClock(kCLOCK_Lpuart8); |
|||
/* Set UART_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_UartDiv, 0); |
|||
/* Set Uart clock source. */ |
|||
CLOCK_SetMux(kCLOCK_UartMux, 0); |
|||
/* Disable LCDIF clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_LcdPixel); |
|||
/* Set LCDIF_PRED. */ |
|||
CLOCK_SetDiv(kCLOCK_LcdifPreDiv, 6); |
|||
/* Set LCDIF_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_LcdifDiv, 7); |
|||
/* Set Lcdif pre clock source. */ |
|||
CLOCK_SetMux(kCLOCK_LcdifPreMux, 5); |
|||
/* Disable SPDIF clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Spdif); |
|||
/* Set SPDIF0_CLK_PRED. */ |
|||
CLOCK_SetDiv(kCLOCK_Spdif0PreDiv, 1); |
|||
/* Set SPDIF0_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Spdif0Div, 7); |
|||
/* Set Spdif clock source. */ |
|||
CLOCK_SetMux(kCLOCK_SpdifMux, 3); |
|||
/* Disable Flexio1 clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Flexio1); |
|||
/* Set FLEXIO1_CLK_PRED. */ |
|||
CLOCK_SetDiv(kCLOCK_Flexio1PreDiv, 1); |
|||
/* Set FLEXIO1_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Flexio1Div, 7); |
|||
/* Set Flexio1 clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Flexio1Mux, 3); |
|||
/* Disable Flexio2 clock gate. */ |
|||
CLOCK_DisableClock(kCLOCK_Flexio2); |
|||
/* Set FLEXIO2_CLK_PRED. */ |
|||
CLOCK_SetDiv(kCLOCK_Flexio2PreDiv, 1); |
|||
/* Set FLEXIO2_CLK_PODF. */ |
|||
CLOCK_SetDiv(kCLOCK_Flexio2Div, 7); |
|||
/* Set Flexio2 clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Flexio2Mux, 3); |
|||
/* Set Pll3 sw clock source. */ |
|||
CLOCK_SetMux(kCLOCK_Pll3SwMux, 0); |
|||
/* Init ARM PLL. */ |
|||
CLOCK_InitArmPll(&armPllConfig_BOARD_BootClockRUN); |
|||
/* In SDK projects, SDRAM (configured by SEMC) will be initialized in either debug script or dcd.
|
|||
* With this macro SKIP_SYSCLK_INIT, system pll (selected to be SEMC source clock in SDK projects) will be left unchanged. |
|||
* Note: If another clock source is selected for SEMC, user may want to avoid changing that clock as well.*/ |
|||
#ifndef SKIP_SYSCLK_INIT |
|||
/* Init System PLL. */ |
|||
CLOCK_InitSysPll(&sysPllConfig_BOARD_BootClockRUN); |
|||
/* Init System pfd0. */ |
|||
CLOCK_InitSysPfd(kCLOCK_Pfd0, 27); |
|||
/* Init System pfd1. */ |
|||
CLOCK_InitSysPfd(kCLOCK_Pfd1, 16); |
|||
/* Init System pfd2. */ |
|||
CLOCK_InitSysPfd(kCLOCK_Pfd2, 24); |
|||
/* Init System pfd3. */ |
|||
CLOCK_InitSysPfd(kCLOCK_Pfd3, 16); |
|||
/* Disable pfd offset. */ |
|||
CCM_ANALOG->PLL_SYS &= ~CCM_ANALOG_PLL_SYS_PFD_OFFSET_EN_MASK; |
|||
#endif |
|||
/* In SDK projects, external flash (configured by FLEXSPI) will be initialized by dcd.
|
|||
* With this macro XIP_EXTERNAL_FLASH, usb1 pll (selected to be FLEXSPI clock source in SDK projects) will be left unchanged. |
|||
* Note: If another clock source is selected for FLEXSPI, user may want to avoid changing that clock as well.*/ |
|||
#if !(defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)) |
|||
/* Init Usb1 PLL. */ |
|||
CLOCK_InitUsb1Pll(&usb1PllConfig_BOARD_BootClockRUN); |
|||
/* Init Usb1 pfd0. */ |
|||
CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 33); |
|||
/* Init Usb1 pfd1. */ |
|||
CLOCK_InitUsb1Pfd(kCLOCK_Pfd1, 16); |
|||
/* Init Usb1 pfd2. */ |
|||
CLOCK_InitUsb1Pfd(kCLOCK_Pfd2, 17); |
|||
/* Init Usb1 pfd3. */ |
|||
CLOCK_InitUsb1Pfd(kCLOCK_Pfd3, 19); |
|||
/* Disable Usb1 PLL output for USBPHY1. */ |
|||
CCM_ANALOG->PLL_USB1 &= ~CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; |
|||
#endif |
|||
/* DeInit Audio PLL. */ |
|||
CLOCK_DeinitAudioPll(); |
|||