forked from xuos/xiuos
Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into prepare_for_master
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
menu "Required Feature" # do not modify this, otherwise, (see `egrep '^# Required'` in kernel_selector.sh)
|
||||
|
||||
menuconfig FS
|
||||
bool "require file system"
|
||||
default n
|
||||
|
||||
if FS
|
||||
config FS_VFS_FATFS
|
||||
bool "Using FATFS file system"
|
||||
default n
|
||||
|
||||
config FS_CH376
|
||||
bool "Using CH376 file system"
|
||||
default n
|
||||
|
||||
config FS_LWEXT4
|
||||
bool "Using LWEXT4 file system"
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
menuconfig INDUSTRIAL
|
||||
bool "Require industrial protocols support"
|
||||
default n
|
||||
|
||||
if INDUSTRIAL
|
||||
config INDUSTRIAL_OPCUA
|
||||
bool "Support OPCUA"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_SNAP7
|
||||
bool "Support Siemens Snap7"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_MODBUS
|
||||
bool "Support Modbus"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_RS232
|
||||
bool "Support RS232"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_RS485
|
||||
bool "Support RS485"
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
menuconfig BUS
|
||||
bool "require bus"
|
||||
default y
|
||||
|
||||
if BUS
|
||||
menu "Required BUS"
|
||||
config USB
|
||||
bool "require USB bus"
|
||||
default n
|
||||
|
||||
config SERIAL
|
||||
bool "require serial bus"
|
||||
default n
|
||||
endmenu
|
||||
endif
|
||||
|
||||
endmenu
|
||||
@@ -1,65 +0,0 @@
|
||||
menu "Required Feature" # do not modify this, otherwise, (see `egrep '^# Required'` in kernel_selector.sh)
|
||||
|
||||
menuconfig FS
|
||||
bool "require file system"
|
||||
default n
|
||||
|
||||
if FS
|
||||
config FS_VFS_FATFS
|
||||
bool "Using FATFS file system"
|
||||
default n
|
||||
|
||||
config FS_CH376
|
||||
bool "Using CH376 file system"
|
||||
default n
|
||||
|
||||
config FS_LWEXT4
|
||||
bool "Using LWEXT4 file system"
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
menuconfig INDUSTRIAL
|
||||
bool "Require industrial protocols support"
|
||||
default n
|
||||
|
||||
if INDUSTRIAL
|
||||
config INDUSTRIAL_OPCUA
|
||||
bool "Support OPCUA"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_SNAP7
|
||||
bool "Support Siemens Snap7"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_MODBUS
|
||||
bool "Support Modbus"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_RS232
|
||||
bool "Support RS232"
|
||||
default n
|
||||
|
||||
config INDUSTRIAL_RS485
|
||||
bool "Support RS485"
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
menuconfig BUS
|
||||
bool "require bus"
|
||||
default y
|
||||
|
||||
if BUS
|
||||
menu "Required BUS"
|
||||
config USB
|
||||
bool "require USB bus"
|
||||
default n
|
||||
|
||||
config SERIAL
|
||||
bool "require serial bus"
|
||||
default n
|
||||
endmenu
|
||||
endif
|
||||
|
||||
endmenu
|
||||
@@ -1,26 +0,0 @@
|
||||
menu "Required Parameter"
|
||||
config RAM_LESS_THAN
|
||||
int "RAM footprint limit (MB) upper bound"
|
||||
default 10000
|
||||
help
|
||||
Kernel RAM footprint should be lower than this limit
|
||||
|
||||
config RAM_GREATER_THAN
|
||||
int "RAM footprint limit (MB) lower bound"
|
||||
default 0
|
||||
help
|
||||
Kernel RAM footprint should be higher than this limit
|
||||
|
||||
config ROM_LESS_THAN
|
||||
int "ROM limit (MB) upper bound"
|
||||
default 10000
|
||||
help
|
||||
Kernel ROM requirement should be lower than this limit
|
||||
|
||||
config ROM_GREATER_THAN
|
||||
int "ROM limit (MB) lower bound"
|
||||
default 0
|
||||
help
|
||||
Kernel ROM requirement should be higher than this limit
|
||||
|
||||
endmenu
|
||||
@@ -1,26 +0,0 @@
|
||||
menu "Required Parameter"
|
||||
config RAM_LESS_THAN
|
||||
int "RAM footprint limit (MB) upper bound"
|
||||
default 10000
|
||||
help
|
||||
Kernel RAM footprint should be lower than this limit
|
||||
|
||||
config RAM_GREATER_THAN
|
||||
int "RAM footprint limit (MB) lower bound"
|
||||
default 0
|
||||
help
|
||||
Kernel RAM footprint should be higher than this limit
|
||||
|
||||
config ROM_LESS_THAN
|
||||
int "ROM limit (MB) upper bound"
|
||||
default 10000
|
||||
help
|
||||
Kernel ROM requirement should be lower than this limit
|
||||
|
||||
config ROM_GREATER_THAN
|
||||
int "ROM limit (MB) lower bound"
|
||||
default 0
|
||||
help
|
||||
Kernel ROM requirement should be higher than this limit
|
||||
|
||||
endmenu
|
||||
@@ -6,8 +6,9 @@ MAKEFLAGS += --no-print-directory
|
||||
|
||||
|
||||
riscv_support := kd233 maix-go hifive1-rev-B gapuino gd32vf103-rvstar rv32m1-vega aiit-riscv64-board xidatong-riscv64 edu-riscv64 ch32v307vct6
|
||||
arm_support += stm32f407-st-discovery stm32f407zgt6 stm32f103-nano nuvoton-m2354 ok1052-c imxrt1176-sbc aiit-arm32-board xidatong-arm32 xiwangtong-arm32 edu-arm32
|
||||
emulator_support += hifive1-emulator k210-emulator cortex-m0-emulator cortex-m3-emulator cortex-m4-emulator
|
||||
arm_support += stm32f407-st-discovery stm32f407zgt6 stm32f103-nano nuvoton-m2354 ok1052-c imxrt1176-sbc aiit-arm32-board xidatong-arm32 xiwangtong-arm32 edu-arm32 xishutong-arm32
|
||||
emulator_support += hifive1-emulator k210-emulator cortex-m0-emulator cortex-m3-emulator cortex-m4-emulator cortex-m7-emulator
|
||||
|
||||
support := $(riscv_support) $(arm_support) $(emulator_support)
|
||||
SRC_DIR :=
|
||||
|
||||
@@ -49,6 +50,7 @@ export SRC_DIR:= $(SRC_APP_DIR) $(SRC_KERNEL_DIR)
|
||||
export LIBCC
|
||||
export MUSL_DIR := $(KERNEL_ROOT)/lib/musllib
|
||||
export LWIP_DIR := $(KERNEL_ROOT)/resources/ethernet
|
||||
export MONGOOSE_DIR := $(KERNEL_ROOT)/../../APP_Framework/Applications/mongoose/lib
|
||||
|
||||
PART:=
|
||||
|
||||
@@ -73,6 +75,10 @@ ifeq ($(CONFIG_RESOURCES_LWIP), y)
|
||||
PART += COMPILE_LWIP
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USE_MONGOOSE), y)
|
||||
# PART += COMPILE_MONGOOSE
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MCUBOOT_BOOTLOADER), y)
|
||||
PART += COMPILE_BOOTLOADER
|
||||
else ifeq ($(CONFIG_MCUBOOT_APPLICATION), y)
|
||||
@@ -129,6 +135,15 @@ COMPILE_LWIP:
|
||||
@cp build/liblwip.a $(KERNEL_ROOT)/resources/ethernet/LwIP/liblwip.a
|
||||
@rm build/Makefile build/make.obj
|
||||
|
||||
COMPILE_MONGOOSE:
|
||||
@for dir in $(MONGOOSE_DIR);do \
|
||||
$(MAKE) -C $$dir COMPILE_TYPE=$@; \
|
||||
done
|
||||
@cp link_mongoose.mk build/Makefile
|
||||
@$(MAKE) -C build TARGET=mongoose.a LINK_FLAGS=LFLAGS
|
||||
@cp build/mongoose.a $(KERNEL_ROOT)/../../APP_Framework/Applications/mongoose/mongoose.a
|
||||
@rm build/Makefile build/make.obj
|
||||
|
||||
COMPILE_KERNEL:
|
||||
@for dir in $(SRC_KERNEL_DIR);do \
|
||||
$(MAKE) -C $$dir; \
|
||||
|
||||
@@ -30,11 +30,21 @@ SRC_DIR := shared
|
||||
SRC_DIR += cortex-m4
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARD_XISHUTONG_ARM32),y)
|
||||
SRC_DIR := shared
|
||||
SRC_DIR += cortex-m4
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARD_CORTEX_M7_EVB),y)
|
||||
SRC_DIR := shared
|
||||
SRC_DIR += cortex-m7
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARD_CORTEX_V2M_EVB),y)
|
||||
SRC_DIR := shared
|
||||
SRC_DIR += cortex-m7
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARD_IMXRT1176_SBC_EVB),y)
|
||||
SRC_DIR := shared
|
||||
SRC_DIR += cortex-m7
|
||||
|
||||
@@ -18,4 +18,8 @@ ifeq ($(CONFIG_BOARD_EDU_ARM32_EVB),y)
|
||||
SRC_DIR += hc32f4a0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARD_XISHUTONG_ARM32),y)
|
||||
SRC_DIR += hc32f4a0
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
ifeq ($(CONFIG_BOARD_CORTEX_M7_EVB),y)
|
||||
SRC_FILES := boot.S interrupt.c interrupt_vector.S
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARD_CORTEX_V2M_EVB),y)
|
||||
SRC_DIR += V2M
|
||||
endif
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
3
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/Makefile
Normal file
3
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
SRC_FILES := boot.S interrupt.c interrupt_vector.S
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
39
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/arch_interrupt.h
Normal file
39
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/arch_interrupt.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#define ARCH_IRQ_NUM_OFFSET 16
|
||||
|
||||
#define SYSTICK_IRQN -1
|
||||
#define UART0RX_IRQn 0
|
||||
#define UART0TX_IRQn 1
|
||||
#define UART1RX_IRQn 2
|
||||
|
||||
// #define USB1_IRQn 113
|
||||
// #define USB2_IRQn 112
|
||||
|
||||
int32 ArchEnableHwIrq(uint32 irq_num);
|
||||
int32 ArchDisableHwIrq(uint32 irq_num);
|
||||
|
||||
#endif
|
||||
204
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/boot.S
Normal file
204
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/boot.S
Normal file
@@ -0,0 +1,204 @@
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* @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 Cortex-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:
|
||||
#ifdef __BOOTLOADER /* BOOT */
|
||||
cpsid i /* Mask interrupts */
|
||||
.equ VTOR, 0xE000ED08
|
||||
ldr r0, =VTOR
|
||||
ldr r1, =__isr_vector
|
||||
str r1, [r0]
|
||||
ldr r2, [r1]
|
||||
msr msp, r2
|
||||
|
||||
ldr r0,=SystemInit
|
||||
blx r0
|
||||
|
||||
/* 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.
|
||||
* __bootloader_end: 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__
|
||||
|
||||
/* 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 */
|
||||
.LoopCopy0:
|
||||
cmp r2, r3
|
||||
ittt lt
|
||||
ldrlt r0, [r1], #4
|
||||
strlt r0, [r2], #4
|
||||
blt .LoopCopy0
|
||||
|
||||
/* 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
|
||||
.LoopCopy1:
|
||||
cmp r1, r2
|
||||
itt lt
|
||||
strlt r0, [r1], #4
|
||||
blt .LoopCopy1
|
||||
|
||||
ldr r0,=ota_entry
|
||||
blx r0
|
||||
#else /* APP */
|
||||
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 */
|
||||
|
||||
#if 1
|
||||
/* 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
|
||||
#endif /* MCUBOOT_BOOTLOADER */
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
89
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/interrupt.c
Normal file
89
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/interrupt.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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-m7 interrupt function
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-05-28
|
||||
*/
|
||||
|
||||
#include <xs_base.h>
|
||||
#include <xs_isr.h>
|
||||
#include "fsl_common.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)
|
||||
{
|
||||
EnableIRQ(irq_num);
|
||||
return EOK;
|
||||
}
|
||||
|
||||
int32 ArchDisableHwIrq(uint32 irq_num)
|
||||
{
|
||||
DisableIRQ(irq_num);
|
||||
return EOK;
|
||||
}
|
||||
|
||||
extern void KTaskOsAssignAfterIrq(void *context);
|
||||
|
||||
void IsrEntry()
|
||||
{
|
||||
uint32 ipsr;
|
||||
|
||||
__asm__ volatile("MRS %0, IPSR" : "=r"(ipsr));
|
||||
if (ipsr!=17){
|
||||
KPrintf("%d\n",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)
|
||||
{
|
||||
}
|
||||
}
|
||||
319
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/interrupt_vector.S
Normal file
319
Ubiquitous/XiZi_IIoT/arch/arm/cortex-m7/V2M/interrupt_vector.S
Normal file
@@ -0,0 +1,319 @@
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* @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 /* Initial Stack Pointer */
|
||||
.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 SVC_Handler /* -5 SVC Handler */
|
||||
.long DebugMon_Handler /* -4 Debug Monitor Handler */
|
||||
.long 0 /* Reserved */
|
||||
.long PendSV_Handler /* -2 PendSV Handler */
|
||||
.long SysTick_Handler /* -1 SysTick Handler */
|
||||
|
||||
/* Interrupts */
|
||||
.long UART0RX_Handler /* 0 UART 0 receive interrupt */
|
||||
.long UART0TX_Handler /* 1 UART 0 transmit interrupt */
|
||||
.long UART1RX_Handler /* 2 UART 1 receive interrupt */
|
||||
.long UART1TX_Handler /* 3 UART 1 transmit interrupt */
|
||||
.long UART2RX_Handler /* 4 UART 2 receive interrupt */
|
||||
.long UART2TX_Handler /* 5 UART 2 transmit interrupt */
|
||||
.long GPIO0ALL_Handler /* 6 GPIO 0 combined interrupt */
|
||||
.long GPIO1ALL_Handler /* 7 GPIO 1 combined interrupt */
|
||||
.long TIMER0_Handler /* 8 Timer 0 interrupt */
|
||||
.long TIMER1_Handler /* 9 Timer 1 interrupt */
|
||||
.long DUALTIMER_Handler /* 10 Dual Timer interrupt */
|
||||
.long SPI_0_1_Handler /* 11 SPI 0, 1 interrupt */
|
||||
.long UART_0_1_2_OVF_Handler /* 12 UART overflow (0, 1 & 2) interrupt */
|
||||
.long ETHERNET_Handler /* 13 Ethernet interrupt */
|
||||
.long I2S_Handler /* 14 Audio I2S interrupt */
|
||||
.long TOUCHSCREEN_Handler /* 15 Touch Screen interrupt */
|
||||
.long GPIO2_Handler /* 16 GPIO 2 combined interrupt */
|
||||
.long GPIO3_Handler /* 17 GPIO 3 combined interrupt */
|
||||
.long UART3RX_Handler /* 18 UART 3 receive interrupt */
|
||||
.long UART3TX_Handler /* 19 UART 3 transmit interrupt */
|
||||
.long UART4RX_Handler /* 20 UART 4 receive interrupt */
|
||||
.long UART4TX_Handler /* 21 UART 4 transmit interrupt */
|
||||
.long SPI_2_Handler /* 22 SPI 2 interrupt */
|
||||
.long SPI_3_4_Handler /* 23 SPI 3, 4 interrupt */
|
||||
.long GPIO0_0_Handler /* 24 GPIO 0 individual interrupt ( 0) */
|
||||
.long GPIO0_1_Handler /* 25 GPIO 0 individual interrupt ( 1) */
|
||||
.long GPIO0_2_Handler /* 26 GPIO 0 individual interrupt ( 2) */
|
||||
.long GPIO0_3_Handler /* 27 GPIO 0 individual interrupt ( 3) */
|
||||
.long GPIO0_4_Handler /* 28 GPIO 0 individual interrupt ( 4) */
|
||||
.long GPIO0_5_Handler /* 29 GPIO 0 individual interrupt ( 5) */
|
||||
.long GPIO0_6_Handler /* 30 GPIO 0 individual interrupt ( 6) */
|
||||
.long GPIO0_7_Handler /* 31 GPIO 0 individual interrupt ( 7) */
|
||||
.long 0 /* 32 Reserved */
|
||||
.long 0 /* 33 Reserved */
|
||||
.long 0 /* 34 Reserved */
|
||||
.long 0 /* 35 Reserved */
|
||||
.long 0 /* 36 Reserved */
|
||||
.long 0 /* 37 Reserved */
|
||||
.long 0 /* 38 Reserved */
|
||||
.long 0 /* 39 Reserved */
|
||||
.long 0 /* 40 Reserved */
|
||||
.long 0 /* 41 Reserved */
|
||||
.long 0 /* 42 Reserved */
|
||||
.long 0 /* 43 Reserved */
|
||||
.long 0 /* 44 Reserved */
|
||||
.long 0 /* 45 Reserved */
|
||||
.long 0 /* 46 Reserved */
|
||||
.long 0 /* 47 Reserved */
|
||||
.long 0 /* 48 Reserved */
|
||||
.long 0 /* 49 Reserved */
|
||||
.long 0 /* 50 Reserved */
|
||||
.long 0 /* 51 Reserved */
|
||||
.long 0 /* 52 Reserved */
|
||||
.long 0 /* 53 Reserved */
|
||||
.long 0 /* 54 Reserved */
|
||||
.long 0 /* 55 Reserved */
|
||||
.long 0 /* 56 Reserved */
|
||||
.long 0 /* 57 Reserved */
|
||||
.long 0 /* 58 Reserved */
|
||||
.long 0 /* 59 Reserved */
|
||||
.long 0 /* 60 Reserved */
|
||||
.long 0 /* 61 Reserved */
|
||||
.long 0 /* 62 Reserved */
|
||||
.long 0 /* 63 Reserved */
|
||||
.long 0 /* 64 Reserved */
|
||||
.long 0 /* 65 Reserved */
|
||||
.long 0 /* 66 Reserved */
|
||||
.long 0 /* 67 Reserved */
|
||||
.long 0 /* 68 Reserved */
|
||||
.long 0 /* 69 Reserved */
|
||||
.long 0 /* 70 Reserved */
|
||||
.long 0 /* 71 Reserved */
|
||||
.long 0 /* 72 Reserved */
|
||||
.long 0 /* 73 Reserved */
|
||||
.long 0 /* 74 Reserved */
|
||||
.long 0 /* 75 Reserved */
|
||||
.long 0 /* 76 Reserved */
|
||||
.long 0 /* 77 Reserved */
|
||||
.long 0 /* 78 Reserved */
|
||||
.long 0 /* 79 Reserved */
|
||||
.long 0 /* 80 Reserved */
|
||||
.long 0 /* 81 Reserved */
|
||||
.long 0 /* 82 Reserved */
|
||||
.long 0 /* 83 Reserved */
|
||||
.long 0 /* 84 Reserved */
|
||||
.long 0 /* 85 Reserved */
|
||||
.long 0 /* 86 Reserved */
|
||||
.long 0 /* 87 Reserved */
|
||||
.long 0 /* 88 Reserved */
|
||||
.long 0 /* 89 Reserved */
|
||||
.long 0 /* 90 Reserved */
|
||||
.long 0 /* 91 Reserved */
|
||||
.long 0 /* 92 Reserved */
|
||||
.long 0 /* 93 Reserved */
|
||||
.long 0 /* 94 Reserved */
|
||||
.long 0 /* 95 Reserved */
|
||||
.long 0 /* 96 Reserved */
|
||||
.long 0 /* 97 Reserved */
|
||||
.long 0 /* 98 Reserved */
|
||||
.long 0 /* 99 Reserved */
|
||||
.long 0 /* 100 Reserved */
|
||||
.long 0 /* 101 Reserved */
|
||||
.long 0 /* 102 Reserved */
|
||||
.long 0 /* 103 Reserved */
|
||||
.long 0 /* 104 Reserved */
|
||||
.long 0 /* 105 Reserved */
|
||||
.long 0 /* 106 Reserved */
|
||||
.long 0 /* 107 Reserved */
|
||||
.long 0 /* 108 Reserved */
|
||||
.long 0 /* 109 Reserved */
|
||||
.long 0 /* 110 Reserved */
|
||||
.long 0 /* 111 Reserved */
|
||||
.long 0 /* 112 Reserved */
|
||||
.long 0 /* 113 Reserved */
|
||||
.long 0 /* 114 Reserved */
|
||||
.long 0 /* 115 Reserved */
|
||||
.long 0 /* 116 Reserved */
|
||||
.long 0 /* 117 Reserved */
|
||||
.long 0 /* 118 Reserved */
|
||||
.long 0 /* 119 Reserved */
|
||||
.long 0 /* 120 Reserved */
|
||||
.long 0 /* 121 Reserved */
|
||||
.long 0 /* 122 Reserved */
|
||||
.long 0 /* 123 Reserved */
|
||||
.long 0 /* 124 Reserved */
|
||||
.long 0 /* 125 Reserved */
|
||||
.long 0 /* 126 Reserved */
|
||||
.long 0 /* 127 Reserved */
|
||||
.long 0 /* 128 Reserved */
|
||||
.long 0 /* 129 Reserved */
|
||||
.long 0 /* 130 Reserved */
|
||||
.long 0 /* 131 Reserved */
|
||||
.long 0 /* 132 Reserved */
|
||||
.long 0 /* 133 Reserved */
|
||||
.long 0 /* 134 Reserved */
|
||||
.long 0 /* 135 Reserved */
|
||||
.long 0 /* 136 Reserved */
|
||||
.long 0 /* 137 Reserved */
|
||||
.long 0 /* 138 Reserved */
|
||||
.long 0 /* 139 Reserved */
|
||||
.long 0 /* 140 Reserved */
|
||||
.long 0 /* 141 Reserved */
|
||||
.long 0 /* 142 Reserved */
|
||||
.long 0 /* 143 Reserved */
|
||||
.long 0 /* 144 Reserved */
|
||||
.long 0 /* 145 Reserved */
|
||||
.long 0 /* 146 Reserved */
|
||||
.long 0 /* 147 Reserved */
|
||||
.long 0 /* 148 Reserved */
|
||||
.long 0 /* 149 Reserved */
|
||||
.long 0 /* 150 Reserved */
|
||||
.long 0 /* 151 Reserved */
|
||||
.long 0 /* 152 Reserved */
|
||||
.long 0 /* 153 Reserved */
|
||||
.long 0 /* 154 Reserved */
|
||||
.long 0 /* 155 Reserved */
|
||||
.long 0 /* 156 Reserved */
|
||||
.long 0 /* 157 Reserved */
|
||||
.long 0 /* 158 Reserved */
|
||||
.long 0 /* 159 Reserved */
|
||||
.long 0 /* 160 Reserved */
|
||||
.long 0 /* 161 Reserved */
|
||||
.long 0 /* 162 Reserved */
|
||||
.long 0 /* 163 Reserved */
|
||||
.long 0 /* 164 Reserved */
|
||||
.long 0 /* 165 Reserved */
|
||||
.long 0 /* 166 Reserved */
|
||||
.long 0 /* 167 Reserved */
|
||||
.long 0 /* 168 Reserved */
|
||||
.long 0 /* 169 Reserved */
|
||||
.long 0 /* 170 Reserved */
|
||||
.long 0 /* 171 Reserved */
|
||||
.long 0 /* 172 Reserved */
|
||||
.long 0 /* 173 Reserved */
|
||||
.long 0 /* 174 Reserved */
|
||||
.long 0 /* 175 Reserved */
|
||||
.long 0 /* 176 Reserved */
|
||||
.long 0 /* 177 Reserved */
|
||||
.long 0 /* 178 Reserved */
|
||||
.long 0 /* 179 Reserved */
|
||||
.long 0 /* 180 Reserved */
|
||||
.long 0 /* 181 Reserved */
|
||||
.long 0 /* 182 Reserved */
|
||||
.long 0 /* 183 Reserved */
|
||||
.long 0 /* 184 Reserved */
|
||||
.long 0 /* 185 Reserved */
|
||||
.long 0 /* 186 Reserved */
|
||||
.long 0 /* 187 Reserved */
|
||||
.long 0 /* 188 Reserved */
|
||||
.long 0 /* 189 Reserved */
|
||||
.long 0 /* 190 Reserved */
|
||||
.long 0 /* 191 Reserved */
|
||||
.long 0 /* 192 Reserved */
|
||||
.long 0 /* 193 Reserved */
|
||||
.long 0 /* 194 Reserved */
|
||||
.long 0 /* 195 Reserved */
|
||||
.long 0 /* 196 Reserved */
|
||||
.long 0 /* 197 Reserved */
|
||||
.long 0 /* 198 Reserved */
|
||||
.long 0 /* 199 Reserved */
|
||||
.long 0 /* 200 Reserved */
|
||||
.long 0 /* 201 Reserved */
|
||||
.long 0 /* 202 Reserved */
|
||||
.long 0 /* 203 Reserved */
|
||||
.long 0 /* 204 Reserved */
|
||||
.long 0 /* 205 Reserved */
|
||||
.long 0 /* 206 Reserved */
|
||||
.long 0 /* 207 Reserved */
|
||||
.long 0 /* 208 Reserved */
|
||||
.long 0 /* 209 Reserved */
|
||||
.long 0 /* 210 Reserved */
|
||||
.long 0 /* 211 Reserved */
|
||||
.long 0 /* 212 Reserved */
|
||||
.long 0 /* 213 Reserved */
|
||||
.long 0 /* 214 Reserved */
|
||||
.long 0 /* 215 Reserved */
|
||||
.long 0 /* 216 Reserved */
|
||||
.long 0 /* 217 Reserved */
|
||||
.long 0 /* 218 Reserved */
|
||||
.long 0 /* 219 Reserved */
|
||||
.long 0 /* 220 Reserved */
|
||||
.long 0 /* 221 Reserved */
|
||||
.long 0 /* 222 Reserved */
|
||||
.long 0 /* 223 Reserved */
|
||||
#if defined CMSDK_CM7_VHT || defined CMSDK_CM7_SP_VHT || defined CMSDK_CM7_DP_VHT
|
||||
.long ARM_VSI0_Handler /* 224 VSI 0 interrupt */
|
||||
.long ARM_VSI1_Handler /* 225 VSI 1 interrupt */
|
||||
.long ARM_VSI2_Handler /* 226 VSI 2 interrupt */
|
||||
.long ARM_VSI3_Handler /* 227 VSI 3 interrupt */
|
||||
.long ARM_VSI4_Handler /* 228 VSI 4 interrupt */
|
||||
.long ARM_VSI5_Handler /* 229 VSI 5 interrupt */
|
||||
.long ARM_VSI6_Handler /* 230 VSI 6 interrupt */
|
||||
.long ARM_VSI7_Handler /* 231 VSI 7 interrupt */
|
||||
#else
|
||||
.long 0 /* 224 reserved */
|
||||
.long 0 /* 225 reserved */
|
||||
.long 0 /* 226 reserved */
|
||||
.long 0 /* 227 reserved */
|
||||
.long 0 /* 228 reserved */
|
||||
.long 0 /* 229 reserved */
|
||||
.long 0 /* 230 reserved */
|
||||
.long 0 /* 231 reserved */
|
||||
#endif
|
||||
.long 0 /* 232 reserved */
|
||||
.long 0 /* 233 reserved */
|
||||
.long 0 /* 234 reserved */
|
||||
.long 0 /* 235 reserved */
|
||||
.long 0 /* 236 reserved */
|
||||
.long 0 /* 237 reserved */
|
||||
.long 0 /* 238 reserved */
|
||||
.long 0 /* 239 reserved */
|
||||
|
||||
.size __isr_vector, . - __isr_vector
|
||||
|
||||
.text
|
||||
.thumb
|
||||
@@ -1,16 +1,16 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : ch32v10x_it.c
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2020/04/30
|
||||
* Description : Main Interrupt Service Routines.
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*******************************************************************************/
|
||||
* File Name : ch32v10x_it.c
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2020/04/30
|
||||
* Description : Main Interrupt Service Routines.
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*******************************************************************************/
|
||||
/*************************************************
|
||||
File name: ch32v30x_it.c
|
||||
Description: include peripheral supports for ch32v30x
|
||||
History:
|
||||
Description: include peripheral supports for ch32v30x
|
||||
History:
|
||||
1. Date: 2022-08-09
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
@@ -18,12 +18,16 @@ Modification:
|
||||
*************************************************/
|
||||
#include "ch32v30x_it.h"
|
||||
#include "board.h"
|
||||
#include "ch32v30x_exti.h"
|
||||
#include "ch32v30x_tim.h"
|
||||
#include "eth_driver.h"
|
||||
#include <xs_isr.h>
|
||||
|
||||
|
||||
|
||||
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void NMI_Handler(void) __attribute__((interrupt()));
|
||||
void HardFault_Handler(void) __attribute__((interrupt()));
|
||||
void ETH_IRQHandler(void) __attribute__((interrupt()));
|
||||
void TIM2_IRQHandler(void) __attribute__((interrupt()));
|
||||
void EXTI9_5_IRQHandler(void) __attribute__((interrupt()));
|
||||
|
||||
/*********************************************************************
|
||||
* @fn NMI_Handler
|
||||
@@ -53,9 +57,51 @@ void HardFault_Handler(void)
|
||||
GET_INT_SP();
|
||||
isrManager.done->incCounter();
|
||||
KPrintf("HardFault_Handler.\n");
|
||||
|
||||
KPrintf("mepc :%08x\r\n", __get_MEPC());
|
||||
KPrintf("mcause:%08x\r\n", __get_MCAUSE());
|
||||
KPrintf("mtval :%08x\r\n", __get_MTVAL());
|
||||
while (1)
|
||||
;
|
||||
|
||||
isrManager.done->decCounter();
|
||||
FREE_INT_SP();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ETH_IRQHandler
|
||||
*
|
||||
* @brief This function handles ETH exception.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ETH_IRQHandler(void)
|
||||
{
|
||||
WCHNET_ETHIsr();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TIM2_IRQHandler
|
||||
*
|
||||
* @brief This function handles TIM2 exception.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TIM2_IRQHandler(void)
|
||||
{
|
||||
WCHNET_TimeIsr(WCHNETTIMERPERIOD);
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn EXTI9_5_IRQHandler
|
||||
*
|
||||
* @brief This function handles GPIO exception.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void EXTI9_5_IRQHandler(void)
|
||||
{
|
||||
ETH_PHYLink();
|
||||
EXTI_ClearITPendingBit(EXTI_Line7); /* Clear Flag */
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
extern void KTaskOsAssignAfterIrq(void *);
|
||||
|
||||
void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void SysTick_Handler(void) __attribute__((interrupt()));
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
GET_INT_SP();
|
||||
|
||||
@@ -268,13 +268,17 @@ static uint32 Stm32SerialInit(struct SerialDriver *serial_drv, struct BusConfigu
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
struct UsartHwCfg *serial_hw_cfg = (struct UsartHwCfg *)serial_cfg->hw_cfg.private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
@@ -143,13 +143,17 @@ static uint32 SerialHsInit(struct SerialDriver *serial_drv, struct BusConfigureI
|
||||
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
@@ -226,13 +230,17 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
@@ -9,48 +9,48 @@
|
||||
* 2018-11-12 Ernest Chen modify copyright
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.c
|
||||
* @brief support ch32v307 init configure and start-up
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-08-08
|
||||
*/
|
||||
#include <board.h>
|
||||
#include <xizi.h>
|
||||
#include <stdint.h>
|
||||
#include <device.h>
|
||||
#include "connect_uart.h"
|
||||
#include "xsconfig.h"
|
||||
* @file board.c
|
||||
* @brief support ch32v307 init configure and start-up
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-08-08
|
||||
*/
|
||||
#include "ch32v30x.h"
|
||||
#include "connect_ether.h"
|
||||
#include "connect_uart.h"
|
||||
#include "core_riscv.h"
|
||||
// #include <system_ch32v30x.h>
|
||||
#include "xsconfig.h"
|
||||
#include <board.h>
|
||||
#include <device.h>
|
||||
#include <stdint.h>
|
||||
#include <xizi.h>
|
||||
|
||||
// core clock.
|
||||
// core clock.
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
static uint32_t _SysTick_Config(uint32_t ticks)
|
||||
{
|
||||
NVIC_SetPriority(SysTicK_IRQn,0xf0);
|
||||
NVIC_SetPriority(Software_IRQn,0xf0);
|
||||
NVIC_SetPriority(SysTicK_IRQn, 0xf0);
|
||||
NVIC_SetPriority(Software_IRQn, 0xf0);
|
||||
NVIC_EnableIRQ(SysTicK_IRQn);
|
||||
NVIC_EnableIRQ(Software_IRQn);
|
||||
SysTick->CTLR=0;
|
||||
SysTick->SR=0;
|
||||
SysTick->CNT=0;
|
||||
SysTick->CMP=ticks-1;
|
||||
SysTick->CTLR=0xF;
|
||||
SysTick->CTLR = 0;
|
||||
SysTick->SR = 0;
|
||||
SysTick->CNT = 0;
|
||||
SysTick->CMP = ticks - 1;
|
||||
SysTick->CTLR = 0xF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -67,12 +67,15 @@ void InitBoardHardware()
|
||||
InitHwUart();
|
||||
InstallConsole("uart1", "uart1_drv", "uart1_dev1");
|
||||
|
||||
#ifdef BSP_USING_ETH
|
||||
InitHwEth();
|
||||
#endif
|
||||
|
||||
KPrintf("consle init completed.\n");
|
||||
KPrintf("board initialization......\n");
|
||||
// KPrintf("memory address range: [0x%08x - 0x%08x], size: %d\n", (x_ubase) MEMORY_START_ADDRESS, (x_ubase) MEMORY_END_ADDRESS, gd32vf103_SRAM_SIZE);
|
||||
/* initialize memory system */
|
||||
|
||||
KPrintf("board init done.\n");
|
||||
KPrintf("start okernel...\n");
|
||||
}
|
||||
|
||||
KPrintf("board init done.\n");
|
||||
KPrintf("start okernel...\n");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ export CROSS_COMPILE ?=/opt/riscv-embedded-gcc/bin/riscv-none-embed-
|
||||
|
||||
export DEFINES := -DHAVE_CCONFIG_H -DHAVE_SIGINFO
|
||||
|
||||
export LINK_WCH_NET := $(KERNEL_ROOT)/board/ch32v307vct6/third_party_driver/ethernet/libwchnet.a
|
||||
|
||||
export ARCH = risc-v
|
||||
export MCU = GH32V307
|
||||
|
||||
|
||||
@@ -14,5 +14,9 @@ menuconfig BSP_USING_GPIO
|
||||
if BSP_USING_GPIO
|
||||
source "$BSP_DIR/third_party_driver/gpio/Kconfig"
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_ETH
|
||||
bool "Using Ethernet"
|
||||
default y
|
||||
|
||||
|
||||
@@ -9,4 +9,8 @@ ifeq ($(CONFIG_BSP_USING_GPIO),y)
|
||||
SRC_DIR += gpio
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BSP_USING_ETH),y)
|
||||
SRC_DIR += ethernet
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -319,6 +319,9 @@ typedef struct
|
||||
/* PHY basic register */
|
||||
#define PHY_BCR 0x0 /*PHY transceiver Basic Control Register */
|
||||
#define PHY_BSR 0x01 /*PHY transceiver Basic Status Register */
|
||||
#define PHY_ANAR 0x04 /* Auto-Negotiation Advertisement Register */
|
||||
#define PHY_ANLPAR 0x05 /* Auto-Negotiation Link Partner Base Page Ability Register*/
|
||||
#define PHY_ANER 0x06 /* Auto-Negotiation Expansion Register */
|
||||
#define PHY_BMCR PHY_BCR
|
||||
#define PHY_BMSR PHY_BSR
|
||||
#define PHY_STATUS 0x10
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
SRC_FILES := eth_driver.c connect_ether.c
|
||||
SRC_DIR := test
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,268 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : main.c
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2022/05/31
|
||||
* Description : Main program body.
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
/*
|
||||
*@Note
|
||||
TCP Client example, demonstrating that TCP Client connects
|
||||
to the server and receives data and then sends it back.
|
||||
For details on the selection of engineering chips,
|
||||
please refer to the "CH32V30x Evaluation Board Manual" under the CH32V307EVT\EVT\PUB folder.
|
||||
*/
|
||||
|
||||
#include "connect_ether.h"
|
||||
#include "ch32v30x_rcc.h"
|
||||
#include "ch32v30x_tim.h"
|
||||
#include "core_riscv.h"
|
||||
#include "eth_driver.h"
|
||||
#include "string.h"
|
||||
#include "xs_base.h"
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
#define KEEPALIVE_ENABLE 1 // Enable keep alive function
|
||||
|
||||
uint8_t MACAddr[6]; // MAC address
|
||||
uint8_t IPAddr[4] = { 192, 168, 1, 10 }; // IP address
|
||||
uint8_t GWIPAddr[4] = { 192, 168, 1, 1 }; // Gateway IP address
|
||||
uint8_t IPMask[4] = { 255, 255, 255, 0 }; // subnet mask
|
||||
|
||||
uint8_t MyBuf[RECE_BUF_LEN];
|
||||
uint8_t socket[WCHNET_MAX_SOCKET_NUM]; // Save the currently connected socket
|
||||
uint8_t SocketRecvBuf[WCHNET_MAX_SOCKET_NUM][RECE_BUF_LEN]; // socket receive buffer
|
||||
|
||||
/*********************************************************************
|
||||
* @fn mStopIfError
|
||||
*
|
||||
* @brief check if error.
|
||||
*
|
||||
* @param iError - error constants.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void mStopIfError(uint8_t iError)
|
||||
{
|
||||
if (iError == WCHNET_ERR_SUCCESS)
|
||||
return;
|
||||
KPrintf("Error: %02X\r\n", (uint16_t)iError);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TIM2_Init
|
||||
*
|
||||
* @brief Initializes TIM2.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TIM2_Init(void)
|
||||
{
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = { 0 };
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Period = SystemCoreClock / 1000000;
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = WCHNETTIMERPERIOD * 1000 - 1;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
|
||||
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
|
||||
|
||||
TIM_Cmd(TIM2, ENABLE);
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
||||
NVIC_EnableIRQ(TIM2_IRQn);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WCHNET_CreateTcpSocket
|
||||
*
|
||||
* @brief Create TCP Socket
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void WCHNET_CreateTcpSocket(uint8_t* DESIP, uint16_t srcport, uint16_t desport, uint8_t* SocketId)
|
||||
{
|
||||
uint8_t i;
|
||||
SOCK_INF TmpSocketInf;
|
||||
|
||||
memset((void*)&TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||
memcpy((void*)TmpSocketInf.IPAddr, DESIP, 4);
|
||||
TmpSocketInf.DesPort = desport;
|
||||
TmpSocketInf.SourPort = srcport++;
|
||||
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
||||
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
||||
i = WCHNET_SocketCreat(SocketId, &TmpSocketInf);
|
||||
KPrintf("SocketId %d\r\n", *SocketId);
|
||||
mStopIfError(i);
|
||||
i = WCHNET_SocketConnect(*SocketId); // make a TCP connection
|
||||
mStopIfError(i);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WCHNET_DataLoopback
|
||||
*
|
||||
* @brief Data loopback function.
|
||||
*
|
||||
* @param id - socket id.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void WCHNET_DataLoopback(uint8_t id)
|
||||
{
|
||||
u32 len, totallen;
|
||||
uint8_t *p = MyBuf, TransCnt = 255;
|
||||
|
||||
len = WCHNET_SocketRecvLen(id, NULL); // query length
|
||||
KPrintf("Receive Len = %d\r\n", len);
|
||||
totallen = len;
|
||||
WCHNET_SocketRecv(id, MyBuf, &len); // Read the data of the receive buffer into MyBuf
|
||||
while (1) {
|
||||
len = totallen;
|
||||
WCHNET_SocketSend(id, p, &len); // Send the data
|
||||
totallen -= len; // Subtract the sent length from the total length
|
||||
p += len; // offset buffer pointer
|
||||
if (!--TransCnt)
|
||||
break; // Timeout exit
|
||||
if (totallen)
|
||||
continue; // If the data is not sent, continue to send
|
||||
break; // After sending, exit
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WCHNET_HandleSockInt
|
||||
*
|
||||
* @brief Socket Interrupt Handle
|
||||
*
|
||||
* @param socketid - socket id.
|
||||
* intstat - interrupt status
|
||||
*
|
||||
* @return 0 or TIME_OUT
|
||||
*/
|
||||
int WCHNET_HandleSockInt(uint8_t socketid, uint8_t intstat)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if (intstat & SINT_STAT_RECV) // receive data
|
||||
{
|
||||
WCHNET_DataLoopback(socketid); // Data loopback
|
||||
}
|
||||
if (intstat & SINT_STAT_CONNECT) // connect successfully
|
||||
{
|
||||
#if KEEPALIVE_ENABLE
|
||||
WCHNET_SocketSetKeepLive(socketid, ENABLE);
|
||||
#endif
|
||||
WCHNET_ModifyRecvBuf(socketid, (u32)SocketRecvBuf[socketid], RECE_BUF_LEN);
|
||||
for (i = 0; i < WCHNET_MAX_SOCKET_NUM; i++) {
|
||||
if (socket[i] == 0xff) { // save connected socket id
|
||||
socket[i] = socketid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
KPrintf("TCP Connect Success\r\n");
|
||||
KPrintf("socket id: %d\r\n", socket[i]);
|
||||
}
|
||||
if (intstat & SINT_STAT_DISCONNECT) // disconnect
|
||||
{
|
||||
for (i = 0; i < WCHNET_MAX_SOCKET_NUM; i++) { // delete disconnected socket id
|
||||
if (socket[i] == socketid) {
|
||||
socket[i] = 0xff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
KPrintf("TCP Disconnect\r\n");
|
||||
}
|
||||
if (intstat & SINT_STAT_TIM_OUT) // timeout disconnect
|
||||
{
|
||||
for (i = 0; i < WCHNET_MAX_SOCKET_NUM; i++) { // delete disconnected socket id
|
||||
if (socket[i] == socketid) {
|
||||
socket[i] = 0xff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
KPrintf("TCP Timeout\r\n");
|
||||
return TIME_OUT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WCHNET_HandleGlobalInt
|
||||
*
|
||||
* @brief Global Interrupt Handle
|
||||
*
|
||||
* @return 0 or SockInt
|
||||
*/
|
||||
int WCHNET_HandleGlobalInt(void)
|
||||
{
|
||||
uint8_t intstat;
|
||||
uint16_t i;
|
||||
uint8_t socketint;
|
||||
|
||||
intstat = WCHNET_GetGlobalInt(); // get global interrupt flag
|
||||
if (intstat & GINT_STAT_UNREACH) // Unreachable interrupt
|
||||
{
|
||||
KPrintf("GINT_STAT_UNREACH\r\n");
|
||||
}
|
||||
if (intstat & GINT_STAT_IP_CONFLI) // IP conflict
|
||||
{
|
||||
KPrintf("GINT_STAT_IP_CONFLI\r\n");
|
||||
}
|
||||
if (intstat & GINT_STAT_PHY_CHANGE) // PHY status change
|
||||
{
|
||||
i = WCHNET_GetPHYStatus();
|
||||
if (i & PHY_Linked_Status)
|
||||
KPrintf("PHY Link Success\r\n");
|
||||
}
|
||||
if (intstat & GINT_STAT_SOCKET) { // socket related interrupt
|
||||
for (i = 0; i < WCHNET_MAX_SOCKET_NUM; i++) {
|
||||
socketint = WCHNET_GetSocketInt(i);
|
||||
if (socketint) {
|
||||
return WCHNET_HandleSockInt(i, socketint);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t InitHwEth()
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
KPrintf("net version:%x\n", WCHNET_GetVer());
|
||||
if (WCHNET_LIB_VER != WCHNET_GetVer()) {
|
||||
KPrintf("version error.\n");
|
||||
}
|
||||
|
||||
WCHNET_GetMacAddr(MACAddr); // get the chip MAC address
|
||||
KPrintf("mac addr:");
|
||||
for (i = 0; i < 6; i++)
|
||||
KPrintf("%x ", MACAddr[i]);
|
||||
KPrintf("\n");
|
||||
|
||||
TIM2_Init();
|
||||
|
||||
i = ETH_LibInit(IPAddr, GWIPAddr, IPMask, MACAddr); // Ethernet library initialize
|
||||
mStopIfError(i);
|
||||
if (i == WCHNET_ERR_SUCCESS)
|
||||
KPrintf("WCHNET_LibInit Success\r\n");
|
||||
#if KEEPALIVE_ENABLE // Configure keep alive parameters
|
||||
{
|
||||
struct _KEEP_CFG cfg;
|
||||
|
||||
cfg.KLIdle = 20000;
|
||||
cfg.KLIntvl = 15000;
|
||||
cfg.KLCount = 9;
|
||||
WCHNET_ConfigKeepLive(&cfg);
|
||||
}
|
||||
#endif
|
||||
|
||||
memset(socket, 0xff, WCHNET_MAX_SOCKET_NUM);
|
||||
|
||||
return i;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
SRC_FILES := wch_tcp_test.c
|
||||
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "connect_ether.h"
|
||||
#include "eth_driver.h"
|
||||
#include "shell.h"
|
||||
#include "wchnet.h"
|
||||
#include "xs_base.h"
|
||||
|
||||
uint8_t DESIP[4] = { 192, 168, 1, 100 }; // destination IP address
|
||||
uint16_t desport = 1000; // destination port
|
||||
uint16_t srcport = 1000; // source port
|
||||
|
||||
uint8_t SocketId;
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TCP client
|
||||
*
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
int Tcp_Client(void)
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; i < WCHNET_MAX_SOCKET_NUM; i++)
|
||||
WCHNET_CreateTcpSocket(DESIP, srcport, desport, &SocketId); // Create TCP Socket
|
||||
|
||||
while (1) {
|
||||
/*Ethernet library main task function,
|
||||
* which needs to be called cyclically*/
|
||||
WCHNET_MainTask();
|
||||
/*Query the Ethernet global interrupt,
|
||||
* if there is an interrupt, call the global interrupt handler*/
|
||||
if (WCHNET_QueryGlobalInt()) {
|
||||
if (WCHNET_HandleGlobalInt() == TIME_OUT) {
|
||||
WCHNET_CreateTcpSocket(DESIP, srcport, desport, &SocketId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int test_tcp_client(int argc, char* argv[])
|
||||
{
|
||||
KPrintf("TCPClient Test\r\n");
|
||||
Tcp_Client();
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||
test_tcp_client, test_tcp_client, test tcp client);
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 connect_ethernet.h
|
||||
* @brief define rvstar uart function
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-08-01
|
||||
*/
|
||||
|
||||
#ifndef CONNECT_ETH_H
|
||||
#define CONNECT_ETH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t InitHwEth();
|
||||
void WCHNET_CreateTcpSocket(uint8_t* DESIP, uint16_t srcport, uint16_t desport, uint8_t* SocketId);
|
||||
void WCHNET_CreateTcpSocketListen(uint16_t srcport, uint8_t* SocketId);
|
||||
|
||||
int WCHNET_HandleGlobalInt(void);
|
||||
|
||||
#define TIME_OUT -1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,181 @@
|
||||
/********************************** (C) COPYRIGHT ************* ******************
|
||||
* File Name : eth_driver.h
|
||||
* Author : WCH
|
||||
* Version : V1.3.0
|
||||
* Date : 2022/06/02
|
||||
* Description : This file contains the headers of the ETH Driver.
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#ifndef __ETH_DRIVER__
|
||||
#define __ETH_DRIVER__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ch32v30x_eth.h"
|
||||
#include "debug.h"
|
||||
#include "wchnet.h"
|
||||
|
||||
/* Internal 10M PHY */
|
||||
#define USE_10M_BASE 1
|
||||
/* The chips supported by the MII/RMII driver are: CH182/RTL8201F, etc. */
|
||||
#define USE_MAC_MII 2
|
||||
#define USE_MAC_RMII 3
|
||||
#define USE_MAC_RGMII 4
|
||||
|
||||
#ifndef PHY_MODE
|
||||
#define PHY_MODE USE_10M_BASE
|
||||
#endif
|
||||
|
||||
/* 1: interrupt 0: polling in RMII or RGMII mode */
|
||||
#define LINK_STAT_ACQUISITION_METHOD 1
|
||||
|
||||
#define PHY_ADDRESS 1
|
||||
|
||||
#define ETH_DMARxDesc_FrameLengthShift 16
|
||||
|
||||
#define ROM_CFG_USERADR_ID 0x1FFFF7E8
|
||||
|
||||
#define PHY_LINK_TASK_PERIOD 50
|
||||
|
||||
#define PHY_ANLPAR_SELECTOR_FIELD 0x1F
|
||||
#define PHY_ANLPAR_SELECTOR_VALUE 0x01 /* 5B'00001 */
|
||||
|
||||
#define PHY_LINK_INIT 0x00
|
||||
#define PHY_LINK_SUC_P (1 << 0)
|
||||
#define PHY_LINK_SUC_N (1 << 1)
|
||||
#define PHY_LINK_WAIT_SUC (1 << 7)
|
||||
|
||||
#define PHY_PN_SWITCH_P (0 << 2)
|
||||
#define PHY_PN_SWITCH_N (1 << 2)
|
||||
#define PHY_PN_SWITCH_AUTO (2 << 2)
|
||||
|
||||
#ifndef WCHNETTIMERPERIOD
|
||||
#define WCHNETTIMERPERIOD 10 /* Timer period, in Ms. */
|
||||
#endif
|
||||
|
||||
#define GPIO_Output(a, b) \
|
||||
GPIO_InitStructure.GPIO_Pin = b; \
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; \
|
||||
GPIO_Init(a, &GPIO_InitStructure)
|
||||
|
||||
#define GPIO_Input(a, b) \
|
||||
GPIO_InitStructure.GPIO_Pin = b; \
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; \
|
||||
GPIO_Init(a, &GPIO_InitStructure)
|
||||
|
||||
#define QUERY_STAT_FLAG ((LastQueryPhyTime == (LocalTime / 1000)) ? 0 : 1)
|
||||
|
||||
#define ENABLE_POLLING_TO_QUERY_PHY_LINK_STAT ((PHY_MODE == USE_MAC_MII) || (((PHY_MODE == USE_MAC_RMII) || (PHY_MODE == USE_MAC_RGMII)) && !LINK_STAT_ACQUISITION_METHOD))
|
||||
|
||||
#define ACCELERATE_LINK_PROCESS() \
|
||||
do { \
|
||||
if ((TRDetectStep < 2) && (ETH_ReadPHYRegister(gPHYAddress, PHY_ANLPAR) & PHY_ANLPAR_SELECTOR_FIELD)) \
|
||||
LinkTaskPeriod = 0; \
|
||||
} while (0)
|
||||
|
||||
#define UPDATE_LINKTASKPERIOD() \
|
||||
do { \
|
||||
if (TRDetectStep == 1) { \
|
||||
RandVal = RandVal * 214017 + 2531017; \
|
||||
LinkTaskPeriod = RandVal % 100 + 50; \
|
||||
} else { \
|
||||
LinkTaskPeriod = 50; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PHY_RESTART_AUTONEGOTIATION() \
|
||||
do { \
|
||||
RegVal = ETH_ReadPHYRegister(gPHYAddress, PHY_BCR); \
|
||||
RegVal &= ~0x01; \
|
||||
RegVal |= PHY_Restart_AutoNegotiation; \
|
||||
ETH_WritePHYRegister(gPHYAddress, PHY_BCR, RegVal); \
|
||||
RegVal = ETH_ReadPHYRegister(gPHYAddress, PHY_BCR); \
|
||||
RegVal |= 0x03 | PHY_Restart_AutoNegotiation; \
|
||||
ETH_WritePHYRegister(gPHYAddress, PHY_BCR, RegVal); \
|
||||
} while (0)
|
||||
|
||||
#define PHY_TR_SWITCH() \
|
||||
do { \
|
||||
phy_mdix = ETH_ReadPHYRegister(gPHYAddress, PHY_MDIX); \
|
||||
if (phy_mdix & 0x01) { \
|
||||
phy_mdix &= ~0x03; \
|
||||
phy_mdix |= 1 << 1; \
|
||||
} else { \
|
||||
phy_mdix &= ~0x03; \
|
||||
phy_mdix |= 1 << 0; \
|
||||
} \
|
||||
ETH_WritePHYRegister(gPHYAddress, PHY_MDIX, phy_mdix); \
|
||||
PHY_RESTART_AUTONEGOTIATION(); \
|
||||
} while (0)
|
||||
|
||||
#define PHY_TR_REVERSE() \
|
||||
do { \
|
||||
RegVal = ETH_ReadPHYRegister(gPHYAddress, PHY_MDIX); \
|
||||
if (RegVal & 0x01) { \
|
||||
RegVal &= ~0x03; \
|
||||
RegVal |= 1 << 1; \
|
||||
} else { \
|
||||
RegVal &= ~0x03; \
|
||||
RegVal |= 1 << 0; \
|
||||
} \
|
||||
ETH_WritePHYRegister(gPHYAddress, PHY_MDIX, RegVal); \
|
||||
} while (0)
|
||||
|
||||
#define PHY_PN_SWITCH(PNMode) \
|
||||
do { \
|
||||
if (PNMode == PHY_PN_SWITCH_AUTO) { \
|
||||
phyPN = PHY_PN_SWITCH_AUTO; \
|
||||
} else { \
|
||||
phyPN = (ETH_ReadPHYRegister(gPHYAddress, PHY_MDIX) & (~(0x03 << 2))) | PNMode; \
|
||||
} \
|
||||
ETH_WritePHYRegister(gPHYAddress, PHY_MDIX, phyPN); \
|
||||
phyPN = PNMode; \
|
||||
PHY_RESTART_AUTONEGOTIATION(); \
|
||||
} while (0)
|
||||
|
||||
#define PHY_NEGOTIATION_PARAM_INIT() \
|
||||
do { \
|
||||
phyStatus = 0; \
|
||||
phySucCnt = 0; \
|
||||
phyLinkCnt = 0; \
|
||||
TRDetectStep = 0; \
|
||||
PhyPolarityDetect = 0; \
|
||||
phyLinkStatus = PHY_LINK_INIT; \
|
||||
phyPN = PHY_PN_SWITCH_AUTO; \
|
||||
ETH_WritePHYRegister(gPHYAddress, PHY_MDIX, phyPN); \
|
||||
} while (0)
|
||||
|
||||
#define PHY_LINK_RESET() \
|
||||
do { \
|
||||
ETH_WritePHYRegister(gPHYAddress, PHY_BCR, PHY_Reset); \
|
||||
PHY_NEGOTIATION_PARAM_INIT(); \
|
||||
} while (0)
|
||||
|
||||
extern ETH_DMADESCTypeDef* DMATxDescToSet;
|
||||
extern ETH_DMADESCTypeDef* DMARxDescToGet;
|
||||
extern SOCK_INF SocketInf[];
|
||||
|
||||
void ETH_PHYLink(void);
|
||||
void WCHNET_ETHIsr(void);
|
||||
void WCHNET_MainTask(void);
|
||||
void ETH_LedConfiguration(void);
|
||||
void ETH_Init(uint8_t* macAddr);
|
||||
void ETH_LedLinkSet(uint8_t mode);
|
||||
void ETH_LedDataSet(uint8_t mode);
|
||||
void WCHNET_TimeIsr(uint16_t timperiod);
|
||||
void ETH_Configuration(uint8_t* macAddr);
|
||||
uint8_t ETH_LibInit(uint8_t* ip, uint8_t* gwip, uint8_t* mask, uint8_t* macaddr);
|
||||
void WCHNET_MainTask(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : net_config.h
|
||||
* Author : WCH
|
||||
* Version : V1.30
|
||||
* Date : 2022/06/02
|
||||
* Description : This file contains the configurations of
|
||||
* Ethernet protocol stack library
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#ifndef __NET_CONFIG_H__
|
||||
#define __NET_CONFIG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* socket configuration, IPRAW + UDP + TCP + TCP_LISTEN = number of sockets
|
||||
*/
|
||||
#define WCHNET_NUM_IPRAW 0 /* Number of IPRAW connections */
|
||||
|
||||
#define WCHNET_NUM_UDP 0 /* The number of UDP connections */
|
||||
|
||||
#define WCHNET_NUM_TCP 1 /* Number of TCP connections */
|
||||
|
||||
#define WCHNET_NUM_TCP_LISTEN 0 /* Number of TCP listening */
|
||||
|
||||
/* The number of sockets, the maximum is 31 */
|
||||
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW + WCHNET_NUM_UDP + WCHNET_NUM_TCP + WCHNET_NUM_TCP_LISTEN)
|
||||
|
||||
#define WCHNET_TCP_MSS 1460 /* Size of TCP MSS*/
|
||||
|
||||
#define WCHNET_NUM_POOL_BUF (WCHNET_NUM_TCP * 2 + 2) /* The number of POOL BUFs, the number of receive queues */
|
||||
|
||||
/*********************************************************************
|
||||
* MAC queue configuration
|
||||
*/
|
||||
#define ETH_TXBUFNB 2 /* The number of descriptors sent by the MAC */
|
||||
|
||||
#define ETH_RXBUFNB 4 /* Number of MAC received descriptors */
|
||||
|
||||
#ifndef ETH_MAX_PACKET_SIZE
|
||||
#define ETH_RX_BUF_SZE 1520 /* MAC receive buffer length, an integer multiple of 4 */
|
||||
#define ETH_TX_BUF_SZE 1520 /* MAC send buffer length, an integer multiple of 4 */
|
||||
#else
|
||||
#define ETH_RX_BUF_SZE ETH_MAX_PACKET_SIZE
|
||||
#define ETH_TX_BUF_SZE ETH_MAX_PACKET_SIZE
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* Functional configuration
|
||||
*/
|
||||
#define WCHNET_PING_ENABLE 1 /* PING is enabled, PING is enabled by default */
|
||||
|
||||
#define TCP_RETRY_COUNT 20 /* The number of TCP retransmissions, the default value is 20 */
|
||||
|
||||
#define TCP_RETRY_PERIOD 10 /* TCP retransmission period, the default value is 10, the unit is 50ms */
|
||||
|
||||
#define SOCKET_SEND_RETRY 0 /* Send failed retry configuration, 1: enable, 0: disable */
|
||||
|
||||
#define HARDWARE_CHECKSUM_CONFIG 0 /* Hardware checksum checking and insertion configuration, 1: enable, 0: disable */
|
||||
|
||||
#define FINE_DHCP_PERIOD 8 /* Fine DHCP period, the default value is 8, the unit is 250ms */
|
||||
|
||||
#define CFG0_TCP_SEND_COPY 1 /* TCP send buffer copy, 1: copy, 0: not copy */
|
||||
|
||||
#define CFG0_TCP_RECV_COPY 1 /* TCP receive replication optimization, internal debugging use */
|
||||
|
||||
#define CFG0_TCP_OLD_DELETE 0 /* Delete oldest TCP connection, 1: enable, 0: disable */
|
||||
|
||||
#define CFG0_IP_REASS_PBUFS 0 /* Number of reassembled IP PBUFs */
|
||||
|
||||
#define CFG0_TCP_DEALY_ACK_DISABLE 1 /* 1: disable TCP delay ACK 0: enable TCP delay ACK */
|
||||
|
||||
/*********************************************************************
|
||||
* Memory related configuration
|
||||
*/
|
||||
/* If you want to achieve a higher transmission speed,
|
||||
* try to increase RECE_BUF_LEN to (WCHNET_TCP_MSS*4)
|
||||
* and increase WCHNET_NUM_TCP_SEG to (WCHNET_NUM_TCP*4)*/
|
||||
#define RECE_BUF_LEN (WCHNET_TCP_MSS * 2) /* socket receive buffer size */
|
||||
|
||||
#define WCHNET_NUM_PBUF WCHNET_NUM_POOL_BUF /* Number of PBUF structures */
|
||||
|
||||
#define WCHNET_NUM_TCP_SEG (WCHNET_NUM_TCP * 2) /* The number of TCP segments used to send */
|
||||
|
||||
#define WCHNET_MEM_HEAP_SIZE (((WCHNET_TCP_MSS + 0x10 + 54 + 8) * WCHNET_NUM_TCP_SEG) + ETH_TX_BUF_SZE + 64 + 2 * 0x18) /* memory heap size */
|
||||
|
||||
#define WCHNET_NUM_ARP_TABLE 50 /* Number of ARP lists */
|
||||
|
||||
#define WCHNET_MEM_ALIGNMENT 4 /* 4 byte alignment */
|
||||
|
||||
#if CFG0_IP_REASS_PBUFS
|
||||
#define WCHNET_NUM_IP_REASSDATA 2 /* Number of reassembled IP structures */
|
||||
/*1: When using the fragmentation function,
|
||||
* ensure that the size of WCHNET_SIZE_POOL_BUF is large enough to store a single fragmented packet*/
|
||||
#define WCHNET_SIZE_POOL_BUF (((1500 + 14 + 4) + 3) & ~3) /* Buffer size for receiving a single packet */
|
||||
/*2: When creating a socket that can receive fragmented packets,
|
||||
* ensure that "RecvBufLen" member of the "struct _SOCK_INF" structure
|
||||
* (the parameter initialized when calling WCHNET_SocketCreat) is sufficient
|
||||
* to receive a complete fragmented packet */
|
||||
#else
|
||||
#define WCHNET_NUM_IP_REASSDATA 0 /* Number of reassembled IP structures */
|
||||
#define WCHNET_SIZE_POOL_BUF (((WCHNET_TCP_MSS + 40 + 14 + 4) + 3) & ~3) /* Buffer size for receiving a single packet */
|
||||
#endif
|
||||
|
||||
/* Check receive buffer */
|
||||
#if (WCHNET_NUM_POOL_BUF * WCHNET_SIZE_POOL_BUF < ETH_RX_BUF_SZE)
|
||||
#error "WCHNET_NUM_POOL_BUF or WCHNET_TCP_MSS Error"
|
||||
#error "Please Increase WCHNET_NUM_POOL_BUF or WCHNET_TCP_MSS to make sure the receive buffer is sufficient"
|
||||
#endif
|
||||
/* Check the configuration of the SOCKET quantity */
|
||||
#if (WCHNET_NUM_TCP_LISTEN && !WCHNET_NUM_TCP)
|
||||
#error "WCHNET_NUM_TCP Error,Please Configure WCHNET_NUM_TCP >= 1"
|
||||
#endif
|
||||
/* Check byte alignment must be a multiple of 4 */
|
||||
#if ((WCHNET_MEM_ALIGNMENT % 4) || (WCHNET_MEM_ALIGNMENT == 0))
|
||||
#error "WCHNET_MEM_ALIGNMENT Error,Please Configure WCHNET_MEM_ALIGNMENT = 4 * N, N >=1"
|
||||
#endif
|
||||
/* TCP maximum segment length */
|
||||
#if ((WCHNET_TCP_MSS > 1460) || (WCHNET_TCP_MSS < 60))
|
||||
#error "WCHNET_TCP_MSS Error,Please Configure WCHNET_TCP_MSS >= 60 && WCHNET_TCP_MSS <= 1460"
|
||||
#endif
|
||||
/* Number of ARP cache tables */
|
||||
#if ((WCHNET_NUM_ARP_TABLE > 0X7F) || (WCHNET_NUM_ARP_TABLE < 1))
|
||||
#error "WCHNET_NUM_ARP_TABLE Error,Please Configure WCHNET_NUM_ARP_TABLE >= 1 && WCHNET_NUM_ARP_TABLE <= 0X7F"
|
||||
#endif
|
||||
/* Check POOL BUF configuration */
|
||||
#if (WCHNET_NUM_POOL_BUF < 1)
|
||||
#error "WCHNET_NUM_POOL_BUF Error,Please Configure WCHNET_NUM_POOL_BUF >= 1"
|
||||
#endif
|
||||
/* Check PBUF structure configuration */
|
||||
#if (WCHNET_NUM_PBUF < 1)
|
||||
#error "WCHNET_NUM_PBUF Error,Please Configure WCHNET_NUM_PBUF >= 1"
|
||||
#endif
|
||||
/* Check IP Assignment Configuration */
|
||||
#if (CFG0_IP_REASS_PBUFS && ((WCHNET_NUM_IP_REASSDATA > 10) || (WCHNET_NUM_IP_REASSDATA < 1)))
|
||||
#error "WCHNET_NUM_IP_REASSDATA Error,Please Configure WCHNET_NUM_IP_REASSDATA < 10 && WCHNET_NUM_IP_REASSDATA >= 1 "
|
||||
#endif
|
||||
/* Check the number of reassembled IP PBUFs */
|
||||
#if (CFG0_IP_REASS_PBUFS > WCHNET_NUM_POOL_BUF)
|
||||
#error "WCHNET_NUM_POOL_BUF Error,Please Configure CFG0_IP_REASS_PBUFS < WCHNET_NUM_POOL_BUF"
|
||||
#endif
|
||||
/* Check Timer period, in Ms. */
|
||||
#if (WCHNETTIMERPERIOD > 50)
|
||||
#error "WCHNETTIMERPERIOD Error,Please Configure WCHNETTIMERPERIOD < 50"
|
||||
#endif
|
||||
|
||||
/* Configuration value 0 */
|
||||
#define WCHNET_MISC_CONFIG0 (((CFG0_TCP_SEND_COPY) << 0) | ((CFG0_TCP_RECV_COPY) << 1) | ((CFG0_TCP_OLD_DELETE) << 2) | ((CFG0_IP_REASS_PBUFS) << 3) | ((CFG0_TCP_DEALY_ACK_DISABLE) << 8))
|
||||
/* Configuration value 1 */
|
||||
#define WCHNET_MISC_CONFIG1 (((WCHNET_MAX_SOCKET_NUM) << 0) | ((WCHNET_PING_ENABLE) << 13) | ((TCP_RETRY_COUNT) << 14) | ((TCP_RETRY_PERIOD) << 19) | ((SOCKET_SEND_RETRY) << 25) | ((HARDWARE_CHECKSUM_CONFIG) << 26) | ((FINE_DHCP_PERIOD) << 27))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,591 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : wchnet.h
|
||||
* Author : WCH
|
||||
* Version : V1.80
|
||||
* Date : 2023/05/12
|
||||
* Description : This file contains the headers of
|
||||
* the Ethernet protocol stack library.
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#ifndef __WCHNET_H__
|
||||
#define __WCHNET_H__
|
||||
|
||||
#include "stdint.h"
|
||||
#ifndef NET_LIB
|
||||
#include "net_config.h"
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WCHNET_LIB_VER 0x18 // the library version number
|
||||
#define WCHNET_CFG_VALID 0x12345678 // Configuration value valid flag
|
||||
|
||||
/* LED state @LED_STAT */
|
||||
#define LED_ON 0
|
||||
#define LED_OFF 1
|
||||
|
||||
/* PHY state @PHY_STAT */
|
||||
#define PHY_LINK_SUCCESS (1 << 2) // PHY connection success
|
||||
#define PHY_AUTO_SUCCESS (1 << 5) // PHY auto negotiation completed
|
||||
|
||||
/* Library initialization state @CFG_INIT_STAT */
|
||||
#define INIT_OK 0x00
|
||||
#define INIT_ERR_RX_BUF_SIZE 0x01
|
||||
#define INIT_ERR_TCP_MSS 0x02
|
||||
#define INIT_ERR_HEAP_SIZE 0x03
|
||||
#define INIT_ERR_ARP_TABLE_NEM 0x04
|
||||
#define INIT_ERR_MISC_CONFIG0 0x05
|
||||
#define INIT_ERR_MISC_CONFIG1 0x06
|
||||
#define INIT_ERR_FUNC_SEND 0x09
|
||||
#define INIT_ERR_CHECK_VALID 0xFF
|
||||
|
||||
/* Socket protocol type */
|
||||
#define PROTO_TYPE_IP_RAW 0 // IP layer raw data
|
||||
#define PROTO_TYPE_UDP 2 // UDP protocol
|
||||
#define PROTO_TYPE_TCP 3 // TCP protocol
|
||||
|
||||
/* interrupt status */
|
||||
/* The following are the states
|
||||
* that GLOB_INT will generate */
|
||||
#define GINT_STAT_UNREACH (1 << 0) // unreachable interrupt
|
||||
#define GINT_STAT_IP_CONFLI (1 << 1) // IP conflict interrupt
|
||||
#define GINT_STAT_PHY_CHANGE (1 << 2) // PHY state change interrupt
|
||||
#define GINT_STAT_SOCKET (1 << 4) // socket related interrupt
|
||||
|
||||
/* The following are the states
|
||||
* that Sn_INT will generate*/
|
||||
#define SINT_STAT_RECV (1 << 2) // the socket receives data or the receive buffer is not empty
|
||||
#define SINT_STAT_CONNECT (1 << 3) // connect successfully,generated in TCP mode
|
||||
#define SINT_STAT_DISCONNECT (1 << 4) // disconnect,generated in TCP mode
|
||||
#define SINT_STAT_TIM_OUT (1 << 6) // timeout disconnect,generated in TCP mode
|
||||
|
||||
/* Definitions for error constants. @ERR_T */
|
||||
#define ERR_T
|
||||
#define WCHNET_ERR_SUCCESS 0x00 // No error, everything OK
|
||||
#define WCHNET_ERR_BUSY 0x10 // busy
|
||||
#define WCHNET_ERR_MEM 0x11 // Out of memory error
|
||||
#define WCHNET_ERR_BUF 0x12 // Buffer error
|
||||
#define WCHNET_ERR_TIMEOUT 0x13 // Timeout
|
||||
#define WCHNET_ERR_RTE 0x14 // Routing problem
|
||||
#define WCHNET_ERR_ABRT 0x15 // Connection aborted
|
||||
#define WCHNET_ERR_RST 0x16 // Connection reset
|
||||
#define WCHNET_ERR_CLSD 0x17 // Connection closed
|
||||
#define WCHNET_ERR_CONN 0x18 // Not connected
|
||||
#define WCHNET_ERR_VAL 0x19 // Illegal value
|
||||
#define WCHNET_ERR_ARG 0x1a // Illegal argument
|
||||
#define WCHNET_ERR_USE 0x1b // Address in use
|
||||
#define WCHNET_ERR_IF 0x1c // Low-level netif error
|
||||
#define WCHNET_ERR_ISCONN 0x1d // Already connected
|
||||
#define WCHNET_ERR_INPROGRESS 0x1e // Operation in progress
|
||||
#define WCHNET_ERR_SOCKET_MEM 0X20 // Socket information error
|
||||
#define WCHNET_ERR_UNSUPPORT_PROTO 0X21 // unsupported protocol type
|
||||
#define WCHNET_RET_ABORT 0x5F // command process fail
|
||||
#define WCHNET_ERR_UNKNOW 0xFA // unknow
|
||||
|
||||
/* unreachable condition related codes */
|
||||
#define UNREACH_CODE_HOST 0 // host unreachable
|
||||
#define UNREACH_CODE_NET 1 // network unreachable
|
||||
#define UNREACH_CODE_PROTOCOL 2 // protocol unreachable
|
||||
#define UNREACH_CODE_PROT 3 // port unreachable
|
||||
/*For other values, please refer to the RFC792 document*/
|
||||
|
||||
/* TCP disconnect related codes */
|
||||
#define TCP_CLOSE_NORMAL 0 // normal disconnect,a four-way handshake
|
||||
#define TCP_CLOSE_RST 1 // reset the connection and close
|
||||
#define TCP_CLOSE_ABANDON 2 // drop connection, and no termination message is sent
|
||||
|
||||
/* socket state code */
|
||||
#define SOCK_STAT_CLOSED 0X00 // socket close
|
||||
#define SOCK_STAT_OPEN 0X05 // socket open
|
||||
|
||||
/* TCP state code */
|
||||
#define TCP_CLOSED 0 // TCP close
|
||||
#define TCP_LISTEN 1 // TCP listening
|
||||
#define TCP_SYN_SENT 2 // SYN send, connect request
|
||||
#define TCP_SYN_RCVD 3 // SYN received, connection request received
|
||||
#define TCP_ESTABLISHED 4 // TCP connection establishment
|
||||
#define TCP_FIN_WAIT_1 5 // WAIT_1 state
|
||||
#define TCP_FIN_WAIT_2 6 // WAIT_2 state
|
||||
#define TCP_CLOSE_WAIT 7 // wait to close
|
||||
#define TCP_CLOSING 8 // closing
|
||||
#define TCP_LAST_ACK 9 // LAST_ACK
|
||||
#define TCP_TIME_WAIT 10 // 2MSL wait
|
||||
|
||||
/* The following values are fixed and cannot be changed */
|
||||
#define WCHNET_MEM_ALIGN_SIZE(size) (((size) + WCHNET_MEM_ALIGNMENT - 1) & ~(WCHNET_MEM_ALIGNMENT - 1))
|
||||
#define WCHNET_SIZE_IPRAW_PCB 0x1C // IPRAW PCB size
|
||||
#define WCHNET_SIZE_UDP_PCB 0x20 // UDP PCB size
|
||||
#define WCHNET_SIZE_TCP_PCB 0xB4 // TCP PCB size
|
||||
#define WCHNET_SIZE_TCP_PCB_LISTEN 0x24 // TCP LISTEN PCB size
|
||||
#define WCHNET_SIZE_IP_REASSDATA 0x20 // IP reassembled Management
|
||||
#define WCHNET_SIZE_PBUF 0x10 // Packet Buf
|
||||
#define WCHNET_SIZE_TCP_SEG 0x14 // TCP SEG structure
|
||||
#define WCHNET_SIZE_MEM 0x08 // sizeof(struct mem)
|
||||
#define WCHNET_SIZE_ARP_TABLE 0x18 // sizeof ARP table
|
||||
|
||||
#define WCHNET_MEMP_SIZE ((WCHNET_MEM_ALIGNMENT - 1) + (WCHNET_NUM_IPRAW * WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_IPRAW_PCB)) + (WCHNET_NUM_UDP * WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_UDP_PCB)) + (WCHNET_NUM_TCP * WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_TCP_PCB)) + (WCHNET_NUM_TCP_LISTEN * WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_TCP_PCB_LISTEN)) + (WCHNET_NUM_TCP_SEG * WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_TCP_SEG)) + (WCHNET_NUM_IP_REASSDATA * WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_IP_REASSDATA)) + (WCHNET_NUM_PBUF * WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_PBUF)) + (WCHNET_NUM_POOL_BUF * (WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_PBUF) + WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_POOL_BUF))))
|
||||
|
||||
#define HEAP_MEM_ALIGN_SIZE (WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_MEM))
|
||||
#define WCHNET_RAM_HEAP_SIZE (WCHNET_MEM_ALIGN_SIZE(WCHNET_MEM_HEAP_SIZE) + HEAP_MEM_ALIGN_SIZE)
|
||||
#define WCHNET_RAM_ARP_TABLE_SIZE (WCHNET_MEM_ALIGN_SIZE(WCHNET_SIZE_ARP_TABLE) * WCHNET_NUM_ARP_TABLE)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t length;
|
||||
uint32_t buffer;
|
||||
} ETHFrameType;
|
||||
|
||||
/* LED callback type */
|
||||
typedef void (*led_callback)(uint8_t setbit);
|
||||
|
||||
/* net send callback type */
|
||||
typedef uint32_t (*eth_tx_set)(uint16_t len, uint32_t* pBuff);
|
||||
|
||||
/* net receive callback type */
|
||||
typedef uint32_t (*eth_rx_set)(ETHFrameType* pkt);
|
||||
|
||||
/* DNS callback type */
|
||||
typedef void (*dns_callback)(const char* name, uint8_t* ipaddr, void* callback_arg);
|
||||
|
||||
/* DHCP callback type */
|
||||
typedef uint8_t (*dhcp_callback)(uint8_t status, void*);
|
||||
|
||||
/* socket receive callback type */
|
||||
struct _SOCK_INF;
|
||||
typedef void (*pSockRecv)(struct _SOCK_INF*, uint32_t, uint16_t, uint8_t*, uint32_t);
|
||||
|
||||
/* Socket information struct */
|
||||
typedef struct _SOCK_INF {
|
||||
uint32_t IntStatus; // interrupt state
|
||||
uint32_t SockIndex; // Socket index value
|
||||
uint32_t RecvStartPoint; // Start pointer of the receive buffer
|
||||
uint32_t RecvBufLen; // Receive buffer length
|
||||
uint32_t RecvCurPoint; // current pointer to receive buffer
|
||||
uint32_t RecvReadPoint; // The read pointer of the receive buffer
|
||||
uint32_t RecvRemLen; // The length of the remaining data in the receive buffer
|
||||
uint32_t ProtoType; // protocol type
|
||||
uint32_t SockStatus; // Low byte Socket state, the next low byte is TCP state, only meaningful in TCP mode
|
||||
uint32_t DesPort; // destination port
|
||||
uint32_t SourPort; // Source port, protocol type in IPRAW mode
|
||||
uint8_t IPAddr[4]; // Socket destination IP address
|
||||
void* Resv1; // Reserved, for internal use, for saving individual PCBs
|
||||
void* Resv2; // Reserved, used internally, used by TCP Server
|
||||
pSockRecv AppCallBack; // receive callback function
|
||||
} SOCK_INF;
|
||||
|
||||
struct _WCH_CFG {
|
||||
uint32_t TxBufSize; // MAC send buffer size, reserved for use
|
||||
uint32_t TCPMss; // TCP MSS size
|
||||
uint32_t HeapSize; // heap memory size
|
||||
uint32_t ARPTableNum; // Number of ARP lists
|
||||
uint32_t MiscConfig0; // Miscellaneous Configuration 0
|
||||
/* Bit 0 TCP send buffer copy 1: copy, 0: not copy */
|
||||
/* Bit 1 TCP receive replication optimization, used for internal debugging */
|
||||
/* bit 2 delete oldest TCP connection 1: enable, 0: disable */
|
||||
/* Bits 3-7 Number of PBUFs of IP segments */
|
||||
/* Bit 8 TCP Delay ACK disable */
|
||||
uint32_t MiscConfig1; // Miscellaneous Configuration 1
|
||||
/* Bits 0-7 Number of Sockets*/
|
||||
/* Bits 8-12 Reserved */
|
||||
/* Bit 13 PING enable, 1: On 0: Off */
|
||||
/* Bits 14-18 TCP retransmission times */
|
||||
/* Bits 19-23 TCP retransmission period, in 50 milliseconds */
|
||||
/* bit 25 send failed retry, 1: enable, 0: disable */
|
||||
/* bit 26 Select whether to perform IPv4 checksum check on
|
||||
* the TCP/UDP/ICMP header of the received frame payload by hardware,
|
||||
* and calculate and insert the checksum of the IP header and payload of the sent frame by hardware.*/
|
||||
/* Bits 27-31 period (in 250 milliseconds) of Fine DHCP periodic process */
|
||||
led_callback led_link; // PHY Link Status Indicator
|
||||
led_callback led_data; // Ethernet communication indicator
|
||||
eth_tx_set net_send; // Ethernet send
|
||||
eth_rx_set net_recv; // Ethernet receive
|
||||
uint32_t CheckValid; // Configuration value valid flag, fixed value @WCHNET_CFG_VALID
|
||||
};
|
||||
|
||||
struct _NET_SYS {
|
||||
uint8_t IPAddr[4]; // IP address
|
||||
uint8_t GWIPAddr[4]; // Gateway IP address
|
||||
uint8_t MASKAddr[4]; // subnet mask
|
||||
uint8_t MacAddr[8]; // MAC address
|
||||
uint8_t UnreachIPAddr[4]; // Unreachable IP address
|
||||
uint32_t RetranCount; // number of retries,default is 10 times
|
||||
uint32_t RetranPeriod; // Retry period, unit MS, default 500MS
|
||||
uint32_t PHYStat; // PHY state code
|
||||
uint32_t NetStat; // The status of the Ethernet, including whether it is open, etc.
|
||||
uint32_t MackFilt; // MAC filtering, the default is to receive broadcasts, receive local MAC
|
||||
uint32_t GlobIntStatus; // global interrupt
|
||||
uint32_t UnreachCode; // unreachable code
|
||||
uint32_t UnreachProto; // unreachable protocol
|
||||
uint32_t UnreachPort; // unreachable port
|
||||
uint32_t SendFlag;
|
||||
uint32_t Flags;
|
||||
};
|
||||
|
||||
/* KEEP LIVE configuration structure */
|
||||
struct _KEEP_CFG {
|
||||
uint32_t KLIdle; // KEEPLIVE idle time, in ms
|
||||
uint32_t KLIntvl; // KEEPLIVE period, in ms
|
||||
uint32_t KLCount; // KEEPLIVE times
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Library initialization .
|
||||
*
|
||||
* @param ip - IP address pointer
|
||||
* @param gwip - Gateway address pointer
|
||||
* @param mask - Subnet mask pointer
|
||||
* @param macaddr - MAC address pointer
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_Init(const uint8_t* ip, const uint8_t* gwip, const uint8_t* mask, const uint8_t* macaddr);
|
||||
|
||||
/**
|
||||
* @brief get library version
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return library version
|
||||
*/
|
||||
uint8_t WCHNET_GetVer(void);
|
||||
|
||||
/**
|
||||
* @brief Get MAC address.
|
||||
*
|
||||
* @param(in) macaddr - MAC address
|
||||
*
|
||||
* @param(out) MAC address
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_GetMacAddr(uint8_t* macaddr);
|
||||
|
||||
/**
|
||||
* @brief Library parameter configuration.
|
||||
*
|
||||
* @param cfg - Configuration parameter @_WCH_CFG
|
||||
*
|
||||
* @return Library configuration initialization state @CFG_INIT_STAT
|
||||
*/
|
||||
uint8_t WCHNET_ConfigLIB(struct _WCH_CFG* cfg);
|
||||
|
||||
/**
|
||||
* @brief Handle periodic tasks in the protocol stack
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_PeriodicHandle(void);
|
||||
|
||||
/**
|
||||
* @brief Ethernet data input. Always called in the main program,
|
||||
* or called after the reception interrupt is detected.
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_NetInput(void);
|
||||
|
||||
/**
|
||||
* @brief Ethernet interrupt service function. Called after
|
||||
* Ethernet interrupt is generated.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_ETHIsr(void);
|
||||
|
||||
/**
|
||||
* @brief Get PHY status
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return PHY status @PHY_STAT
|
||||
*/
|
||||
uint8_t WCHNET_GetPHYStatus(void);
|
||||
|
||||
/**
|
||||
* @brief Query global interrupt status.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return GLOB_INT
|
||||
*/
|
||||
uint8_t WCHNET_QueryGlobalInt(void);
|
||||
|
||||
/**
|
||||
* @brief Read global interrupt and clear it.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return GLOB_INT
|
||||
*/
|
||||
uint8_t WCHNET_GetGlobalInt(void);
|
||||
|
||||
/**
|
||||
* @brief create socket
|
||||
*
|
||||
* @param(in) *socketid - socket variable pointer
|
||||
* @param socinf - Configuration parameters for creating sockets @SOCK_INF
|
||||
*
|
||||
* @param(out) *socketid - socket value
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketCreat(uint8_t* socketid, SOCK_INF* socinf);
|
||||
|
||||
/**
|
||||
* @brief Socket sends data.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param *buf - the first address of send buffer
|
||||
* @param(in) *len - pointer to the length of the data expected to be sent
|
||||
*
|
||||
* @param(out) *len - pointer to the length of the data sent actually
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketSend(uint8_t socketid, uint8_t* buf, uint32_t* len);
|
||||
|
||||
/**
|
||||
* @brief Socket receives data.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param *buf - the first address of receive buffer
|
||||
* @param(in) *len - pointer to the length of the data expected to be read
|
||||
*
|
||||
* @param(out) *buf - the first address of data buffer
|
||||
* @param(out) *len - pointer to the length of the data read actually
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketRecv(uint8_t socketid, uint8_t* buf, uint32_t* len);
|
||||
|
||||
/**
|
||||
* @brief Get socket interrupt, and clear socket interrupt.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
*
|
||||
* @return Sn_INT
|
||||
*/
|
||||
uint8_t WCHNET_GetSocketInt(uint8_t socketid);
|
||||
|
||||
/**
|
||||
* @brief Get the length of the data received by socket.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param(in) *bufaddr - the first address of receive buffer
|
||||
*
|
||||
* @param(out) *bufaddr - the first address of data buffer
|
||||
*
|
||||
* @return the length of the data
|
||||
*/
|
||||
uint32_t WCHNET_SocketRecvLen(uint8_t socketid, uint32_t* bufaddr);
|
||||
|
||||
/**
|
||||
* @brief TCP connect. Used in TCP Client mode.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketConnect(uint8_t socketid);
|
||||
|
||||
/**
|
||||
* @brief TCP listen. Used in TCP SERVER mode.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketListen(uint8_t socketid);
|
||||
|
||||
/**
|
||||
* @brief Close socket.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param mode - the way of disconnection.Used in TCP connection.
|
||||
* @TCP disconnect related codes
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketClose(uint8_t socketid, uint8_t mode);
|
||||
|
||||
/**
|
||||
* @brief Modify socket receive buffer.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param bufaddr - Address of the receive buffer
|
||||
* @param bufsize - Size of the receive buffer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_ModifyRecvBuf(uint8_t socketid, uint32_t bufaddr, uint32_t bufsize);
|
||||
|
||||
/**
|
||||
* @brief UDP send, specify the target IP and target port
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param *buf - Address of the sent data
|
||||
* @param(in) *slen - Address of the sent length
|
||||
* @param *sip - destination IP address
|
||||
* @param port - destination port
|
||||
*
|
||||
* @param(out) *slen - actual length sent
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketUdpSendTo(uint8_t socketid, uint8_t* buf, uint32_t* slen, uint8_t* sip, uint16_t port);
|
||||
|
||||
/**
|
||||
* @brief Convert ASCII address to network address.
|
||||
*
|
||||
* @param *cp - ASCII address to be converted, such as "192.168.1.2"
|
||||
* @param(in) *addr - First address of the memory stored in the converted network address
|
||||
* @param(out) *addr - Converted network address, such as 0xC0A80102
|
||||
* @return 0 - Success. Others - Failure.
|
||||
*/
|
||||
uint8_t WCHNET_Aton(const char* cp, uint8_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Convert network address to ASCII address.
|
||||
*
|
||||
* @param *ipaddr - socket id value
|
||||
*
|
||||
* @return Converted ASCII address
|
||||
*/
|
||||
uint8_t* WCHNET_Ntoa(uint8_t* ipaddr);
|
||||
|
||||
/**
|
||||
* @brief Set socket TTL.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param ttl - TTL value
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SetSocketTTL(uint8_t socketid, uint8_t ttl);
|
||||
|
||||
/**
|
||||
* @brief Start TCP retry sending immediately.
|
||||
*
|
||||
* @param socketid - TTL value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_RetrySendUnack(uint8_t socketid);
|
||||
|
||||
/**
|
||||
* @brief Query the packets that are not sent successfully.
|
||||
*
|
||||
* @param socketid - TTL value
|
||||
* @param(in) *addrlist - pointer to the address of the address list
|
||||
* @param lislen - Length of the list
|
||||
*
|
||||
* @param(out) *addrlist - Address list of the data packets that are not sent successfully
|
||||
*
|
||||
* @return Number of unsent and unacknowledged segments
|
||||
*/
|
||||
uint8_t WCHNET_QueryUnack(uint8_t socketid, uint32_t* addrlist, uint16_t lislen);
|
||||
|
||||
/**
|
||||
* @brief Start DHCP.
|
||||
*
|
||||
* @param dhcp - Application layer callback function
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_DHCPStart(dhcp_callback dhcp);
|
||||
|
||||
/**
|
||||
* @brief Stop DHCP.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_DHCPStop(void);
|
||||
|
||||
/**
|
||||
* @brief Configure DHCP host name.
|
||||
*
|
||||
* @param *name - First address of DHCP host name
|
||||
*
|
||||
* @return 0 - Success. Others - Failure.
|
||||
*/
|
||||
uint8_t WCHNET_DHCPSetHostname(char* name);
|
||||
|
||||
/**
|
||||
* @brief Initialize the resolver: set up the UDP pcb and configure the default server
|
||||
*
|
||||
* @param *dnsip - the IP address of dns server
|
||||
* @param port - the port number of dns server
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_InitDNS(uint8_t* dnsip, uint16_t port);
|
||||
|
||||
/**
|
||||
* @brief Stop DNS.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_DNSStop(void);
|
||||
|
||||
/**
|
||||
* Resolve a hostname (string) into an IP address.
|
||||
*
|
||||
* @param hostname - the hostname that is to be queried
|
||||
* @param addr - pointer to a struct ip_addr where to store the address if it is already
|
||||
* cached in the dns_table (only valid if ERR_OK is returned!)
|
||||
* @param found - a callback function to be called on success, failure or timeout (only if
|
||||
* ERR_INPROGRESS is returned!)
|
||||
* @param arg - argument to pass to the callback function
|
||||
*
|
||||
* @return @ERR_T
|
||||
* WCHNET_ERR_SUCCESS if hostname is a valid IP address string or the host name is already in the local names table.
|
||||
* ERR_INPROGRESS enqueue a request to be sent to the DNS server for resolution if no errors are present.
|
||||
*/
|
||||
uint8_t WCHNET_HostNameGetIp(const char* hostname, uint8_t* addr, dns_callback found, void* arg);
|
||||
|
||||
/**
|
||||
* @brief Configure KEEP LIVE parameter.
|
||||
*
|
||||
* @param *cfg - KEEPLIVE configuration parameter
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_ConfigKeepLive(struct _KEEP_CFG* cfg);
|
||||
|
||||
/**
|
||||
* @brief Configure socket KEEP LIVE enable.
|
||||
*
|
||||
* @param socketid - socket id value
|
||||
* @param enable - 1: Enabled. 0: Disabled.
|
||||
*
|
||||
* @return @ERR_T
|
||||
*/
|
||||
uint8_t WCHNET_SocketSetKeepLive(uint8_t socketid, uint8_t enable);
|
||||
|
||||
/**
|
||||
* @brief Configure PHY state
|
||||
*
|
||||
* @param phy_stat - PHY state
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void WCHNET_PhyStatus(uint32_t phy_stat);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,35 +1,35 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 connect_usart.c
|
||||
* @brief support ch32v307 vct6 uart function and register to bus framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-08-01
|
||||
*/
|
||||
* @file connect_usart.c
|
||||
* @brief support ch32v307 vct6 uart function and register to bus framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-08-01
|
||||
*/
|
||||
|
||||
#include <xizi.h>
|
||||
#include "ch32v30x.h"
|
||||
#include "xsconfig.h"
|
||||
#include "connect_uart.h"
|
||||
#include "ch32v30x.h"
|
||||
#include "ch32v30x_usart.h"
|
||||
#include "xsconfig.h"
|
||||
#include <xizi.h>
|
||||
|
||||
/* uart driver */
|
||||
|
||||
static void SerialCfgParamCheck(struct SerialCfgParam* serial_cfg_default, struct SerialCfgParam* serial_cfg_new)
|
||||
{
|
||||
struct SerialDataCfg *data_cfg_default = &serial_cfg_default->data_cfg;
|
||||
struct SerialDataCfg *data_cfg_new = &serial_cfg_new->data_cfg;
|
||||
struct SerialDataCfg* data_cfg_default = &serial_cfg_default->data_cfg;
|
||||
struct SerialDataCfg* data_cfg_new = &serial_cfg_new->data_cfg;
|
||||
|
||||
if ((data_cfg_default->serial_baud_rate != data_cfg_new->serial_baud_rate) && (data_cfg_new->serial_baud_rate)) {
|
||||
data_cfg_default->serial_baud_rate = data_cfg_new->serial_baud_rate;
|
||||
@@ -64,36 +64,39 @@ static void SerialCfgParamCheck(struct SerialCfgParam* serial_cfg_default, struc
|
||||
}
|
||||
}
|
||||
|
||||
static void UartIsr(struct SerialDriver *serial_drv, struct SerialHardwareDevice *serial_dev)
|
||||
static void UartIsr(struct SerialDriver* serial_drv, struct SerialHardwareDevice* serial_dev)
|
||||
{
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
if (RESET != USART_GetITStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE))
|
||||
{
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_drv->private_data;
|
||||
|
||||
if (RESET != USART_GetITStatus((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE)) {
|
||||
SerialSetIsr(serial_dev, SERIAL_EVENT_RX_IND);
|
||||
USART_ClearITPendingBit((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE);
|
||||
USART_ClearITPendingBit((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInfo *configure_info)
|
||||
static uint32 SerialInit(struct SerialDriver* serial_drv, struct BusConfigureInfo* configure_info)
|
||||
{
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_drv->private_data;
|
||||
// struct UsartHwCfg *serial_hw_cfg = (struct UsartHwCfg *)serial_cfg->hw_cfg.private_data;
|
||||
|
||||
struct SerialHardwareDevice* serial_dev = (struct SerialHardwareDevice*)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam* dev_param = (struct SerialDevParam*)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
struct SerialCfgParam* serial_cfg_new = (struct SerialCfgParam*)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
// init usart type def
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
|
||||
|
||||
@@ -105,8 +108,7 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
USART_InitStructure.USART_BaudRate = serial_cfg->data_cfg.serial_baud_rate;
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_data_bits)
|
||||
{
|
||||
switch (serial_cfg->data_cfg.serial_data_bits) {
|
||||
case DATA_BITS_8:
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
break;
|
||||
@@ -118,9 +120,8 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_stop_bits)
|
||||
{
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_stop_bits) {
|
||||
case STOP_BITS_1:
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
break;
|
||||
@@ -131,9 +132,8 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_parity_mode)
|
||||
{
|
||||
|
||||
switch (serial_cfg->data_cfg.serial_parity_mode) {
|
||||
case PARITY_NONE:
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
break;
|
||||
@@ -156,81 +156,77 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
// usart_hardware_flow_rts_config(serial_cfg->hw_cfg.serial_register_base, USART_RTS_DISABLE);
|
||||
// usart_hardware_flow_cts_config(serial_cfg->hw_cfg.serial_register_base, USART_CTS_DISABLE);
|
||||
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
static uint32 SerialConfigure(struct SerialDriver *serial_drv, int serial_operation_cmd)
|
||||
static uint32 SerialConfigure(struct SerialDriver* serial_drv, int serial_operation_cmd)
|
||||
{
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_drv->private_data;
|
||||
|
||||
switch (serial_operation_cmd)
|
||||
{
|
||||
switch (serial_operation_cmd) {
|
||||
case OPER_CLR_INT:
|
||||
NVIC_DisableIRQ(serial_cfg->hw_cfg.serial_irq_interrupt);
|
||||
USART_ITConfig((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE, DISABLE);
|
||||
USART_ITConfig((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE, DISABLE);
|
||||
break;
|
||||
case OPER_SET_INT:
|
||||
NVIC_EnableIRQ(serial_cfg->hw_cfg.serial_irq_interrupt);
|
||||
/* enable USART0 receive interrupt */
|
||||
USART_ITConfig((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_IT_RXNE, ENABLE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
static uint32 SerialDrvConfigure(void *drv, struct BusConfigureInfo *configure_info)
|
||||
static uint32 SerialDrvConfigure(void* drv, struct BusConfigureInfo* configure_info)
|
||||
{
|
||||
NULL_PARAM_CHECK(drv);
|
||||
NULL_PARAM_CHECK(configure_info);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
int serial_operation_cmd;
|
||||
struct SerialDriver *serial_drv = (struct SerialDriver *)drv;
|
||||
struct SerialDriver* serial_drv = (struct SerialDriver*)drv;
|
||||
|
||||
switch (configure_info->configure_cmd)
|
||||
{
|
||||
case OPE_INT:
|
||||
ret = SerialInit(serial_drv, configure_info);
|
||||
break;
|
||||
case OPE_CFG:
|
||||
serial_operation_cmd = *(int *)configure_info->private_data;
|
||||
ret = SerialConfigure(serial_drv, serial_operation_cmd);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (configure_info->configure_cmd) {
|
||||
case OPE_INT:
|
||||
ret = SerialInit(serial_drv, configure_info);
|
||||
break;
|
||||
case OPE_CFG:
|
||||
serial_operation_cmd = *(int*)configure_info->private_data;
|
||||
ret = SerialConfigure(serial_drv, serial_operation_cmd);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int SerialPutChar(struct SerialHardwareDevice *serial_dev, char c)
|
||||
static int SerialPutChar(struct SerialHardwareDevice* serial_dev, char c)
|
||||
{
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_dev->private_data;
|
||||
|
||||
while (USART_GetFlagStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_TXE) == RESET);
|
||||
USART_SendData((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, (uint8_t) c);
|
||||
while (USART_GetFlagStatus((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_TXE) == RESET)
|
||||
;
|
||||
USART_SendData((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, (uint8_t)c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SerialGetChar(struct SerialHardwareDevice *serial_dev)
|
||||
static int SerialGetChar(struct SerialHardwareDevice* serial_dev)
|
||||
{
|
||||
int ch = -1;
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_dev->private_data;
|
||||
struct SerialCfgParam* serial_cfg = (struct SerialCfgParam*)serial_dev->private_data;
|
||||
|
||||
if (RESET != USART_GetFlagStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_RXNE))
|
||||
{
|
||||
if (RESET != USART_GetFlagStatus((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_RXNE)) {
|
||||
ch = USART_ReceiveData((USART_TypeDef*)serial_cfg->hw_cfg.serial_register_base) & 0xff;
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static const struct SerialDataCfg data_cfg_init =
|
||||
{
|
||||
static const struct SerialDataCfg data_cfg_init = {
|
||||
.serial_baud_rate = BAUD_RATE_115200,
|
||||
.serial_data_bits = DATA_BITS_8,
|
||||
.serial_stop_bits = STOP_BITS_1,
|
||||
@@ -242,20 +238,18 @@ static const struct SerialDataCfg data_cfg_init =
|
||||
};
|
||||
|
||||
/*manage the serial device operations*/
|
||||
static const struct SerialDrvDone drv_done =
|
||||
{
|
||||
static const struct SerialDrvDone drv_done = {
|
||||
.init = SerialInit,
|
||||
.configure = SerialConfigure,
|
||||
};
|
||||
|
||||
/*manage the serial device hal operations*/
|
||||
static struct SerialHwDevDone hwdev_done =
|
||||
{
|
||||
static struct SerialHwDevDone hwdev_done = {
|
||||
.put_char = SerialPutChar,
|
||||
.get_char = SerialGetChar,
|
||||
};
|
||||
|
||||
static int BoardSerialBusInit(struct SerialBus *serial_bus, struct SerialDriver *serial_driver, const char *bus_name, const char *drv_name)
|
||||
static int BoardSerialBusInit(struct SerialBus* serial_bus, struct SerialDriver* serial_driver, const char* bus_name, const char* drv_name)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
|
||||
@@ -278,13 +272,13 @@ static int BoardSerialBusInit(struct SerialBus *serial_bus, struct SerialDriver
|
||||
if (EOK != ret) {
|
||||
KPrintf("InitHwUart SerialDriverAttachToBus error %d\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*Attach the serial device to the serial bus*/
|
||||
static int BoardSerialDevBend(struct SerialHardwareDevice *serial_device, void *serial_param, const char *bus_name, const char *dev_name)
|
||||
static int BoardSerialDevBend(struct SerialHardwareDevice* serial_device, void* serial_param, const char* bus_name, const char* dev_name)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
|
||||
@@ -292,27 +286,27 @@ static int BoardSerialDevBend(struct SerialHardwareDevice *serial_device, void *
|
||||
if (EOK != ret) {
|
||||
KPrintf("InitHwUart SerialDeviceInit device %s error %d\n", dev_name, ret);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
ret = SerialDeviceAttachToBus(dev_name, bus_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("InitHwUart SerialDeviceAttachToBus device %s error %d\n", dev_name, ret);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_UART1
|
||||
struct SerialDriver serial_driver_1;
|
||||
struct SerialHardwareDevice serial_device_1;
|
||||
|
||||
void USART1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void USART1_IRQHandler(void) __attribute__((interrupt()));
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
GET_INT_SP();
|
||||
x_base level;
|
||||
level= DisableLocalInterrupt();
|
||||
level = DisableLocalInterrupt();
|
||||
isrManager.done->incCounter();
|
||||
EnableLocalInterrupt(level);
|
||||
UartIsr(&serial_driver_1, &serial_device_1);
|
||||
@@ -329,7 +323,7 @@ int InitHwUart(void)
|
||||
|
||||
static struct SerialBus serial_bus;
|
||||
memset(&serial_bus, 0, sizeof(struct SerialBus));
|
||||
|
||||
|
||||
memset(&serial_driver_1, 0, sizeof(struct SerialDriver));
|
||||
|
||||
memset(&serial_device_1, 0, sizeof(struct SerialHardwareDevice));
|
||||
@@ -339,7 +333,7 @@ int InitHwUart(void)
|
||||
|
||||
static struct SerialDevParam serial_dev_param;
|
||||
memset(&serial_dev_param, 0, sizeof(struct SerialDevParam));
|
||||
|
||||
|
||||
serial_driver_1.drv_done = &drv_done;
|
||||
serial_driver_1.configure = &SerialDrvConfigure;
|
||||
serial_device_1.hwdev_done = &hwdev_done;
|
||||
@@ -350,11 +344,11 @@ int InitHwUart(void)
|
||||
serial_cfg.hw_cfg.serial_register_base = (uint32)USART1;
|
||||
serial_cfg.hw_cfg.serial_irq_interrupt = USART1_IRQn;
|
||||
#endif
|
||||
|
||||
|
||||
serial_driver_1.private_data = (void*)&serial_cfg;
|
||||
|
||||
serial_dev_param.serial_work_mode = SIGN_OPER_INT_RX;
|
||||
serial_device_1.haldev.private_data = (void *)&serial_dev_param;
|
||||
serial_device_1.haldev.private_data = (void*)&serial_dev_param;
|
||||
|
||||
ret = BoardSerialBusInit(&serial_bus, &serial_driver_1, SERIAL_BUS_NAME_1, SERIAL_DRV_NAME_1);
|
||||
if (EOK != ret) {
|
||||
@@ -362,7 +356,7 @@ int InitHwUart(void)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
ret = BoardSerialDevBend(&serial_device_1, (void *)&serial_cfg, SERIAL_BUS_NAME_1, SERIAL_1_DEVICE_NAME_0);
|
||||
ret = BoardSerialDevBend(&serial_device_1, (void*)&serial_cfg, SERIAL_BUS_NAME_1, SERIAL_1_DEVICE_NAME_0);
|
||||
if (EOK != ret) {
|
||||
KPrintf("InitHwUart uarths error ret %u\n", ret);
|
||||
return ERROR;
|
||||
@@ -380,14 +374,14 @@ int InitHwUart(void)
|
||||
GPIO_Init(GPIOA, &gpio_init_struct);
|
||||
|
||||
USART_InitTypeDef usart_init_struct;
|
||||
usart_init_struct.USART_BaudRate = 115200;
|
||||
usart_init_struct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
usart_init_struct.USART_Mode = USART_Mode_Tx|USART_Mode_Rx;
|
||||
usart_init_struct.USART_WordLength = USART_WordLength_8b;
|
||||
usart_init_struct.USART_StopBits = USART_StopBits_1;
|
||||
usart_init_struct.USART_Parity = USART_Parity_No;
|
||||
USART_Init((USART_TypeDef *)serial_cfg.hw_cfg.serial_register_base, &usart_init_struct);
|
||||
usart_init_struct.USART_BaudRate = 115200;
|
||||
usart_init_struct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
usart_init_struct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||
usart_init_struct.USART_WordLength = USART_WordLength_8b;
|
||||
usart_init_struct.USART_StopBits = USART_StopBits_1;
|
||||
usart_init_struct.USART_Parity = USART_Parity_No;
|
||||
USART_Init((USART_TypeDef*)serial_cfg.hw_cfg.serial_register_base, &usart_init_struct);
|
||||
USART_Cmd((USART_TypeDef*)serial_cfg.hw_cfg.serial_register_base, ENABLE);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -120,6 +120,10 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
if (serial_cfg->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg->data_cfg.dev_recv_callback);
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
|
||||
@@ -121,6 +121,10 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
if (serial_cfg->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg->data_cfg.dev_recv_callback);
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export CROSS_COMPILE ?=/usr/bin/arm-none-eabi-
|
||||
|
||||
export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror
|
||||
export AFLAGS := -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb -gdwarf-2
|
||||
export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror
|
||||
export AFLAGS := -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb
|
||||
export LFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-cortex-m4-emulator.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds
|
||||
export CXXFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -Werror
|
||||
export CXXFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -Werror
|
||||
|
||||
ifeq ($(CONFIG_LIB_MUSLLIB), y)
|
||||
export LFLAGS += -nostdlib -nostdinc -fno-builtin -nodefaultlibs
|
||||
|
||||
@@ -63,6 +63,7 @@ SECTIONS
|
||||
PROVIDE(g_service_table_end = ABSOLUTE(.));
|
||||
|
||||
PROVIDE(_etext = ABSOLUTE(.));
|
||||
_exit = .;
|
||||
} > flash
|
||||
|
||||
/* .ARM.exidx is sorted, so has to go in its own output section. */
|
||||
|
||||
@@ -269,13 +269,17 @@ static uint32 Stm32SerialInit(struct SerialDriver *serial_drv, struct BusConfigu
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
struct UsartHwCfg *serial_hw_cfg = (struct UsartHwCfg *)serial_cfg->hw_cfg.private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
294
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/.defconfig
Normal file
294
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/.defconfig
Normal file
@@ -0,0 +1,294 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# XiZi_IIoT Project Configuration
|
||||
#
|
||||
CONFIG_BOARD_CORTEX_M7_EVB=y
|
||||
CONFIG_ARCH_ARM=y
|
||||
|
||||
#
|
||||
# xidatong-arm32 feature
|
||||
#
|
||||
CONFIG_BSP_USING_LPUART=y
|
||||
CONFIG_BSP_USING_LPUART1=y
|
||||
CONFIG_SERIAL_BUS_NAME_1="uart1"
|
||||
CONFIG_SERIAL_DRV_NAME_1="uart1_drv"
|
||||
CONFIG_SERIAL_1_DEVICE_NAME_0="uart1_dev1"
|
||||
CONFIG_BSP_USING_LPUART2=y
|
||||
CONFIG_SERIAL_BUS_NAME_2="uart2"
|
||||
CONFIG_SERIAL_DRV_NAME_2="uart2_drv"
|
||||
CONFIG_SERIAL_2_DEVICE_NAME_0="uart2_dev2"
|
||||
CONFIG_BSP_USING_LPUART3=y
|
||||
CONFIG_SERIAL_BUS_NAME_3="uart3"
|
||||
CONFIG_SERIAL_DRV_NAME_3="uart3_drv"
|
||||
CONFIG_SERIAL_3_DEVICE_NAME_0="uart3_dev3"
|
||||
# CONFIG_BSP_USING_LPUART4 is not set
|
||||
# CONFIG_BSP_USING_LPUART8 is not set
|
||||
# CONFIG_BSP_USING_CH438 is not set
|
||||
CONFIG_BSP_USING_GPIO=y
|
||||
CONFIG_PIN_BUS_NAME="pin"
|
||||
CONFIG_PIN_DRIVER_NAME="pin_drv"
|
||||
CONFIG_PIN_DEVICE_NAME="pin_dev"
|
||||
# CONFIG_BSP_USING_I2C is not set
|
||||
# CONFIG_BSP_USING_LWIP is not set
|
||||
# CONFIG_BSP_USING_SEMC is not set
|
||||
# CONFIG_BSP_USING_SDIO is not set
|
||||
# CONFIG_BSP_USING_LCD is not set
|
||||
# CONFIG_BSP_USING_TOUCH is not set
|
||||
# CONFIG_BSP_USING_USB is not set
|
||||
# CONFIG_BSP_USING_WDT is not set
|
||||
|
||||
#
|
||||
# config default board resources
|
||||
#
|
||||
|
||||
#
|
||||
# config board app name
|
||||
#
|
||||
CONFIG_BOARD_APP_NAME="/XiUOS_xidatong_app.bin"
|
||||
|
||||
#
|
||||
# config board service table
|
||||
#
|
||||
CONFIG_SERVICE_TABLE_ADDRESS=0x2007F0000
|
||||
CONFIG___STACKSIZE__=4096
|
||||
|
||||
#
|
||||
# config board peripheral
|
||||
#
|
||||
# CONFIG_MOUNT_SDCARD is not set
|
||||
# CONFIG_MOUNT_USB is not set
|
||||
|
||||
#
|
||||
# Hardware feature
|
||||
#
|
||||
CONFIG_RESOURCES_SERIAL=y
|
||||
CONFIG_SERIAL_USING_DMA=y
|
||||
CONFIG_SERIAL_RB_BUFSZ=128
|
||||
CONFIG_RESOURCES_PIN=y
|
||||
|
||||
#
|
||||
# Kernel feature
|
||||
#
|
||||
|
||||
#
|
||||
# separate compile(choose none for compile once)
|
||||
#
|
||||
# CONFIG_SEPARATE_COMPILE is not set
|
||||
# CONFIG_COMPILER_APP is not set
|
||||
# CONFIG_APP_STARTUP_FROM_SDCARD is not set
|
||||
CONFIG_APP_STARTUP_FROM_FLASH=y
|
||||
# CONFIG_COMPILER_KERNEL is not set
|
||||
|
||||
#
|
||||
# Memory Management
|
||||
#
|
||||
# CONFIG_KERNEL_MEMBLOCK is not set
|
||||
CONFIG_MEM_ALIGN_SIZE=8
|
||||
# CONFIG_MEM_EXTERN_SRAM is not set
|
||||
CONFIG_MM_PAGE_SIZE=4096
|
||||
|
||||
#
|
||||
# Using small memory allocator
|
||||
#
|
||||
CONFIG_KERNEL_SMALL_MEM_ALLOC=y
|
||||
CONFIG_SMALL_NUMBER_32B=64
|
||||
CONFIG_SMALL_NUMBER_64B=32
|
||||
|
||||
#
|
||||
# Task feature
|
||||
#
|
||||
CONFIG_USER_APPLICATION=y
|
||||
# CONFIG_TASK_ISOLATION is not set
|
||||
|
||||
#
|
||||
# Inter-Task communication
|
||||
#
|
||||
CONFIG_KERNEL_SEMAPHORE=y
|
||||
CONFIG_KERNEL_MUTEX=y
|
||||
CONFIG_KERNEL_EVENT=y
|
||||
CONFIG_KERNEL_MESSAGEQUEUE=y
|
||||
# CONFIG_KERNEL_SOFTTIMER is not set
|
||||
CONFIG_SCHED_POLICY_RR_REMAINSLICE=y
|
||||
# CONFIG_SCHED_POLICY_RR is not set
|
||||
# CONFIG_SCHED_POLICY_FIFO is not set
|
||||
# CONFIG_KTASK_PRIORITY_8 is not set
|
||||
CONFIG_KTASK_PRIORITY_32=y
|
||||
# CONFIG_KTASK_PRIORITY_256 is not set
|
||||
CONFIG_KTASK_PRIORITY_MAX=32
|
||||
CONFIG_TICK_PER_SECOND=1000
|
||||
CONFIG_KERNEL_STACK_OVERFLOW_CHECK=y
|
||||
CONFIG_IDLE_KTASK_STACKSIZE=1024
|
||||
CONFIG_ZOMBIE_KTASK_STACKSIZE=2048
|
||||
|
||||
#
|
||||
# Kernel Console
|
||||
#
|
||||
CONFIG_KERNEL_CONSOLE=y
|
||||
CONFIG_KERNEL_BANNER=y
|
||||
CONFIG_KERNEL_CONSOLEBUF_SIZE=128
|
||||
|
||||
#
|
||||
# Kernel Hook
|
||||
#
|
||||
# CONFIG_KERNEL_HOOK is not set
|
||||
|
||||
#
|
||||
# Command shell
|
||||
#
|
||||
CONFIG_TOOL_SHELL=y
|
||||
CONFIG_SHELL_ENTER_CR=y
|
||||
CONFIG_SHELL_ENTER_LF=y
|
||||
CONFIG_SHELL_ENTER_CR_AND_LF=y
|
||||
# CONFIG_SHELL_ENTER_CRLF is not set
|
||||
|
||||
#
|
||||
# Set shell user control
|
||||
#
|
||||
CONFIG_SHELL_DEFAULT_USER="letter"
|
||||
CONFIG_SHELL_DEFAULT_USER_PASSWORD=""
|
||||
CONFIG_SHELL_LOCK_TIMEOUT=10000
|
||||
|
||||
#
|
||||
# Set shell config param
|
||||
#
|
||||
CONFIG_SHELL_TASK_STACK_SIZE=4096
|
||||
CONFIG_SHELL_TASK_PRIORITY=20
|
||||
CONFIG_SHELL_MAX_NUMBER=5
|
||||
CONFIG_SHELL_PARAMETER_MAX_NUMBER=8
|
||||
CONFIG_SHELL_HISTORY_MAX_NUMBER=5
|
||||
CONFIG_SHELL_PRINT_BUFFER=128
|
||||
CONFIG_SHELL_HELP_SHOW_PERMISSION=y
|
||||
# CONFIG_SHELL_HELP_LIST_USER is not set
|
||||
CONFIG_SHELL_HELP_LIST_VAR=y
|
||||
# CONFIG_SHELL_HELP_LIST_KEY is not set
|
||||
|
||||
#
|
||||
# Kernel data structure Manage
|
||||
#
|
||||
CONFIG_KERNEL_QUEUEMANAGE=y
|
||||
CONFIG_KERNEL_WORKQUEUE=y
|
||||
CONFIG_WORKQUEUE_KTASK_STACKSIZE=2048
|
||||
CONFIG_WORKQUEUE_KTASK_PRIORITY=23
|
||||
CONFIG_QUEUE_MAX=16
|
||||
CONFIG_KERNEL_WAITQUEUE=y
|
||||
CONFIG_KERNEL_DATAQUEUE=y
|
||||
# CONFIG_KERNEL_CIRCULAR_AREA is not set
|
||||
# CONFIG_KERNEL_AVL_TREE is not set
|
||||
|
||||
#
|
||||
# Kernel components init
|
||||
#
|
||||
CONFIG_KERNEL_COMPONENTS_INIT=y
|
||||
CONFIG_ENV_INIT_KTASK_STACK_SIZE=8192
|
||||
CONFIG_KERNEL_USER_MAIN=y
|
||||
CONFIG_NAME_NUM_MAX=32
|
||||
# CONFIG_KERNEL_DEBUG is not set
|
||||
# CONFIG_ARCH_SMP is not set
|
||||
|
||||
#
|
||||
# hash table config
|
||||
#
|
||||
CONFIG_ID_HTABLE_SIZE=16
|
||||
CONFIG_ID_NUM_MAX=128
|
||||
# CONFIG_KERNEL_TEST is not set
|
||||
|
||||
#
|
||||
# Lib
|
||||
#
|
||||
CONFIG_LIB=y
|
||||
CONFIG_LIB_POSIX=y
|
||||
CONFIG_LIB_NEWLIB=y
|
||||
# CONFIG_LIB_MUSLLIB is not set
|
||||
|
||||
#
|
||||
# C++ features
|
||||
#
|
||||
# CONFIG_LIB_CPLUSPLUS is not set
|
||||
|
||||
#
|
||||
# File system
|
||||
#
|
||||
# CONFIG_FS_VFS=y
|
||||
# CONFIG_VFS_USING_WORKDIR=y
|
||||
# CONFIG_FS_VFS_DEVFS=y
|
||||
# CONFIG_FS_VFS_FATFS=y
|
||||
# CONFIG_FS_CH376 is not set
|
||||
# CONFIG_FS_LWEXT4 is not set
|
||||
|
||||
#
|
||||
# APP_Framework
|
||||
#
|
||||
|
||||
#
|
||||
# Framework
|
||||
#
|
||||
CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y
|
||||
CONFIG_ADD_XIZI_FEATURES=y
|
||||
# CONFIG_ADD_NUTTX_FEATURES is not set
|
||||
# CONFIG_ADD_RTTHREAD_FEATURES is not set
|
||||
# CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set
|
||||
# CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set
|
||||
# CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set
|
||||
# CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set
|
||||
|
||||
#
|
||||
# Security
|
||||
#
|
||||
# CONFIG_CRYPTO is not set
|
||||
# CONFIG_MBEDTLS is not set
|
||||
|
||||
#
|
||||
# Applications
|
||||
#
|
||||
|
||||
#
|
||||
# config stack size and priority of main task
|
||||
#
|
||||
CONFIG_MAIN_KTASK_STACK_SIZE=4096
|
||||
CONFIG_MAIN_KTASK_PRIORITY=16
|
||||
|
||||
#
|
||||
# ota app
|
||||
#
|
||||
# CONFIG_APPLICATION_OTA is not set
|
||||
|
||||
#
|
||||
# test app
|
||||
#
|
||||
# CONFIG_USER_TEST is not set
|
||||
|
||||
#
|
||||
# connection app
|
||||
#
|
||||
# CONFIG_APPLICATION_CONNECTION is not set
|
||||
|
||||
#
|
||||
# control app
|
||||
#
|
||||
|
||||
#
|
||||
# knowing app
|
||||
#
|
||||
# CONFIG_APPLICATION_KNOWING is not set
|
||||
|
||||
#
|
||||
# sensor app
|
||||
#
|
||||
# CONFIG_APPLICATION_SENSOR is not set
|
||||
# CONFIG_USING_EMBEDDED_DATABASE_APP is not set
|
||||
# CONFIG_APP_USING_WEBNET is not set
|
||||
|
||||
#
|
||||
# lib
|
||||
#
|
||||
CONFIG_APP_SELECT_NEWLIB=y
|
||||
# CONFIG_APP_SELECT_OTHER_LIB is not set
|
||||
# CONFIG_LIB_USING_CJSON is not set
|
||||
# CONFIG_LIB_USING_QUEUE is not set
|
||||
# CONFIG_LIB_LV is not set
|
||||
|
||||
#
|
||||
# LVGL configuration
|
||||
#
|
||||
# CONFIG_LV_CONF_MINIMAL is not set
|
||||
# CONFIG_USING_EMBEDDED_DATABASE is not set
|
||||
61
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/Kconfig
Normal file
61
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/Kconfig
Normal file
@@ -0,0 +1,61 @@
|
||||
mainmenu "XiZi_IIoT Project Configuration"
|
||||
|
||||
config BSP_DIR
|
||||
string
|
||||
option env="BSP_ROOT"
|
||||
default "."
|
||||
|
||||
config KERNEL_DIR
|
||||
string
|
||||
option env="KERNEL_ROOT"
|
||||
default "../.."
|
||||
|
||||
config BOARD_CORTEX_V2M_EVB
|
||||
bool
|
||||
select ARCH_ARM
|
||||
default y
|
||||
|
||||
|
||||
source "$KERNEL_DIR/arch/Kconfig"
|
||||
|
||||
menu "cortex-m7-emulator 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_cortex-m7-emulator_app.bin"
|
||||
endmenu
|
||||
|
||||
menu "config board service table"
|
||||
config SERVICE_TABLE_ADDRESS
|
||||
hex "board service table address"
|
||||
default 0x20000000
|
||||
endmenu
|
||||
|
||||
|
||||
endmenu
|
||||
|
||||
config __STACKSIZE__
|
||||
int "stack size for interrupt"
|
||||
default 4096
|
||||
|
||||
menu "config board peripheral"
|
||||
config MOUNT_SDCARD
|
||||
bool
|
||||
default n
|
||||
config MOUNT_USB
|
||||
bool
|
||||
default n
|
||||
endmenu
|
||||
|
||||
|
||||
endmenu
|
||||
|
||||
|
||||
menu "Hardware feature"
|
||||
source "$KERNEL_DIR/resources/Kconfig"
|
||||
endmenu
|
||||
|
||||
source "$KERNEL_DIR/Kconfig"
|
||||
8
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/Makefile
Normal file
8
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
SRC_FILES := board.c
|
||||
|
||||
SRC_DIR := third_party_driver
|
||||
|
||||
|
||||
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
208
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/README.md
Normal file
208
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/README.md
Normal file
@@ -0,0 +1,208 @@
|
||||
# 从零开始构建矽璓工业物联操作系统:使用ARM架构的cortex-m7 emulator
|
||||
|
||||
[XiUOS](http://xuos.io/) (X Industrial Ubiquitous Operating System) 矽璓XiUOS是一款面向智慧车间的工业物联网操作系统,主要由一个极简的微型实时操作系统内核和其上的工业物联框架构成,通过高效管理工业物联网设备、支撑工业物联应用,在生产车间内实现智能化的“感知环境、联网传输、知悉识别、控制调整”,促进以工业设备和工业控制系统为核心的人、机、物深度互联,帮助提升生产线的数字化和智能化水平。
|
||||
|
||||
|
||||
|
||||
## 1. 简介
|
||||
|
||||
QEMU 是一个通用的开源模拟器和虚拟化工具。目前QEMU已经可以较完整的支持ARM cortex-m4架构。XiUOS同样支持运行在QEMU上
|
||||
|
||||
| 硬件 | 描述 |
|
||||
| -------- | ------------- |
|
||||
| 芯片型号 | mps2-an500 |
|
||||
| 架构 | cortex-m7 |
|
||||
| 主频 | 168MHz |
|
||||
| 片内SRAM | 100+KB |
|
||||
| 外设支持 | UART、GPIO |
|
||||
|
||||
|
||||
|
||||
## 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://www.gitlink.org.cn/xuos/xiuos](https://www.gitlink.org.cn/xuos/xiuos)
|
||||
|
||||
新建一个空文件夹并进入文件夹中,并下载源码,具体命令如下:
|
||||
|
||||
```c
|
||||
mkdir test && cd test
|
||||
git clone https://gitlink.org.cn/xuos/xiuos.git
|
||||
```
|
||||
|
||||
1、打开XiUOS源码文件包可以看到以下目录:
|
||||
| 名称 | 说明 |
|
||||
| -- | -- |
|
||||
| APP_Framework | 应用代码 |
|
||||
| Ubiquitous | 板级支持包,支持NuttX、RT-Thread和XiZi内核 |
|
||||
|
||||
2、打开XiZi内核源码文件包可以看到以下目录:
|
||||
| 名称 | 说明 |
|
||||
| -- | -- |
|
||||
| arch | 架构代码 |
|
||||
| board | 板级支持包 |
|
||||
| fs | 文件系统 |
|
||||
| kernel | 内核源码 |
|
||||
| lib | 第三方库源码 |
|
||||
| resources | 驱动文件 |
|
||||
| tool | 系统工具 |
|
||||
|
||||
使用VScode打开代码,具体操作步骤为:在源码文件夹下打开系统终端,输入`code .`即可打开VScode开发环境,如下图所示:
|
||||
|
||||
<div align= "center">
|
||||
<img src="img/vscode.jpg" width =1000>
|
||||
</div>
|
||||
|
||||
|
||||
### 裁减配置工具的下载
|
||||
|
||||
裁减配置工具:
|
||||
|
||||
**工具地址:** kconfig-frontends [https://www.gitlink.org.cn/xuos/kconfig-frontends](https://www.gitlink.org.cn/xuos/kconfig-frontends),下载与安装的具体命令如下:
|
||||
|
||||
```c
|
||||
mkdir kfrontends && cd kfrontends
|
||||
git clone https://gitlink.org.cn/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
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 3. 编译说明
|
||||
|
||||
### 编辑环境:`Ubuntu18.04`
|
||||
|
||||
### 编译工具链:`arm-none-eabi-gcc`
|
||||
|
||||
使用`VScode`打开工程的方法有多种,本文介绍一种快捷键,在项目目录下将`code .`输入linux系统命令终端即可打开目标项目
|
||||
|
||||
|
||||
编译步骤:
|
||||
|
||||
1.在VScode命令终端中执行以下命令,生成配置文件
|
||||
|
||||
```c
|
||||
cd ./Ubiquitous/XiZi
|
||||
make BOARD=cortex-m7-emulator distclean
|
||||
make BOARD=cortex-m7-emulator menuconfig
|
||||
```
|
||||
|
||||
2.在menuconfig界面配置需要关闭和开启的功能,按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后保存并退出(本例旨在演示简单的输出例程,所以没有需要配置的选项,双击快捷键ESC退出配置)
|
||||
|
||||
<div align= "center">
|
||||
<img src="img/menuconfig.png" width =1000>
|
||||
</div>
|
||||
|
||||
退出时选择`yes`保存上面所配置的内容,如下图所示:
|
||||
|
||||
<div align= "center">
|
||||
<img src="img/menuconfig1.png" width =1000>
|
||||
</div>
|
||||
|
||||
3.继续执行以下命令,进行编译
|
||||
|
||||
```
|
||||
make BOARD=cortex-m7-emulator
|
||||
```
|
||||
|
||||
4.如果编译正确无误,会产生XiZi-cortex-m7-emulator.elf、XiZi-cortex-m7-emulator.bin文件。
|
||||
|
||||
|
||||
|
||||
## 4. 运行
|
||||
|
||||
### 4.1 安装QEMU
|
||||
|
||||
```
|
||||
sudo apt install qemu-system-arm
|
||||
```
|
||||
|
||||
### 4.2 运行结果
|
||||
|
||||
通过以下命令启动QEMU并加载XiUOS ELF文件
|
||||
|
||||
```
|
||||
qemu-system-arm -machine mps2-an500 -nographic -kernel build/XiZi-cortex-m7-emulator.elf
|
||||
```
|
||||
|
||||
QEMU运行起来后将会在终端上看到信息打印输出
|
||||
|
||||
<div align= "center">
|
||||
<img src="img/terminal.png" width =1000>
|
||||
</div>
|
||||
|
||||
### 4.3 调试
|
||||
|
||||
通过QEMU可以方便的对XiUOS进行调试,首先安装gdb调试工具
|
||||
|
||||
```
|
||||
sudo apt install gdb-multiarch
|
||||
```
|
||||
|
||||
并通过以下命令启动QEMU
|
||||
|
||||
```
|
||||
qemu-system-arm -machine mps2-an500 -nographic -kernel build/XiZi-cortex-m7-emulator.elf -s -S
|
||||
```
|
||||
|
||||
然后要重新开启另一个linux系统终端一个终端,执行`riscv-none-embed-gdb`命令
|
||||
|
||||
```
|
||||
gdb-multiarch build/XiZi-cortex-m7-emulator.elf -ex "target remote localhost:1234"
|
||||
```
|
||||
202
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/board.c
Normal file
202
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/board.c
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* 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.c
|
||||
* @brief support cortex-m7-emulator-board init configure and start-up
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-09-27
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: board.c
|
||||
Description: support cortex-m7-emulator-board init configure and driver/task/... init
|
||||
Others:
|
||||
History:
|
||||
1. Date: 2023-09-27
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. support cortex-m7-emulator-board InitBoardHardware
|
||||
*************************************************/
|
||||
|
||||
|
||||
#include "board.h"
|
||||
#include "clock_config.h"
|
||||
#include <device.h>
|
||||
|
||||
|
||||
#ifdef BSP_USING_LPUART
|
||||
#include <connect_uart.h>
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_GPIO
|
||||
#include <connect_gpio.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
/* MPU configuration. */
|
||||
void BOARD_ConfigMPU(void)
|
||||
{
|
||||
|
||||
|
||||
/* Disable MPU */
|
||||
ARM_MPU_Disable();
|
||||
|
||||
/* MPU configure:
|
||||
* Use ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable,
|
||||
* SubRegionDisable, Size)
|
||||
* API in mpu_armv7.h.
|
||||
* param DisableExec Instruction access (XN) disable bit,0=instruction fetches enabled, 1=instruction fetches
|
||||
* disabled.
|
||||
* param AccessPermission Data access permissions, allows you to configure read/write access for User and
|
||||
* Privileged mode.
|
||||
* Use MACROS defined in mpu_armv7.h:
|
||||
* ARM_MPU_AP_NONE/ARM_MPU_AP_PRIV/ARM_MPU_AP_URO/ARM_MPU_AP_FULL/ARM_MPU_AP_PRO/ARM_MPU_AP_RO
|
||||
* Combine TypeExtField/IsShareable/IsCacheable/IsBufferable to configure MPU memory access attributes.
|
||||
* TypeExtField IsShareable IsCacheable IsBufferable Memory Attribtue Shareability Cache
|
||||
* 0 x 0 0 Strongly Ordered shareable
|
||||
* 0 x 0 1 Device shareable
|
||||
* 0 0 1 0 Normal not shareable Outer and inner write
|
||||
* through no write allocate
|
||||
* 0 0 1 1 Normal not shareable Outer and inner write
|
||||
* back no write allocate
|
||||
* 0 1 1 0 Normal shareable Outer and inner write
|
||||
* through no write allocate
|
||||
* 0 1 1 1 Normal shareable Outer and inner write
|
||||
* back no write allocate
|
||||
* 1 0 0 0 Normal not shareable outer and inner
|
||||
* noncache
|
||||
* 1 1 0 0 Normal shareable outer and inner
|
||||
* noncache
|
||||
* 1 0 1 1 Normal not shareable outer and inner write
|
||||
* back write/read acllocate
|
||||
* 1 1 1 1 Normal shareable outer and inner write
|
||||
* back write/read acllocate
|
||||
* 2 x 0 0 Device not shareable
|
||||
* Above are normal use settings, if your want to see more details or want to config different inner/outter cache
|
||||
* policy.
|
||||
* please refer to Table 4-55 /4-56 in arm cortex-M7 generic user guide <dui0646b_cortex_m7_dgug.pdf>
|
||||
* param SubRegionDisable Sub-region disable field. 0=sub-region is enabled, 1=sub-region is disabled.
|
||||
* param Size Region size of the region to be configured. use ARM_MPU_REGION_SIZE_xxx MACRO in
|
||||
* mpu_armv7.h.
|
||||
*/
|
||||
|
||||
// /* Region 0 setting: Memory with Device type, not shareable, non-cacheable. */
|
||||
// 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: Memory with Device type, not shareable, non-cacheable. */
|
||||
MPU->RBAR = ARM_MPU_RBAR(0, 0x20000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_256MB);
|
||||
|
||||
/* Region 2 setting */
|
||||
#if defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)
|
||||
/* Setting Memory with Normal type, not shareable, outer/inner write back. */
|
||||
MPU->RBAR = ARM_MPU_RBAR(2, 0x60000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_RO, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_64MB);
|
||||
#else
|
||||
/* Setting Memory with Device type, not shareable, non-cacheable. */
|
||||
MPU->RBAR = ARM_MPU_RBAR(1, 0x20000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_RO, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_64MB);
|
||||
#endif
|
||||
|
||||
/* Region 3 setting: Memory with Device type, not shareable, non-cacheable. */
|
||||
MPU->RBAR = ARM_MPU_RBAR(2, 0x00000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB);
|
||||
|
||||
/* Region 4 setting: Memory with Normal type, not shareable, outer/inner write back */
|
||||
MPU->RBAR = ARM_MPU_RBAR(3, 0x00000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);
|
||||
|
||||
/* Region 5 setting: Memory with Normal type, not shareable, outer/inner write back */
|
||||
MPU->RBAR = ARM_MPU_RBAR(4, 0x20000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);
|
||||
|
||||
/* Region 6 setting: Memory with Normal type, not shareable, outer/inner write back */
|
||||
MPU->RBAR = ARM_MPU_RBAR(5, 0x20200000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB);
|
||||
|
||||
/* The define sets the cacheable memory to shareable,
|
||||
* this suggestion is referred from chapter 2.2.1 Memory regions,
|
||||
* types and attributes in Cortex-M7 Devices, Generic User Guide */
|
||||
#if defined(SDRAM_IS_SHAREABLE)
|
||||
/* Region 7 setting: Memory with Normal type, shareable, outer/inner write back */
|
||||
MPU->RBAR = ARM_MPU_RBAR(7, 0x80000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 1, 1, 1, 0, ARM_MPU_REGION_SIZE_32MB);
|
||||
#else
|
||||
/* Region 7 setting: Memory with Normal type, not shareable, outer/inner write back */
|
||||
MPU->RBAR = ARM_MPU_RBAR(6, 0x21000000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_2MB);
|
||||
#endif
|
||||
|
||||
/* Region 8 setting, set last 2MB of SDRAM can't be accessed by cache, glocal variables which are not expected to be
|
||||
* accessed by cache can be put here */
|
||||
/* Memory with Normal type, not shareable, non-cacheable */
|
||||
MPU->RBAR = ARM_MPU_RBAR(7, 0x21200000U);
|
||||
MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 1, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_2MB);
|
||||
|
||||
/* 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void InitBoardHardware()
|
||||
{
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
|
||||
BOARD_ConfigMPU();
|
||||
// BOARD_InitPins();
|
||||
BOARD_BootClockRUN();
|
||||
|
||||
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
||||
SysTick_Config(SystemCoreClock / TICK_PER_SECOND);
|
||||
|
||||
InitBoardMemory((void *)HEAP_BEGIN, (void *)HEAP_END);
|
||||
|
||||
|
||||
#ifdef BSP_USING_LPUART
|
||||
Imxrt1052HwUartInit();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
InstallConsole(KERNEL_CONSOLE_BUS_NAME, KERNEL_CONSOLE_DRV_NAME, KERNEL_CONSOLE_DEVICE_NAME);
|
||||
KPrintf("0");
|
||||
KPrintf("\nconsole init completed.\n");
|
||||
KPrintf("board initialization......\n");
|
||||
|
||||
// for(i = 0; _board_init[i].fn != NONE; i++) {
|
||||
// ret = _board_init[i].fn();
|
||||
// KPrintf("initialize %s %s\n",_board_init[i].fn_name, ret == 0 ? "success" : "failed");
|
||||
// }
|
||||
KPrintf("board init done.\n");
|
||||
KPrintf("start kernel...\n");
|
||||
|
||||
|
||||
}
|
||||
64
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/board.h
Normal file
64
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/board.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file board.h
|
||||
* @brief definecortex-m7-emulator init configure and start-up function
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-05-28
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: board.h
|
||||
Description: define cortex-m7-emulator init function and struct
|
||||
Others:
|
||||
History:
|
||||
1. Date: 2023-09-27
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. define imxrt-board InitBoardHardware
|
||||
2. define imxrt-board heap struct
|
||||
*************************************************/
|
||||
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
|
||||
#define M7_EMULATOR
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <xizi.h>
|
||||
#include <arch_interrupt.h>
|
||||
#include "fsl_common.h"
|
||||
#include "xsconfig.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*/
|
||||
|
||||
|
||||
|
||||
|
||||
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 /* _BOARD_H_ */
|
||||
15
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/config.mk
Normal file
15
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/config.mk
Normal file
@@ -0,0 +1,15 @@
|
||||
export CROSS_COMPILE ?=/usr/bin/arm-none-eabi-
|
||||
|
||||
export CFLAGS := -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror
|
||||
export AFLAGS := -c -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb -gdwarf-2
|
||||
export LFLAGS := -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-cortex-m7-emulator.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds
|
||||
export CXXFLAGS := -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -Werror
|
||||
|
||||
|
||||
export APPLFLAGS := -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-app.map,-cref,-u, -T $(BSP_ROOT)/link_userspace.lds
|
||||
|
||||
|
||||
export DEFINES := -DHAVE_CCONFIG_H -DCPU_MIMXRT1052CVL5B
|
||||
|
||||
export ARCH = arm
|
||||
export MCU = cortex-m7
|
||||
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/main.png
Normal file
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/main.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/menuconfig.png
Normal file
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/menuconfig.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/terminal.png
Normal file
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/terminal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/vscode.jpg
Normal file
BIN
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/img/vscode.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
252
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/link.lds
Normal file
252
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/link.lds
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: MIMXRT1052CVJ5B
|
||||
** MIMXRT1052CVL5B
|
||||
** MIMXRT1052DVJ6B
|
||||
** MIMXRT1052DVL6B
|
||||
**
|
||||
** Compiler: GNU C Compiler
|
||||
** Reference manual: IMXRT1050RM Rev.1, 03/2018
|
||||
** Version: rev. 1.0, 2018-09-21
|
||||
** Build: b180921
|
||||
**
|
||||
** Abstract:
|
||||
** Linker file for the GNU C Compiler
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2018 NXP
|
||||
** All rights reserved.
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file link.lds
|
||||
* @brief cortex-m7 emulator Linker script
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-09-27
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: link.lds
|
||||
Description: cortex-m7 emulator Linker script
|
||||
Others: take MIMXRT1052xxxxx_flexspi_nor.ld for references
|
||||
History:
|
||||
1. Date: 2021-09-27
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. add shell cmd table and g_service_table
|
||||
*************************************************/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
STACK_SIZE = 0x400;
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
|
||||
|
||||
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
|
||||
m_text (RX) : ORIGIN = 0x00000400, LENGTH = 0x000FDC00
|
||||
m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000
|
||||
m_data2 (RW) : ORIGIN = 0x20200000, LENGTH = 0x00060000
|
||||
|
||||
m_sdram (RW) : ORIGIN = 0x21000000, LENGTH = 0x00200000
|
||||
m_nocache (RW) : ORIGIN = 0x21200000, LENGTH = 0x00200000
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
|
||||
/* The startup code goes first into internal RAM */
|
||||
.interrupts :
|
||||
{
|
||||
__VECTOR_TABLE = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
__VECTOR_RAM = __VECTOR_TABLE;
|
||||
__RAM_VECTOR_TABLE_SIZE_BYTES = 0x0;
|
||||
|
||||
/* The program code and other data goes into internal RAM */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
/* section information for shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP (*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
__isrtbl_idx_start = .;
|
||||
KEEP(*(.isrtbl.idx))
|
||||
__isrtbl_start = .;
|
||||
KEEP(*(.isrtbl))
|
||||
__isrtbl_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
PROVIDE(g_service_table_start = ABSOLUTE(.));
|
||||
KEEP(*(.g_service_table))
|
||||
PROVIDE(g_service_table_end = ABSOLUTE(.));
|
||||
} > m_text
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > m_text
|
||||
|
||||
.ARM :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*crtbegin?.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*crtbegin?.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} > m_text
|
||||
|
||||
__etext = .; /* define a global symbol at end of code */
|
||||
__DATA_ROM = .; /* Symbol is used by startup for data initialization */
|
||||
|
||||
.data : AT(__DATA_ROM)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__DATA_RAM = .;
|
||||
__data_start__ = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(4);
|
||||
__data_end__ = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
__NDATA_ROM = __DATA_ROM + (__data_end__ - __data_start__);
|
||||
.ncache.init : AT(__NDATA_ROM)
|
||||
{
|
||||
__noncachedata_start__ = .; /* create a global symbol at ncache data start */
|
||||
*(NonCacheable.init)
|
||||
. = ALIGN(4);
|
||||
__noncachedata_init_end__ = .; /* create a global symbol at initialized ncache data end */
|
||||
} > m_nocache
|
||||
. = __noncachedata_init_end__;
|
||||
.ncache :
|
||||
{
|
||||
*(NonCacheable)
|
||||
. = ALIGN(4);
|
||||
__noncachedata_end__ = .; /* define a global symbol at ncache data end */
|
||||
} > m_nocache
|
||||
|
||||
__DATA_END = __NDATA_ROM + (__noncachedata_init_end__ - __noncachedata_start__);
|
||||
text_end = ORIGIN(m_text) + LENGTH(m_text);
|
||||
ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
|
||||
|
||||
/* Uninitialized data section */
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
. = ALIGN(4);
|
||||
__START_BSS = .;
|
||||
__bss_start__ = .;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
__END_BSS = .;
|
||||
} > m_data
|
||||
|
||||
.stack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
stack_start = .;
|
||||
. += STACK_SIZE;
|
||||
stack_end = .;
|
||||
__StackTop = .;
|
||||
heap_start = .;
|
||||
} > m_data2
|
||||
|
||||
PROVIDE(heap_end = ORIGIN(m_data2) + LENGTH(m_data2));
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
252
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/link_m7.lds
Normal file
252
Ubiquitous/XiZi_IIoT/board/cortex-m7-emulator/link_m7.lds
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Processors: MIMXRT1052CVJ5B
|
||||
** MIMXRT1052CVL5B
|
||||
** MIMXRT1052DVJ6B
|
||||
** MIMXRT1052DVL6B
|
||||
**
|
||||
** Compiler: GNU C Compiler
|
||||
** Reference manual: IMXRT1050RM Rev.1, 03/2018
|
||||
** Version: rev. 1.0, 2018-09-21
|
||||
** Build: b180921
|
||||
**
|
||||
** Abstract:
|
||||
** Linker file for the GNU C Compiler
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2018 NXP
|
||||
** All rights reserved.
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file link.lds
|
||||
* @brief cortex-m7 emulator Linker script
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-09-27
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: link.lds
|
||||
Description:cortex-m7 emulator Linker script
|
||||
Others: take MIMXRT1052xxxxx_flexspi_nor.ld for references
|
||||
History:
|
||||
1. Date: 2021-09-27
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. add shell cmd table and g_service_table
|
||||
*************************************************/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
STACK_SIZE = 0x400;
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
|
||||
|
||||
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
|
||||
m_text (RX) : ORIGIN = 0x00000400, LENGTH = 0x000FDC00
|
||||
m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000
|
||||
m_data2 (RW) : ORIGIN = 0x20200000, LENGTH = 0x00060000
|
||||
|
||||
m_sdram (RW) : ORIGIN = 0x21000000, LENGTH = 0x00200000
|
||||
m_nocache (RW) : ORIGIN = 0x21200000, LENGTH = 0x00200000
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
|
||||
/* The startup code goes first into internal RAM */
|
||||
.interrupts :
|
||||
{
|
||||
__VECTOR_TABLE = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
__VECTOR_RAM = __VECTOR_TABLE;
|
||||
__RAM_VECTOR_TABLE_SIZE_BYTES = 0x0;
|
||||
|
||||
/* The program code and other data goes into internal RAM */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
/* section information for shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP (*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
__isrtbl_idx_start = .;
|
||||
KEEP(*(.isrtbl.idx))
|
||||
__isrtbl_start = .;
|
||||
KEEP(*(.isrtbl))
|
||||
__isrtbl_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
PROVIDE(g_service_table_start = ABSOLUTE(.));
|
||||
KEEP(*(.g_service_table))
|
||||
PROVIDE(g_service_table_end = ABSOLUTE(.));
|
||||
} > m_text
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > m_text
|
||||
|
||||
.ARM :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*crtbegin?.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*crtbegin?.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} > m_text
|
||||
|
||||
__etext = .; /* define a global symbol at end of code */
|
||||
__DATA_ROM = .; /* Symbol is used by startup for data initialization */
|
||||
|
||||
.data : AT(__DATA_ROM)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__DATA_RAM = .;
|
||||
__data_start__ = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(4);
|
||||
__data_end__ = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
__NDATA_ROM = __DATA_ROM + (__data_end__ - __data_start__);
|
||||
.ncache.init : AT(__NDATA_ROM)
|
||||
{
|
||||
__noncachedata_start__ = .; /* create a global symbol at ncache data start */
|
||||
*(NonCacheable.init)
|
||||
. = ALIGN(4);
|
||||
__noncachedata_init_end__ = .; /* create a global symbol at initialized ncache data end */
|
||||
} > m_nocache
|
||||
. = __noncachedata_init_end__;
|
||||
.ncache :
|
||||
{
|
||||
*(NonCacheable)
|
||||
. = ALIGN(4);
|
||||
__noncachedata_end__ = .; /* define a global symbol at ncache data end */
|
||||
} > m_nocache
|
||||
|
||||
__DATA_END = __NDATA_ROM + (__noncachedata_init_end__ - __noncachedata_start__);
|
||||
text_end = ORIGIN(m_text) + LENGTH(m_text);
|
||||
ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
|
||||
|
||||
/* Uninitialized data section */
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
. = ALIGN(4);
|
||||
__START_BSS = .;
|
||||
__bss_start__ = .;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
__END_BSS = .;
|
||||
} > m_data
|
||||
|
||||
.stack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
stack_start = .;
|
||||
. += STACK_SIZE;
|
||||
stack_end = .;
|
||||
__StackTop = .;
|
||||
heap_start = .;
|
||||
} > m_data2
|
||||
|
||||
PROVIDE(heap_end = ORIGIN(m_data2) + LENGTH(m_data2));
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_compiler.h
|
||||
* @brief CMSIS compiler generic header file
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_COMPILER_H
|
||||
#define __CMSIS_COMPILER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Arm Compiler 4/5
|
||||
*/
|
||||
#if defined ( __CC_ARM )
|
||||
#include "cmsis_armcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* Arm Compiler 6 (armclang)
|
||||
*/
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#include "cmsis_armclang.h"
|
||||
|
||||
|
||||
/*
|
||||
* GNU Compiler
|
||||
*/
|
||||
#elif defined ( __GNUC__ )
|
||||
#include "cmsis_gcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* IAR Compiler
|
||||
*/
|
||||
#elif defined ( __ICCARM__ )
|
||||
#include <cmsis_iccarm.h>
|
||||
|
||||
|
||||
/*
|
||||
* TI Arm Compiler
|
||||
*/
|
||||
#elif defined ( __TI_ARM__ )
|
||||
#include <cmsis_ccs.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* TASKING Compiler
|
||||
*/
|
||||
#elif defined ( __TASKING__ )
|
||||
/*
|
||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||
* Including the CMSIS ones.
|
||||
*/
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __packed__
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __packed__ T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __align(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* COSMIC Compiler
|
||||
*/
|
||||
#elif defined ( __CSMC__ )
|
||||
#include <cmsis_csm.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM _asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
// NO RETURN is automatically detected hence no warning here
|
||||
#define __NO_RETURN
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#warning No compiler specific solution for __USED. __USED is ignored.
|
||||
#define __USED
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED @packed
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT @packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION @packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
@packed struct T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
|
||||
#define __ALIGNED(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
#error Unknown compiler.
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __CMSIS_COMPILER_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_version.h
|
||||
* @brief CMSIS Core(M) Version definitions
|
||||
* @version V5.0.2
|
||||
* @date 19. April 2017
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_VERSION_H
|
||||
#define __CMSIS_VERSION_H
|
||||
|
||||
/* CMSIS Version definitions */
|
||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||
#define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,197 @@
|
||||
/******************************************************************************
|
||||
* @file mpu_armv7.h
|
||||
* @brief CMSIS MPU API for Armv7-M MPU
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2017-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef ARM_MPU_ARMV7_H
|
||||
#define ARM_MPU_ARMV7_H
|
||||
|
||||
#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U)
|
||||
#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U)
|
||||
#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U)
|
||||
#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U)
|
||||
#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U)
|
||||
#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U)
|
||||
#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU)
|
||||
#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU)
|
||||
#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU)
|
||||
#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU)
|
||||
#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU)
|
||||
#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU)
|
||||
#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U)
|
||||
#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U)
|
||||
#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U)
|
||||
#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U)
|
||||
#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U)
|
||||
#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U)
|
||||
#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U)
|
||||
#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U)
|
||||
#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U)
|
||||
#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U)
|
||||
#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU)
|
||||
#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU)
|
||||
#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU)
|
||||
#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU)
|
||||
#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU)
|
||||
#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU)
|
||||
|
||||
#define ARM_MPU_AP_NONE 0U
|
||||
#define ARM_MPU_AP_PRIV 1U
|
||||
#define ARM_MPU_AP_URO 2U
|
||||
#define ARM_MPU_AP_FULL 3U
|
||||
#define ARM_MPU_AP_PRO 5U
|
||||
#define ARM_MPU_AP_RO 6U
|
||||
|
||||
/** MPU Region Base Address Register Value
|
||||
*
|
||||
* \param Region The region to be configured, number 0 to 15.
|
||||
* \param BaseAddress The base address for the region.
|
||||
*/
|
||||
#define ARM_MPU_RBAR(Region, BaseAddress) \
|
||||
(((BaseAddress) & MPU_RBAR_ADDR_Msk) | \
|
||||
((Region) & MPU_RBAR_REGION_Msk) | \
|
||||
(MPU_RBAR_VALID_Msk))
|
||||
|
||||
/**
|
||||
* MPU Region Attribute and Size Register Value
|
||||
*
|
||||
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
||||
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
||||
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
||||
* \param IsShareable Region is shareable between multiple bus masters.
|
||||
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
|
||||
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
||||
* \param SubRegionDisable Sub-region disable field.
|
||||
* \param Size Region size of the region to be configured, for example 4K, 8K.
|
||||
*/
|
||||
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
|
||||
((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
|
||||
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
|
||||
(((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
|
||||
(((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
|
||||
(((IsCacheable ) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \
|
||||
(((IsBufferable ) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk) | \
|
||||
(((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \
|
||||
(((Size ) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \
|
||||
(MPU_RASR_ENABLE_Msk))
|
||||
|
||||
|
||||
/**
|
||||
* Struct for a single MPU Region
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t RBAR; //!< The region base address register value (RBAR)
|
||||
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
|
||||
} ARM_MPU_Region_t;
|
||||
|
||||
/** Enable the MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Disable the MPU.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Disable(void)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
/** Clear and disable the given MPU region.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
|
||||
{
|
||||
MPU->RNR = rnr;
|
||||
MPU->RASR = 0U;
|
||||
}
|
||||
|
||||
/** Configure an MPU region.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rsar Value for RSAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RBAR = rbar;
|
||||
MPU->RASR = rasr;
|
||||
}
|
||||
|
||||
/** Configure the given MPU region.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rsar Value for RSAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RNR = rnr;
|
||||
MPU->RBAR = rbar;
|
||||
MPU->RASR = rasr;
|
||||
}
|
||||
|
||||
/** Memcopy with strictly ordered memory access, e.g. for register targets.
|
||||
* \param dst Destination data is copied to.
|
||||
* \param src Source data is copied from.
|
||||
* \param len Amount of data words to be copied.
|
||||
*/
|
||||
__STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0U; i < len; ++i)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** Load the given number of MPU regions from a table.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
||||
while (cnt > MPU_TYPE_RALIASES) {
|
||||
orderedCpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
|
||||
table += MPU_TYPE_RALIASES;
|
||||
cnt -= MPU_TYPE_RALIASES;
|
||||
}
|
||||
orderedCpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,10 @@
|
||||
menuconfig BSP_USING_LPUART
|
||||
bool "Using UART device"
|
||||
default y
|
||||
select RESOURCES_SERIAL
|
||||
if BSP_USING_LPUART
|
||||
source "$BSP_DIR/third_party_driver/uart/Kconfig"
|
||||
endif
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
SRC_FILES := flash_ops.c
|
||||
SRC_DIR := common uart
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,5 @@
|
||||
SRC_FILES := fsl_common.c system_CMSDK_CM7.c startup_CMSDK_CM7.c clock_config.c
|
||||
|
||||
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
/* System clock frequency. */
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/*******************************************************************************
|
||||
************************ BOARD_InitBootClocks function ************************
|
||||
******************************************************************************/
|
||||
void BOARD_InitBootClocks(void)
|
||||
{
|
||||
BOARD_BootClockRUN();
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockRUN configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockRUN(void)
|
||||
{
|
||||
|
||||
SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file fsl_common.c
|
||||
* @brief common drivers
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.11.11
|
||||
*/
|
||||
|
||||
#include "fsl_common.h"
|
||||
#define SDK_MEM_MAGIC_NUMBER 12345U
|
||||
|
||||
typedef struct _mem_align_control_block
|
||||
{
|
||||
uint16_t identifier; /*!< Identifier for the memory control block. */
|
||||
uint16_t offset; /*!< offset from aligned address to real address */
|
||||
} mem_align_cb_t;
|
||||
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "platform.drivers.common"
|
||||
#endif
|
||||
|
||||
#ifndef __GIC_PRIO_BITS
|
||||
#if defined(ENABLE_RAM_VECTOR_TABLE)
|
||||
uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler)
|
||||
{
|
||||
/* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */
|
||||
#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
extern uint32_t Image$$VECTOR_ROM$$Base[];
|
||||
extern uint32_t Image$$VECTOR_RAM$$Base[];
|
||||
extern uint32_t Image$$RW_m_data$$Base[];
|
||||
|
||||
#define __VECTOR_TABLE Image$$VECTOR_ROM$$Base
|
||||
#define __VECTOR_RAM Image$$VECTOR_RAM$$Base
|
||||
#define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base))
|
||||
#elif defined(__ICCARM__)
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE[];
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[];
|
||||
uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES);
|
||||
#endif /* defined(__CC_ARM) || defined(__ARMCC_VERSION) */
|
||||
uint32_t n;
|
||||
uint32_t ret;
|
||||
uint32_t irqMaskValue;
|
||||
|
||||
irqMaskValue = DisableGlobalIRQ();
|
||||
if (SCB->VTOR != (uint32_t)__VECTOR_RAM)
|
||||
{
|
||||
/* Copy the vector table from ROM to RAM */
|
||||
for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++)
|
||||
{
|
||||
__VECTOR_RAM[n] = __VECTOR_TABLE[n];
|
||||
}
|
||||
/* Point the VTOR to the position of vector table */
|
||||
SCB->VTOR = (uint32_t)__VECTOR_RAM;
|
||||
}
|
||||
|
||||
ret = __VECTOR_RAM[irq + 16];
|
||||
/* make sure the __VECTOR_RAM is noncachable */
|
||||
__VECTOR_RAM[irq + 16] = irqHandler;
|
||||
|
||||
EnableGlobalIRQ(irqMaskValue);
|
||||
|
||||
/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
|
||||
exception return operation might vector to incorrect interrupt */
|
||||
#if defined __CORTEX_M && (__CORTEX_M == 4U)
|
||||
__DSB();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* ENABLE_RAM_VECTOR_TABLE. */
|
||||
#endif /* __GIC_PRIO_BITS. */
|
||||
|
||||
#if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
|
||||
#if !(defined(FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS) && FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS)
|
||||
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
|
||||
uint32_t index = 0;
|
||||
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
SYSCON->STARTERSET[index] = 1u << intNumber;
|
||||
EnableIRQ(interrupt); /* also enable interrupt at NVIC */
|
||||
}
|
||||
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
|
||||
DisableIRQ(interrupt); /* also disable interrupt at NVIC */
|
||||
uint32_t index = 0;
|
||||
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
SYSCON->STARTERCLR[index] = 1u << intNumber;
|
||||
}
|
||||
#endif /* FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS */
|
||||
#endif /* FSL_FEATURE_SOC_SYSCON_COUNT */
|
||||
|
||||
void *SDK_Malloc(size_t size, size_t alignbytes)
|
||||
{
|
||||
mem_align_cb_t *p_cb = NULL;
|
||||
uint32_t alignedsize = SDK_SIZEALIGN(size, alignbytes) + alignbytes + sizeof(mem_align_cb_t);
|
||||
void *p_align_addr, *p_addr = malloc(alignedsize);
|
||||
|
||||
if (!p_addr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p_align_addr = (void *)SDK_SIZEALIGN((uint32_t)p_addr + sizeof(mem_align_cb_t), alignbytes);
|
||||
|
||||
p_cb = (mem_align_cb_t *)((uint32_t)p_align_addr - 4U);
|
||||
p_cb->identifier = SDK_MEM_MAGIC_NUMBER;
|
||||
p_cb->offset = (uint32_t)p_align_addr - (uint32_t)p_addr;
|
||||
|
||||
return (void *)p_align_addr;
|
||||
}
|
||||
|
||||
void SDK_Free(void *ptr)
|
||||
{
|
||||
mem_align_cb_t *p_cb = (mem_align_cb_t *)((uint32_t)ptr - 4U);
|
||||
|
||||
if (p_cb->identifier != SDK_MEM_MAGIC_NUMBER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
free((void *)((uint32_t)ptr - p_cb->offset));
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
/******************************************************************************
|
||||
* @file startup_CMSDK_CM7.c
|
||||
* @brief CMSIS Startup File for CMSDK_M7 Device
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2022 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 ARM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "CMSDK_CM7_SP.h"
|
||||
#include "system_CMSDK_CM7.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
External References
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern uint32_t __StackTop ;
|
||||
|
||||
// extern __NO_RETURN void __PROGRAM_START(void);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Internal References
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern __NO_RETURN void Reset_Handler (void);
|
||||
void Default_Handler(void);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Exception / Interrupt Handler
|
||||
*----------------------------------------------------------------------------*/
|
||||
/* Exceptions */
|
||||
void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void HardFault_Handler (void) __attribute__ ((weak));
|
||||
void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
|
||||
/* Interrupts */
|
||||
void UART0RX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART0TX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART1RX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART1TX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART2RX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART2TX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0ALL_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO1ALL_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void TIMER0_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void TIMER1_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void DUALTIMER_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void SPI_0_1_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART_0_1_2_OVF_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ETHERNET_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void I2S_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void TOUCHSCREEN_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO2_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO3_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART3RX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART3TX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART4RX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UART4TX_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void SPI_2_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void SPI_3_4_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_0_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_1_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_2_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_3_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_4_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_5_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_6_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void GPIO0_7_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
#if defined CMSDK_CM7_VHT || defined CMSDK_CM7_SP_VHT || defined CMSDK_CM7_DP_VHT
|
||||
void ARM_VSI0_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ARM_VSI1_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ARM_VSI2_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ARM_VSI3_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ARM_VSI4_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ARM_VSI5_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ARM_VSI6_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void ARM_VSI7_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Exception / Interrupt Vector table
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#if defined ( __GNUC__ )
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
// extern const VECTOR_TABLE_Type __VECTOR_TABLE[256];
|
||||
// const VECTOR_TABLE_Type __VECTOR_TABLE[256] = {
|
||||
// (VECTOR_TABLE_Type)(&__StackTop), /* Initial Stack Pointer */
|
||||
// Reset_Handler, /* Reset Handler */
|
||||
// NMI_Handler, /* -14 NMI Handler */
|
||||
// HardFault_Handler, /* -13 Hard Fault Handler */
|
||||
// MemManage_Handler, /* -12 MPU Fault Handler */
|
||||
// BusFault_Handler, /* -11 Bus Fault Handler */
|
||||
// UsageFault_Handler, /* -10 Usage Fault Handler */
|
||||
// 0, /* Reserved */
|
||||
// 0, /* Reserved */
|
||||
// 0, /* Reserved */
|
||||
// 0, /* Reserved */
|
||||
// SVC_Handler, /* -5 SVC Handler */
|
||||
// DebugMon_Handler, /* -4 Debug Monitor Handler */
|
||||
// 0, /* Reserved */
|
||||
// PendSV_Handler, /* -2 PendSV Handler */
|
||||
// SysTick_Handler, /* -1 SysTick Handler */
|
||||
|
||||
// /* Interrupts */
|
||||
// UART0RX_Handler, /* 0 UART 0 receive interrupt */
|
||||
// UART0TX_Handler, /* 1 UART 0 transmit interrupt */
|
||||
// UART1RX_Handler, /* 2 UART 1 receive interrupt */
|
||||
// UART1TX_Handler, /* 3 UART 1 transmit interrupt */
|
||||
// UART2RX_Handler, /* 4 UART 2 receive interrupt */
|
||||
// UART2TX_Handler, /* 5 UART 2 transmit interrupt */
|
||||
// GPIO0ALL_Handler, /* 6 GPIO 0 combined interrupt */
|
||||
// GPIO1ALL_Handler, /* 7 GPIO 1 combined interrupt */
|
||||
// TIMER0_Handler, /* 8 Timer 0 interrupt */
|
||||
// TIMER1_Handler, /* 9 Timer 1 interrupt */
|
||||
// DUALTIMER_Handler, /* 10 Dual Timer interrupt */
|
||||
// SPI_0_1_Handler, /* 11 SPI 0, SPI 1 interrupt */
|
||||
// UART_0_1_2_OVF_Handler, /* 12 UART overflow (0, 1 & 2) interrupt */
|
||||
// ETHERNET_Handler, /* 13 Ethernet interrupt */
|
||||
// I2S_Handler, /* 14 Audio I2S interrupt */
|
||||
// TOUCHSCREEN_Handler, /* 15 Touch Screen interrupt */
|
||||
// GPIO2_Handler, /* 16 GPIO 2 combined interrupt */
|
||||
// GPIO3_Handler, /* 17 GPIO 3 combined interrupt */
|
||||
// UART3RX_Handler, /* 18 UART 3 receive interrupt */
|
||||
// UART3TX_Handler, /* 19 UART 3 transmit interrupt */
|
||||
// UART4RX_Handler, /* 20 UART 4 receive interrupt */
|
||||
// UART4TX_Handler, /* 21 UART 4 transmit interrupt */
|
||||
// SPI_2_Handler, /* 22 SPI 2 interrupt */
|
||||
// SPI_3_4_Handler, /* 23 SPI 3, SPI 4 interrupt */
|
||||
// GPIO0_0_Handler, /* 24 GPIO 0 individual interrupt ( 0) */
|
||||
// GPIO0_1_Handler, /* 25 GPIO 0 individual interrupt ( 1) */
|
||||
// GPIO0_2_Handler, /* 26 GPIO 0 individual interrupt ( 2) */
|
||||
// GPIO0_3_Handler, /* 27 GPIO 0 individual interrupt ( 3) */
|
||||
// GPIO0_4_Handler, /* 28 GPIO 0 individual interrupt ( 4) */
|
||||
// GPIO0_5_Handler, /* 29 GPIO 0 individual interrupt ( 5) */
|
||||
// GPIO0_6_Handler, /* 30 GPIO 0 individual interrupt ( 6) */
|
||||
// GPIO0_7_Handler, /* 31 GPIO 0 individual interrupt ( 7) */
|
||||
// 0, /* 32 Reserved */
|
||||
// 0, /* 33 Reserved */
|
||||
// 0, /* 34 Reserved */
|
||||
// 0, /* 35 Reserved */
|
||||
// 0, /* 36 Reserved */
|
||||
// 0, /* 37 Reserved */
|
||||
// 0, /* 38 Reserved */
|
||||
// 0, /* 39 Reserved */
|
||||
// 0, /* 40 Reserved */
|
||||
// 0, /* 41 Reserved */
|
||||
// 0, /* 42 Reserved */
|
||||
// 0, /* 43 Reserved */
|
||||
// 0, /* 44 Reserved */
|
||||
// 0, /* 45 Reserved */
|
||||
// 0, /* 46 Reserved */
|
||||
// 0, /* 47 Reserved */
|
||||
// 0, /* 48 Reserved */
|
||||
// 0, /* 49 Reserved */
|
||||
// 0, /* 50 Reserved */
|
||||
// 0, /* 51 Reserved */
|
||||
// 0, /* 52 Reserved */
|
||||
// 0, /* 53 Reserved */
|
||||
// 0, /* 54 Reserved */
|
||||
// 0, /* 55 Reserved */
|
||||
// 0, /* 56 Reserved */
|
||||
// 0, /* 57 Reserved */
|
||||
// 0, /* 58 Reserved */
|
||||
// 0, /* 59 Reserved */
|
||||
// 0, /* 60 Reserved */
|
||||
// 0, /* 61 Reserved */
|
||||
// 0, /* 62 Reserved */
|
||||
// 0, /* 63 Reserved */
|
||||
// 0, /* 64 Reserved */
|
||||
// 0, /* 65 Reserved */
|
||||
// 0, /* 66 Reserved */
|
||||
// 0, /* 67 Reserved */
|
||||
// 0, /* 68 Reserved */
|
||||
// 0, /* 69 Reserved */
|
||||
// 0, /* 70 Reserved */
|
||||
// 0, /* 71 Reserved */
|
||||
// 0, /* 72 Reserved */
|
||||
// 0, /* 73 Reserved */
|
||||
// 0, /* 74 Reserved */
|
||||
// 0, /* 75 Reserved */
|
||||
// 0, /* 76 Reserved */
|
||||
// 0, /* 77 Reserved */
|
||||
// 0, /* 78 Reserved */
|
||||
// 0, /* 79 Reserved */
|
||||
// 0, /* 80 Reserved */
|
||||
// 0, /* 81 Reserved */
|
||||
// 0, /* 82 Reserved */
|
||||
// 0, /* 83 Reserved */
|
||||
// 0, /* 84 Reserved */
|
||||
// 0, /* 85 Reserved */
|
||||
// 0, /* 86 Reserved */
|
||||
// 0, /* 87 Reserved */
|
||||
// 0, /* 88 Reserved */
|
||||
// 0, /* 89 Reserved */
|
||||
// 0, /* 90 Reserved */
|
||||
// 0, /* 91 Reserved */
|
||||
// 0, /* 92 Reserved */
|
||||
// 0, /* 93 Reserved */
|
||||
// 0, /* 94 Reserved */
|
||||
// 0, /* 95 Reserved */
|
||||
// 0, /* 96 Reserved */
|
||||
// 0, /* 97 Reserved */
|
||||
// 0, /* 98 Reserved */
|
||||
// 0, /* 99 Reserved */
|
||||
// 0, /* 100 Reserved */
|
||||
// 0, /* 101 Reserved */
|
||||
// 0, /* 102 Reserved */
|
||||
// 0, /* 103 Reserved */
|
||||
// 0, /* 104 Reserved */
|
||||
// 0, /* 105 Reserved */
|
||||
// 0, /* 106 Reserved */
|
||||
// 0, /* 107 Reserved */
|
||||
// 0, /* 108 Reserved */
|
||||
// 0, /* 109 Reserved */
|
||||
// 0, /* 110 Reserved */
|
||||
// 0, /* 111 Reserved */
|
||||
// 0, /* 112 Reserved */
|
||||
// 0, /* 113 Reserved */
|
||||
// 0, /* 114 Reserved */
|
||||
// 0, /* 115 Reserved */
|
||||
// 0, /* 116 Reserved */
|
||||
// 0, /* 117 Reserved */
|
||||
// 0, /* 118 Reserved */
|
||||
// 0, /* 119 Reserved */
|
||||
// 0, /* 120 Reserved */
|
||||
// 0, /* 121 Reserved */
|
||||
// 0, /* 122 Reserved */
|
||||
// 0, /* 123 Reserved */
|
||||
// 0, /* 124 Reserved */
|
||||
// 0, /* 125 Reserved */
|
||||
// 0, /* 126 Reserved */
|
||||
// 0, /* 127 Reserved */
|
||||
// 0, /* 128 Reserved */
|
||||
// 0, /* 129 Reserved */
|
||||
// 0, /* 130 Reserved */
|
||||
// 0, /* 131 Reserved */
|
||||
// 0, /* 132 Reserved */
|
||||
// 0, /* 133 Reserved */
|
||||
// 0, /* 134 Reserved */
|
||||
// 0, /* 135 Reserved */
|
||||
// 0, /* 136 Reserved */
|
||||
// 0, /* 137 Reserved */
|
||||
// 0, /* 138 Reserved */
|
||||
// 0, /* 139 Reserved */
|
||||
// 0, /* 140 Reserved */
|
||||
// 0, /* 141 Reserved */
|
||||
// 0, /* 142 Reserved */
|
||||
// 0, /* 143 Reserved */
|
||||
// 0, /* 144 Reserved */
|
||||
// 0, /* 145 Reserved */
|
||||
// 0, /* 146 Reserved */
|
||||
// 0, /* 147 Reserved */
|
||||
// 0, /* 148 Reserved */
|
||||
// 0, /* 149 Reserved */
|
||||
// 0, /* 150 Reserved */
|
||||
// 0, /* 151 Reserved */
|
||||
// 0, /* 152 Reserved */
|
||||
// 0, /* 153 Reserved */
|
||||
// 0, /* 154 Reserved */
|
||||
// 0, /* 155 Reserved */
|
||||
// 0, /* 156 Reserved */
|
||||
// 0, /* 157 Reserved */
|
||||
// 0, /* 158 Reserved */
|
||||
// 0, /* 159 Reserved */
|
||||
// 0, /* 160 Reserved */
|
||||
// 0, /* 161 Reserved */
|
||||
// 0, /* 162 Reserved */
|
||||
// 0, /* 163 Reserved */
|
||||
// 0, /* 164 Reserved */
|
||||
// 0, /* 165 Reserved */
|
||||
// 0, /* 166 Reserved */
|
||||
// 0, /* 167 Reserved */
|
||||
// 0, /* 168 Reserved */
|
||||
// 0, /* 169 Reserved */
|
||||
// 0, /* 170 Reserved */
|
||||
// 0, /* 171 Reserved */
|
||||
// 0, /* 172 Reserved */
|
||||
// 0, /* 173 Reserved */
|
||||
// 0, /* 174 Reserved */
|
||||
// 0, /* 175 Reserved */
|
||||
// 0, /* 176 Reserved */
|
||||
// 0, /* 177 Reserved */
|
||||
// 0, /* 178 Reserved */
|
||||
// 0, /* 179 Reserved */
|
||||
// 0, /* 180 Reserved */
|
||||
// 0, /* 181 Reserved */
|
||||
// 0, /* 182 Reserved */
|
||||
// 0, /* 183 Reserved */
|
||||
// 0, /* 184 Reserved */
|
||||
// 0, /* 185 Reserved */
|
||||
// 0, /* 186 Reserved */
|
||||
// 0, /* 187 Reserved */
|
||||
// 0, /* 188 Reserved */
|
||||
// 0, /* 189 Reserved */
|
||||
// 0, /* 190 Reserved */
|
||||
// 0, /* 191 Reserved */
|
||||
// 0, /* 192 Reserved */
|
||||
// 0, /* 193 Reserved */
|
||||
// 0, /* 194 Reserved */
|
||||
// 0, /* 195 Reserved */
|
||||
// 0, /* 196 Reserved */
|
||||
// 0, /* 197 Reserved */
|
||||
// 0, /* 198 Reserved */
|
||||
// 0, /* 199 Reserved */
|
||||
// 0, /* 200 Reserved */
|
||||
// 0, /* 201 Reserved */
|
||||
// 0, /* 202 Reserved */
|
||||
// 0, /* 203 Reserved */
|
||||
// 0, /* 204 Reserved */
|
||||
// 0, /* 205 Reserved */
|
||||
// 0, /* 206 Reserved */
|
||||
// 0, /* 207 Reserved */
|
||||
// 0, /* 208 Reserved */
|
||||
// 0, /* 209 Reserved */
|
||||
// 0, /* 210 Reserved */
|
||||
// 0, /* 211 Reserved */
|
||||
// 0, /* 212 Reserved */
|
||||
// 0, /* 213 Reserved */
|
||||
// 0, /* 214 Reserved */
|
||||
// 0, /* 215 Reserved */
|
||||
// 0, /* 216 Reserved */
|
||||
// 0, /* 217 Reserved */
|
||||
// 0, /* 218 Reserved */
|
||||
// 0, /* 219 Reserved */
|
||||
// 0, /* 220 Reserved */
|
||||
// 0, /* 221 Reserved */
|
||||
// 0, /* 222 Reserved */
|
||||
// 0, /* 223 Reserved */
|
||||
// #if defined CMSDK_CM7_VHT || defined CMSDK_CM7_SP_VHT || defined CMSDK_CM7_DP_VHT
|
||||
// ARM_VSI0_Handler, /* 224 VSI 0 interrupt */
|
||||
// ARM_VSI1_Handler, /* 225 VSI 1 interrupt */
|
||||
// ARM_VSI2_Handler, /* 226 VSI 2 interrupt */
|
||||
// ARM_VSI3_Handler, /* 227 VSI 3 interrupt */
|
||||
// ARM_VSI4_Handler, /* 228 VSI 4 interrupt */
|
||||
// ARM_VSI5_Handler, /* 229 VSI 5 interrupt */
|
||||
// ARM_VSI6_Handler, /* 230 VSI 6 interrupt */
|
||||
// ARM_VSI7_Handler /* 231 VSI 7 interrupt */
|
||||
// #else
|
||||
// 0, /* 224 Reserved */
|
||||
// 0, /* 225 Reserved */
|
||||
// 0, /* 226 Reserved */
|
||||
// 0, /* 227 Reserved */
|
||||
// 0, /* 228 Reserved */
|
||||
// 0, /* 229 Reserved */
|
||||
// 0, /* 230 Reserved */
|
||||
// 0 /* 231 Reserved */
|
||||
// #endif
|
||||
// };
|
||||
|
||||
#if defined ( __GNUC__ )
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Reset Handler called on controller reset
|
||||
*----------------------------------------------------------------------------*/
|
||||
// __NO_RETURN void Reset_Handler(void)
|
||||
// {
|
||||
// SystemInit();
|
||||
// }
|
||||
|
||||
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wmissing-noreturn"
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Hard Fault Handler
|
||||
*----------------------------------------------------------------------------*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Default Handler for Exceptions / Interrupts
|
||||
*----------------------------------------------------------------------------*/
|
||||
void Default_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
/******************************************************************************
|
||||
* @file system_CMSDK_CM7.c
|
||||
* @brief CMSIS System Source File for CMSDK_CM7 Device
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2011 - 2022 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 ARM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CMSDK_CM7_SP.h"
|
||||
#include "system_CMSDK_CM7.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Define clocks
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define XTAL (50000000UL) /* Oscillator frequency */
|
||||
|
||||
#define SYSTEM_CLOCK (XTAL / 2U)
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Exception / Interrupt Vector table
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern const VECTOR_TABLE_Type __VECTOR_TABLE[256];
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
System Core Clock Variable
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
System Core Clock update function
|
||||
*----------------------------------------------------------------------------*/
|
||||
void SystemCoreClockUpdate (void)
|
||||
{
|
||||
SystemCoreClock = SYSTEM_CLOCK;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
System initialization function
|
||||
*----------------------------------------------------------------------------*/
|
||||
void SystemInit (void)
|
||||
{
|
||||
#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
|
||||
SCB->VTOR = (uint32_t) &(__VECTOR_TABLE[0]);
|
||||
#endif
|
||||
|
||||
#if defined (__FPU_USED) && (__FPU_USED == 1U)
|
||||
SCB->CPACR |= ((3U << 10U*2U) | /* enable CP10 Full Access */
|
||||
(3U << 11U*2U) ); /* enable CP11 Full Access */
|
||||
#endif
|
||||
|
||||
#ifdef UNALIGNED_SUPPORT_DISABLE
|
||||
SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
|
||||
#endif
|
||||
|
||||
SystemCoreClock = SYSTEM_CLOCK;
|
||||
}
|
||||
@@ -0,0 +1,616 @@
|
||||
/******************************************************************************
|
||||
* @file CMSDK_CM7_SP.h
|
||||
* @brief CMSIS Device Header File for CMSDK_CM7 Device (single precision FPU)
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2011 - 2022 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 ARM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CMSDK_CM7_SP_H
|
||||
#define CMSDK_CM7_SP_H
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------- Interrupt Number Definition ------------------------ */
|
||||
|
||||
typedef enum IRQn
|
||||
{
|
||||
|
||||
|
||||
/* ------------------- Processor Exceptions Numbers ----------------------------- */
|
||||
NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
|
||||
HardFault_IRQn = -13, /* 3 HardFault Interrupt */
|
||||
MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */
|
||||
BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */
|
||||
UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */
|
||||
SVCall_IRQn = -5, /* 11 SV Call Interrupt */
|
||||
DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */
|
||||
PendSV_IRQn = -2, /* 14 Pend SV Interrupt */
|
||||
SysTick_IRQn = -1, /* 15 System Tick Interrupt */
|
||||
|
||||
/* ------------------- Processor Interrupt Numbers ------------------------------ */
|
||||
UART0RX_IRQn = 0, /* UART 0 receive interrupt */
|
||||
UART0TX_IRQn = 1, /* UART 0 transmit interrupt */
|
||||
UART1RX_IRQn = 2, /* UART 1 receive interrupt */
|
||||
UART1TX_IRQn = 3, /* UART 1 transmit interrupt */
|
||||
UART2RX_IRQn = 4, /* UART 2 receive interrupt */
|
||||
UART2TX_IRQn = 5, /* UART 2 transmit interrupt */
|
||||
GPIO0ALL_IRQn = 6, /* GPIO 0 combined interrupt */
|
||||
GPIO1ALL_IRQn = 7, /* GPIO 1 combined interrupt */
|
||||
TIMER0_IRQn = 8, /* Timer 0 interrupt */
|
||||
TIMER1_IRQn = 9, /* Timer 1 interrupt */
|
||||
DUALTIMER_IRQn = 10, /* Dual Timer interrupt */
|
||||
SPI_0_1_IRQn = 11, /* SPI 0, SPI 1 interrupt */
|
||||
UART_0_1_2_OVF_IRQn = 12, /* UART overflow (0, 1 & 2) interrupt */
|
||||
ETHERNET_IRQn = 13, /* Ethernet interrupt */
|
||||
I2S_IRQn = 14, /* Audio I2S interrupt */
|
||||
TOUCHSCREEN_IRQn = 15, /* Touch Screen interrupt */
|
||||
GPIO2_IRQn = 16, /* GPIO 2 combined interrupt */
|
||||
GPIO3_IRQn = 17, /* GPIO 3 combined interrupt */
|
||||
UART3RX_IRQn = 18, /* UART 3 receive interrupt */
|
||||
UART3TX_IRQn = 19, /* UART 3 transmit interrupt */
|
||||
UART4RX_IRQn = 20, /* UART 4 receive interrupt */
|
||||
UART4TX_IRQn = 21, /* UART 4 transmit interrupt */
|
||||
SPI_2_IRQn = 22, /* SPI 2 interrupt */
|
||||
SPI_3_4_IRQn = 23, /* SPI 3, SPI 4 interrupt */
|
||||
GPIO0_0_IRQn = 24, /* GPIO 0 individual interrupt ( 0) */
|
||||
GPIO0_1_IRQn = 25, /* GPIO 0 individual interrupt ( 1) */
|
||||
GPIO0_2_IRQn = 26, /* GPIO 0 individual interrupt ( 2) */
|
||||
GPIO0_3_IRQn = 27, /* GPIO 0 individual interrupt ( 3) */
|
||||
GPIO0_4_IRQn = 28, /* GPIO 0 individual interrupt ( 4) */
|
||||
GPIO0_5_IRQn = 29, /* GPIO 0 individual interrupt ( 5) */
|
||||
GPIO0_6_IRQn = 30, /* GPIO 0 individual interrupt ( 6) */
|
||||
GPIO0_7_IRQn = 31, /* GPIO 0 individual interrupt ( 7) */
|
||||
#if defined CMSDK_CM7_SP_VHT
|
||||
ARM_VSI0_IRQn = 224, /* VSI 0 interrupt */
|
||||
ARM_VSI1_IRQn = 225, /* VSI 1 interrupt */
|
||||
ARM_VSI2_IRQn = 226, /* VSI 2 interrupt */
|
||||
ARM_VSI3_IRQn = 227, /* VSI 3 interrupt */
|
||||
ARM_VSI4_IRQn = 228, /* VSI 4 interrupt */
|
||||
ARM_VSI5_IRQn = 229, /* VSI 5 interrupt */
|
||||
ARM_VSI6_IRQn = 230, /* VSI 6 interrupt */
|
||||
ARM_VSI7_IRQn = 231, /* VSI 7 interrupt */
|
||||
#endif
|
||||
} IRQn_Type;
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ Processor and Core Peripheral Section ================ */
|
||||
/* ================================================================================ */
|
||||
|
||||
/* ------- Start of section using anonymous unions and disabling warnings ------- */
|
||||
#if defined (__CC_ARM)
|
||||
#pragma push
|
||||
#pragma anon_unions
|
||||
#elif defined (__ICCARM__)
|
||||
#pragma language=extended
|
||||
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wc11-extensions"
|
||||
#pragma clang diagnostic ignored "-Wreserved-id-macro"
|
||||
#elif defined (__GNUC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TMS470__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TASKING__)
|
||||
#pragma warning 586
|
||||
#elif defined (__CSMC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#else
|
||||
#warning Not supported compiler type
|
||||
#endif
|
||||
|
||||
|
||||
/* -------- Configuration of Core Peripherals ----------------------------------- */
|
||||
#define __CM4_REV 0x0000U /* Core revision r0p0 */
|
||||
#define __MPU_PRESENT 1U /* MPU present */
|
||||
#define __VTOR_PRESENT 1U /* VTOR present */
|
||||
#define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */
|
||||
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
|
||||
#define __FPU_PRESENT 1U /* FPU present */
|
||||
#define __FPU_DP 0U /* unused */
|
||||
#define __ICACHE_PRESENT 1U
|
||||
#define __DCACHE_PRESENT 1U
|
||||
|
||||
#include "core_cm7.h" /* Processor and core peripherals */
|
||||
#if defined CMSDK_CM7_SP_VHT
|
||||
#include "arm_vio.h"
|
||||
#include "arm_vsi.h"
|
||||
#include "arm_vsocket.h"
|
||||
#endif
|
||||
// #include "system_CMSDK_CM7.h" /* System Header */
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ Device Specific Peripheral Section ================ */
|
||||
/* ================================================================================ */
|
||||
|
||||
/*------------- Universal Asynchronous Receiver Transmitter (UART) -----------*/
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t DATA; /* Offset: 0x000 (R/W) Data Register */
|
||||
__IOM uint32_t STATE; /* Offset: 0x004 (R/W) Status Register */
|
||||
__IOM uint32_t CTRL; /* Offset: 0x008 (R/W) Control Register */
|
||||
union {
|
||||
__IM uint32_t INTSTATUS; /* Offset: 0x00C (R/ ) Interrupt Status Register */
|
||||
__OM uint32_t INTCLEAR; /* Offset: 0x00C ( /W) Interrupt Clear Register */
|
||||
};
|
||||
__IOM uint32_t BAUDDIV; /* Offset: 0x010 (R/W) Baudrate Divider Register */
|
||||
|
||||
} CMSDK_UART_TypeDef;
|
||||
|
||||
/* CMSDK_UART DATA Register Definitions */
|
||||
#define CMSDK_UART_DATA_Pos 0 /* CMSDK_UART_DATA_Pos: DATA Position */
|
||||
#define CMSDK_UART_DATA_Msk (0xFFUL /*<< CMSDK_UART_DATA_Pos*/) /* CMSDK_UART DATA: DATA Mask */
|
||||
|
||||
/* CMSDK_UART STATE Register Definitions */
|
||||
#define CMSDK_UART_STATE_RXOR_Pos 3 /* CMSDK_UART STATE: RXOR Position */
|
||||
#define CMSDK_UART_STATE_RXOR_Msk (0x1UL << CMSDK_UART_STATE_RXOR_Pos) /* CMSDK_UART STATE: RXOR Mask */
|
||||
|
||||
#define CMSDK_UART_STATE_TXOR_Pos 2 /* CMSDK_UART STATE: TXOR Position */
|
||||
#define CMSDK_UART_STATE_TXOR_Msk (0x1UL << CMSDK_UART_STATE_TXOR_Pos) /* CMSDK_UART STATE: TXOR Mask */
|
||||
|
||||
#define CMSDK_UART_STATE_RXBF_Pos 1 /* CMSDK_UART STATE: RXBF Position */
|
||||
#define CMSDK_UART_STATE_RXBF_Msk (0x1UL << CMSDK_UART_STATE_RXBF_Pos) /* CMSDK_UART STATE: RXBF Mask */
|
||||
|
||||
#define CMSDK_UART_STATE_TXBF_Pos 0 /* CMSDK_UART STATE: TXBF Position */
|
||||
#define CMSDK_UART_STATE_TXBF_Msk (0x1UL /*<< CMSDK_UART_STATE_TXBF_Pos*/) /* CMSDK_UART STATE: TXBF Mask */
|
||||
|
||||
/* CMSDK_UART CTRL Register Definitions */
|
||||
#define CMSDK_UART_CTRL_HSTM_Pos 6 /* CMSDK_UART CTRL: HSTM Position */
|
||||
#define CMSDK_UART_CTRL_HSTM_Msk (0x01UL << CMSDK_UART_CTRL_HSTM_Pos) /* CMSDK_UART CTRL: HSTM Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_RXORIRQEN_Pos 5 /* CMSDK_UART CTRL: RXORIRQEN Position */
|
||||
#define CMSDK_UART_CTRL_RXORIRQEN_Msk (0x01UL << CMSDK_UART_CTRL_RXORIRQEN_Pos) /* CMSDK_UART CTRL: RXORIRQEN Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_TXORIRQEN_Pos 4 /* CMSDK_UART CTRL: TXORIRQEN Position */
|
||||
#define CMSDK_UART_CTRL_TXORIRQEN_Msk (0x01UL << CMSDK_UART_CTRL_TXORIRQEN_Pos) /* CMSDK_UART CTRL: TXORIRQEN Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_RXIRQEN_Pos 3 /* CMSDK_UART CTRL: RXIRQEN Position */
|
||||
#define CMSDK_UART_CTRL_RXIRQEN_Msk (0x01UL << CMSDK_UART_CTRL_RXIRQEN_Pos) /* CMSDK_UART CTRL: RXIRQEN Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_TXIRQEN_Pos 2 /* CMSDK_UART CTRL: TXIRQEN Position */
|
||||
#define CMSDK_UART_CTRL_TXIRQEN_Msk (0x01UL << CMSDK_UART_CTRL_TXIRQEN_Pos) /* CMSDK_UART CTRL: TXIRQEN Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_RXEN_Pos 1 /* CMSDK_UART CTRL: RXEN Position */
|
||||
#define CMSDK_UART_CTRL_RXEN_Msk (0x01UL << CMSDK_UART_CTRL_RXEN_Pos) /* CMSDK_UART CTRL: RXEN Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_TXEN_Pos 0 /* CMSDK_UART CTRL: TXEN Position */
|
||||
#define CMSDK_UART_CTRL_TXEN_Msk (0x01UL /*<< CMSDK_UART_CTRL_TXEN_Pos*/) /* CMSDK_UART CTRL: TXEN Mask */
|
||||
|
||||
#define CMSDK_UART_INTSTATUS_RXORIRQ_Pos 3 /* CMSDK_UART CTRL: RXORIRQ Position */
|
||||
#define CMSDK_UART_CTRL_RXORIRQ_Msk (0x01UL << CMSDK_UART_INTSTATUS_RXORIRQ_Pos) /* CMSDK_UART CTRL: RXORIRQ Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_TXORIRQ_Pos 2 /* CMSDK_UART CTRL: TXORIRQ Position */
|
||||
#define CMSDK_UART_CTRL_TXORIRQ_Msk (0x01UL << CMSDK_UART_CTRL_TXORIRQ_Pos) /* CMSDK_UART CTRL: TXORIRQ Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_RXIRQ_Pos 1 /* CMSDK_UART CTRL: RXIRQ Position */
|
||||
#define CMSDK_UART_CTRL_RXIRQ_Msk (0x01UL << CMSDK_UART_CTRL_RXIRQ_Pos) /* CMSDK_UART CTRL: RXIRQ Mask */
|
||||
|
||||
#define CMSDK_UART_CTRL_TXIRQ_Pos 0 /* CMSDK_UART CTRL: TXIRQ Position */
|
||||
#define CMSDK_UART_CTRL_TXIRQ_Msk (0x01UL /*<< CMSDK_UART_CTRL_TXIRQ_Pos*/) /* CMSDK_UART CTRL: TXIRQ Mask */
|
||||
|
||||
/* CMSDK_UART BAUDDIV Register Definitions */
|
||||
#define CMSDK_UART_BAUDDIV_Pos 0 /* CMSDK_UART BAUDDIV: BAUDDIV Position */
|
||||
#define CMSDK_UART_BAUDDIV_Msk (0xFFFFFUL /*<< CMSDK_UART_BAUDDIV_Pos*/) /* CMSDK_UART BAUDDIV: BAUDDIV Mask */
|
||||
|
||||
|
||||
/*----------------------------- Timer (TIMER) -------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t CTRL; /* Offset: 0x000 (R/W) Control Register */
|
||||
__IOM uint32_t VALUE; /* Offset: 0x004 (R/W) Current Value Register */
|
||||
__IOM uint32_t RELOAD; /* Offset: 0x008 (R/W) Reload Value Register */
|
||||
union {
|
||||
__IM uint32_t INTSTATUS; /* Offset: 0x00C (R/ ) Interrupt Status Register */
|
||||
__OM uint32_t INTCLEAR; /* Offset: 0x00C ( /W) Interrupt Clear Register */
|
||||
};
|
||||
|
||||
} CMSDK_TIMER_TypeDef;
|
||||
|
||||
/* CMSDK_TIMER CTRL Register Definitions */
|
||||
#define CMSDK_TIMER_CTRL_IRQEN_Pos 3 /* CMSDK_TIMER CTRL: IRQEN Position */
|
||||
#define CMSDK_TIMER_CTRL_IRQEN_Msk (0x01UL << CMSDK_TIMER_CTRL_IRQEN_Pos) /* CMSDK_TIMER CTRL: IRQEN Mask */
|
||||
|
||||
#define CMSDK_TIMER_CTRL_SELEXTCLK_Pos 2 /* CMSDK_TIMER CTRL: SELEXTCLK Position */
|
||||
#define CMSDK_TIMER_CTRL_SELEXTCLK_Msk (0x01UL << CMSDK_TIMER_CTRL_SELEXTCLK_Pos) /* CMSDK_TIMER CTRL: SELEXTCLK Mask */
|
||||
|
||||
#define CMSDK_TIMER_CTRL_SELEXTEN_Pos 1 /* CMSDK_TIMER CTRL: SELEXTEN Position */
|
||||
#define CMSDK_TIMER_CTRL_SELEXTEN_Msk (0x01UL << CMSDK_TIMER_CTRL_SELEXTEN_Pos) /* CMSDK_TIMER CTRL: SELEXTEN Mask */
|
||||
|
||||
#define CMSDK_TIMER_CTRL_EN_Pos 0 /* CMSDK_TIMER CTRL: EN Position */
|
||||
#define CMSDK_TIMER_CTRL_EN_Msk (0x01UL /*<< CMSDK_TIMER_CTRL_EN_Pos*/) /* CMSDK_TIMER CTRL: EN Mask */
|
||||
|
||||
/* CMSDK_TIMER VAL Register Definitions */
|
||||
#define CMSDK_TIMER_VAL_CURRENT_Pos 0 /* CMSDK_TIMER VALUE: CURRENT Position */
|
||||
#define CMSDK_TIMER_VAL_CURRENT_Msk (0xFFFFFFFFUL /*<< CMSDK_TIMER_VAL_CURRENT_Pos*/) /* CMSDK_TIMER VALUE: CURRENT Mask */
|
||||
|
||||
/* CMSDK_TIMER RELOAD Register Definitions */
|
||||
#define CMSDK_TIMER_RELOAD_VAL_Pos 0 /* CMSDK_TIMER RELOAD: RELOAD Position */
|
||||
#define CMSDK_TIMER_RELOAD_VAL_Msk (0xFFFFFFFFUL /*<< CMSDK_TIMER_RELOAD_VAL_Pos*/) /* CMSDK_TIMER RELOAD: RELOAD Mask */
|
||||
|
||||
/* CMSDK_TIMER INTSTATUS Register Definitions */
|
||||
#define CMSDK_TIMER_INTSTATUS_Pos 0 /* CMSDK_TIMER INTSTATUS: INTSTATUSPosition */
|
||||
#define CMSDK_TIMER_INTSTATUS_Msk (0x01UL /*<< CMSDK_TIMER_INTSTATUS_Pos*/) /* CMSDK_TIMER INTSTATUS: INTSTATUSMask */
|
||||
|
||||
/* CMSDK_TIMER INTCLEAR Register Definitions */
|
||||
#define CMSDK_TIMER_INTCLEAR_Pos 0 /* CMSDK_TIMER INTCLEAR: INTCLEAR Position */
|
||||
#define CMSDK_TIMER_INTCLEAR_Msk (0x01UL /*<< CMSDK_TIMER_INTCLEAR_Pos*/) /* CMSDK_TIMER INTCLEAR: INTCLEAR Mask */
|
||||
|
||||
|
||||
/*------------- Timer (TIM) --------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t T1LOAD; /* Offset: 0x000 (R/W) Timer 1 Load */
|
||||
__IM uint32_t T1VALUE; /* Offset: 0x004 (R/ ) Timer 1 Counter Current Value */
|
||||
__IOM uint32_t T1CTRL; /* Offset: 0x008 (R/W) Timer 1 Control */
|
||||
__OM uint32_t T1INTCLR; /* Offset: 0x00C ( /W) Timer 1 Interrupt Clear */
|
||||
__IM uint32_t T1RIS; /* Offset: 0x010 (R/ ) Timer 1 Raw Interrupt Status */
|
||||
__IM uint32_t T1MIS; /* Offset: 0x014 (R/ ) Timer 1 Masked Interrupt Status */
|
||||
__IOM uint32_t T1BGLOAD; /* Offset: 0x018 (R/W) Background Load Register */
|
||||
uint32_t RESERVED0;
|
||||
__IOM uint32_t T2LOAD; /* Offset: 0x020 (R/W) Timer 2 Load */
|
||||
__IM uint32_t T2VALUE; /* Offset: 0x024 (R/ ) Timer 2 Counter Current Value */
|
||||
__IOM uint32_t T2CTRL; /* Offset: 0x028 (R/W) Timer 2 Control */
|
||||
__OM uint32_t T2INTCLR; /* Offset: 0x02C ( /W) Timer 2 Interrupt Clear */
|
||||
__IM uint32_t T2RIS; /* Offset: 0x030 (R/ ) Timer 2 Raw Interrupt Status */
|
||||
__IM uint32_t T2MIS; /* Offset: 0x034 (R/ ) Timer 2 Masked Interrupt Status */
|
||||
__IOM uint32_t T2BGLOAD; /* Offset: 0x038 (R/W) Background Load Register */
|
||||
uint32_t RESERVED1[945];
|
||||
__IOM uint32_t ITCR; /* Offset: 0xF00 (R/W) Integration Test Control Register */
|
||||
__OM uint32_t ITOP; /* Offset: 0xF04 ( /W) Integration Test Output Set Register */
|
||||
} CMSDK_DUALTIMER_BOTH_TypeDef;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t LOAD; /* Offset: 0x000 (R/W) Timer Load */
|
||||
__IM uint32_t VALUE; /* Offset: 0x000 (R/W) Timer Counter Current Value */
|
||||
__IOM uint32_t CTRL; /* Offset: 0x000 (R/W) Timer Control */
|
||||
__OM uint32_t INTCLR; /* Offset: 0x000 (R/W) Timer Interrupt Clear */
|
||||
__IM uint32_t RIS; /* Offset: 0x000 (R/W) Timer Raw Interrupt Status */
|
||||
__IM uint32_t MIS; /* Offset: 0x000 (R/W) Timer Masked Interrupt Status */
|
||||
__IOM uint32_t BGLOAD; /* Offset: 0x000 (R/W) Background Load Register */
|
||||
} CMSDK_DUALTIMER_SINGLE_TypeDef;
|
||||
|
||||
/* CMSDK_DUALTIMER_SINGLE LOAD Register Definitions */
|
||||
#define CMSDK_DUALTIMER_LOAD_Pos 0 /* CMSDK_DUALTIMER LOAD: LOAD Position */
|
||||
#define CMSDK_DUALTIMER_LOAD_Msk (0xFFFFFFFFUL /*<< CMSDK_DUALTIMER_LOAD_Pos*/) /* CMSDK_DUALTIMER LOAD: LOAD Mask */
|
||||
|
||||
/* CMSDK_DUALTIMER_SINGLE VALUE Register Definitions */
|
||||
#define CMSDK_DUALTIMER_VALUE_Pos 0 /* CMSDK_DUALTIMER VALUE: VALUE Position */
|
||||
#define CMSDK_DUALTIMER_VALUE_Msk (0xFFFFFFFFUL /*<< CMSDK_DUALTIMER_VALUE_Pos*/) /* CMSDK_DUALTIMER VALUE: VALUE Mask */
|
||||
|
||||
/* CMSDK_DUALTIMER_SINGLE CTRL Register Definitions */
|
||||
#define CMSDK_DUALTIMER_CTRL_EN_Pos 7 /* CMSDK_DUALTIMER CTRL_EN: CTRL Enable Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_EN_Msk (0x1UL << CMSDK_DUALTIMER_CTRL_EN_Pos) /* CMSDK_DUALTIMER CTRL_EN: CTRL Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_MODE_Pos 6 /* CMSDK_DUALTIMER CTRL_MODE: CTRL MODE Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_MODE_Msk (0x1UL << CMSDK_DUALTIMER_CTRL_MODE_Pos) /* CMSDK_DUALTIMER CTRL_MODE: CTRL MODE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_INTEN_Pos 5 /* CMSDK_DUALTIMER CTRL_INTEN: CTRL Int Enable Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_INTEN_Msk (0x1UL << CMSDK_DUALTIMER_CTRL_INTEN_Pos) /* CMSDK_DUALTIMER CTRL_INTEN: CTRL Int Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_PRESCALE_Pos 2 /* CMSDK_DUALTIMER CTRL_PRESCALE: CTRL PRESCALE Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_PRESCALE_Msk (0x3UL << CMSDK_DUALTIMER_CTRL_PRESCALE_Pos) /* CMSDK_DUALTIMER CTRL_PRESCALE: CTRL PRESCALE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_SIZE_Pos 1 /* CMSDK_DUALTIMER CTRL_SIZE: CTRL SIZE Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_SIZE_Msk (0x1UL << CMSDK_DUALTIMER_CTRL_SIZE_Pos) /* CMSDK_DUALTIMER CTRL_SIZE: CTRL SIZE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_ONESHOOT_Pos 0 /* CMSDK_DUALTIMER CTRL_ONESHOOT: CTRL ONESHOOT Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_ONESHOOT_Msk (0x1UL /*<< CMSDK_DUALTIMER_CTRL_ONESHOOT_Pos*/) /* CMSDK_DUALTIMER CTRL_ONESHOOT: CTRL ONESHOOT Mask */
|
||||
|
||||
/* CMSDK_DUALTIMER_SINGLE INTCLR Register Definitions */
|
||||
#define CMSDK_DUALTIMER_INTCLR_Pos 0 /* CMSDK_DUALTIMER INTCLR: INT Clear Position */
|
||||
#define CMSDK_DUALTIMER_INTCLR_Msk (0x1UL /*<< CMSDK_DUALTIMER_INTCLR_Pos*/) /* CMSDK_DUALTIMER INTCLR: INT Clear Mask */
|
||||
|
||||
/* CMSDK_DUALTIMER_SINGLE RIS Register Definitions */
|
||||
#define CMSDK_DUALTIMER_RIS_Pos 0 /* CMSDK_DUALTIMER RAWINTSTAT: Raw Int Status Position */
|
||||
#define CMSDK_DUALTIMER_RIS_Msk (0x1UL /*<< CMSDK_DUALTIMER_RAWINTSTAT_Pos*/) /* CMSDK_DUALTIMER RAWINTSTAT: Raw Int Status Mask */
|
||||
|
||||
/* CMSDK_DUALTIMER_SINGLE MIS Register Definitions */
|
||||
#define CMSDK_DUALTIMER_MIS_Pos 0 /* CMSDK_DUALTIMER MASKINTSTAT: Mask Int Status Position */
|
||||
#define CMSDK_DUALTIMER_MIS_Msk (0x1UL /*<< CMSDK_DUALTIMER_MASKINTSTAT_Pos*/) /* CMSDK_DUALTIMER MASKINTSTAT: Mask Int Status Mask */
|
||||
|
||||
/* CMSDK_DUALTIMER_SINGLE BGLOAD Register Definitions */
|
||||
#define CMSDK_DUALTIMER_BGLOAD_Pos 0 /* CMSDK_DUALTIMER BGLOAD: Background Load Position */
|
||||
#define CMSDK_DUALTIMER_BGLOAD_Msk (0xFFFFFFFFUL /*<< CMSDK_DUALTIMER_BGLOAD_Pos*/) /* CMSDK_DUALTIMER BGLOAD: Background Load Mask */
|
||||
|
||||
|
||||
/*-------------------- General Purpose Input Output (GPIO) -------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t DATA; /* Offset: 0x000 (R/W) DATA Register */
|
||||
__IOM uint32_t DATAOUT; /* Offset: 0x004 (R/W) Data Output Latch Register */
|
||||
uint32_t RESERVED0[2];
|
||||
__IOM uint32_t OUTENSET; /* Offset: 0x010 (R/W) Output Enable Set Register */
|
||||
__IOM uint32_t OUTENCLR; /* Offset: 0x014 (R/W) Output Enable Clear Register */
|
||||
__IOM uint32_t ALTFUNCSET; /* Offset: 0x018 (R/W) Alternate Function Set Register */
|
||||
__IOM uint32_t ALTFUNCCLR; /* Offset: 0x01C (R/W) Alternate Function Clear Register */
|
||||
__IOM uint32_t INTENSET; /* Offset: 0x020 (R/W) Interrupt Enable Set Register */
|
||||
__IOM uint32_t INTENCLR; /* Offset: 0x024 (R/W) Interrupt Enable Clear Register */
|
||||
__IOM uint32_t INTTYPESET; /* Offset: 0x028 (R/W) Interrupt Type Set Register */
|
||||
__IOM uint32_t INTTYPECLR; /* Offset: 0x02C (R/W) Interrupt Type Clear Register */
|
||||
__IOM uint32_t INTPOLSET; /* Offset: 0x030 (R/W) Interrupt Polarity Set Register */
|
||||
__IOM uint32_t INTPOLCLR; /* Offset: 0x034 (R/W) Interrupt Polarity Clear Register */
|
||||
union {
|
||||
__IM uint32_t INTSTATUS; /* Offset: 0x038 (R/ ) Interrupt Status Register */
|
||||
__OM uint32_t INTCLEAR; /* Offset: 0x038 ( /W) Interrupt Clear Register */
|
||||
};
|
||||
uint32_t RESERVED1[241];
|
||||
__IOM uint32_t LB_MASKED[256]; /* Offset: 0x400 - 0x7FC Lower byte Masked Access Register (R/W) */
|
||||
__IOM uint32_t UB_MASKED[256]; /* Offset: 0x800 - 0xBFC Upper byte Masked Access Register (R/W) */
|
||||
} CMSDK_GPIO_TypeDef;
|
||||
|
||||
/* CMSDK_GPIO DATA Register Definitions */
|
||||
#define CMSDK_GPIO_DATA_Pos 0 /* CMSDK_GPIO DATA: DATA Position */
|
||||
#define CMSDK_GPIO_DATA_Msk (0xFFFFUL /*<< CMSDK_GPIO_DATA_Pos*/) /* CMSDK_GPIO DATA: DATA Mask */
|
||||
|
||||
/* CMSDK_GPIO DATAOUT Register Definitions */
|
||||
#define CMSDK_GPIO_DATAOUT_Pos 0 /* CMSDK_GPIO DATAOUT: DATAOUT Position */
|
||||
#define CMSDK_GPIO_DATAOUT_Msk (0xFFFFUL /*<< CMSDK_GPIO_DATAOUT_Pos*/) /* CMSDK_GPIO DATAOUT: DATAOUT Mask */
|
||||
|
||||
/* CMSDK_GPIO OUTENSET Register Definitions */
|
||||
#define CMSDK_GPIO_OUTENSET_Pos 0 /* CMSDK_GPIO OUTEN: OUTEN Position */
|
||||
#define CMSDK_GPIO_OUTENSET_Msk (0xFFFFUL /*<< CMSDK_GPIO_OUTEN_Pos*/) /* CMSDK_GPIO OUTEN: OUTEN Mask */
|
||||
|
||||
/* CMSDK_GPIO OUTENCLR Register Definitions */
|
||||
#define CMSDK_GPIO_OUTENCLR_Pos 0 /* CMSDK_GPIO OUTEN: OUTEN Position */
|
||||
#define CMSDK_GPIO_OUTENCLR_Msk (0xFFFFUL /*<< CMSDK_GPIO_OUTEN_Pos*/) /* CMSDK_GPIO OUTEN: OUTEN Mask */
|
||||
|
||||
/* CMSDK_GPIO ALTFUNCSET Register Definitions */
|
||||
#define CMSDK_GPIO_ALTFUNCSET_Pos 0 /* CMSDK_GPIO ALTFUNC: ALTFUNC Position */
|
||||
#define CMSDK_GPIO_ALTFUNCSET_Msk (0xFFFFUL /*<< CMSDK_GPIO_ALTFUNC_Pos*/) /* CMSDK_GPIO ALTFUNC: ALTFUNC Mask */
|
||||
|
||||
/* CMSDK_GPIO ALTFUNCCLR Register Definitions */
|
||||
#define CMSDK_GPIO_ALTFUNCCLR_Pos 0 /* CMSDK_GPIO ALTFUNC: ALTFUNC Position */
|
||||
#define CMSDK_GPIO_ALTFUNCCLR_Msk (0xFFFFUL /*<< CMSDK_GPIO_ALTFUNC_Pos*/) /* CMSDK_GPIO ALTFUNC: ALTFUNC Mask */
|
||||
|
||||
/* CMSDK_GPIO INTENSET Register Definitions */
|
||||
#define CMSDK_GPIO_INTENSET_Pos 0 /* CMSDK_GPIO INTEN: INTEN Position */
|
||||
#define CMSDK_GPIO_INTENSET_Msk (0xFFFFUL /*<< CMSDK_GPIO_INTEN_Pos*/) /* CMSDK_GPIO INTEN: INTEN Mask */
|
||||
|
||||
/* CMSDK_GPIO INTENCLR Register Definitions */
|
||||
#define CMSDK_GPIO_INTENCLR_Pos 0 /* CMSDK_GPIO INTEN: INTEN Position */
|
||||
#define CMSDK_GPIO_INTENCLR_Msk (0xFFFFUL /*<< CMSDK_GPIO_INTEN_Pos*/) /* CMSDK_GPIO INTEN: INTEN Mask */
|
||||
|
||||
/* CMSDK_GPIO INTTYPESET Register Definitions */
|
||||
#define CMSDK_GPIO_INTTYPESET_Pos 0 /* CMSDK_GPIO INTTYPE: INTTYPE Position */
|
||||
#define CMSDK_GPIO_INTTYPESET_Msk (0xFFFFUL /*<< CMSDK_GPIO_INTTYPE_Pos*/) /* CMSDK_GPIO INTTYPE: INTTYPE Mask */
|
||||
|
||||
/* CMSDK_GPIO INTTYPECLR Register Definitions */
|
||||
#define CMSDK_GPIO_INTTYPECLR_Pos 0 /* CMSDK_GPIO INTTYPE: INTTYPE Position */
|
||||
#define CMSDK_GPIO_INTTYPECLR_Msk (0xFFFFUL /*<< CMSDK_GPIO_INTTYPE_Pos*/) /* CMSDK_GPIO INTTYPE: INTTYPE Mask */
|
||||
|
||||
/* CMSDK_GPIO INTPOLSET Register Definitions */
|
||||
#define CMSDK_GPIO_INTPOLSET_Pos 0 /* CMSDK_GPIO INTPOL: INTPOL Position */
|
||||
#define CMSDK_GPIO_INTPOLSET_Msk (0xFFFFUL /*<< CMSDK_GPIO_INTPOL_Pos*/) /* CMSDK_GPIO INTPOL: INTPOL Mask */
|
||||
|
||||
/* CMSDK_GPIO INTPOLCLR Register Definitions */
|
||||
#define CMSDK_GPIO_INTPOLCLR_Pos 0 /* CMSDK_GPIO INTPOL: INTPOL Position */
|
||||
#define CMSDK_GPIO_INTPOLCLR_Msk (0xFFFFUL /*<< CMSDK_GPIO_INTPOL_Pos*/) /* CMSDK_GPIO INTPOL: INTPOL Mask */
|
||||
|
||||
/* CMSDK_GPIO INTCLEAR Register Definitions */
|
||||
#define CMSDK_GPIO_INTSTATUS_Pos 0 /* CMSDK_GPIO INTSTATUS: INTSTATUS Position */
|
||||
#define CMSDK_GPIO_INTCLEAR_Msk (0xFFUL /*<< CMSDK_GPIO_INTSTATUS_Pos*/) /* CMSDK_GPIO INTSTATUS: INTSTATUS Mask */
|
||||
|
||||
/* CMSDK_GPIO INTCLEAR Register Definitions */
|
||||
#define CMSDK_GPIO_INTCLEAR_Pos 0 /* CMSDK_GPIO INTCLEAR: INTCLEAR Position */
|
||||
#define CMSDK_GPIO_INTCLEAR_Msk (0xFFUL /*<< CMSDK_GPIO_INTCLEAR_Pos*/) /* CMSDK_GPIO INTCLEAR: INTCLEAR Mask */
|
||||
|
||||
/* CMSDK_GPIO MASKLOWBYTE Register Definitions */
|
||||
#define CMSDK_GPIO_MASKLOWBYTE_Pos 0 /* CMSDK_GPIO MASKLOWBYTE: MASKLOWBYTE Position */
|
||||
#define CMSDK_GPIO_MASKLOWBYTE_Msk (0x00FFUL /*<< CMSDK_GPIO_MASKLOWBYTE_Pos*/) /* CMSDK_GPIO MASKLOWBYTE: MASKLOWBYTE Mask */
|
||||
|
||||
/* CMSDK_GPIO MASKHIGHBYTE Register Definitions */
|
||||
#define CMSDK_GPIO_MASKHIGHBYTE_Pos 0 /* CMSDK_GPIO MASKHIGHBYTE: MASKHIGHBYTE Position */
|
||||
#define CMSDK_GPIO_MASKHIGHBYTE_Msk (0xFF00UL /*<< CMSDK_GPIO_MASKHIGHBYTE_Pos*/) /* CMSDK_GPIO MASKHIGHBYTE: MASKHIGHBYTE Mask */
|
||||
|
||||
|
||||
/*------------- System Control (SYSCON) --------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t REMAP; /* Offset: 0x000 (R/W) Remap Control Register */
|
||||
__IOM uint32_t PMUCTRL; /* Offset: 0x004 (R/W) PMU Control Register */
|
||||
__IOM uint32_t RESETOP; /* Offset: 0x008 (R/W) Reset Option Register */
|
||||
__IOM uint32_t EMICTRL; /* Offset: 0x00C (R/W) EMI Control Register */
|
||||
__IOM uint32_t RSTINFO; /* Offset: 0x010 (R/W) Reset Information Register */
|
||||
} CMSDK_SYSCON_TypeDef;
|
||||
|
||||
/* CMSDK_SYSCON REMAP Register Definitions */
|
||||
#define CMSDK_SYSCON_REMAP_Pos 0
|
||||
#define CMSDK_SYSCON_REMAP_Msk (0x1UL /*<< CMSDK_SYSCON_REMAP_Pos*/) /* CMSDK_SYSCON MEME_CTRL: REMAP Mask */
|
||||
|
||||
/* CMSDK_SYSCON PMUCTRL Register Definitions */
|
||||
#define CMSDK_SYSCON_PMUCTRL_EN_Pos 0
|
||||
#define CMSDK_SYSCON_PMUCTRL_EN_Msk (0x1UL /*<< CMSDK_SYSCON_PMUCTRL_EN_Pos*/) /* CMSDK_SYSCON PMUCTRL: PMUCTRL ENABLE Mask */
|
||||
|
||||
/* CMSDK_SYSCON LOCKUPRST Register Definitions */
|
||||
#define CMSDK_SYSCON_LOCKUPRST_RESETOP_Pos 0
|
||||
#define CMSDK_SYSCON_LOCKUPRST_RESETOP_Msk (0x1UL /*<< CMSDK_SYSCON_LOCKUPRST_RESETOP_Pos*/) /* CMSDK_SYSCON SYS_CTRL: LOCKUP RESET ENABLE Mask */
|
||||
|
||||
/* CMSDK_SYSCON EMICTRL Register Definitions */
|
||||
#define CMSDK_SYSCON_EMICTRL_SIZE_Pos 24
|
||||
#define CMSDK_SYSCON_EMICTRL_SIZE_Msk (0x1UL << CMSDK_SYSCON_EMICTRL_SIZE_Pos) /* CMSDK_SYSCON EMICTRL: SIZE Mask */
|
||||
|
||||
#define CMSDK_SYSCON_EMICTRL_TACYC_Pos 16
|
||||
#define CMSDK_SYSCON_EMICTRL_TACYC_Msk (0x7UL << CMSDK_SYSCON_EMICTRL_TACYC_Pos) /* CMSDK_SYSCON EMICTRL: TURNAROUNDCYCLE Mask */
|
||||
|
||||
#define CMSDK_SYSCON_EMICTRL_WCYC_Pos 8
|
||||
#define CMSDK_SYSCON_EMICTRL_WCYC_Msk (0x3UL << CMSDK_SYSCON_EMICTRL_WCYC_Pos) /* CMSDK_SYSCON EMICTRL: WRITECYCLE Mask */
|
||||
|
||||
#define CMSDK_SYSCON_EMICTRL_RCYC_Pos 0
|
||||
#define CMSDK_SYSCON_EMICTRL_RCYC_Msk (0x7UL /*<< CMSDK_SYSCON_EMICTRL_RCYC_Pos*/) /* CMSDK_SYSCON EMICTRL: READCYCLE Mask */
|
||||
|
||||
/* CMSDK_SYSCON RSTINFO Register Definitions */
|
||||
#define CMSDK_SYSCON_RSTINFO_LOCKUPRESET_Pos 2
|
||||
#define CMSDK_SYSCON_RSTINFO_LOCKUPRESET_Msk (0x1UL << CMSDK_SYSCON_RSTINFO_LOCKUPRESET_Pos) /* CMSDK_SYSCON RSTINFO: LOCKUPRESET Mask */
|
||||
|
||||
#define CMSDK_SYSCON_RSTINFO_WDOGRESETREQ_Pos 1
|
||||
#define CMSDK_SYSCON_RSTINFO_WDOGRESETREQ_Msk (0x1UL << CMSDK_SYSCON_RSTINFO_WDOGRESETREQ_Pos) /* CMSDK_SYSCON RSTINFO: WDOGRESETREQ Mask */
|
||||
|
||||
#define CMSDK_SYSCON_RSTINFO_SYSRESETREQ_Pos 0
|
||||
#define CMSDK_SYSCON_RSTINFO_SYSRESETREQ_Msk (0x1UL /*<< CMSDK_SYSCON_RSTINFO_SYSRESETREQ_Pos*/) /* CMSDK_SYSCON RSTINFO: SYSRESETREQ Mask */
|
||||
|
||||
|
||||
/*------------------- Watchdog ----------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
__IOM uint32_t LOAD; /* Offset: 0x000 (R/W) Watchdog Load Register */
|
||||
__IM uint32_t VALUE; /* Offset: 0x004 (R/ ) Watchdog Value Register */
|
||||
__IOM uint32_t CTRL; /* Offset: 0x008 (R/W) Watchdog Control Register */
|
||||
__OM uint32_t INTCLR; /* Offset: 0x00C ( /W) Watchdog Clear Interrupt Register */
|
||||
__IM uint32_t RAWINTSTAT; /* Offset: 0x010 (R/ ) Watchdog Raw Interrupt Status Register */
|
||||
__IM uint32_t MASKINTSTAT; /* Offset: 0x014 (R/ ) Watchdog Interrupt Status Register */
|
||||
uint32_t RESERVED0[762];
|
||||
__IOM uint32_t LOCK; /* Offset: 0xC00 (R/W) Watchdog Lock Register */
|
||||
uint32_t RESERVED1[191];
|
||||
__IOM uint32_t ITCR; /* Offset: 0xF00 (R/W) Watchdog Integration Test Control Register */
|
||||
__OM uint32_t ITOP; /* Offset: 0xF04 ( /W) Watchdog Integration Test Output Set Register */
|
||||
}CMSDK_WATCHDOG_TypeDef;
|
||||
|
||||
/* CMSDK_WATCHDOG LOAD Register Definitions */
|
||||
#define CMSDK_Watchdog_LOAD_Pos 0 /* CMSDK_Watchdog LOAD: LOAD Position */
|
||||
#define CMSDK_Watchdog_LOAD_Msk (0xFFFFFFFFUL /*<< CMSDK_Watchdog_LOAD_Pos*/) /* CMSDK_Watchdog LOAD: LOAD Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG VALUE Register Definitions */
|
||||
#define CMSDK_Watchdog_VALUE_Pos 0 /* CMSDK_Watchdog VALUE: VALUE Position */
|
||||
#define CMSDK_Watchdog_VALUE_Msk (0xFFFFFFFFUL /*<< CMSDK_Watchdog_VALUE_Pos*/) /* CMSDK_Watchdog VALUE: VALUE Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG CTRL Register Definitions */
|
||||
#define CMSDK_Watchdog_CTRL_RESEN_Pos 1 /* CMSDK_Watchdog CTRL_RESEN: Enable Reset Output Position */
|
||||
#define CMSDK_Watchdog_CTRL_RESEN_Msk (0x1UL << CMSDK_Watchdog_CTRL_RESEN_Pos) /* CMSDK_Watchdog CTRL_RESEN: Enable Reset Output Mask */
|
||||
|
||||
#define CMSDK_Watchdog_CTRL_INTEN_Pos 0 /* CMSDK_Watchdog CTRL_INTEN: Int Enable Position */
|
||||
#define CMSDK_Watchdog_CTRL_INTEN_Msk (0x1UL /*<< CMSDK_Watchdog_CTRL_INTEN_Pos*/) /* CMSDK_Watchdog CTRL_INTEN: Int Enable Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG INTCLR Register Definitions */
|
||||
#define CMSDK_Watchdog_INTCLR_Pos 0 /* CMSDK_Watchdog INTCLR: Int Clear Position */
|
||||
#define CMSDK_Watchdog_INTCLR_Msk (0x1UL /*<< CMSDK_Watchdog_INTCLR_Pos*/) /* CMSDK_Watchdog INTCLR: Int Clear Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG RAWINTSTAT Register Definitions */
|
||||
#define CMSDK_Watchdog_RAWINTSTAT_Pos 0 /* CMSDK_Watchdog RAWINTSTAT: Raw Int Status Position */
|
||||
#define CMSDK_Watchdog_RAWINTSTAT_Msk (0x1UL /*<< CMSDK_Watchdog_RAWINTSTAT_Pos*/) /* CMSDK_Watchdog RAWINTSTAT: Raw Int Status Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG MASKINTSTAT Register Definitions */
|
||||
#define CMSDK_Watchdog_MASKINTSTAT_Pos 0 /* CMSDK_Watchdog MASKINTSTAT: Mask Int Status Position */
|
||||
#define CMSDK_Watchdog_MASKINTSTAT_Msk (0x1UL /*<< CMSDK_Watchdog_MASKINTSTAT_Pos*/) /* CMSDK_Watchdog MASKINTSTAT: Mask Int Status Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG LOCK Register Definitions */
|
||||
#define CMSDK_Watchdog_LOCK_Pos 0 /* CMSDK_Watchdog LOCK: LOCK Position */
|
||||
#define CMSDK_Watchdog_LOCK_Msk (0x1UL /*<< CMSDK_Watchdog_LOCK_Pos*/) /* CMSDK_Watchdog LOCK: LOCK Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG INTEGTESTEN Register Definitions */
|
||||
#define CMSDK_Watchdog_INTEGTESTEN_Pos 0 /* CMSDK_Watchdog INTEGTESTEN: Integration Test Enable Position */
|
||||
#define CMSDK_Watchdog_INTEGTESTEN_Msk (0x1UL /*<< CMSDK_Watchdog_INTEGTESTEN_Pos*/) /* CMSDK_Watchdog INTEGTESTEN: Integration Test Enable Mask */
|
||||
|
||||
/* CMSDK_WATCHDOG INTEGTESTOUTSET Register Definitions */
|
||||
#define CMSDK_Watchdog_INTEGTESTOUTSET_Pos 1 /* CMSDK_Watchdog INTEGTESTOUTSET: Integration Test Output Set Position */
|
||||
#define CMSDK_Watchdog_INTEGTESTOUTSET_Msk (0x1UL /*<< CMSDK_Watchdog_INTEGTESTOUTSET_Pos*/) /* CMSDK_Watchdog INTEGTESTOUTSET: Integration Test Output Set Mask */
|
||||
|
||||
|
||||
|
||||
/* -------------------- End of section using anonymous unions ------------------- */
|
||||
#if defined (__CC_ARM)
|
||||
#pragma pop
|
||||
#elif defined (__ICCARM__)
|
||||
/* leave anonymous unions enabled */
|
||||
#elif (__ARMCC_VERSION >= 6010050)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined (__GNUC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TMS470__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TASKING__)
|
||||
#pragma warning restore
|
||||
#elif defined (__CSMC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#else
|
||||
#warning Not supported compiler type
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ Peripheral memory map ================ */
|
||||
/* ================================================================================ */
|
||||
|
||||
/* Peripheral and SRAM base address */
|
||||
#define CMSDK_FLASH_BASE (0x00000000UL)
|
||||
#define CMSDK_SRAM_BASE (0x20000000UL)
|
||||
#define CMSDK_PERIPH_BASE (0x40000000UL)
|
||||
|
||||
#define CMSDK_RAM_BASE (0x20000000UL)
|
||||
#define CMSDK_APB_BASE (0x40000000UL)
|
||||
#define CMSDK_AHB_BASE (0x40010000UL)
|
||||
|
||||
/* APB peripherals */
|
||||
#define CMSDK_TIMER0_BASE (CMSDK_APB_BASE + 0x0000UL)
|
||||
#define CMSDK_TIMER1_BASE (CMSDK_APB_BASE + 0x1000UL)
|
||||
#define CMSDK_DUALTIMER_BASE (CMSDK_APB_BASE + 0x2000UL)
|
||||
#define CMSDK_DUALTIMER_1_BASE (CMSDK_DUALTIMER_BASE)
|
||||
#define CMSDK_DUALTIMER_2_BASE (CMSDK_DUALTIMER_BASE + 0x20UL)
|
||||
#define CMSDK_UART0_BASE (CMSDK_APB_BASE + 0x4000UL)
|
||||
#define CMSDK_UART1_BASE (CMSDK_APB_BASE + 0x5000UL)
|
||||
#define CMSDK_UART2_BASE (CMSDK_APB_BASE + 0x6000UL)
|
||||
#define CMSDK_WATCHDOG_BASE (CMSDK_APB_BASE + 0x8000UL)
|
||||
|
||||
/* AHB peripherals */
|
||||
#define CMSDK_GPIO0_BASE (CMSDK_AHB_BASE + 0x0000UL)
|
||||
#define CMSDK_GPIO1_BASE (CMSDK_AHB_BASE + 0x1000UL)
|
||||
#define CMSDK_SYSCTRL_BASE (CMSDK_AHB_BASE + 0xF000UL)
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ Peripheral declaration ================ */
|
||||
/* ================================================================================ */
|
||||
|
||||
#define CMSDK_UART0 ((CMSDK_UART_TypeDef *) CMSDK_UART0_BASE )
|
||||
#define CMSDK_UART1 ((CMSDK_UART_TypeDef *) CMSDK_UART1_BASE )
|
||||
#define CMSDK_UART2 ((CMSDK_UART_TypeDef *) CMSDK_UART2_BASE )
|
||||
#define CMSDK_TIMER0 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER0_BASE )
|
||||
#define CMSDK_TIMER1 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER1_BASE )
|
||||
#define CMSDK_DUALTIMER ((CMSDK_DUALTIMER_BOTH_TypeDef *) CMSDK_DUALTIMER_BASE )
|
||||
#define CMSDK_DUALTIMER1 ((CMSDK_DUALTIMER_SINGLE_TypeDef *) CMSDK_DUALTIMER_1_BASE )
|
||||
#define CMSDK_DUALTIMER2 ((CMSDK_DUALTIMER_SINGLE_TypeDef *) CMSDK_DUALTIMER_2_BASE )
|
||||
#define CMSDK_WATCHDOG ((CMSDK_WATCHDOG_TypeDef *) CMSDK_WATCHDOG_BASE )
|
||||
#define CMSDK_GPIO0 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO0_BASE )
|
||||
#define CMSDK_GPIO1 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO1_BASE )
|
||||
#define CMSDK_SYSCON ((CMSDK_SYSCON_TypeDef *) CMSDK_SYSCTRL_BASE )
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CMSDK_CM7_SP_H */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Name: Device.h
|
||||
* Purpose: Include the correct device header file
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Copyright (c) 2011 - 2021 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 ARM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __DEVICE_H
|
||||
#define __DEVICE_H
|
||||
|
||||
|
||||
#include "CMSDK_CM7_SP.h" /* device specific header file */
|
||||
|
||||
|
||||
#endif /* __DEVICE_H */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Date: 2. Feb 2017
|
||||
* $Revision: V2.0
|
||||
*
|
||||
* Project: Common Driver definitions
|
||||
*/
|
||||
|
||||
/* History:
|
||||
* Version 2.0
|
||||
* Changed prefix ARM_DRV -> ARM_DRIVER
|
||||
* Added General return codes definitions
|
||||
* Version 1.10
|
||||
* Namespace prefix ARM_ added
|
||||
* Version 1.00
|
||||
* Initial release
|
||||
*/
|
||||
|
||||
#ifndef DRIVER_COMMON_H_
|
||||
#define DRIVER_COMMON_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define ARM_DRIVER_VERSION_MAJOR_MINOR(major,minor) (((major) << 8) | (minor))
|
||||
|
||||
/**
|
||||
\brief Driver Version
|
||||
*/
|
||||
typedef struct _ARM_DRIVER_VERSION {
|
||||
uint16_t api; ///< API version
|
||||
uint16_t drv; ///< Driver version
|
||||
} ARM_DRIVER_VERSION;
|
||||
|
||||
/* General return codes */
|
||||
#define ARM_DRIVER_OK 0 ///< Operation succeeded
|
||||
#define ARM_DRIVER_ERROR -1 ///< Unspecified error
|
||||
#define ARM_DRIVER_ERROR_BUSY -2 ///< Driver is busy
|
||||
#define ARM_DRIVER_ERROR_TIMEOUT -3 ///< Timeout occurred
|
||||
#define ARM_DRIVER_ERROR_UNSUPPORTED -4 ///< Operation not supported
|
||||
#define ARM_DRIVER_ERROR_PARAMETER -5 ///< Parameter error
|
||||
#define ARM_DRIVER_ERROR_SPECIFIC -6 ///< Start of driver specific errors
|
||||
|
||||
/**
|
||||
\brief General power states
|
||||
*/
|
||||
typedef enum _ARM_POWER_STATE {
|
||||
ARM_POWER_OFF, ///< Power off: no operation possible
|
||||
ARM_POWER_LOW, ///< Low Power mode: retain state, detect and signal wake-up events
|
||||
ARM_POWER_FULL ///< Power on: full operation at maximum performance
|
||||
} ARM_POWER_STATE;
|
||||
|
||||
#endif /* DRIVER_COMMON_H_ */
|
||||
@@ -0,0 +1,341 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Date: 2. Feb 2017
|
||||
* $Revision: V2.3
|
||||
*
|
||||
* Project: USART (Universal Synchronous Asynchronous Receiver Transmitter)
|
||||
* Driver definitions
|
||||
*/
|
||||
|
||||
/* History:
|
||||
* Version 2.3
|
||||
* ARM_USART_STATUS and ARM_USART_MODEM_STATUS made volatile
|
||||
* Version 2.2
|
||||
* Corrected ARM_USART_CPOL_Pos and ARM_USART_CPHA_Pos definitions
|
||||
* Version 2.1
|
||||
* Removed optional argument parameter from Signal Event
|
||||
* Version 2.0
|
||||
* New simplified driver:
|
||||
* complexity moved to upper layer (especially data handling)
|
||||
* more unified API for different communication interfaces
|
||||
* renamed driver UART -> USART (Asynchronous & Synchronous)
|
||||
* Added modes:
|
||||
* Synchronous
|
||||
* Single-wire
|
||||
* IrDA
|
||||
* Smart Card
|
||||
* Changed prefix ARM_DRV -> ARM_DRIVER
|
||||
* Version 1.10
|
||||
* Namespace prefix ARM_ added
|
||||
* Version 1.01
|
||||
* Added events:
|
||||
* ARM_UART_EVENT_TX_EMPTY, ARM_UART_EVENT_RX_TIMEOUT
|
||||
* ARM_UART_EVENT_TX_THRESHOLD, ARM_UART_EVENT_RX_THRESHOLD
|
||||
* Added functions: SetTxThreshold, SetRxThreshold
|
||||
* Added "rx_timeout_event" to capabilities
|
||||
* Version 1.00
|
||||
* Initial release
|
||||
*/
|
||||
|
||||
#ifndef DRIVER_USART_H_
|
||||
#define DRIVER_USART_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "Driver_Common.h"
|
||||
|
||||
#define ARM_USART_API_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2,3) /* API version */
|
||||
|
||||
|
||||
/****** USART Control Codes *****/
|
||||
|
||||
#define ARM_USART_CONTROL_Pos 0
|
||||
#define ARM_USART_CONTROL_Msk (0xFFUL << ARM_USART_CONTROL_Pos)
|
||||
|
||||
/*----- USART Control Codes: Mode -----*/
|
||||
#define ARM_USART_MODE_ASYNCHRONOUS (0x01UL << ARM_USART_CONTROL_Pos) ///< UART (Asynchronous); arg = Baudrate
|
||||
#define ARM_USART_MODE_SYNCHRONOUS_MASTER (0x02UL << ARM_USART_CONTROL_Pos) ///< Synchronous Master (generates clock signal); arg = Baudrate
|
||||
#define ARM_USART_MODE_SYNCHRONOUS_SLAVE (0x03UL << ARM_USART_CONTROL_Pos) ///< Synchronous Slave (external clock signal)
|
||||
#define ARM_USART_MODE_SINGLE_WIRE (0x04UL << ARM_USART_CONTROL_Pos) ///< UART Single-wire (half-duplex); arg = Baudrate
|
||||
#define ARM_USART_MODE_IRDA (0x05UL << ARM_USART_CONTROL_Pos) ///< UART IrDA; arg = Baudrate
|
||||
#define ARM_USART_MODE_SMART_CARD (0x06UL << ARM_USART_CONTROL_Pos) ///< UART Smart Card; arg = Baudrate
|
||||
|
||||
/*----- USART Control Codes: Mode Parameters: Data Bits -----*/
|
||||
#define ARM_USART_DATA_BITS_Pos 8
|
||||
#define ARM_USART_DATA_BITS_Msk (7UL << ARM_USART_DATA_BITS_Pos)
|
||||
#define ARM_USART_DATA_BITS_5 (5UL << ARM_USART_DATA_BITS_Pos) ///< 5 Data bits
|
||||
#define ARM_USART_DATA_BITS_6 (6UL << ARM_USART_DATA_BITS_Pos) ///< 6 Data bit
|
||||
#define ARM_USART_DATA_BITS_7 (7UL << ARM_USART_DATA_BITS_Pos) ///< 7 Data bits
|
||||
#define ARM_USART_DATA_BITS_8 (0UL << ARM_USART_DATA_BITS_Pos) ///< 8 Data bits (default)
|
||||
#define ARM_USART_DATA_BITS_9 (1UL << ARM_USART_DATA_BITS_Pos) ///< 9 Data bits
|
||||
|
||||
/*----- USART Control Codes: Mode Parameters: Parity -----*/
|
||||
#define ARM_USART_PARITY_Pos 12
|
||||
#define ARM_USART_PARITY_Msk (3UL << ARM_USART_PARITY_Pos)
|
||||
#define ARM_USART_PARITY_NONE (0UL << ARM_USART_PARITY_Pos) ///< No Parity (default)
|
||||
#define ARM_USART_PARITY_EVEN (1UL << ARM_USART_PARITY_Pos) ///< Even Parity
|
||||
#define ARM_USART_PARITY_ODD (2UL << ARM_USART_PARITY_Pos) ///< Odd Parity
|
||||
|
||||
/*----- USART Control Codes: Mode Parameters: Stop Bits -----*/
|
||||
#define ARM_USART_STOP_BITS_Pos 14
|
||||
#define ARM_USART_STOP_BITS_Msk (3UL << ARM_USART_STOP_BITS_Pos)
|
||||
#define ARM_USART_STOP_BITS_1 (0UL << ARM_USART_STOP_BITS_Pos) ///< 1 Stop bit (default)
|
||||
#define ARM_USART_STOP_BITS_2 (1UL << ARM_USART_STOP_BITS_Pos) ///< 2 Stop bits
|
||||
#define ARM_USART_STOP_BITS_1_5 (2UL << ARM_USART_STOP_BITS_Pos) ///< 1.5 Stop bits
|
||||
#define ARM_USART_STOP_BITS_0_5 (3UL << ARM_USART_STOP_BITS_Pos) ///< 0.5 Stop bits
|
||||
|
||||
/*----- USART Control Codes: Mode Parameters: Flow Control -----*/
|
||||
#define ARM_USART_FLOW_CONTROL_Pos 16
|
||||
#define ARM_USART_FLOW_CONTROL_Msk (3UL << ARM_USART_FLOW_CONTROL_Pos)
|
||||
#define ARM_USART_FLOW_CONTROL_NONE (0UL << ARM_USART_FLOW_CONTROL_Pos) ///< No Flow Control (default)
|
||||
#define ARM_USART_FLOW_CONTROL_RTS (1UL << ARM_USART_FLOW_CONTROL_Pos) ///< RTS Flow Control
|
||||
#define ARM_USART_FLOW_CONTROL_CTS (2UL << ARM_USART_FLOW_CONTROL_Pos) ///< CTS Flow Control
|
||||
#define ARM_USART_FLOW_CONTROL_RTS_CTS (3UL << ARM_USART_FLOW_CONTROL_Pos) ///< RTS/CTS Flow Control
|
||||
|
||||
/*----- USART Control Codes: Mode Parameters: Clock Polarity (Synchronous mode) -----*/
|
||||
#define ARM_USART_CPOL_Pos 18
|
||||
#define ARM_USART_CPOL_Msk (1UL << ARM_USART_CPOL_Pos)
|
||||
#define ARM_USART_CPOL0 (0UL << ARM_USART_CPOL_Pos) ///< CPOL = 0 (default)
|
||||
#define ARM_USART_CPOL1 (1UL << ARM_USART_CPOL_Pos) ///< CPOL = 1
|
||||
|
||||
/*----- USART Control Codes: Mode Parameters: Clock Phase (Synchronous mode) -----*/
|
||||
#define ARM_USART_CPHA_Pos 19
|
||||
#define ARM_USART_CPHA_Msk (1UL << ARM_USART_CPHA_Pos)
|
||||
#define ARM_USART_CPHA0 (0UL << ARM_USART_CPHA_Pos) ///< CPHA = 0 (default)
|
||||
#define ARM_USART_CPHA1 (1UL << ARM_USART_CPHA_Pos) ///< CPHA = 1
|
||||
|
||||
|
||||
/*----- USART Control Codes: Miscellaneous Controls -----*/
|
||||
#define ARM_USART_SET_DEFAULT_TX_VALUE (0x10UL << ARM_USART_CONTROL_Pos) ///< Set default Transmit value (Synchronous Receive only); arg = value
|
||||
#define ARM_USART_SET_IRDA_PULSE (0x11UL << ARM_USART_CONTROL_Pos) ///< Set IrDA Pulse in ns; arg: 0=3/16 of bit period
|
||||
#define ARM_USART_SET_SMART_CARD_GUARD_TIME (0x12UL << ARM_USART_CONTROL_Pos) ///< Set Smart Card Guard Time; arg = number of bit periods
|
||||
#define ARM_USART_SET_SMART_CARD_CLOCK (0x13UL << ARM_USART_CONTROL_Pos) ///< Set Smart Card Clock in Hz; arg: 0=Clock not generated
|
||||
#define ARM_USART_CONTROL_SMART_CARD_NACK (0x14UL << ARM_USART_CONTROL_Pos) ///< Smart Card NACK generation; arg: 0=disabled, 1=enabled
|
||||
#define ARM_USART_CONTROL_TX (0x15UL << ARM_USART_CONTROL_Pos) ///< Transmitter; arg: 0=disabled, 1=enabled
|
||||
#define ARM_USART_CONTROL_RX (0x16UL << ARM_USART_CONTROL_Pos) ///< Receiver; arg: 0=disabled, 1=enabled
|
||||
#define ARM_USART_CONTROL_BREAK (0x17UL << ARM_USART_CONTROL_Pos) ///< Continuous Break transmission; arg: 0=disabled, 1=enabled
|
||||
#define ARM_USART_ABORT_SEND (0x18UL << ARM_USART_CONTROL_Pos) ///< Abort \ref ARM_USART_Send
|
||||
#define ARM_USART_ABORT_RECEIVE (0x19UL << ARM_USART_CONTROL_Pos) ///< Abort \ref ARM_USART_Receive
|
||||
#define ARM_USART_ABORT_TRANSFER (0x1AUL << ARM_USART_CONTROL_Pos) ///< Abort \ref ARM_USART_Transfer
|
||||
|
||||
|
||||
|
||||
/****** USART specific error codes *****/
|
||||
#define ARM_USART_ERROR_MODE (ARM_DRIVER_ERROR_SPECIFIC - 1) ///< Specified Mode not supported
|
||||
#define ARM_USART_ERROR_BAUDRATE (ARM_DRIVER_ERROR_SPECIFIC - 2) ///< Specified baudrate not supported
|
||||
#define ARM_USART_ERROR_DATA_BITS (ARM_DRIVER_ERROR_SPECIFIC - 3) ///< Specified number of Data bits not supported
|
||||
#define ARM_USART_ERROR_PARITY (ARM_DRIVER_ERROR_SPECIFIC - 4) ///< Specified Parity not supported
|
||||
#define ARM_USART_ERROR_STOP_BITS (ARM_DRIVER_ERROR_SPECIFIC - 5) ///< Specified number of Stop bits not supported
|
||||
#define ARM_USART_ERROR_FLOW_CONTROL (ARM_DRIVER_ERROR_SPECIFIC - 6) ///< Specified Flow Control not supported
|
||||
#define ARM_USART_ERROR_CPOL (ARM_DRIVER_ERROR_SPECIFIC - 7) ///< Specified Clock Polarity not supported
|
||||
#define ARM_USART_ERROR_CPHA (ARM_DRIVER_ERROR_SPECIFIC - 8) ///< Specified Clock Phase not supported
|
||||
|
||||
|
||||
/**
|
||||
\brief USART Status
|
||||
*/
|
||||
typedef volatile struct _ARM_USART_STATUS {
|
||||
uint32_t tx_busy : 1; ///< Transmitter busy flag
|
||||
uint32_t rx_busy : 1; ///< Receiver busy flag
|
||||
uint32_t tx_underflow : 1; ///< Transmit data underflow detected (cleared on start of next send operation)
|
||||
uint32_t rx_overflow : 1; ///< Receive data overflow detected (cleared on start of next receive operation)
|
||||
uint32_t rx_break : 1; ///< Break detected on receive (cleared on start of next receive operation)
|
||||
uint32_t rx_framing_error : 1; ///< Framing error detected on receive (cleared on start of next receive operation)
|
||||
uint32_t rx_parity_error : 1; ///< Parity error detected on receive (cleared on start of next receive operation)
|
||||
uint32_t reserved : 25;
|
||||
} ARM_USART_STATUS;
|
||||
|
||||
/**
|
||||
\brief USART Modem Control
|
||||
*/
|
||||
typedef enum _ARM_USART_MODEM_CONTROL {
|
||||
ARM_USART_RTS_CLEAR, ///< Deactivate RTS
|
||||
ARM_USART_RTS_SET, ///< Activate RTS
|
||||
ARM_USART_DTR_CLEAR, ///< Deactivate DTR
|
||||
ARM_USART_DTR_SET ///< Activate DTR
|
||||
} ARM_USART_MODEM_CONTROL;
|
||||
|
||||
/**
|
||||
\brief USART Modem Status
|
||||
*/
|
||||
typedef volatile struct _ARM_USART_MODEM_STATUS {
|
||||
uint32_t cts : 1; ///< CTS state: 1=Active, 0=Inactive
|
||||
uint32_t dsr : 1; ///< DSR state: 1=Active, 0=Inactive
|
||||
uint32_t dcd : 1; ///< DCD state: 1=Active, 0=Inactive
|
||||
uint32_t ri : 1; ///< RI state: 1=Active, 0=Inactive
|
||||
uint32_t reserved : 28;
|
||||
} ARM_USART_MODEM_STATUS;
|
||||
|
||||
|
||||
/****** USART Event *****/
|
||||
#define ARM_USART_EVENT_SEND_COMPLETE (1UL << 0) ///< Send completed; however USART may still transmit data
|
||||
#define ARM_USART_EVENT_RECEIVE_COMPLETE (1UL << 1) ///< Receive completed
|
||||
#define ARM_USART_EVENT_TRANSFER_COMPLETE (1UL << 2) ///< Transfer completed
|
||||
#define ARM_USART_EVENT_TX_COMPLETE (1UL << 3) ///< Transmit completed (optional)
|
||||
#define ARM_USART_EVENT_TX_UNDERFLOW (1UL << 4) ///< Transmit data not available (Synchronous Slave)
|
||||
#define ARM_USART_EVENT_RX_OVERFLOW (1UL << 5) ///< Receive data overflow
|
||||
#define ARM_USART_EVENT_RX_TIMEOUT (1UL << 6) ///< Receive character timeout (optional)
|
||||
#define ARM_USART_EVENT_RX_BREAK (1UL << 7) ///< Break detected on receive
|
||||
#define ARM_USART_EVENT_RX_FRAMING_ERROR (1UL << 8) ///< Framing error detected on receive
|
||||
#define ARM_USART_EVENT_RX_PARITY_ERROR (1UL << 9) ///< Parity error detected on receive
|
||||
#define ARM_USART_EVENT_CTS (1UL << 10) ///< CTS state changed (optional)
|
||||
#define ARM_USART_EVENT_DSR (1UL << 11) ///< DSR state changed (optional)
|
||||
#define ARM_USART_EVENT_DCD (1UL << 12) ///< DCD state changed (optional)
|
||||
#define ARM_USART_EVENT_RI (1UL << 13) ///< RI state changed (optional)
|
||||
|
||||
|
||||
// Function documentation
|
||||
/**
|
||||
\fn ARM_DRIVER_VERSION ARM_USART_GetVersion (void)
|
||||
\brief Get driver version.
|
||||
\return \ref ARM_DRIVER_VERSION
|
||||
|
||||
\fn ARM_USART_CAPABILITIES ARM_USART_GetCapabilities (void)
|
||||
\brief Get driver capabilities
|
||||
\return \ref ARM_USART_CAPABILITIES
|
||||
|
||||
\fn int32_t ARM_USART_Initialize (ARM_USART_SignalEvent_t cb_event)
|
||||
\brief Initialize USART Interface.
|
||||
\param[in] cb_event Pointer to \ref ARM_USART_SignalEvent
|
||||
\return \ref execution_status
|
||||
|
||||
\fn int32_t ARM_USART_Uninitialize (void)
|
||||
\brief De-initialize USART Interface.
|
||||
\return \ref execution_status
|
||||
|
||||
\fn int32_t ARM_USART_PowerControl (ARM_POWER_STATE state)
|
||||
\brief Control USART Interface Power.
|
||||
\param[in] state Power state
|
||||
\return \ref execution_status
|
||||
|
||||
\fn int32_t ARM_USART_Send (const void *data, uint32_t num)
|
||||
\brief Start sending data to USART transmitter.
|
||||
\param[in] data Pointer to buffer with data to send to USART transmitter
|
||||
\param[in] num Number of data items to send
|
||||
\return \ref execution_status
|
||||
|
||||
\fn int32_t ARM_USART_Receive (void *data, uint32_t num)
|
||||
\brief Start receiving data from USART receiver.
|
||||
\param[out] data Pointer to buffer for data to receive from USART receiver
|
||||
\param[in] num Number of data items to receive
|
||||
\return \ref execution_status
|
||||
|
||||
\fn int32_t ARM_USART_Transfer (const void *data_out,
|
||||
void *data_in,
|
||||
uint32_t num)
|
||||
\brief Start sending/receiving data to/from USART transmitter/receiver.
|
||||
\param[in] data_out Pointer to buffer with data to send to USART transmitter
|
||||
\param[out] data_in Pointer to buffer for data to receive from USART receiver
|
||||
\param[in] num Number of data items to transfer
|
||||
\return \ref execution_status
|
||||
|
||||
\fn uint32_t ARM_USART_GetTxCount (void)
|
||||
\brief Get transmitted data count.
|
||||
\return number of data items transmitted
|
||||
|
||||
\fn uint32_t ARM_USART_GetRxCount (void)
|
||||
\brief Get received data count.
|
||||
\return number of data items received
|
||||
|
||||
\fn int32_t ARM_USART_Control (uint32_t control, uint32_t arg)
|
||||
\brief Control USART Interface.
|
||||
\param[in] control Operation
|
||||
\param[in] arg Argument of operation (optional)
|
||||
\return common \ref execution_status and driver specific \ref usart_execution_status
|
||||
|
||||
\fn ARM_USART_STATUS ARM_USART_GetStatus (void)
|
||||
\brief Get USART status.
|
||||
\return USART status \ref ARM_USART_STATUS
|
||||
|
||||
\fn int32_t ARM_USART_SetModemControl (ARM_USART_MODEM_CONTROL control)
|
||||
\brief Set USART Modem Control line state.
|
||||
\param[in] control \ref ARM_USART_MODEM_CONTROL
|
||||
\return \ref execution_status
|
||||
|
||||
\fn ARM_USART_MODEM_STATUS ARM_USART_GetModemStatus (void)
|
||||
\brief Get USART Modem Status lines state.
|
||||
\return modem status \ref ARM_USART_MODEM_STATUS
|
||||
|
||||
\fn void ARM_USART_SignalEvent (uint32_t event)
|
||||
\brief Signal USART Events.
|
||||
\param[in] event \ref USART_events notification mask
|
||||
\return none
|
||||
*/
|
||||
|
||||
typedef void (*ARM_USART_SignalEvent_t) (uint32_t event); ///< Pointer to \ref ARM_USART_SignalEvent : Signal USART Event.
|
||||
|
||||
|
||||
/**
|
||||
\brief USART Device Driver Capabilities.
|
||||
*/
|
||||
typedef struct _ARM_USART_CAPABILITIES {
|
||||
uint32_t asynchronous : 1; ///< supports UART (Asynchronous) mode
|
||||
uint32_t synchronous_master : 1; ///< supports Synchronous Master mode
|
||||
uint32_t synchronous_slave : 1; ///< supports Synchronous Slave mode
|
||||
uint32_t single_wire : 1; ///< supports UART Single-wire mode
|
||||
uint32_t irda : 1; ///< supports UART IrDA mode
|
||||
uint32_t smart_card : 1; ///< supports UART Smart Card mode
|
||||
uint32_t smart_card_clock : 1; ///< Smart Card Clock generator available
|
||||
uint32_t flow_control_rts : 1; ///< RTS Flow Control available
|
||||
uint32_t flow_control_cts : 1; ///< CTS Flow Control available
|
||||
uint32_t event_tx_complete : 1; ///< Transmit completed event: \ref ARM_USART_EVENT_TX_COMPLETE
|
||||
uint32_t event_rx_timeout : 1; ///< Signal receive character timeout event: \ref ARM_USART_EVENT_RX_TIMEOUT
|
||||
uint32_t rts : 1; ///< RTS Line: 0=not available, 1=available
|
||||
uint32_t cts : 1; ///< CTS Line: 0=not available, 1=available
|
||||
uint32_t dtr : 1; ///< DTR Line: 0=not available, 1=available
|
||||
uint32_t dsr : 1; ///< DSR Line: 0=not available, 1=available
|
||||
uint32_t dcd : 1; ///< DCD Line: 0=not available, 1=available
|
||||
uint32_t ri : 1; ///< RI Line: 0=not available, 1=available
|
||||
uint32_t event_cts : 1; ///< Signal CTS change event: \ref ARM_USART_EVENT_CTS
|
||||
uint32_t event_dsr : 1; ///< Signal DSR change event: \ref ARM_USART_EVENT_DSR
|
||||
uint32_t event_dcd : 1; ///< Signal DCD change event: \ref ARM_USART_EVENT_DCD
|
||||
uint32_t event_ri : 1; ///< Signal RI change event: \ref ARM_USART_EVENT_RI
|
||||
uint32_t reserved : 11; ///< Reserved (must be zero)
|
||||
} ARM_USART_CAPABILITIES;
|
||||
|
||||
|
||||
/**
|
||||
\brief Access structure of the USART Driver.
|
||||
*/
|
||||
typedef struct _ARM_DRIVER_USART {
|
||||
ARM_DRIVER_VERSION (*GetVersion) (void); ///< Pointer to \ref ARM_USART_GetVersion : Get driver version.
|
||||
ARM_USART_CAPABILITIES (*GetCapabilities) (void); ///< Pointer to \ref ARM_USART_GetCapabilities : Get driver capabilities.
|
||||
int32_t (*Initialize) (ARM_USART_SignalEvent_t cb_event); ///< Pointer to \ref ARM_USART_Initialize : Initialize USART Interface.
|
||||
int32_t (*Uninitialize) (void); ///< Pointer to \ref ARM_USART_Uninitialize : De-initialize USART Interface.
|
||||
int32_t (*PowerControl) (ARM_POWER_STATE state); ///< Pointer to \ref ARM_USART_PowerControl : Control USART Interface Power.
|
||||
int32_t (*Send) (const void *data, uint32_t num); ///< Pointer to \ref ARM_USART_Send : Start sending data to USART transmitter.
|
||||
int32_t (*Receive) ( void *data, uint32_t num); ///< Pointer to \ref ARM_USART_Receive : Start receiving data from USART receiver.
|
||||
int32_t (*Transfer) (const void *data_out,
|
||||
void *data_in,
|
||||
uint32_t num); ///< Pointer to \ref ARM_USART_Transfer : Start sending/receiving data to/from USART.
|
||||
uint32_t (*GetTxCount) (void); ///< Pointer to \ref ARM_USART_GetTxCount : Get transmitted data count.
|
||||
uint32_t (*GetRxCount) (void); ///< Pointer to \ref ARM_USART_GetRxCount : Get received data count.
|
||||
int32_t (*Control) (uint32_t control, uint32_t arg); ///< Pointer to \ref ARM_USART_Control : Control USART Interface.
|
||||
ARM_USART_STATUS (*GetStatus) (void); ///< Pointer to \ref ARM_USART_GetStatus : Get USART status.
|
||||
int32_t (*SetModemControl) (ARM_USART_MODEM_CONTROL control); ///< Pointer to \ref ARM_USART_SetModemControl : Set USART Modem Control line state.
|
||||
ARM_USART_MODEM_STATUS (*GetModemStatus) (void); ///< Pointer to \ref ARM_USART_GetModemStatus : Get USART Modem Status lines state.
|
||||
} const ARM_DRIVER_USART;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DRIVER_USART_H_ */
|
||||
@@ -0,0 +1,92 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 2016 -2017 ARM Ltd.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software. Permission is granted to anyone to use this
|
||||
* software for any purpose, including commercial applications, and to alter
|
||||
* it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software in
|
||||
* a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
*
|
||||
* $Date: 16. February 2017
|
||||
* $Revision: V1.0.2
|
||||
*
|
||||
* Project: UART Driver Definitions for ARM CMSDK_CM device
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef USART_V2M_MPS2_H_
|
||||
#define USART_V2M_MPS2_H_
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "Driver_USART.h"
|
||||
#include "Device.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// USART Flags
|
||||
#define USART_FLAG_INITIALIZED ((uint8_t)(1U))
|
||||
#define USART_FLAG_POWERED ((uint8_t)(1U << 1))
|
||||
#define USART_FLAG_CONFIGURED ((uint8_t)(1U << 2))
|
||||
#define USART_FLAG_TX_ENABLED ((uint8_t)(1U << 3))
|
||||
#define USART_FLAG_RX_ENABLED ((uint8_t)(1U << 4))
|
||||
|
||||
typedef struct _PIN
|
||||
{
|
||||
CMSDK_GPIO_TypeDef *PinGpio; // Pin GPIO
|
||||
uint8_t PinNum; // Pin Number
|
||||
} PIN;
|
||||
|
||||
// USART Pin Configuration
|
||||
typedef const struct _USART_PINS {
|
||||
PIN *pin_rx; // RX Pin identifier
|
||||
PIN *pin_tx; // TX Pin identifier
|
||||
} USART_PINS;
|
||||
|
||||
// USART Transfer Information (Run-Time)
|
||||
typedef struct _USART_TRANSFER_INFO {
|
||||
uint32_t rx_num; // Total number of receive data
|
||||
uint32_t tx_num; // Total number of transmit data
|
||||
uint8_t *rx_buf; // Pointer to in data buffer
|
||||
const uint8_t *tx_buf; // Pointer to out data buffer
|
||||
uint32_t rx_cnt; // Number of data received
|
||||
uint32_t tx_cnt; // Number of data sent
|
||||
} USART_TRANSFER_INFO;
|
||||
|
||||
typedef struct _USART_STATUS {
|
||||
uint8_t tx_busy; // Transmitter busy flag
|
||||
uint8_t rx_busy; // Receiver busy flag
|
||||
uint8_t rx_overflow; // Receive data overflow detected (cleared on start of next receive operation)
|
||||
} USART_STATUS;
|
||||
|
||||
// USART Information (Run-Time)
|
||||
typedef struct _USART_INFO {
|
||||
ARM_USART_SignalEvent_t cb_event; // Event callback
|
||||
USART_STATUS status; // Status flags
|
||||
uint8_t flags; // Current USART flags
|
||||
} USART_INFO;
|
||||
|
||||
// USART Resources Definitions
|
||||
typedef const struct {
|
||||
ARM_USART_CAPABILITIES capabilities; // Capabilities
|
||||
USART_PINS pins; // USART pins configuration
|
||||
CMSDK_UART_TypeDef *reg; // USART peripheral pointer
|
||||
IRQn_Type irq_num_rx; // USART RX IRQ Number
|
||||
IRQn_Type irq_num_tx; // USART TX IRQ Number
|
||||
USART_INFO *info; // Run-Time Information
|
||||
USART_TRANSFER_INFO *xfer; // USART transfer information
|
||||
} USART_RESOURCES;
|
||||
|
||||
#endif /* USART_V2M_MPS2_H_ */
|
||||
@@ -0,0 +1,68 @@
|
||||
/******************************************************************************
|
||||
* @file system_CMSDK_CM7.h
|
||||
* @brief CMSIS System Header File for CMSDK_CM7 Device
|
||||
******************************************************************************/
|
||||
/* Copyright (c) 2011 - 2022 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 ARM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SYSTEM_CMSDK_CM7_H
|
||||
#define SYSTEM_CMSDK_CM7_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Exception / Interrupt Handler Function Prototype
|
||||
*/
|
||||
typedef void(*VECTOR_TABLE_Type)(void);
|
||||
|
||||
|
||||
/**
|
||||
\brief System Clock Frequency (Core Clock)
|
||||
*/
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/**
|
||||
\brief Setup the microcontroller system.
|
||||
|
||||
Initialize the System and update the SystemCoreClock variable.
|
||||
*/
|
||||
extern void SystemInit (void);
|
||||
|
||||
/**
|
||||
\brief Update SystemCoreClock variable.
|
||||
|
||||
Updates the SystemCoreClock with current core Clock retrieved from cpu registers.
|
||||
*/
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_CMSDK_CM7_H */
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2017-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file clock_config.h
|
||||
* @brief define imxrt1052-board clock configure
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-05-29
|
||||
*/
|
||||
|
||||
#ifndef _CLOCK_CONFIG_H_
|
||||
#define _CLOCK_CONFIG_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define BOARD_XTAL0_CLK_HZ 25000000U /*!< Board xtal0 frequency in Hz */
|
||||
|
||||
#define BOARD_XTAL32K_CLK_HZ 32768U /*!< Board xtal32k frequency in Hz */
|
||||
/*******************************************************************************
|
||||
************************ BOARD_InitBootClocks function ************************
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes default configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_InitBootClocks(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*******************************************************************************
|
||||
********************** Configuration BOARD_BootClockRUN ***********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockRUN configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 25000000U /*!< Core clock frequency: 600000000Hz */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockRUN configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockRUN(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
#endif /* _CLOCK_CONFIG_H_ */
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 connect_gpio.h
|
||||
* @brief define m7 emulator gpio function and struct
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-09-27
|
||||
*/
|
||||
|
||||
#ifndef __CONNECT_GPIO_H_
|
||||
#define __CONNECT_GPIO_H_
|
||||
|
||||
#include <device.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IMXRT_GET_PIN(PORTx, PIN) (32 * (PORTx - 1) + (PIN & 31)) /* PORTx:1,2,3,4,5 */
|
||||
|
||||
int Imxrt1052HwGpioInit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 connect_uart.h
|
||||
* @brief define m7 emulator usart function and struct
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-09-27
|
||||
*/
|
||||
|
||||
#ifndef CONNECT_UART_H
|
||||
#define CONNECT_UART_H
|
||||
|
||||
#include <device.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define KERNEL_CONSOLE_BUS_NAME SERIAL_BUS_NAME_1
|
||||
#define KERNEL_CONSOLE_DRV_NAME SERIAL_DRV_NAME_1
|
||||
#define KERNEL_CONSOLE_DEVICE_NAME SERIAL_1_DEVICE_NAME_0
|
||||
|
||||
int Imxrt1052HwUartInit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,605 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file fsl_common.h
|
||||
* @brief common drivers header
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-03-15
|
||||
*/
|
||||
|
||||
#ifndef _FSL_COMMON_H_
|
||||
#define _FSL_COMMON_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup ksdk_common
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Construct a status code value from a group and code number. */
|
||||
#define MAKE_STATUS(group, code) ((((group)*100) + (code)))
|
||||
|
||||
/*! @brief Construct the version number for drivers. */
|
||||
#define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief common driver version 2.0.1. */
|
||||
#define FSL_COMMON_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))
|
||||
/*@}*/
|
||||
|
||||
/* Debug console type definition. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_NONE 0U /*!< No debug console. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_UART 1U /*!< Debug console based on UART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPUART 2U /*!< Debug console based on LPUART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPSCI 3U /*!< Debug console based on LPSCI. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_USBCDC 4U /*!< Debug console based on USBCDC. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 5U /*!< Debug console based on FLEXCOMM. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_IUART 6U /*!< Debug console based on i.MX UART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_VUSART 7U /*!< Debug console based on LPC_VUSART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_MINI_USART 8U /*!< Debug console based on LPC_USART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_SWO 9U /*!< Debug console based on SWO. */
|
||||
|
||||
/*! @brief Status group numbers. */
|
||||
enum _status_groups
|
||||
{
|
||||
kStatusGroup_Generic = 0, /*!< Group number for generic status codes. */
|
||||
kStatusGroup_FLASH = 1, /*!< Group number for FLASH status codes. */
|
||||
kStatusGroup_LPSPI = 4, /*!< Group number for LPSPI status codes. */
|
||||
kStatusGroup_FLEXIO_SPI = 5, /*!< Group number for FLEXIO SPI status codes. */
|
||||
kStatusGroup_DSPI = 6, /*!< Group number for DSPI status codes. */
|
||||
kStatusGroup_FLEXIO_UART = 7, /*!< Group number for FLEXIO UART status codes. */
|
||||
kStatusGroup_FLEXIO_I2C = 8, /*!< Group number for FLEXIO I2C status codes. */
|
||||
kStatusGroup_LPI2C = 9, /*!< Group number for LPI2C status codes. */
|
||||
kStatusGroup_UART = 10, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_I2C = 11, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_LPSCI = 12, /*!< Group number for LPSCI status codes. */
|
||||
kStatusGroup_LPUART = 13, /*!< Group number for LPUART status codes. */
|
||||
kStatusGroup_SPI = 14, /*!< Group number for SPI status code.*/
|
||||
kStatusGroup_XRDC = 15, /*!< Group number for XRDC status code.*/
|
||||
kStatusGroup_SEMA42 = 16, /*!< Group number for SEMA42 status code.*/
|
||||
kStatusGroup_SDHC = 17, /*!< Group number for SDHC status code */
|
||||
kStatusGroup_SDMMC = 18, /*!< Group number for SDMMC status code */
|
||||
kStatusGroup_SAI = 19, /*!< Group number for SAI status code */
|
||||
kStatusGroup_MCG = 20, /*!< Group number for MCG status codes. */
|
||||
kStatusGroup_SCG = 21, /*!< Group number for SCG status codes. */
|
||||
kStatusGroup_SDSPI = 22, /*!< Group number for SDSPI status codes. */
|
||||
kStatusGroup_FLEXIO_I2S = 23, /*!< Group number for FLEXIO I2S status codes */
|
||||
kStatusGroup_FLEXIO_MCULCD = 24, /*!< Group number for FLEXIO LCD status codes */
|
||||
kStatusGroup_FLASHIAP = 25, /*!< Group number for FLASHIAP status codes */
|
||||
kStatusGroup_FLEXCOMM_I2C = 26, /*!< Group number for FLEXCOMM I2C status codes */
|
||||
kStatusGroup_I2S = 27, /*!< Group number for I2S status codes */
|
||||
kStatusGroup_IUART = 28, /*!< Group number for IUART status codes */
|
||||
kStatusGroup_CSI = 29, /*!< Group number for CSI status codes */
|
||||
kStatusGroup_MIPI_DSI = 30, /*!< Group number for MIPI DSI status codes */
|
||||
kStatusGroup_SDRAMC = 35, /*!< Group number for SDRAMC status codes. */
|
||||
kStatusGroup_POWER = 39, /*!< Group number for POWER status codes. */
|
||||
kStatusGroup_ENET = 40, /*!< Group number for ENET status codes. */
|
||||
kStatusGroup_PHY = 41, /*!< Group number for PHY status codes. */
|
||||
kStatusGroup_TRGMUX = 42, /*!< Group number for TRGMUX status codes. */
|
||||
kStatusGroup_SMARTCARD = 43, /*!< Group number for SMARTCARD status codes. */
|
||||
kStatusGroup_LMEM = 44, /*!< Group number for LMEM status codes. */
|
||||
kStatusGroup_QSPI = 45, /*!< Group number for QSPI status codes. */
|
||||
kStatusGroup_DMA = 50, /*!< Group number for DMA status codes. */
|
||||
kStatusGroup_EDMA = 51, /*!< Group number for EDMA status codes. */
|
||||
kStatusGroup_DMAMGR = 52, /*!< Group number for DMAMGR status codes. */
|
||||
kStatusGroup_FLEXCAN = 53, /*!< Group number for FlexCAN status codes. */
|
||||
kStatusGroup_LTC = 54, /*!< Group number for LTC status codes. */
|
||||
kStatusGroup_FLEXIO_CAMERA = 55, /*!< Group number for FLEXIO CAMERA status codes. */
|
||||
kStatusGroup_LPC_SPI = 56, /*!< Group number for LPC_SPI status codes. */
|
||||
kStatusGroup_LPC_USART = 57, /*!< Group number for LPC_USART status codes. */
|
||||
kStatusGroup_DMIC = 58, /*!< Group number for DMIC status codes. */
|
||||
kStatusGroup_SDIF = 59, /*!< Group number for SDIF status codes.*/
|
||||
kStatusGroup_SPIFI = 60, /*!< Group number for SPIFI status codes. */
|
||||
kStatusGroup_OTP = 61, /*!< Group number for OTP status codes. */
|
||||
kStatusGroup_MCAN = 62, /*!< Group number for MCAN status codes. */
|
||||
kStatusGroup_CAAM = 63, /*!< Group number for CAAM status codes. */
|
||||
kStatusGroup_ECSPI = 64, /*!< Group number for ECSPI status codes. */
|
||||
kStatusGroup_USDHC = 65, /*!< Group number for USDHC status codes.*/
|
||||
kStatusGroup_LPC_I2C = 66, /*!< Group number for LPC_I2C status codes.*/
|
||||
kStatusGroup_DCP = 67, /*!< Group number for DCP status codes.*/
|
||||
kStatusGroup_MSCAN = 68, /*!< Group number for MSCAN status codes.*/
|
||||
kStatusGroup_ESAI = 69, /*!< Group number for ESAI status codes. */
|
||||
kStatusGroup_FLEXSPI = 70, /*!< Group number for FLEXSPI status codes. */
|
||||
kStatusGroup_MMDC = 71, /*!< Group number for MMDC status codes. */
|
||||
kStatusGroup_PDM = 72, /*!< Group number for MIC status codes. */
|
||||
kStatusGroup_SDMA = 73, /*!< Group number for SDMA status codes. */
|
||||
kStatusGroup_ICS = 74, /*!< Group number for ICS status codes. */
|
||||
kStatusGroup_SPDIF = 75, /*!< Group number for SPDIF status codes. */
|
||||
kStatusGroup_LPC_MINISPI = 76, /*!< Group number for LPC_MINISPI status codes. */
|
||||
kStatusGroup_HASHCRYPT = 77, /*!< Group number for Hashcrypt status codes */
|
||||
kStatusGroup_LPC_SPI_SSP = 78, /*!< Group number for LPC_SPI_SSP status codes. */
|
||||
kStatusGroup_I3C = 79, /*!< Group number for I3C status codes */
|
||||
kStatusGroup_LPC_I2C_1 = 97, /*!< Group number for LPC_I2C_1 status codes. */
|
||||
kStatusGroup_NOTIFIER = 98, /*!< Group number for NOTIFIER status codes. */
|
||||
kStatusGroup_DebugConsole = 99, /*!< Group number for debug console status codes. */
|
||||
kStatusGroup_SEMC = 100, /*!< Group number for SEMC status codes. */
|
||||
kStatusGroup_ApplicationRangeStart = 101, /*!< Starting number for application groups. */
|
||||
kStatusGroup_IAP = 102, /*!< Group number for IAP status codes */
|
||||
|
||||
kStatusGroup_HAL_GPIO = 121, /*!< Group number for HAL GPIO status codes. */
|
||||
kStatusGroup_HAL_UART = 122, /*!< Group number for HAL UART status codes. */
|
||||
kStatusGroup_HAL_TIMER = 123, /*!< Group number for HAL TIMER status codes. */
|
||||
kStatusGroup_HAL_SPI = 124, /*!< Group number for HAL SPI status codes. */
|
||||
kStatusGroup_HAL_I2C = 125, /*!< Group number for HAL I2C status codes. */
|
||||
kStatusGroup_HAL_FLASH = 126, /*!< Group number for HAL FLASH status codes. */
|
||||
kStatusGroup_HAL_PWM = 127, /*!< Group number for HAL PWM status codes. */
|
||||
kStatusGroup_HAL_RNG = 128, /*!< Group number for HAL RNG status codes. */
|
||||
kStatusGroup_TIMERMANAGER = 135, /*!< Group number for TiMER MANAGER status codes. */
|
||||
kStatusGroup_SERIALMANAGER = 136, /*!< Group number for SERIAL MANAGER status codes. */
|
||||
kStatusGroup_LED = 137, /*!< Group number for LED status codes. */
|
||||
kStatusGroup_BUTTON = 138, /*!< Group number for BUTTON status codes. */
|
||||
kStatusGroup_EXTERN_EEPROM = 139, /*!< Group number for EXTERN EEPROM status codes. */
|
||||
kStatusGroup_SHELL = 140, /*!< Group number for SHELL status codes. */
|
||||
kStatusGroup_MEM_MANAGER = 141, /*!< Group number for MEM MANAGER status codes. */
|
||||
kStatusGroup_LIST = 142, /*!< Group number for List status codes. */
|
||||
kStatusGroup_OSA = 143, /*!< Group number for OSA status codes. */
|
||||
kStatusGroup_COMMON_TASK = 144, /*!< Group number for Common task status codes. */
|
||||
kStatusGroup_MSG = 145, /*!< Group number for messaging status codes. */
|
||||
kStatusGroup_SDK_OCOTP = 146, /*!< Group number for OCOTP status codes. */
|
||||
kStatusGroup_SDK_FLEXSPINOR = 147, /*!< Group number for FLEXSPINOR status codes.*/
|
||||
kStatusGroup_CODEC = 148, /*!< Group number for codec status codes. */
|
||||
};
|
||||
|
||||
/*! @brief Generic status return codes. */
|
||||
enum _generic_status
|
||||
{
|
||||
kStatus_Success = MAKE_STATUS(kStatusGroup_Generic, 0),
|
||||
kStatus_Fail = MAKE_STATUS(kStatusGroup_Generic, 1),
|
||||
kStatus_ReadOnly = MAKE_STATUS(kStatusGroup_Generic, 2),
|
||||
kStatus_OutOfRange = MAKE_STATUS(kStatusGroup_Generic, 3),
|
||||
kStatus_InvalidArgument = MAKE_STATUS(kStatusGroup_Generic, 4),
|
||||
kStatus_Timeout = MAKE_STATUS(kStatusGroup_Generic, 5),
|
||||
kStatus_NoTransferInProgress = MAKE_STATUS(kStatusGroup_Generic, 6),
|
||||
};
|
||||
|
||||
/*! @brief Type used for all status and error return values. */
|
||||
typedef int32_t status_t;
|
||||
|
||||
/*
|
||||
* Macro guard for whether to use default weak IRQ implementation in drivers
|
||||
*/
|
||||
#ifndef FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ
|
||||
#define FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ 1
|
||||
#endif
|
||||
|
||||
/*! @name Min/max macros */
|
||||
/* @{ */
|
||||
#if !defined(MIN)
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if !defined(MAX)
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @brief Computes the number of elements in an array. */
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
/*! @name UINT16_MAX/UINT32_MAX value */
|
||||
/* @{ */
|
||||
#if !defined(UINT16_MAX)
|
||||
#define UINT16_MAX ((uint16_t)-1)
|
||||
#endif
|
||||
|
||||
#if !defined(UINT32_MAX)
|
||||
#define UINT32_MAX ((uint32_t)-1)
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @name Timer utilities */
|
||||
/* @{ */
|
||||
/*! Macro to convert a microsecond period to raw count value */
|
||||
#define USEC_TO_COUNT(us, clockFreqInHz) (uint64_t)((uint64_t)us * clockFreqInHz / 1000000U)
|
||||
/*! Macro to convert a raw count value to microsecond */
|
||||
#define COUNT_TO_USEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000000U / clockFreqInHz)
|
||||
|
||||
/*! Macro to convert a millisecond period to raw count value */
|
||||
#define MSEC_TO_COUNT(ms, clockFreqInHz) (uint64_t)((uint64_t)ms * clockFreqInHz / 1000U)
|
||||
/*! Macro to convert a raw count value to millisecond */
|
||||
#define COUNT_TO_MSEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000U / clockFreqInHz)
|
||||
/* @} */
|
||||
|
||||
/*! @name Alignment variable definition macros */
|
||||
/* @{ */
|
||||
#if (defined(__ICCARM__))
|
||||
/**
|
||||
* Workaround to disable MISRA C message suppress warnings for IAR compiler.
|
||||
* http://supp.iar.com/Support/?note=24725
|
||||
*/
|
||||
_Pragma("diag_suppress=Pm120")
|
||||
#define SDK_PRAGMA(x) _Pragma(#x)
|
||||
_Pragma("diag_error=Pm120")
|
||||
/*! Macro to define a variable with alignbytes alignment */
|
||||
#define SDK_ALIGN(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var
|
||||
/*! Macro to define a variable with L1 d-cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) SDK_PRAGMA(data_alignment = FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) var
|
||||
#endif
|
||||
/*! Macro to define a variable with L2 cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) SDK_PRAGMA(data_alignment = FSL_FEATURE_L2CACHE_LINESIZE_BYTE) var
|
||||
#endif
|
||||
#elif defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
/*! Macro to define a variable with alignbytes alignment */
|
||||
#define SDK_ALIGN(var, alignbytes) __attribute__((aligned(alignbytes))) var
|
||||
/*! Macro to define a variable with L1 d-cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) __attribute__((aligned(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE))) var
|
||||
#endif
|
||||
/*! Macro to define a variable with L2 cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) __attribute__((aligned(FSL_FEATURE_L2CACHE_LINESIZE_BYTE))) var
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
/*! Macro to define a variable with alignbytes alignment */
|
||||
#define SDK_ALIGN(var, alignbytes) var __attribute__((aligned(alignbytes)))
|
||||
/*! Macro to define a variable with L1 d-cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) var __attribute__((aligned(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)))
|
||||
#endif
|
||||
/*! Macro to define a variable with L2 cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) var __attribute__((aligned(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)))
|
||||
#endif
|
||||
#else
|
||||
#error Toolchain not supported
|
||||
#define SDK_ALIGN(var, alignbytes) var
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) var
|
||||
#endif
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) var
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*! Macro to change a value to a given size aligned value */
|
||||
#define SDK_SIZEALIGN(var, alignbytes) \
|
||||
((unsigned int)((var) + ((alignbytes)-1)) & (unsigned int)(~(unsigned int)((alignbytes)-1)))
|
||||
/* @} */
|
||||
|
||||
/*! @name Non-cacheable region definition macros */
|
||||
/* For initialized non-zero non-cacheable variables, please using "AT_NONCACHEABLE_SECTION_INIT(var) ={xx};" or
|
||||
* "AT_NONCACHEABLE_SECTION_ALIGN_INIT(var) ={xx};" in your projects to define them, for zero-inited non-cacheable variables,
|
||||
* please using "AT_NONCACHEABLE_SECTION(var);" or "AT_NONCACHEABLE_SECTION_ALIGN(var);" to define them, these zero-inited variables
|
||||
* will be initialized to zero in system startup.
|
||||
*/
|
||||
/* @{ */
|
||||
#if (defined(__ICCARM__))
|
||||
#if ((!(defined(FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION) && FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION)) && defined(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE))
|
||||
#define AT_NONCACHEABLE_SECTION(var) var @"NonCacheable"
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var @"NonCacheable"
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var @"NonCacheable.init"
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var @"NonCacheable.init"
|
||||
#else
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var
|
||||
#endif
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#if ((!(defined(FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION) && FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION)) && defined(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE))
|
||||
#define AT_NONCACHEABLE_SECTION(var) __attribute__((section("NonCacheable"), zero_init)) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable"), zero_init)) __attribute__((aligned(alignbytes))) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) __attribute__((section("NonCacheable.init"))) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable.init"))) __attribute__((aligned(alignbytes))) var
|
||||
#else
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) __attribute__((aligned(alignbytes))) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) __attribute__((aligned(alignbytes))) var
|
||||
#endif
|
||||
#elif(defined(__GNUC__))
|
||||
/* For GCC, when the non-cacheable section is required, please define "__STARTUP_INITIALIZE_NONCACHEDATA"
|
||||
* in your projects to make sure the non-cacheable section variables will be initialized in system startup.
|
||||
*/
|
||||
#if ((!(defined(FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION) && FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION)) && defined(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE))
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) __attribute__((section("NonCacheable.init"))) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable.init"))) var __attribute__((aligned(alignbytes)))
|
||||
#define AT_NONCACHEABLE_SECTION(var) __attribute__((section("NonCacheable,\"aw\",%nobits @"))) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable,\"aw\",%nobits @"))) var __attribute__((aligned(alignbytes)))
|
||||
#else
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) var __attribute__((aligned(alignbytes)))
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) var __attribute__((aligned(alignbytes)))
|
||||
#endif
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) var
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @name Time sensitive region */
|
||||
/* @{ */
|
||||
#if defined(FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE) && FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE
|
||||
#if (defined(__ICCARM__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func @"CodeQuickAccess"
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func @"DataQuickAccess"
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("CodeQuickAccess"))) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) __attribute__((section("DataQuickAccess"))) func
|
||||
#elif(defined(__GNUC__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("CodeQuickAccess"))) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) __attribute__((section("DataQuickAccess"))) func
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#endif /* defined(__ICCARM__) */
|
||||
#else
|
||||
#if (defined(__ICCARM__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func
|
||||
#elif(defined(__GNUC__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#endif
|
||||
#endif /* __FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE */
|
||||
/* @} */
|
||||
|
||||
/*! @name Ram Function */
|
||||
#if (defined(__ICCARM__))
|
||||
#define RAMFUNCTION_SECTION_CODE(func) func @"RamFunction"
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#define RAMFUNCTION_SECTION_CODE(func) __attribute__((section("RamFunction"))) func
|
||||
#elif(defined(__GNUC__))
|
||||
#define RAMFUNCTION_SECTION_CODE(func) __attribute__((section("RamFunction"))) func
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#endif /* defined(__ICCARM__) */
|
||||
/* @} */
|
||||
|
||||
/*
|
||||
* The fsl_clock.h is included here because it needs MAKE_VERSION/MAKE_STATUS/status_t
|
||||
* defined in previous of this file.
|
||||
*/
|
||||
// #include "fsl_clock.h"
|
||||
|
||||
/*
|
||||
* Chip level peripheral reset API, for MCUs that implement peripheral reset control external to a peripheral
|
||||
*/
|
||||
#if ((defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0)) || \
|
||||
(defined(FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT) && (FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT > 0)))
|
||||
#include "fsl_reset.h"
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Enable specific interrupt.
|
||||
*
|
||||
* Enable LEVEL1 interrupt. For some devices, there might be multiple interrupt
|
||||
* levels. For example, there are NVIC and intmux. Here the interrupts connected
|
||||
* to NVIC are the LEVEL1 interrupts, because they are routed to the core directly.
|
||||
* The interrupts connected to intmux are the LEVEL2 interrupts, they are routed
|
||||
* to NVIC first then routed to core.
|
||||
*
|
||||
* This function only enables the LEVEL1 interrupts. The number of LEVEL1 interrupts
|
||||
* is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
* @retval kStatus_Success Interrupt enabled successfully
|
||||
* @retval kStatus_Fail Failed to enable the interrupt
|
||||
*/
|
||||
static inline status_t EnableIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
// if (NotAvail_IRQn == interrupt)
|
||||
// {
|
||||
// return kStatus_Fail;
|
||||
// }
|
||||
|
||||
#if defined(FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS) && (FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS > 0)
|
||||
if (interrupt >= FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS)
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GIC_PRIO_BITS)
|
||||
GIC_EnableIRQ(interrupt);
|
||||
#else
|
||||
NVIC_EnableIRQ(interrupt);
|
||||
#endif
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable specific interrupt.
|
||||
*
|
||||
* Disable LEVEL1 interrupt. For some devices, there might be multiple interrupt
|
||||
* levels. For example, there are NVIC and intmux. Here the interrupts connected
|
||||
* to NVIC are the LEVEL1 interrupts, because they are routed to the core directly.
|
||||
* The interrupts connected to intmux are the LEVEL2 interrupts, they are routed
|
||||
* to NVIC first then routed to core.
|
||||
*
|
||||
* This function only disables the LEVEL1 interrupts. The number of LEVEL1 interrupts
|
||||
* is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
* @retval kStatus_Success Interrupt disabled successfully
|
||||
* @retval kStatus_Fail Failed to disable the interrupt
|
||||
*/
|
||||
static inline status_t DisableIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
// if (NotAvail_IRQn == interrupt)
|
||||
// {
|
||||
// return kStatus_Fail;
|
||||
// }
|
||||
|
||||
#if defined(FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS) && (FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS > 0)
|
||||
if (interrupt >= FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS)
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GIC_PRIO_BITS)
|
||||
GIC_DisableIRQ(interrupt);
|
||||
#else
|
||||
NVIC_DisableIRQ(interrupt);
|
||||
#endif
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable the global IRQ
|
||||
*
|
||||
* Disable the global interrupt and return the current primask register. User is required to provided the primask
|
||||
* register for the EnableGlobalIRQ().
|
||||
*
|
||||
* @return Current primask value.
|
||||
*/
|
||||
static inline uint32_t DisableGlobalIRQ(void)
|
||||
{
|
||||
#if defined (__XCC__)
|
||||
return 0;
|
||||
#else
|
||||
#if defined(CPSR_I_Msk)
|
||||
uint32_t cpsr = __get_CPSR() & CPSR_I_Msk;
|
||||
|
||||
__disable_irq();
|
||||
|
||||
return cpsr;
|
||||
#else
|
||||
uint32_t regPrimask = __get_PRIMASK();
|
||||
|
||||
__disable_irq();
|
||||
|
||||
return regPrimask;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enable the global IRQ
|
||||
*
|
||||
* Set the primask register with the provided primask value but not just enable the primask. The idea is for the
|
||||
* convenience of integration of RTOS. some RTOS get its own management mechanism of primask. User is required to
|
||||
* use the EnableGlobalIRQ() and DisableGlobalIRQ() in pair.
|
||||
*
|
||||
* @param primask value of primask register to be restored. The primask value is supposed to be provided by the
|
||||
* DisableGlobalIRQ().
|
||||
*/
|
||||
static inline void EnableGlobalIRQ(uint32_t primask)
|
||||
{
|
||||
#if defined (__XCC__)
|
||||
#else
|
||||
#if defined(CPSR_I_Msk)
|
||||
__set_CPSR((__get_CPSR() & ~CPSR_I_Msk) | primask);
|
||||
#else
|
||||
__set_PRIMASK(primask);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ENABLE_RAM_VECTOR_TABLE)
|
||||
/*!
|
||||
* @brief install IRQ handler
|
||||
*
|
||||
* @param irq IRQ number
|
||||
* @param irqHandler IRQ handler address
|
||||
* @return The old IRQ handler address
|
||||
*/
|
||||
uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler);
|
||||
#endif /* ENABLE_RAM_VECTOR_TABLE. */
|
||||
|
||||
#if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
|
||||
/*!
|
||||
* @brief Enable specific interrupt for wake-up from deep-sleep mode.
|
||||
*
|
||||
* Enable the interrupt for wake-up from deep sleep mode.
|
||||
* Some interrupts are typically used in sleep mode only and will not occur during
|
||||
* deep-sleep mode because relevant clocks are stopped. However, it is possible to enable
|
||||
* those clocks (significantly increasing power consumption in the reduced power mode),
|
||||
* making these wake-ups possible.
|
||||
*
|
||||
* @note This function also enables the interrupt in the NVIC (EnableIRQ() is called internaly).
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt);
|
||||
|
||||
/*!
|
||||
* @brief Disable specific interrupt for wake-up from deep-sleep mode.
|
||||
*
|
||||
* Disable the interrupt for wake-up from deep sleep mode.
|
||||
* Some interrupts are typically used in sleep mode only and will not occur during
|
||||
* deep-sleep mode because relevant clocks are stopped. However, it is possible to enable
|
||||
* those clocks (significantly increasing power consumption in the reduced power mode),
|
||||
* making these wake-ups possible.
|
||||
*
|
||||
* @note This function also disables the interrupt in the NVIC (DisableIRQ() is called internaly).
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt);
|
||||
#endif /* FSL_FEATURE_SOC_SYSCON_COUNT */
|
||||
|
||||
/*!
|
||||
* @brief Allocate memory with given alignment and aligned size.
|
||||
*
|
||||
* This is provided to support the dynamically allocated memory
|
||||
* used in cache-able region.
|
||||
* @param size The length required to malloc.
|
||||
* @param alignbytes The alignment size.
|
||||
* @retval The allocated memory.
|
||||
*/
|
||||
void *SDK_Malloc(size_t size, size_t alignbytes);
|
||||
|
||||
/*!
|
||||
* @brief Free memory.
|
||||
*
|
||||
* @param ptr The memory to be release.
|
||||
*/
|
||||
void SDK_Free(void *ptr);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif /* _FSL_COMMON_H_ */
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2014-2016 Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file fsl_device_registers.h
|
||||
* @brief device register function
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-03-15
|
||||
*/
|
||||
|
||||
#ifndef __FSL_DEVICE_REGISTERS_H__
|
||||
#define __FSL_DEVICE_REGISTERS_H__
|
||||
|
||||
/*
|
||||
* Include the cpu specific register header files.
|
||||
*
|
||||
* The CPU macro should be declared in the project or makefile.
|
||||
*/
|
||||
#if (defined(CPU_MIMXRT1052CVJ5B) || defined(CPU_MIMXRT1052CVL5B) || defined(CPU_MIMXRT1052DVJ6B) || \
|
||||
defined(CPU_MIMXRT1052DVL6B))
|
||||
|
||||
#define MIMXRT1052_SERIES
|
||||
|
||||
// /* CMSIS-style register definitions */
|
||||
// #include "MIMXRT1052.h"
|
||||
// /* CPU specific feature definitions */
|
||||
// #include "MIMXRT1052_features.h"
|
||||
|
||||
#include "CMSDK_CM7_SP.h"
|
||||
|
||||
#else
|
||||
#error "No valid CPU defined!"
|
||||
#endif
|
||||
|
||||
#endif /* __FSL_DEVICE_REGISTERS_H__ */
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,74 @@
|
||||
config BSP_USING_LPUART1
|
||||
bool "Enable LPUART1"
|
||||
default y
|
||||
if BSP_USING_LPUART1
|
||||
config SERIAL_BUS_NAME_1
|
||||
string "serial bus 1 name"
|
||||
default "uart1"
|
||||
config SERIAL_DRV_NAME_1
|
||||
string "serial bus 1 driver name"
|
||||
default "uart1_drv"
|
||||
config SERIAL_1_DEVICE_NAME_0
|
||||
string "serial bus 1 device name"
|
||||
default "uart1_dev1"
|
||||
endif
|
||||
|
||||
config BSP_USING_LPUART2
|
||||
bool "Enable LPUART2"
|
||||
default y
|
||||
if BSP_USING_LPUART2
|
||||
config SERIAL_BUS_NAME_2
|
||||
string "serial bus 2 name"
|
||||
default "uart2"
|
||||
config SERIAL_DRV_NAME_2
|
||||
string "serial bus 2 driver name"
|
||||
default "uart2_drv"
|
||||
config SERIAL_2_DEVICE_NAME_0
|
||||
string "serial bus 2 device name"
|
||||
default "uart2_dev2"
|
||||
endif
|
||||
|
||||
config BSP_USING_LPUART3
|
||||
bool "Enable LPUART3"
|
||||
default y
|
||||
if BSP_USING_LPUART3
|
||||
config SERIAL_BUS_NAME_3
|
||||
string "serial bus 3 name"
|
||||
default "uart3"
|
||||
config SERIAL_DRV_NAME_3
|
||||
string "serial bus 3 driver name"
|
||||
default "uart3_drv"
|
||||
config SERIAL_3_DEVICE_NAME_0
|
||||
string "serial bus 3 device name"
|
||||
default "uart3_dev3"
|
||||
endif
|
||||
|
||||
config BSP_USING_LPUART4
|
||||
bool "Enable LPUART4"
|
||||
default n
|
||||
if BSP_USING_LPUART4
|
||||
config SERIAL_BUS_NAME_4
|
||||
string "serial bus 4 name"
|
||||
default "uart4"
|
||||
config SERIAL_DRV_NAME_4
|
||||
string "serial bus 4 driver name"
|
||||
default "uart4_drv"
|
||||
config SERIAL_4_DEVICE_NAME_0
|
||||
string "serial bus 4 device name"
|
||||
default "uart4_dev4"
|
||||
endif
|
||||
|
||||
config BSP_USING_LPUART8
|
||||
bool "Enable LPUART8"
|
||||
default n
|
||||
if BSP_USING_LPUART8
|
||||
config SERIAL_BUS_NAME_8
|
||||
string "serial bus 8 name"
|
||||
default "uart8"
|
||||
config SERIAL_DRV_NAME_8
|
||||
string "serial bus 8 driver name"
|
||||
default "uart8_drv"
|
||||
config SERIAL_8_DEVICE_NAME_0
|
||||
string "serial bus 8 device name"
|
||||
default "uart8_dev8"
|
||||
endif
|
||||
@@ -0,0 +1,3 @@
|
||||
SRC_FILES := connect_uart.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,961 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 2016 - 2017 ARM Ltd.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software. Permission is granted to anyone to use this
|
||||
* software for any purpose, including commercial applications, and to alter
|
||||
* it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software in
|
||||
* a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
*
|
||||
* $Date: 26. October 2017
|
||||
* $Revision: V1.0.3
|
||||
*
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @file connect_uart.c
|
||||
* @brief support cortex-m7-emulator uart function and register to bus framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-09-27
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: connect_uart.c
|
||||
Description: support cortex-m7-emulator uart function and register to bus framework
|
||||
Others: take Arm\Packs\Keil\V2M-MPS2_CMx_BSP\1.8.0\CMSIS\Driver\USART_V2M-MPS2.c for references
|
||||
History:
|
||||
1. Date: 2023-09-27
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. support cortex-m7-emulator uart configure, write and read
|
||||
2. support cortex-m7-emulator uart bus device and driver register
|
||||
*************************************************/
|
||||
|
||||
#include <board.h>
|
||||
#include <connect_uart.h>
|
||||
#include <CMSDK_CM7_SP.h>
|
||||
|
||||
#include "USART_V2M-MPS2.h"
|
||||
// #include "board.h"
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
|
||||
#define UNUSED(x) (void)(x) /* macro to get rid of 'unused parameter' warning */
|
||||
|
||||
#define ARM_USART_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1,0)
|
||||
|
||||
// Driver Version
|
||||
static const ARM_DRIVER_VERSION usart_driver_version = { ARM_USART_API_VERSION, ARM_USART_DRV_VERSION };
|
||||
|
||||
|
||||
// USART0
|
||||
#ifdef BSP_USING_LPUART1
|
||||
|
||||
// USART0 Run-Time Information
|
||||
static USART_INFO USART0_Info = { 0U, { 0U, 0U, 0U }, 0U };
|
||||
static USART_TRANSFER_INFO USART0_TransferInfo = { 0U, 0U, 0U, 0U, 0U, 0U };
|
||||
static PIN USART0_pin_rx = { CMSDK_GPIO1, 0U };
|
||||
static PIN USART0_pin_tx = { CMSDK_GPIO1, 1U };
|
||||
|
||||
|
||||
// USART0 Resources
|
||||
static const USART_RESOURCES USART0_Resources = {
|
||||
{ // Capabilities
|
||||
1, // supports UART (Asynchronous) mode
|
||||
0, // supports Synchronous Master mode
|
||||
0, // supports Synchronous Slave mode
|
||||
0, // supports UART Single-wire mode
|
||||
0, // supports UART IrDA mode
|
||||
0, // supports UART Smart Card mode
|
||||
0, // Smart Card Clock generator
|
||||
0, // RTS Flow Control available
|
||||
0, // CTS Flow Control available
|
||||
1, // Transmit completed event: \ref ARM_USART_EVENT_TX_COMPLETE
|
||||
1, // Signal receive character timeout event: \ref ARM_USART_EVENT_RX_TIMEOUT
|
||||
0, // RTS Line: 0=not available, 1=available
|
||||
0, // CTS Line: 0=not available, 1=available
|
||||
0, // DTR Line: 0=not available, 1=available
|
||||
0, // DSR Line: 0=not available, 1=available
|
||||
0, // DCD Line: 0=not available, 1=available
|
||||
0, // RI Line: 0=not available, 1=available
|
||||
0, // Signal CTS change event: \ref ARM_USART_EVENT_CTS
|
||||
0, // Signal DSR change event: \ref ARM_USART_EVENT_DSR
|
||||
0, // Signal DCD change event: \ref ARM_USART_EVENT_DCD
|
||||
0, // Signal RI change event: \ref ARM_USART_EVENT_RI
|
||||
0 // Reserved (must be zero)
|
||||
},
|
||||
{
|
||||
&USART0_pin_rx,
|
||||
&USART0_pin_tx
|
||||
},
|
||||
CMSDK_UART0,
|
||||
UART0RX_IRQn,
|
||||
UART0TX_IRQn,
|
||||
&USART0_Info,
|
||||
&USART0_TransferInfo
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// USART Driver functions
|
||||
|
||||
/**
|
||||
\fn ARM_DRIVER_VERSION USARTx_GetVersion (void)
|
||||
\brief Get driver version.
|
||||
\return \ref ARM_DRIVER_VERSION
|
||||
*/
|
||||
static ARM_DRIVER_VERSION USARTx_GetVersion (void) {
|
||||
return usart_driver_version;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn ARM_USART_CAPABILITIES USART_GetCapabilities (const USART_RESOURCES *usart)
|
||||
\brief Get driver capabilities
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref ARM_USART_CAPABILITIES
|
||||
*/
|
||||
static ARM_USART_CAPABILITIES USART_GetCapabilities (const USART_RESOURCES *usart) {
|
||||
return usart->capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_Initialize ( ARM_USART_SignalEvent_t cb_event
|
||||
const USART_RESOURCES *usart)
|
||||
\brief Initialize USART Interface.
|
||||
\param[in] cb_event Pointer to \ref ARM_USART_SignalEvent
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref execution_status
|
||||
*/
|
||||
static int32_t USART_Initialize ( ARM_USART_SignalEvent_t cb_event,
|
||||
const USART_RESOURCES *usart) {
|
||||
|
||||
if (usart->info->flags & USART_FLAG_INITIALIZED) {
|
||||
// Driver is already initialized
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
// Initialize callback
|
||||
usart->info->cb_event = cb_event;
|
||||
|
||||
// Clear transfer information
|
||||
memset(usart->xfer, 0U, sizeof(USART_TRANSFER_INFO));
|
||||
|
||||
// configure USART pins
|
||||
usart->pins.pin_rx->PinGpio->ALTFUNCSET |= (1u << usart->pins.pin_rx->PinNum);
|
||||
usart->pins.pin_tx->PinGpio->ALTFUNCSET |= (1u << usart->pins.pin_tx->PinNum);
|
||||
|
||||
usart->info->flags = USART_FLAG_INITIALIZED; // Set status flags
|
||||
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_Uninitialize (const USART_RESOURCES *usart)
|
||||
\brief De-initialize USART Interface.
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref execution_status
|
||||
*/
|
||||
static int32_t USART_Uninitialize (const USART_RESOURCES *usart) {
|
||||
|
||||
// unconfigure USART pins
|
||||
usart->pins.pin_rx->PinGpio->ALTFUNCSET &= ~(1u << usart->pins.pin_rx->PinNum);
|
||||
usart->pins.pin_tx->PinGpio->ALTFUNCSET &= ~(1u << usart->pins.pin_tx->PinNum);
|
||||
|
||||
usart->info->flags = 0U; // Reset status flags
|
||||
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_PowerControl (ARM_POWER_STATE state)
|
||||
\brief Control USART Interface Power.
|
||||
\param[in] state Power state
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref execution_status
|
||||
*/
|
||||
static int32_t USART_PowerControl ( ARM_POWER_STATE state,
|
||||
const USART_RESOURCES *usart) {
|
||||
|
||||
switch (state) {
|
||||
case ARM_POWER_OFF:
|
||||
// Clear powered flag
|
||||
usart->info->flags &= ~USART_FLAG_POWERED;
|
||||
|
||||
// Clear and disable USART IRQ
|
||||
NVIC_DisableIRQ(usart->irq_num_rx);
|
||||
NVIC_ClearPendingIRQ(usart->irq_num_rx);
|
||||
NVIC_DisableIRQ(usart->irq_num_tx);
|
||||
NVIC_ClearPendingIRQ(usart->irq_num_tx);
|
||||
break;
|
||||
|
||||
case ARM_POWER_LOW:
|
||||
return ARM_DRIVER_ERROR_UNSUPPORTED;
|
||||
|
||||
case ARM_POWER_FULL:
|
||||
if ((usart->info->flags & USART_FLAG_INITIALIZED) == 0U) {
|
||||
return ARM_DRIVER_ERROR;
|
||||
}
|
||||
if ((usart->info->flags & USART_FLAG_POWERED) != 0U) {
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
// Initialize status flags
|
||||
usart->info->status.tx_busy = 0U;
|
||||
usart->info->status.rx_busy = 0U;
|
||||
usart->info->status.rx_overflow = 0U;
|
||||
|
||||
// Set flag initialized
|
||||
usart->info->flags = USART_FLAG_POWERED | USART_FLAG_INITIALIZED;
|
||||
|
||||
// Clear and enable USART IRQ
|
||||
NVIC_ClearPendingIRQ(usart->irq_num_rx);
|
||||
NVIC_EnableIRQ(usart->irq_num_rx);
|
||||
NVIC_ClearPendingIRQ(usart->irq_num_tx);
|
||||
NVIC_EnableIRQ(usart->irq_num_tx);
|
||||
break;
|
||||
|
||||
// default: return ARM_DRIVER_ERROR_UNSUPPORTED;
|
||||
}
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_Send (const void *data,
|
||||
uint32_t num,
|
||||
const USART_RESOURCES *usart)
|
||||
\brief Start sending data to USART transmitter.
|
||||
\param[in] data Pointer to buffer with data to send to USART transmitter
|
||||
\param[in] num Number of data items to send
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref execution_status
|
||||
*/
|
||||
static int32_t USART_Send (const void *data,
|
||||
uint32_t num,
|
||||
const USART_RESOURCES *usart) {
|
||||
|
||||
if ((data == NULL) || (num == 0U)) {
|
||||
// Invalid parameters
|
||||
return ARM_DRIVER_ERROR_PARAMETER;
|
||||
}
|
||||
|
||||
if ((usart->info->flags & USART_FLAG_CONFIGURED) == 0U) {
|
||||
// USART is not configured (mode not selected)
|
||||
return ARM_DRIVER_ERROR;
|
||||
}
|
||||
|
||||
if ((usart->info->status.tx_busy != 0U) ||
|
||||
((usart->reg->STATE & CMSDK_UART_STATE_TXBF_Msk) != 0U)) {
|
||||
// Send is not completed yet
|
||||
return ARM_DRIVER_ERROR_BUSY;
|
||||
}
|
||||
|
||||
// Set tx_busy flag
|
||||
usart->info->status.tx_busy = 0U;
|
||||
|
||||
// Save transmit buffer info
|
||||
usart->xfer->tx_buf = (const uint8_t *)data;
|
||||
usart->xfer->tx_num = num;
|
||||
usart->xfer->tx_cnt = 0U;
|
||||
|
||||
// TX interrupt enable
|
||||
usart->reg->CTRL |= CMSDK_UART_CTRL_TXIRQEN_Msk;
|
||||
|
||||
// Start sending
|
||||
usart->reg->DATA = usart->xfer->tx_buf[usart->xfer->tx_cnt];
|
||||
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_Receive ( void *data,
|
||||
uint32_t num,
|
||||
const USART_RESOURCES *usart)
|
||||
\brief Start receiving data from USART receiver.
|
||||
\param[out] data Pointer to buffer for data to receive from USART receiver
|
||||
\param[in] num Number of data items to receive
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref execution_status
|
||||
*/
|
||||
static int32_t USART_Receive ( void *data,
|
||||
uint32_t num,
|
||||
const USART_RESOURCES *usart) {
|
||||
|
||||
if ((data == NULL) || (num == 0U)) {
|
||||
// Invalid parameters
|
||||
return ARM_DRIVER_ERROR_PARAMETER;
|
||||
}
|
||||
uint32_t state = 0;
|
||||
state = usart->reg->STATE;
|
||||
int ch=-1;
|
||||
if (state){
|
||||
ch=usart->reg->DATA& 0xff;
|
||||
usart->reg->STATE=0;
|
||||
}
|
||||
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_Transfer (const void *data_out,
|
||||
void *data_in,
|
||||
uint32_t num,
|
||||
const USART_RESOURCES *usart)
|
||||
\brief Start sending/receiving data to/from USART transmitter/receiver.
|
||||
\param[in] data_out Pointer to buffer with data to send to USART transmitter
|
||||
\param[out] data_in Pointer to buffer for data to receive from USART receiver
|
||||
\param[in] num Number of data items to transfer
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref execution_status
|
||||
*/
|
||||
static int32_t USART_Transfer (const void *data_out,
|
||||
void *data_in,
|
||||
uint32_t num,
|
||||
const USART_RESOURCES *usart) {
|
||||
UNUSED(data_out);
|
||||
UNUSED(data_in);
|
||||
UNUSED(num);
|
||||
UNUSED(usart);
|
||||
|
||||
// Synchronous mode not supported
|
||||
return ARM_DRIVER_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn uint32_t USART_GetTxCount (const USART_RESOURCES *usart)
|
||||
\brief Get transmitted data count.
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return number of data items transmitted
|
||||
*/
|
||||
static uint32_t USART_GetTxCount (const USART_RESOURCES *usart) {
|
||||
|
||||
return usart->xfer->tx_cnt;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
\fn uint32_t USART_GetRxCount (const USART_RESOURCES *usart)
|
||||
\brief Get received data count.
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return number of data items received
|
||||
*/
|
||||
static uint32_t USART_GetRxCount (const USART_RESOURCES *usart) {
|
||||
|
||||
return usart->xfer->rx_cnt;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_Control ( uint32_t control,
|
||||
uint32_t arg,
|
||||
const USART_RESOURCES *usart)
|
||||
\brief Control USART Interface.
|
||||
\param[in] control Operation
|
||||
\param[in] arg Argument of operation (optional)
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return common \ref execution_status and driver specific \ref usart_execution_status
|
||||
*/
|
||||
static int32_t USART_Control ( uint32_t control,
|
||||
uint32_t arg,
|
||||
const USART_RESOURCES *usart) {
|
||||
|
||||
if ((usart->info->flags & USART_FLAG_POWERED) == 0U) {
|
||||
// USART not powered
|
||||
return ARM_DRIVER_ERROR;
|
||||
}
|
||||
|
||||
switch (control & ARM_USART_CONTROL_Msk) {
|
||||
// Control break
|
||||
case ARM_USART_CONTROL_BREAK:
|
||||
return ARM_DRIVER_ERROR_UNSUPPORTED;
|
||||
|
||||
// Abort Send
|
||||
case ARM_USART_ABORT_SEND:
|
||||
// TX interrupt disable
|
||||
usart->reg->CTRL &= ~CMSDK_UART_CTRL_TXIRQEN_Msk;
|
||||
// Clear tx_busy status
|
||||
usart->info->status.tx_busy = 0U;
|
||||
return ARM_DRIVER_OK;
|
||||
|
||||
// Abort receive
|
||||
case ARM_USART_ABORT_RECEIVE:
|
||||
// RX interrupt disable
|
||||
usart->reg->CTRL &= ~CMSDK_UART_CTRL_RXIRQEN_Msk;
|
||||
// Clear rx_busy status
|
||||
usart->info->status.rx_busy = 0U;
|
||||
return ARM_DRIVER_OK;
|
||||
|
||||
// Abort transfer
|
||||
case ARM_USART_ABORT_TRANSFER:
|
||||
// Synchronous mode not supported
|
||||
return ARM_DRIVER_ERROR_UNSUPPORTED;
|
||||
|
||||
// Control TX
|
||||
case ARM_USART_CONTROL_TX:
|
||||
usart->info->flags |= USART_FLAG_TX_ENABLED;
|
||||
// Transmitter enable
|
||||
usart->reg->CTRL |= ((arg & 1U) << CMSDK_UART_CTRL_TXEN_Pos);
|
||||
return ARM_DRIVER_OK;
|
||||
|
||||
// Control RX
|
||||
case ARM_USART_CONTROL_RX:
|
||||
usart->info->flags |= USART_FLAG_RX_ENABLED;
|
||||
// Receiver enable
|
||||
usart->reg->CTRL |= ((arg & 1U) << CMSDK_UART_CTRL_RXEN_Pos);
|
||||
return ARM_DRIVER_OK;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// Check if busy
|
||||
if ((usart->info->status.tx_busy != 0U) ||
|
||||
(usart->info->status.rx_busy != 0U) ||
|
||||
((usart->reg->STATE & (CMSDK_UART_STATE_TXBF_Msk | CMSDK_UART_STATE_RXBF_Msk)) != 0U)) {
|
||||
return ARM_DRIVER_ERROR_BUSY;
|
||||
}
|
||||
|
||||
switch (control & ARM_USART_CONTROL_Msk) {
|
||||
case ARM_USART_MODE_ASYNCHRONOUS: break;
|
||||
// Unsupported command
|
||||
default: return ARM_DRIVER_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// USART Data bits
|
||||
switch (control & ARM_USART_DATA_BITS_Msk) {
|
||||
case ARM_USART_DATA_BITS_8: break;
|
||||
default: return ARM_USART_ERROR_DATA_BITS;
|
||||
}
|
||||
|
||||
// USART Parity
|
||||
switch (control & ARM_USART_PARITY_Msk) {
|
||||
case ARM_USART_PARITY_NONE: break;
|
||||
default: return ARM_USART_ERROR_PARITY;
|
||||
}
|
||||
|
||||
// USART Stop bits
|
||||
switch (control & ARM_USART_STOP_BITS_Msk) {
|
||||
case ARM_USART_STOP_BITS_1: break;
|
||||
default: return ARM_USART_ERROR_STOP_BITS;
|
||||
}
|
||||
|
||||
// USART Flow control
|
||||
switch (control & ARM_USART_FLOW_CONTROL_Msk) {
|
||||
case ARM_USART_FLOW_CONTROL_NONE: break;
|
||||
default: return ARM_USART_ERROR_FLOW_CONTROL;
|
||||
}
|
||||
|
||||
// USART Baudrate
|
||||
if ((SystemCoreClock/arg) < 16U)
|
||||
return ARM_USART_ERROR_BAUDRATE;
|
||||
else
|
||||
usart->reg->BAUDDIV = SystemCoreClock/arg;
|
||||
|
||||
// Set configured flag
|
||||
usart->info->flags |= USART_FLAG_CONFIGURED;
|
||||
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn ARM_USART_STATUS USART_GetStatus (const USART_RESOURCES *usart)
|
||||
\brief Get USART status.
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return USART status \ref ARM_USART_STATUS
|
||||
*/
|
||||
static ARM_USART_STATUS USART_GetStatus (const USART_RESOURCES *usart) {
|
||||
ARM_USART_STATUS status;
|
||||
|
||||
status.tx_busy = usart->info->status.tx_busy;
|
||||
status.rx_busy = usart->info->status.rx_busy;
|
||||
status.rx_overflow = usart->info->status.rx_overflow;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn int32_t USART_SetModemControl ( ARM_USART_MODEM_CONTROL control,
|
||||
const USART_RESOURCES *usart)
|
||||
\brief Set USART Modem Control line state.
|
||||
\param[in] control \ref ARM_USART_MODEM_CONTROL
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return \ref execution_status
|
||||
*/
|
||||
static int32_t USART_SetModemControl ( ARM_USART_MODEM_CONTROL control,
|
||||
const USART_RESOURCES *usart) {
|
||||
UNUSED(control);
|
||||
UNUSED(usart);
|
||||
|
||||
return ARM_DRIVER_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
\fn ARM_USART_MODEM_STATUS USART_GetModemStatus (const USART_RESOURCES *usart)
|
||||
\brief Get USART Modem Status lines state.
|
||||
\param[in] usart Pointer to USART resources
|
||||
\return modem status \ref ARM_USART_MODEM_STATUS
|
||||
*/
|
||||
static ARM_USART_MODEM_STATUS USART_GetModemStatus (const USART_RESOURCES *usart) {
|
||||
ARM_USART_MODEM_STATUS modem_status = { 0U, 0U, 0U, 0U };
|
||||
|
||||
UNUSED(usart);
|
||||
|
||||
return modem_status;
|
||||
}
|
||||
|
||||
|
||||
static void UartIsr(struct SerialBus *serial, struct SerialDriver *serial_drv, struct SerialHardwareDevice *serial_dev);
|
||||
|
||||
#ifdef BSP_USING_LPUART1
|
||||
struct SerialBus serial_bus_1;
|
||||
struct SerialDriver serial_driver_1;
|
||||
struct SerialHardwareDevice serial_device_1;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn void USARTRX_IRQHandler (UART_RESOURCES *usart)
|
||||
\brief USART RX Interrupt handler.
|
||||
\param[in] usart Pointer to USART resources
|
||||
*/
|
||||
static void USARTRX_IRQHandler (USART_RESOURCES *usart) {
|
||||
uint32_t status;
|
||||
|
||||
status = usart->reg->INTSTATUS;
|
||||
|
||||
usart->xfer->rx_num = 0U;
|
||||
usart->info->status.rx_busy = 0U;
|
||||
usart->reg->CTRL &= ~CMSDK_UART_CTRL_RXIRQEN_Msk;
|
||||
usart->reg->INTCLEAR = status;
|
||||
|
||||
#ifdef BSP_USING_LPUART1
|
||||
DisableIRQ(UART0RX_IRQn);
|
||||
UartIsr(&serial_bus_1, &serial_driver_1, &serial_device_1);
|
||||
EnableIRQ(UART0RX_IRQn);
|
||||
#endif
|
||||
|
||||
usart->reg->BAUDDIV = 16;
|
||||
usart->reg->CTRL = CMSDK_UART_CTRL_RXIRQEN_Msk | CMSDK_UART_CTRL_RXEN_Msk | CMSDK_UART_CTRL_TXEN_Msk;
|
||||
usart->reg->STATE = 0U;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
\fn void USARTTX_IRQHandler (UART_RESOURCES *usart)
|
||||
\brief USART TX Interrupt handler.
|
||||
\param[in] usart Pointer to USART resources
|
||||
*/
|
||||
static void USARTTX_IRQHandler (USART_RESOURCES *usart) {
|
||||
uint32_t status;
|
||||
|
||||
// read interrupt status
|
||||
status = usart->reg->INTSTATUS;
|
||||
|
||||
// clear interrupt
|
||||
usart->reg->INTCLEAR = status;
|
||||
|
||||
if (usart->xfer->tx_num > 0) {
|
||||
|
||||
usart->xfer->tx_cnt++;
|
||||
|
||||
if (usart->xfer->tx_cnt < usart->xfer->tx_num) {
|
||||
// Send next byte
|
||||
usart->reg->DATA = usart->xfer->tx_buf[usart->xfer->tx_cnt];
|
||||
} else {
|
||||
// TX is completed
|
||||
usart->xfer->tx_num = 0U;
|
||||
usart->info->status.tx_busy = 0U;
|
||||
|
||||
// TX interrupt disable
|
||||
usart->reg->CTRL &= ~CMSDK_UART_CTRL_TXIRQEN_Msk;
|
||||
|
||||
// Send event
|
||||
if (usart->info->cb_event!=NULL)
|
||||
usart->info->cb_event(ARM_USART_EVENT_SEND_COMPLETE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_LPUART1
|
||||
// USART0 Driver Wrapper functions
|
||||
void UART0RX_Handler (void);
|
||||
void UART0TX_Handler (void);
|
||||
static ARM_USART_CAPABILITIES USART0_GetCapabilities (void) { return USART_GetCapabilities (&USART0_Resources); }
|
||||
static int32_t USART0_Initialize (ARM_USART_SignalEvent_t cb_event) { return USART_Initialize (cb_event, &USART0_Resources); }
|
||||
static int32_t USART0_Uninitialize (void) { return USART_Uninitialize (&USART0_Resources); }
|
||||
static int32_t USART0_PowerControl (ARM_POWER_STATE state) { return USART_PowerControl (state, &USART0_Resources); }
|
||||
static int32_t USART0_Send (const void *data, uint32_t num) { return USART_Send (data, num, &USART0_Resources); }
|
||||
static int32_t USART0_Receive (void *data, uint32_t num) { return USART_Receive (data, num, &USART0_Resources); }
|
||||
static int32_t USART0_Transfer (const void *data_out, void *data_in, uint32_t num) { return USART_Transfer (data_out, data_in, num, &USART0_Resources); }
|
||||
static uint32_t USART0_GetTxCount (void) { return USART_GetTxCount (&USART0_Resources); }
|
||||
static uint32_t USART0_GetRxCount (void) { return USART_GetRxCount (&USART0_Resources); }
|
||||
static int32_t USART0_Control (uint32_t control, uint32_t arg) { return USART_Control (control, arg, &USART0_Resources); }
|
||||
static ARM_USART_STATUS USART0_GetStatus (void) { return USART_GetStatus (&USART0_Resources); }
|
||||
static int32_t USART0_SetModemControl (ARM_USART_MODEM_CONTROL control) { return USART_SetModemControl (control, &USART0_Resources); }
|
||||
static ARM_USART_MODEM_STATUS USART0_GetModemStatus (void) { return USART_GetModemStatus (&USART0_Resources); }
|
||||
void UART0RX_Handler (void) { USARTRX_IRQHandler (&USART0_Resources); }
|
||||
void UART0TX_Handler (void) { USARTTX_IRQHandler (&USART0_Resources); }
|
||||
|
||||
// USART0 Driver Control Block
|
||||
extern ARM_DRIVER_USART Driver_USART0;
|
||||
ARM_DRIVER_USART Driver_USART0 = {
|
||||
USARTx_GetVersion,
|
||||
USART0_GetCapabilities,
|
||||
USART0_Initialize,
|
||||
USART0_Uninitialize,
|
||||
USART0_PowerControl,
|
||||
USART0_Send,
|
||||
USART0_Receive,
|
||||
USART0_Transfer,
|
||||
USART0_GetTxCount,
|
||||
USART0_GetRxCount,
|
||||
USART0_Control,
|
||||
USART0_GetStatus,
|
||||
USART0_SetModemControl,
|
||||
USART0_GetModemStatus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#define _USART_Driver_(n) Driver_USART##n
|
||||
#define USART_Driver_(n) _USART_Driver_(n)
|
||||
|
||||
extern ARM_DRIVER_USART USART_Driver_(0);
|
||||
#define ptrUSART1 (&USART_Driver_(0))
|
||||
|
||||
#define USART_BAUDRATE 115200
|
||||
|
||||
|
||||
|
||||
static void SerialCfgParamCheck(struct SerialCfgParam *serial_cfg_default, struct SerialCfgParam *serial_cfg_new)
|
||||
{
|
||||
struct SerialDataCfg *data_cfg_default = &serial_cfg_default->data_cfg;
|
||||
struct SerialDataCfg *data_cfg_new = &serial_cfg_new->data_cfg;
|
||||
|
||||
if ((data_cfg_default->serial_baud_rate != data_cfg_new->serial_baud_rate) && (data_cfg_new->serial_baud_rate)) {
|
||||
data_cfg_default->serial_baud_rate = data_cfg_new->serial_baud_rate;
|
||||
}
|
||||
|
||||
if ((data_cfg_default->serial_bit_order != data_cfg_new->serial_bit_order) && (data_cfg_new->serial_bit_order)) {
|
||||
data_cfg_default->serial_bit_order = data_cfg_new->serial_bit_order;
|
||||
}
|
||||
|
||||
if ((data_cfg_default->serial_buffer_size != data_cfg_new->serial_buffer_size) && (data_cfg_new->serial_buffer_size)) {
|
||||
data_cfg_default->serial_buffer_size = data_cfg_new->serial_buffer_size;
|
||||
}
|
||||
|
||||
if ((data_cfg_default->serial_data_bits != data_cfg_new->serial_data_bits) && (data_cfg_new->serial_data_bits)) {
|
||||
data_cfg_default->serial_data_bits = data_cfg_new->serial_data_bits;
|
||||
}
|
||||
|
||||
if ((data_cfg_default->serial_invert_mode != data_cfg_new->serial_invert_mode) && (data_cfg_new->serial_invert_mode)) {
|
||||
data_cfg_default->serial_invert_mode = data_cfg_new->serial_invert_mode;
|
||||
}
|
||||
|
||||
if ((data_cfg_default->serial_parity_mode != data_cfg_new->serial_parity_mode) && (data_cfg_new->serial_parity_mode)) {
|
||||
data_cfg_default->serial_parity_mode = data_cfg_new->serial_parity_mode;
|
||||
}
|
||||
|
||||
if ((data_cfg_default->serial_stop_bits != data_cfg_new->serial_stop_bits) && (data_cfg_new->serial_stop_bits)) {
|
||||
data_cfg_default->serial_stop_bits = data_cfg_new->serial_stop_bits;
|
||||
}
|
||||
|
||||
if ((data_cfg_default->serial_timeout != data_cfg_new->serial_timeout) && (data_cfg_new->serial_timeout)) {
|
||||
data_cfg_default->serial_timeout = data_cfg_new->serial_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
static void UartIsr(struct SerialBus *serial, struct SerialDriver *serial_drv, struct SerialHardwareDevice *serial_dev)
|
||||
{
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
SerialSetIsr(serial_dev, SERIAL_EVENT_RX_IND);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInfo *configure_info)
|
||||
{
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
// LPUART_Type *uart_base = (LPUART_Type *)serial_cfg->hw_cfg.private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
int32_t status;
|
||||
|
||||
status = ptrUSART1->Initialize(NULL);
|
||||
if (status != ARM_DRIVER_OK) return (-1);
|
||||
|
||||
status = ptrUSART1->PowerControl(ARM_POWER_FULL);
|
||||
if (status != ARM_DRIVER_OK) return (-1);
|
||||
|
||||
status = ptrUSART1->Control(ARM_USART_MODE_ASYNCHRONOUS |
|
||||
ARM_USART_DATA_BITS_8 |
|
||||
ARM_USART_PARITY_NONE |
|
||||
ARM_USART_STOP_BITS_1 |
|
||||
ARM_USART_FLOW_CONTROL_NONE,
|
||||
USART_BAUDRATE);
|
||||
if (status != ARM_DRIVER_OK) return (-1);
|
||||
|
||||
status = ptrUSART1->Control(ARM_USART_CONTROL_TX, 1);
|
||||
if (status != ARM_DRIVER_OK) return (-1);
|
||||
|
||||
status = ptrUSART1->Control(ARM_USART_CONTROL_RX, 1);
|
||||
if (status != ARM_DRIVER_OK) return (-1);
|
||||
// stdout_init();
|
||||
// stdout_putchar(36);
|
||||
|
||||
if (configure_info->private_data) {
|
||||
DisableIRQ(serial_cfg->hw_cfg.serial_irq_interrupt);
|
||||
// LPUART_EnableInterrupts(uart_base, kLPUART_RxDataRegFullInterruptEnable);
|
||||
NVIC_SetPriority(serial_cfg->hw_cfg.serial_irq_interrupt, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 4, 0));
|
||||
EnableIRQ(serial_cfg->hw_cfg.serial_irq_interrupt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
static uint32 SerialConfigure(struct SerialDriver *serial_drv, int serial_operation_cmd)
|
||||
{
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
// LPUART_Type *uart_base = (LPUART_Type *)serial_cfg->hw_cfg.private_data;
|
||||
struct BusConfigureInfo configure_info;
|
||||
configure_info.private_data = NONE;
|
||||
|
||||
SerialInit(serial_drv, &configure_info);
|
||||
|
||||
switch (serial_operation_cmd)
|
||||
{
|
||||
case OPER_CLR_INT:
|
||||
DisableIRQ(serial_cfg->hw_cfg.serial_irq_interrupt);
|
||||
break;
|
||||
|
||||
case OPER_SET_INT:
|
||||
// LPUART_EnableInterrupts(uart_base, kLPUART_RxDataRegFullInterruptEnable);
|
||||
NVIC_SetPriority(serial_cfg->hw_cfg.serial_irq_interrupt, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 4, 0));
|
||||
EnableIRQ(serial_cfg->hw_cfg.serial_irq_interrupt);
|
||||
break;
|
||||
}
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
|
||||
static int SerialPutChar(struct SerialHardwareDevice *serial_dev, char c)
|
||||
{
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_dev->private_data;
|
||||
|
||||
uint8_t buf[1];
|
||||
|
||||
buf[0] = c;
|
||||
if (ptrUSART1->Send(buf, 1) != ARM_DRIVER_OK) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
UART0TX_Handler();
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int SerialGetChar(struct SerialHardwareDevice *serial_dev)
|
||||
{
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_dev->private_data;
|
||||
|
||||
int c=-1;
|
||||
int buf[1];
|
||||
buf[0]=0;
|
||||
do{
|
||||
buf[0]=ptrUSART1->Receive(buf, 1);
|
||||
}while (buf[0]==0);
|
||||
|
||||
c=buf[0];
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static uint32 SerialDrvConfigure(void *drv, struct BusConfigureInfo *configure_info)
|
||||
{
|
||||
NULL_PARAM_CHECK(drv);
|
||||
NULL_PARAM_CHECK(configure_info);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
int serial_operation_cmd;
|
||||
struct SerialDriver *serial_drv = (struct SerialDriver *)drv;
|
||||
|
||||
switch (configure_info->configure_cmd)
|
||||
{
|
||||
case OPE_INT:
|
||||
ret = SerialInit(serial_drv, configure_info);
|
||||
break;
|
||||
case OPE_CFG:
|
||||
serial_operation_cmd = *(int *)configure_info->private_data;
|
||||
ret = SerialConfigure(serial_drv, serial_operation_cmd);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct SerialDataCfg data_cfg_init =
|
||||
{
|
||||
.serial_baud_rate = BAUD_RATE_115200,
|
||||
.serial_data_bits = DATA_BITS_8,
|
||||
.serial_stop_bits = STOP_BITS_1,
|
||||
.serial_parity_mode = PARITY_NONE,
|
||||
.serial_bit_order = BIT_ORDER_LSB,
|
||||
.serial_invert_mode = NRZ_NORMAL,
|
||||
.serial_buffer_size = SERIAL_RB_BUFSZ,
|
||||
.serial_timeout = WAITING_FOREVER,
|
||||
};
|
||||
|
||||
/*manage the serial device operations*/
|
||||
static const struct SerialDrvDone drv_done =
|
||||
{
|
||||
.init = SerialInit,
|
||||
.configure = SerialConfigure,
|
||||
};
|
||||
|
||||
/*manage the serial device hal operations*/
|
||||
static struct SerialHwDevDone hwdev_done =
|
||||
{
|
||||
.put_char = SerialPutChar,
|
||||
.get_char = SerialGetChar,
|
||||
};
|
||||
|
||||
static int BoardSerialBusInit(struct SerialBus *serial_bus, struct SerialDriver *serial_driver, const char *bus_name, const char *drv_name)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
|
||||
/*Init the serial bus */
|
||||
ret = SerialBusInit(serial_bus, bus_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Imxrt1052HwUartInit SerialBusInit error %d\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/*Init the serial driver*/
|
||||
ret = SerialDriverInit(serial_driver, drv_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Imxrt1052HwUartInit SerialDriverInit error %d\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/*Attach the serial driver to the serial bus*/
|
||||
ret = SerialDriverAttachToBus(drv_name, bus_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Imxrt1052HwUartInit SerialDriverAttachToBus error %d\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*Attach the serial device to the serial bus*/
|
||||
static int BoardSerialDevBend(struct SerialHardwareDevice *serial_device, void *serial_param, const char *bus_name, const char *dev_name)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
|
||||
ret = SerialDeviceRegister(serial_device, serial_param, dev_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Imxrt1052HwUartInit SerialDeviceInit device %s error %d\n", dev_name, ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
ret = SerialDeviceAttachToBus(dev_name, bus_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Imxrt1052HwUartInit SerialDeviceAttachToBus device %s error %d\n", dev_name, ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Imxrt1052HwUartInit(void)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
|
||||
#ifdef BSP_USING_LPUART1
|
||||
static struct SerialCfgParam serial_cfg_1;
|
||||
memset(&serial_cfg_1, 0, sizeof(struct SerialCfgParam));
|
||||
|
||||
static struct SerialDevParam serial_dev_param_1;
|
||||
memset(&serial_dev_param_1, 0, sizeof(struct SerialDevParam));
|
||||
|
||||
serial_driver_1.drv_done = &drv_done;
|
||||
serial_driver_1.configure = &SerialDrvConfigure;
|
||||
serial_device_1.hwdev_done = &hwdev_done;
|
||||
|
||||
serial_cfg_1.data_cfg = data_cfg_init;
|
||||
|
||||
CMSDK_UART0->BAUDDIV = 16;
|
||||
CMSDK_UART0->CTRL = CMSDK_UART_CTRL_RXIRQEN_Msk | CMSDK_UART_CTRL_RXEN_Msk | CMSDK_UART_CTRL_TXEN_Msk;
|
||||
CMSDK_UART0->STATE = 0U;
|
||||
|
||||
serial_cfg_1.hw_cfg.private_data = (void *)CMSDK_UART0;
|
||||
serial_cfg_1.hw_cfg.serial_irq_interrupt = UART0RX_IRQn ;
|
||||
serial_driver_1.private_data = (void *)&serial_cfg_1;
|
||||
|
||||
|
||||
|
||||
serial_dev_param_1.serial_work_mode = SIGN_OPER_INT_RX;
|
||||
serial_device_1.haldev.private_data = (void *)&serial_dev_param_1;
|
||||
|
||||
ret = BoardSerialBusInit(&serial_bus_1, &serial_driver_1, SERIAL_BUS_NAME_1, SERIAL_DRV_NAME_1);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Imxrt1052HwUartInit uart error ret %u\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
ret = BoardSerialDevBend(&serial_device_1, (void *)&serial_cfg_1, SERIAL_BUS_NAME_1, SERIAL_1_DEVICE_NAME_0);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Imxrt1052HwUartInit uart error ret %u\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
export CROSS_COMPILE ?=/usr/bin/arm-none-eabi-
|
||||
|
||||
export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror -Wuninitialized
|
||||
export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O2 -gdwarf-2 -g -fgnu89-inline -Wa,-mimplicit-it=thumb
|
||||
# export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror
|
||||
export AFLAGS := -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb -gdwarf-2
|
||||
export LFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-edu-arm32.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds
|
||||
export CXXFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -Werror
|
||||
export CXXFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O2 -Werror
|
||||
# export CXXFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -Werror
|
||||
|
||||
export APPLFLAGS :=
|
||||
|
||||
@@ -107,6 +107,7 @@ SECTIONS
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
_exit = .;
|
||||
} >FLASH
|
||||
|
||||
.rodata :
|
||||
|
||||
@@ -24,27 +24,29 @@ Others: connect_can.c for references
|
||||
|
||||
#define CAN_X (CM_CAN2)
|
||||
|
||||
#define CAN_TX_PORT (GPIO_PORT_D)
|
||||
#define CAN_TX_PIN (GPIO_PIN_07)
|
||||
#define CAN_RX_PORT (GPIO_PORT_D)
|
||||
#define CAN_RX_PIN (GPIO_PIN_06)
|
||||
#define CAN_TX_PIN_FUNC (GPIO_FUNC_62)
|
||||
#define CAN_RX_PIN_FUNC (GPIO_FUNC_63)
|
||||
#define CAN_TX_PORT (GPIO_PORT_D)
|
||||
#define CAN_TX_PIN (GPIO_PIN_07)
|
||||
#define CAN_RX_PORT (GPIO_PORT_D)
|
||||
#define CAN_RX_PIN (GPIO_PIN_06)
|
||||
#define CAN_TX_PIN_FUNC (GPIO_FUNC_62)
|
||||
#define CAN_RX_PIN_FUNC (GPIO_FUNC_63)
|
||||
|
||||
#define INTSEL_REG ((uint32_t)(&CM_INTC->SEL0))
|
||||
#define CANX_IRQ_SRC INT_SRC_CAN2_HOST
|
||||
#define CANX_IRQ_NUM 17
|
||||
#define IRQ_NUM_OFFSET 16
|
||||
|
||||
#define CAN_AF1_ID (0x123UL)
|
||||
#define CAN_AF1_ID_MSK (0xFFFUL)
|
||||
#define CAN_AF1_MSK_TYPE CAN_ID_STD
|
||||
#define CAN_AF2_ID (0x005UL)
|
||||
#define CAN_AF2_ID_MSK (0x00FUL)
|
||||
#define CAN_AF2_MSK_TYPE CAN_ID_STD
|
||||
#define CAN_AF3_ID (0x23UL)
|
||||
#define CAN_AF3_ID_MSK (0xFFUL)
|
||||
#define CAN_AF3_MSK_TYPE CAN_ID_STD
|
||||
#define CAN_AF1_ID (0x123UL)
|
||||
#define CAN_AF1_ID_MSK (0xFFFUL)
|
||||
#define CAN_AF1_MSK_TYPE CAN_ID_STD
|
||||
|
||||
#define CAN_AF2_ID (0x005UL)
|
||||
#define CAN_AF2_ID_MSK (0x00FUL)
|
||||
#define CAN_AF2_MSK_TYPE CAN_ID_STD
|
||||
|
||||
#define CAN_AF3_ID (0x23UL)
|
||||
#define CAN_AF3_ID_MSK (0xFFUL)
|
||||
#define CAN_AF3_MSK_TYPE CAN_ID_STD
|
||||
|
||||
#ifdef CAN_USING_INTERRUPT
|
||||
void CanIrqHandler(int vector, void *param)
|
||||
@@ -95,18 +97,9 @@ static void CanInit(struct CanDriverConfigure *can_drv_config)
|
||||
stcInit.stcBitCfg.u32TimeSeg2 = can_drv_config->tbs2;
|
||||
stcInit.u8WorkMode = can_drv_config->mode;
|
||||
|
||||
#ifdef CAN_USING_FD
|
||||
stcInit.stcFDCfg.u8TDCSSP = 16U;
|
||||
stcInit.stcFDCfg.u8CANFDMode = CAN_FD_MODE_ISO_11898;
|
||||
stcInit.stcFDCfg.stcFBT.u32SEG1 = 16U;
|
||||
stcInit.stcFDCfg.stcFBT.u32SEG2 = 4U;
|
||||
stcInit.stcFDCfg.stcFBT.u32SJW = 4U;
|
||||
stcInit.stcFDCfg.stcFBT.u32Prescaler = 1U;
|
||||
(void)CAN_FD_Init(APP_CAN_UNIT, &stcInit);
|
||||
#else
|
||||
FCG_Fcg1PeriphClockCmd(PWC_FCG1_CAN2, ENABLE);
|
||||
(void)CAN_Init(CAN_X, &stcInit);
|
||||
#endif
|
||||
|
||||
CAN_ClearStatus(CAN_X, 0xFFFFFFFFU);
|
||||
|
||||
#ifdef CAN_USING_INTERRUPT
|
||||
|
||||
@@ -278,10 +278,7 @@ struct pbuf* low_level_input(struct netif* netif)
|
||||
return p;
|
||||
}
|
||||
|
||||
extern void LwipSetIPTest(int argc, char* argv[]);
|
||||
int HwEthInit(void)
|
||||
{
|
||||
// lwip_config_tcp(0, lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
LwipSetIPTest(1, NULL);
|
||||
return EOK;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ static int lwip_netdev_set_addr_info(struct netdev* netdev, ip_addr_t* ip_addr,
|
||||
netif_set_gw((struct netif*)netdev->user_data, ip_2_ip4(gw));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef LWIP_DNS
|
||||
@@ -92,7 +93,7 @@ static int lwip_netdev_set_dns_server(struct netdev* netdev, uint8_t dns_num, ip
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DHCP
|
||||
#if LWIP_DHCP
|
||||
static int lwip_netdev_set_dhcp(struct netdev* netdev, bool is_enabled)
|
||||
{
|
||||
netdev_low_level_set_dhcp_status(netdev, is_enabled);
|
||||
@@ -120,7 +121,7 @@ static const struct netdev_ops lwip_netdev_ops = {
|
||||
#ifdef LWIP_DNS
|
||||
.set_dns_server = lwip_netdev_set_dns_server,
|
||||
#endif
|
||||
#ifdef LWIP_DHCP
|
||||
#if LWIP_DHCP
|
||||
.set_dhcp = lwip_netdev_set_dhcp,
|
||||
#endif
|
||||
.set_default = lwip_netdev_set_default,
|
||||
@@ -179,9 +180,9 @@ int lwip_netdev_add(struct netif* lwip_netif)
|
||||
netdev->ops = &lwip_netdev_ops;
|
||||
netdev->hwaddr_len = lwip_netif->hwaddr_len;
|
||||
memcpy(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
|
||||
netdev->ip_addr = lwip_netif->ip_addr;
|
||||
netdev->gw = lwip_netif->gw;
|
||||
netdev->netmask = lwip_netif->netmask;
|
||||
netdev->ip_addr = &lwip_netif->ip_addr;
|
||||
netdev->gw = &lwip_netif->gw;
|
||||
netdev->netmask = &lwip_netif->netmask;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -229,11 +229,13 @@ static void SdCardAttach(void)
|
||||
|
||||
KPrintf("\r\nCard inserted.\r\n");
|
||||
|
||||
int err_code = LL_OK;
|
||||
|
||||
/* Reset and init SDIOC */
|
||||
if (LL_OK != SDIOC_SWReset(sd_handle->SDIOCx, SDIOC_SW_RST_ALL)) {
|
||||
KPrintf("Reset SDIOC failed!\r\n");
|
||||
} else if (LL_OK != SD_Init(sd_handle)) {
|
||||
KPrintf("SD card initialize failed!\r\n");
|
||||
if (LL_OK != (err_code = SDIOC_SWReset(sd_handle->SDIOCx, SDIOC_SW_RST_ALL))) {
|
||||
KPrintf("Reset SDIOC failed! error code: %d\r\n", err_code);
|
||||
} else if (LL_OK != (err_code = SD_Init(sd_handle))) {
|
||||
KPrintf("SD card initialize failed!, error code: %d\r\n", err_code);
|
||||
} else {
|
||||
KPrintf("SD card init done!\r\n");
|
||||
}
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
|
||||
#include <connect_hwtimer.h>
|
||||
|
||||
#define TMR0_CMP_VAL 1000
|
||||
#define TMR0_CMP_VAL (100000000U / 1024U / 2 - 1U)
|
||||
#define TMR0x ((CM_TMR0_TypeDef *)CM_TMR0_1_BASE)
|
||||
#define TMR0_CH_x (TMR0_CH_A)
|
||||
#define INTSEL_REG ((uint32_t)(&CM_INTC->SEL0))
|
||||
#define TIMER0_IRQn (18)
|
||||
|
||||
|
||||
void (*callback_function)(void *) ;
|
||||
|
||||
static void Timer0Callback(int vector, void *param)
|
||||
@@ -47,10 +46,10 @@ static uint32 HwtimerOpen(void *dev)
|
||||
|
||||
/* TIMER0 basetimer function initialize */
|
||||
(void)TMR0_StructInit(&stcTmr0Init);
|
||||
stcTmr0Init.u32ClockDiv = TMR0_CLK_DIV128; /* Config clock division */
|
||||
stcTmr0Init.u32ClockSrc = TMR0_CLK_SRC_INTERN_CLK; /* Chose clock source */
|
||||
stcTmr0Init.u32Func = TMR0_FUNC_CMP; /* Timer0 compare mode */
|
||||
stcTmr0Init.u16CompareValue = TMR0_CMP_VAL; /* Set compare register data */
|
||||
stcTmr0Init.u32ClockDiv = TMR0_CLK_DIV1024; /* Config clock division */
|
||||
stcTmr0Init.u32ClockSrc = TMR0_CLK_SRC_INTERN_CLK; /* Chose clock source */
|
||||
stcTmr0Init.u32Func = TMR0_FUNC_CMP; /* Timer0 compare mode */
|
||||
stcTmr0Init.u16CompareValue = TMR0_CMP_VAL; /* Set compare register data */
|
||||
(void)TMR0_Init(TMR0x, TMR0_CH_x, &stcTmr0Init);
|
||||
|
||||
// DelayKTask(1);
|
||||
@@ -98,7 +97,8 @@ static uint32 HwtimerDrvConfigure(void *drv, struct BusConfigureInfo *configure_
|
||||
break;
|
||||
case OPE_CFG:
|
||||
TMR0_ClearStatus(TMR0x, TMR0_FLAG_CMP_A);
|
||||
TMR0_SetCompareValue(TMR0x, TMR0_CH_x, *((int *)configure_info->private_data) );
|
||||
uint32_t cmp_value = *((uint32_t *)configure_info->private_data) * 100;//1ms 100, max 655ms 65535
|
||||
TMR0_SetCompareValue(TMR0x, TMR0_CH_x, (uint16_t)cmp_value);
|
||||
/* Timer0 interrupt function Enable */
|
||||
TMR0_SetCountValue(TMR0x, TMR0_CH_x, 0x0000);
|
||||
TMR0_Start(TMR0x, TMR0_CH_x);
|
||||
|
||||
@@ -234,13 +234,17 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
struct UsartHwCfg *serial_hw_cfg = (struct UsartHwCfg *)serial_cfg->hw_cfg.private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# SRC_FILES := socket.c connect_w5500.c w5500.c wizchip_conf.c spi_interface.c wiz_ping.c connect_w5500_test.c wiz_iperf.c
|
||||
SRC_FILES := socket.c connect_w5500.c w5500.c wizchip_conf.c spi_interface.c wiz_ping.c connect_w5500_test.c w5x00_lwip.c wiz_iperf.c
|
||||
SRC_FILES := socket.c connect_w5500.c w5500.c wizchip_conf.c spi_interface.c w5x00_lwip.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -328,8 +328,12 @@ int HwWiznetInit(void)
|
||||
setSHAR(wiz_mac);
|
||||
ctlwizchip(CW_RESET_PHY, 0);
|
||||
|
||||
network_init();
|
||||
|
||||
wiz_interrupt_init(0, wiz_irq_handler);
|
||||
|
||||
network_init();
|
||||
|
||||
setSn_RXBUF_SIZE(0, 16);
|
||||
setSn_TXBUF_SIZE(0, 16);
|
||||
#define SOCK_ANY_PORT_NUM 0xC000
|
||||
@@ -349,7 +353,5 @@ int HwWiznetInit(void)
|
||||
}
|
||||
}
|
||||
|
||||
network_init();
|
||||
|
||||
return EOK;
|
||||
}
|
||||
@@ -152,6 +152,9 @@ static uint32 SpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_info
|
||||
|
||||
static uint32 SpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg)
|
||||
{
|
||||
#define WRITE_BUF_SIZE 1600
|
||||
static uint32_t write_buf[4 * WRITE_BUF_SIZE] = { 0 };
|
||||
|
||||
SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data);
|
||||
|
||||
uint8 device_id = dev_param->spi_slave_param->spi_slave_id;
|
||||
@@ -184,10 +187,15 @@ static uint32 SpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStan
|
||||
dmac_set_single_mode(dev_param->spi_dma_param->spi_dmac_txchannel, &dummy, (void *)(&spi_instance[device_master_id]->dr[0]), DMAC_ADDR_NOCHANGE, DMAC_ADDR_NOCHANGE,
|
||||
DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, spi_datacfg->length);
|
||||
} else {
|
||||
tx_buff = x_malloc(spi_datacfg->length * 4);
|
||||
if (!tx_buff) {
|
||||
goto transfer_done;
|
||||
if (spi_datacfg->length > WRITE_BUF_SIZE) {
|
||||
tx_buff = x_malloc(spi_datacfg->length * 4);
|
||||
if (!tx_buff) {
|
||||
goto transfer_done;
|
||||
}
|
||||
} else {
|
||||
tx_buff = write_buf;
|
||||
}
|
||||
|
||||
for (i = 0; i < spi_datacfg->length; i++) {
|
||||
tx_buff[i] = ((uint8_t *)spi_datacfg->tx_buff)[i];
|
||||
}
|
||||
@@ -201,10 +209,10 @@ static uint32 SpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStan
|
||||
spi_instance[device_master_id]->ser = 0x00;
|
||||
spi_instance[device_master_id]->ssienr = 0x00;
|
||||
|
||||
transfer_done:
|
||||
if (tx_buff != NULL) {
|
||||
x_free(tx_buff);
|
||||
}
|
||||
transfer_done:
|
||||
if (tx_buff != NULL && spi_datacfg->length > WRITE_BUF_SIZE) {
|
||||
x_free(tx_buff);
|
||||
}
|
||||
}
|
||||
|
||||
if (spi_datacfg->spi_cs_release) {
|
||||
@@ -219,6 +227,9 @@ static uint32 SpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStan
|
||||
|
||||
static uint32 SpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg)
|
||||
{
|
||||
#define READ_BUF_SIZE 1600
|
||||
static uint32_t read_buf[4 * READ_BUF_SIZE] = { 0 };
|
||||
|
||||
SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data);
|
||||
|
||||
uint32 spi_read_length = 0;;
|
||||
@@ -251,12 +262,15 @@ static uint32 SpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStand
|
||||
dmac_set_single_mode(dev_param->spi_dma_param->spi_dmac_rxchannel, (void *)(&spi_instance[device_master_id]->dr[0]), &dummy, DMAC_ADDR_NOCHANGE, DMAC_ADDR_NOCHANGE,
|
||||
DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, spi_datacfg->length);
|
||||
} else {
|
||||
rx_buff = x_calloc(spi_datacfg->length * 4, 1);
|
||||
if(!rx_buff)
|
||||
{
|
||||
goto transfer_done;
|
||||
if (spi_datacfg->length > READ_BUF_SIZE) {
|
||||
rx_buff = x_calloc(spi_datacfg->length * 4, 1);
|
||||
if (!rx_buff) {
|
||||
goto transfer_done;
|
||||
}
|
||||
} else {
|
||||
rx_buff = read_buf;
|
||||
}
|
||||
|
||||
|
||||
dmac_set_single_mode(dev_param->spi_dma_param->spi_dmac_rxchannel, (void *)(&spi_instance[device_master_id]->dr[0]), rx_buff, DMAC_ADDR_NOCHANGE, DMAC_ADDR_INCREMENT,
|
||||
DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, spi_datacfg->length);
|
||||
}
|
||||
@@ -273,8 +287,8 @@ static uint32 SpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStand
|
||||
}
|
||||
}
|
||||
|
||||
transfer_done:
|
||||
if (rx_buff) {
|
||||
transfer_done:
|
||||
if (rx_buff && spi_datacfg->length > READ_BUF_SIZE) {
|
||||
x_free(rx_buff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,13 +145,17 @@ static uint32 SerialHsInit(struct SerialDriver *serial_drv, struct BusConfigureI
|
||||
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
@@ -227,15 +231,19 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
{
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
|
||||
@@ -78,13 +78,17 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
@@ -103,13 +103,17 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
// struct UsartHwCfg *serial_hw_cfg = (struct UsartHwCfg *)serial_cfg->hw_cfg.private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
@@ -78,13 +78,17 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
@@ -78,13 +78,17 @@ static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInf
|
||||
NULL_PARAM_CHECK(serial_drv);
|
||||
struct SerialCfgParam *serial_cfg = (struct SerialCfgParam *)serial_drv->private_data;
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
|
||||
if (configure_info->private_data) {
|
||||
struct SerialCfgParam *serial_cfg_new = (struct SerialCfgParam *)configure_info->private_data;
|
||||
SerialCfgParamCheck(serial_cfg, serial_cfg_new);
|
||||
}
|
||||
|
||||
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)serial_drv->driver.owner_bus->owner_haldev;
|
||||
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
|
||||
if (serial_cfg_new->data_cfg.dev_recv_callback) {
|
||||
BusDevRecvCallback(&(serial_dev->haldev), serial_cfg_new->data_cfg.dev_recv_callback);
|
||||
}
|
||||
}
|
||||
|
||||
// config serial receive sem timeout
|
||||
dev_param->serial_timeout = serial_cfg->data_cfg.serial_timeout;
|
||||
|
||||
@@ -76,6 +76,7 @@ static int lwip_netdev_set_addr_info(struct netdev* netdev, ip_addr_t* ip_addr,
|
||||
netif_set_gw((struct netif*)netdev->user_data, ip_2_ip4(gw));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef LWIP_DNS
|
||||
@@ -92,7 +93,7 @@ static int lwip_netdev_set_dns_server(struct netdev* netdev, uint8_t dns_num, ip
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DHCP
|
||||
#if LWIP_DHCP
|
||||
static int lwip_netdev_set_dhcp(struct netdev* netdev, bool is_enabled)
|
||||
{
|
||||
netdev_low_level_set_dhcp_status(netdev, is_enabled);
|
||||
@@ -120,7 +121,7 @@ static const struct netdev_ops lwip_netdev_ops = {
|
||||
#ifdef LWIP_DNS
|
||||
.set_dns_server = lwip_netdev_set_dns_server,
|
||||
#endif
|
||||
#ifdef LWIP_DHCP
|
||||
#if LWIP_DHCP
|
||||
.set_dhcp = lwip_netdev_set_dhcp,
|
||||
#endif
|
||||
.set_default = lwip_netdev_set_default,
|
||||
@@ -180,9 +181,9 @@ int lwip_netdev_add(struct netif* lwip_netif)
|
||||
netdev->ops = &lwip_netdev_ops;
|
||||
netdev->hwaddr_len = lwip_netif->hwaddr_len;
|
||||
memcpy(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
|
||||
netdev->ip_addr = lwip_netif->ip_addr;
|
||||
netdev->gw = lwip_netif->gw;
|
||||
netdev->netmask = lwip_netif->netmask;
|
||||
netdev->ip_addr = &lwip_netif->ip_addr;
|
||||
netdev->gw = &lwip_netif->gw;
|
||||
netdev->netmask = &lwip_netif->netmask;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user