From 01671090a79b598ee2b185ff8661f32edac8bc77 Mon Sep 17 00:00:00 2001 From: misonyo Date: Fri, 8 Mar 2019 15:02:46 +0800 Subject: [PATCH] =?UTF-8?q?[bsp/lpc408x]=E6=9B=B4=E6=96=B0=E6=97=A7?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/lpc408x/.config | 198 ++- bsp/lpc408x/README.md | 28 +- bsp/lpc408x/SConscript | 3 +- bsp/lpc408x/SConstruct | 9 +- bsp/lpc408x/applications/SConscript | 6 +- bsp/lpc408x/applications/application.c | 38 - bsp/lpc408x/applications/board.h | 63 - bsp/lpc408x/applications/canapp.c | 80 -- bsp/lpc408x/applications/main.c | 19 + bsp/lpc408x/applications/sram.c | 43 - bsp/lpc408x/applications/sram.h | 18 - bsp/lpc408x/applications/startup.c | 67 - bsp/lpc408x/drivers/Kconfig | 58 +- bsp/lpc408x/drivers/SConscript | 26 +- bsp/lpc408x/{applications => drivers}/board.c | 39 +- bsp/lpc408x/drivers/board.h | 50 + bsp/lpc408x/drivers/drv_emac.c | 4 +- bsp/lpc408x/drivers/drv_emac.h | 9 +- bsp/lpc408x/drivers/drv_hwtimer.c | 11 +- bsp/lpc408x/drivers/drv_hwtimer.h | 18 +- bsp/lpc408x/drivers/drv_led.c | 5 +- bsp/lpc408x/drivers/drv_led.h | 16 + bsp/lpc408x/drivers/drv_lpccan.c | 1086 ----------------- bsp/lpc408x/drivers/drv_lpccan.h | 25 - bsp/lpc408x/drivers/drv_sdram.c | 68 +- bsp/lpc408x/drivers/drv_sdram.h | 23 +- bsp/lpc408x/drivers/drv_uart.c | 136 +-- bsp/lpc408x/drivers/drv_uart.h | 4 +- .../linker_scripts/link.lds} | 5 +- .../linker_scripts/link.sct} | 0 bsp/lpc408x/project.uvopt | 30 +- bsp/lpc408x/project.uvoptx | 177 +++ bsp/lpc408x/project.uvproj | 970 ++++++--------- bsp/lpc408x/project.uvprojx | 671 +++++----- bsp/lpc408x/rtconfig.h | 153 +-- bsp/lpc408x/rtconfig.py | 29 +- bsp/lpc408x/template.uvopt | 30 +- bsp/lpc408x/template.uvoptx | 177 +++ bsp/lpc408x/template.uvproj | 33 +- bsp/lpc408x/template.uvprojx | 54 +- 40 files changed, 1628 insertions(+), 2851 deletions(-) delete mode 100644 bsp/lpc408x/applications/application.c delete mode 100644 bsp/lpc408x/applications/board.h delete mode 100644 bsp/lpc408x/applications/canapp.c create mode 100644 bsp/lpc408x/applications/main.c delete mode 100644 bsp/lpc408x/applications/sram.c delete mode 100644 bsp/lpc408x/applications/sram.h delete mode 100644 bsp/lpc408x/applications/startup.c rename bsp/lpc408x/{applications => drivers}/board.c (60%) create mode 100644 bsp/lpc408x/drivers/board.h delete mode 100644 bsp/lpc408x/drivers/drv_lpccan.c delete mode 100644 bsp/lpc408x/drivers/drv_lpccan.h rename bsp/lpc408x/{rtthread-lpc408x.ld => drivers/linker_scripts/link.lds} (95%) rename bsp/lpc408x/{rtthread-lpc408x.sct => drivers/linker_scripts/link.sct} (100%) create mode 100644 bsp/lpc408x/project.uvoptx create mode 100644 bsp/lpc408x/template.uvoptx diff --git a/bsp/lpc408x/.config b/bsp/lpc408x/.config index fca755e768..b87d2cd213 100644 --- a/bsp/lpc408x/.config +++ b/bsp/lpc408x/.config @@ -7,20 +7,31 @@ # RT-Thread Kernel # CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_SMP is not set CONFIG_RT_ALIGN_SIZE=4 # CONFIG_RT_THREAD_PRIORITY_8 is not set CONFIG_RT_THREAD_PRIORITY_32=y # CONFIG_RT_THREAD_PRIORITY_256 is not set CONFIG_RT_THREAD_PRIORITY_MAX=32 -CONFIG_RT_TICK_PER_SECOND=100 +CONFIG_RT_TICK_PER_SECOND=1000 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=256 +# CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y CONFIG_RT_DEBUG_COLOR=y -CONFIG_RT_USING_OVERFLOW_CHECK=y -CONFIG_RT_DEBUG_INIT=0 -CONFIG_RT_DEBUG_THREAD=0 -CONFIG_RT_USING_HOOK=y -CONFIG_IDLE_THREAD_STACK_SIZE=512 -# CONFIG_RT_USING_TIMER_SOFT is not set +# CONFIG_RT_DEBUG_INIT_CONFIG is not set +# CONFIG_RT_DEBUG_THREAD_CONFIG is not set +# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set +# CONFIG_RT_DEBUG_IPC_CONFIG is not set +# CONFIG_RT_DEBUG_TIMER_CONFIG is not set +# CONFIG_RT_DEBUG_IRQ_CONFIG is not set +# CONFIG_RT_DEBUG_MEM_CONFIG is not set +# CONFIG_RT_DEBUG_SLAB_CONFIG is not set +# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set +# CONFIG_RT_DEBUG_MODULE_CONFIG is not set # # Inter-Thread communication @@ -38,29 +49,33 @@ CONFIG_RT_USING_MESSAGEQUEUE=y CONFIG_RT_USING_MEMPOOL=y CONFIG_RT_USING_MEMHEAP=y # CONFIG_RT_USING_NOHEAP is not set -CONFIG_RT_USING_SMALL_MEM=y +# CONFIG_RT_USING_SMALL_MEM is not set # CONFIG_RT_USING_SLAB is not set -# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set -# CONFIG_RT_USING_MEMTRACE is not set +CONFIG_RT_USING_MEMHEAP_AS_HEAP=y CONFIG_RT_USING_HEAP=y # # Kernel Device Object # CONFIG_RT_USING_DEVICE=y +# CONFIG_RT_USING_DEVICE_OPS is not set # CONFIG_RT_USING_INTERRUPT_INFO is not set CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" -# CONFIG_RT_USING_MODULE is not set +CONFIG_RT_VER_NUM=0x40001 CONFIG_ARCH_ARM=y CONFIG_ARCH_ARM_CORTEX_M=y CONFIG_ARCH_ARM_CORTEX_M4=y +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set # # RT-Thread Components # -# CONFIG_RT_USING_COMPONENTS_INIT is not set +CONFIG_RT_USING_COMPONENTS_INIT=y +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 # # C++ features @@ -76,13 +91,15 @@ CONFIG_FINSH_USING_HISTORY=y CONFIG_FINSH_HISTORY_LINES=5 CONFIG_FINSH_USING_SYMTAB=y CONFIG_FINSH_USING_DESCRIPTION=y +# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set CONFIG_FINSH_THREAD_PRIORITY=20 CONFIG_FINSH_THREAD_STACK_SIZE=4096 CONFIG_FINSH_CMD_SIZE=80 # CONFIG_FINSH_USING_AUTH is not set CONFIG_FINSH_USING_MSH=y CONFIG_FINSH_USING_MSH_DEFAULT=y -# CONFIG_FINSH_USING_MSH_ONLY is not set +CONFIG_FINSH_USING_MSH_ONLY=y +CONFIG_FINSH_ARG_MAX=10 # # Device virtual file system @@ -92,6 +109,7 @@ CONFIG_DFS_USING_WORKDIR=y CONFIG_DFS_FILESYSTEMS_MAX=2 CONFIG_DFS_FILESYSTEM_TYPES_MAX=2 CONFIG_DFS_FD_MAX=16 +# CONFIG_RT_USING_DFS_MNTTABLE is not set CONFIG_RT_USING_DFS_ELMFAT=y # @@ -110,30 +128,40 @@ CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096 # CONFIG_RT_DFS_ELM_USE_ERASE is not set CONFIG_RT_DFS_ELM_REENTRANT=y CONFIG_RT_USING_DFS_DEVFS=y -# CONFIG_RT_USING_DFS_NET is not set # CONFIG_RT_USING_DFS_ROMFS is not set # CONFIG_RT_USING_DFS_RAMFS is not set # CONFIG_RT_USING_DFS_UFFS is not set # CONFIG_RT_USING_DFS_JFFS2 is not set -# CONFIG_RT_USING_DFS_NFS is not set # # Device Drivers # CONFIG_RT_USING_DEVICE_IPC=y +CONFIG_RT_PIPE_BUFSZ=512 CONFIG_RT_USING_SERIAL=y CONFIG_RT_SERIAL_USING_DMA=y -CONFIG_RT_USING_CAN=y +CONFIG_RT_SERIAL_RB_BUFSZ=64 +# CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_HWTIMER is not set # CONFIG_RT_USING_CPUTIME is not set # CONFIG_RT_USING_I2C is not set CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_ADC is not set +# CONFIG_RT_USING_PWM is not set # CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_MTD is not set +# CONFIG_RT_USING_PM is not set # CONFIG_RT_USING_RTC is not set # CONFIG_RT_USING_SDIO is not set # CONFIG_RT_USING_SPI is not set # CONFIG_RT_USING_WDT is not set +# CONFIG_RT_USING_AUDIO is not set +# CONFIG_RT_USING_SENSOR is not set + +# +# Using WiFi +# # CONFIG_RT_USING_WIFI is not set # @@ -145,28 +173,36 @@ CONFIG_RT_USING_PIN=y # # POSIX layer and C standard library # -CONFIG_RT_USING_LIBC=y -CONFIG_RT_USING_PTHREADS=y -CONFIG_RT_USING_POSIX=y -# CONFIG_RT_USING_POSIX_MMAP is not set -# CONFIG_RT_USING_POSIX_TERMIOS is not set -# CONFIG_RT_USING_POSIX_AIO is not set -# CONFIG_HAVE_SYS_SIGNALS is not set +# CONFIG_RT_USING_LIBC is not set +# CONFIG_RT_USING_PTHREADS is not set # -# Network stack +# Network # +# +# Socket abstraction layer +# +# CONFIG_RT_USING_SAL is not set + # # light weight TCP/IP stack # # CONFIG_RT_USING_LWIP is not set +# CONFIG_RT_USING_LWIP141 is not set +# CONFIG_RT_USING_LWIP202 is not set +# CONFIG_RT_USING_LWIP210 is not set # # Modbus master and slave stack # # CONFIG_RT_USING_MODBUS is not set +# +# AT commands +# +# CONFIG_RT_USING_AT is not set + # # VBUS(Virtual Software BUS) # @@ -177,43 +213,33 @@ CONFIG_RT_USING_POSIX=y # # CONFIG_RT_USING_LOGTRACE is not set # CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set +# CONFIG_RT_USING_UTEST is not set # # ARM CMSIS # # CONFIG_RT_USING_CMSIS_OS is not set # CONFIG_RT_USING_RTT_CMSIS is not set +# CONFIG_RT_USING_LWP is not set # # RT-Thread online packages # -# -# system packages -# - -# -# RT-Thread GUI Engine -# -# CONFIG_PKG_USING_GUIENGINE is not set -# CONFIG_PKG_USING_PERSIMMON is not set -# CONFIG_PKG_USING_LWEXT4 is not set -# CONFIG_PKG_USING_PARTITION is not set -# CONFIG_PKG_USING_SQLITE is not set -# CONFIG_PKG_USING_RTI is not set - # # IoT - internet of things # # CONFIG_PKG_USING_PAHOMQTT is not set # CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_WEBNET is not set # CONFIG_PKG_USING_MONGOOSE is not set # CONFIG_PKG_USING_WEBTERMINAL is not set # CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_JSMN is not set # CONFIG_PKG_USING_LJSON is not set # CONFIG_PKG_USING_EZXML is not set # CONFIG_PKG_USING_NANOPB is not set -# CONFIG_PKG_USING_GAGENT_CLOUD is not set # # Wi-Fi @@ -231,6 +257,17 @@ CONFIG_RT_USING_POSIX=y # CONFIG_PKG_USING_COAP is not set # CONFIG_PKG_USING_NOPOLL is not set # CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_WIZNET is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOTKIT is not set # # security packages @@ -242,6 +279,7 @@ CONFIG_RT_USING_POSIX=y # # language packages # +# CONFIG_PKG_USING_LUA is not set # CONFIG_PKG_USING_JERRYSCRIPT is not set # CONFIG_PKG_USING_MICROPYTHON is not set @@ -249,27 +287,99 @@ CONFIG_RT_USING_POSIX=y # multimedia packages # # CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set # # tools packages # # CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set # CONFIG_PKG_USING_EASYLOGGER is not set # CONFIG_PKG_USING_SYSTEMVIEW is not set -# CONFIG_PKG_USING_IPERF is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set + +# +# system packages +# +# CONFIG_PKG_USING_GUIENGINE is not set +# CONFIG_PKG_USING_PERSIMMON is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_FAL is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_LITTLEVGL2RTT is not set +# CONFIG_PKG_USING_CMSIS is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_LITTLEFS is not set + +# +# peripheral libraries and drivers +# +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_AHT10 is not set +# CONFIG_PKG_USING_AP3216C is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_MPU6XXX is not set +# CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_KENDRYTE_SDK is not set # # miscellaneous packages # +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set # CONFIG_PKG_USING_FASTLZ is not set # CONFIG_PKG_USING_MINILZO is not set # CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set +# CONFIG_PKG_USING_KENDRYTE_DEMO is not set # -# example package: hello +# samples: kernel and components samples # +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set # CONFIG_PKG_USING_HELLO is not set -# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_VI is not set CONFIG_SOC_LPC4088=y -# CONFIG_RT_USING_UART0 is not set -CONFIG_RT_USING_UART1=y + +# +# Hardware Drivers Config +# + +# +# On-chip Peripheral Drivers +# +# CONFIG_BSP_USING_EMAC is not set +# CONFIG_BSP_USING_HWTIMER0 is not set + +# +# UART Drivers +# +CONFIG_BSP_USING_UART0=y +# CONFIG_BSP_USING_UART2 is not set + +# +# Onboard Peripheral Drivers +# +# CONFIG_BSP_USING_SDRAM is not set +# CONFIG_BSP_USING_LED is not set + +# +# Offboard Peripheral Drivers +# diff --git a/bsp/lpc408x/README.md b/bsp/lpc408x/README.md index a7055ec097..7561dcc8f8 100644 --- a/bsp/lpc408x/README.md +++ b/bsp/lpc408x/README.md @@ -1,23 +1,23 @@ -# LPC408x +# LPC408x BSP 使用说明 ## 简介 -LPC408x是RT-Thread推出的一款基于LPC408x系列的评估板,板载资源主要如下: +LPC408x 是 RT-Thread 推出的一款基于 LPC408x 系列的评估板,板载资源主要如下: | 硬件 | 描述 | | --------- | ------------- | | 芯片型号 | LPC4088FET208 | | CPU | ARM Cortex M4 | | 主频 | 120M | -| 片内SRAM | 64K | -| 片外SDRAM | 32M | -| 片内FLASH | 512K | +| 片内 SRAM | 64K | +| 片外 SDRAM | 32M | +| 片内 FLASH | 512K | ## 编译说明 -LPC408x板级包支持MDK4﹑MDK5开发环境和GCC编译器,以下是具体版本信息: +LPC408x 板级包支持 MDK4﹑MDK5 开发环境和 GCC 编译器,以下是具体版本信息: -| IDE/编译器 | 已测试版本 | +| IDE / 编译器 | 已测试版本 | | ---------- | ---------------------------- | | MDK4 | MDK4.74 | | MDK5 | MDK524a | @@ -25,15 +25,15 @@ LPC408x板级包支持MDK4﹑MDK5开发环境和GCC编译器,以下是具体 ## 烧写及执行 -供电方式:使用方口USB 连接电脑和开发板。 +供电方式:使用方口 USB 连接电脑和开发板。 -下载程序:使用JLink/ULink等等仿真器连接到板子上的20Pin仿真口。 +下载程序:使用 JLink/ULink 等等仿真器连接到板子上的 20Pin 仿真口。 -串口连接:板载CP2102,连接了USB后打开相应的串口即可。 +串口连接:板载 CP2102,连接了 USB 后打开相应的串口即可。 ### 运行结果 -如果编译 & 烧写无误,当复位设备后,会在串口上看到RT-Thread的启动logo信息: +如果编译 & 烧写无误,当复位设备后,会在串口上看到 RT-Thread 的启动 logo 信息: ```bash \ | / @@ -47,14 +47,14 @@ finsh /> | 驱动 | 支持情况 | 备注 | | ----- | -------- | :------------: | -| UART | 支持 | UART0~4 | +| UART | 支持 | UART0/2 | | ETH | 支持 | | | LCD | 支持 | | | SDRAM | 支持 | | -### IO在板级支持包中的映射情况 +### IO 在板级支持包中的映射情况 -| IO号 | 板级包中的定义 | +| IO 号 | 板级包中的定义 | | ----- | -------------- | | P3_14 | LED1 | | P3_3 | LED2 | diff --git a/bsp/lpc408x/SConscript b/bsp/lpc408x/SConscript index 381b1612c7..858221d5a2 100644 --- a/bsp/lpc408x/SConscript +++ b/bsp/lpc408x/SConscript @@ -1,6 +1,7 @@ from building import * -cwd = str(Dir('#')) +cwd = GetCurrentDir() + objs = [] list = os.listdir(cwd) diff --git a/bsp/lpc408x/SConstruct b/bsp/lpc408x/SConstruct index fb728723bc..22bb73b311 100644 --- a/bsp/lpc408x/SConstruct +++ b/bsp/lpc408x/SConstruct @@ -10,7 +10,7 @@ else: sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] from building import * -TARGET = 'rtthread-%s.%s' % (rtconfig.BOARD_NAME, rtconfig.TARGET_EXT) +TARGET = 'rtthread.' + rtconfig.TARGET_EXT env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, @@ -20,11 +20,16 @@ env = Environment(tools = ['mingw'], LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) +if rtconfig.PLATFORM == 'iar': + env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES']) + env.Replace(ARFLAGS = ['']) + env.Replace(LINKCOM = env["LINKCOM"] + ' --map project.map') + Export('RTT_ROOT') Export('rtconfig') # prepare building environment -objs = PrepareBuilding(env, RTT_ROOT) +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/lpc408x/applications/SConscript b/bsp/lpc408x/applications/SConscript index 01eb940dfb..6452d39145 100644 --- a/bsp/lpc408x/applications/SConscript +++ b/bsp/lpc408x/applications/SConscript @@ -1,10 +1,8 @@ -Import('RTT_ROOT') -Import('rtconfig') from building import * -cwd = os.path.join(str(Dir('#')), 'applications') -src = Glob('*.c') +cwd = GetCurrentDir() CPPPATH = [cwd, str(Dir('#'))] +src = Glob('*.c') group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) diff --git a/bsp/lpc408x/applications/application.c b/bsp/lpc408x/applications/application.c deleted file mode 100644 index 29f7c36bba..0000000000 --- a/bsp/lpc408x/applications/application.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2014-01-02 xiaonong the first version for lpc408x - */ - -#include - -#ifdef RT_USING_FINSH -#include -#include -#endif - -/* thread phase init */ -void rt_init_thread_entry(void *parameter) -{ - /* Initialization RT-Thread Components */ -#ifdef RT_USING_COMPONENTS_INIT - rt_components_init(); -#elif defined(RT_USING_FINSH) - finsh_system_init(); -#endif -} - -int rt_application_init(void) -{ - rt_thread_t tid; - tid = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - 2048, RT_THREAD_PRIORITY_MAX / 3, 20); - if (tid != RT_NULL) rt_thread_startup(tid); - - return 0; -} diff --git a/bsp/lpc408x/applications/board.h b/bsp/lpc408x/applications/board.h deleted file mode 100644 index 654a5bea9e..0000000000 --- a/bsp/lpc408x/applications/board.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2009-09-22 Bernard add board.h to this bsp - * 2010-02-04 Magicoe add board.h to LPC176x bsp - * 2013-12-18 Bernard porting to LPC4088 bsp - */ - -#ifndef __BOARD_H__ -#define __BOARD_H__ - -#include "LPC407x_8x_177x_8x.h" -#include - -/* SRAM allocation for Peripherals */ -#define USB_RAM_BASE 0x20000000 -#define MCI_RAM_BASE 0x20002000 -#define ETH_RAM_BASE 0x20004000 - -/* use SDRAM in default */ -#define LPC_EXT_SDRAM 1 - -/* disable SDRAM in default */ -#ifndef LPC_EXT_SDRAM -#define LPC_EXT_SDRAM 0 -#endif - -// - -// -#define LPC_EXT_SDRAM_BEGIN 0xA0000000 -// -#define LPC_EXT_SDRAM_END 0xA2000000 - -// -#define RT_USING_UART0 -// -//#define RT_USING_UART1 -// -#define RT_USING_UART2 - -// - -#ifdef __CC_ARM -extern int Image$$RW_IRAM1$$ZI$$Limit; -#define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit) -#elif __ICCARM__ -#pragma section="HEAP" -#define HEAP_BEGIN (__segment_end("HEAP")) -#else -extern int __bss_end; -#define HEAP_BEGIN ((void *)&__bss_end) -#endif -#define HEAP_END (void*)(0x10000000 + 0x10000) - -#define FINSH_DEVICE_NAME RT_CONSOLE_DEVICE_NAME -void rt_hw_board_init(void); - -#endif diff --git a/bsp/lpc408x/applications/canapp.c b/bsp/lpc408x/applications/canapp.c deleted file mode 100644 index 96a0ceeb39..0000000000 --- a/bsp/lpc408x/applications/canapp.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2015-05-14 aubrcool@qq.com first version - */ - -#include -#include -#include -#ifdef RT_USING_CAN -#include "drv_lpccan.h" -struct can_app_struct -{ - const char* name; - struct rt_can_filter_config * filter; - rt_uint8_t eventopt; - struct rt_semaphore sem; -}; -static struct can_app_struct can_data[1]; -struct rt_can_filter_item filter1item[4] = -{ - LPC_CAN_AF_STD_INIT(1), - LPC_CAN_AF_STD_GRP_INIT(3,5), - LPC_CAN_AF_EXT_INIT(2), - LPC_CAN_AF_EXT_GRP_INIT(4,6), -}; -struct rt_can_filter_config filter1 = -{ - 4, - 1, - filter1item, -}; -static struct can_app_struct can_data[1] = { - { - "lpccan1", - &filter1, - RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, - }, -}; -static rt_err_t lpccanind(rt_device_t dev, rt_size_t size) -{ - rt_sem_release(&can_data[0].sem); -} -void rt_can_thread_entry(void* parameter) -{ - struct rt_can_msg msg; - struct can_app_struct* canpara = (struct can_app_struct*) parameter; - rt_device_t candev; - - candev = rt_device_find(canpara->name); - RT_ASSERT(candev); - rt_sem_init(&canpara->sem, canpara->name, 0, RT_IPC_FLAG_FIFO); - rt_device_open(candev, (RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_INT_TX)); - rt_device_control(candev,RT_CAN_CMD_SET_FILTER,canpara->filter); - rt_device_set_rx_indicate(candev, lpccanind); - while(1) { - rt_sem_take(&canpara->sem, RT_WAITING_FOREVER); - while (rt_device_read(candev, 0, &msg, sizeof(msg)) == sizeof(msg)) { - rt_device_write(candev, 0, &msg, sizeof(msg)); - } - } -} -int rt_can_app_init(void) -{ - rt_thread_t tid; - - tid = rt_thread_create("canapp1", - rt_can_thread_entry, &can_data[0], - 512, RT_THREAD_PRIORITY_MAX /3 - 1, 20); - if (tid != RT_NULL) rt_thread_startup(tid); - - return 0; -} - -INIT_APP_EXPORT(rt_can_app_init); -#endif /*RT_USING_CAN*/ diff --git a/bsp/lpc408x/applications/main.c b/bsp/lpc408x/applications/main.c new file mode 100644 index 0000000000..7874a25073 --- /dev/null +++ b/bsp/lpc408x/applications/main.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2006-2018, Synwit Technology Co.,Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-12-10 armink first version + */ + +#include +#include + +int main(void) +{ + rt_kprintf("Hello RT-Thread!\n"); + + return RT_EOK; +} diff --git a/bsp/lpc408x/applications/sram.c b/bsp/lpc408x/applications/sram.c deleted file mode 100644 index 633d3eb6d4..0000000000 --- a/bsp/lpc408x/applications/sram.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * -* Change Logs: -* Date Author Notes -* 2013-05-19 Bernard The first version for LPC40xx -*/ - -#include "sram.h" -#include "board.h" - -#include - -#ifdef LPC_EXT_SDRAM -struct rt_memheap system_heap; - -void sram_init(void) -{ - /* initialize the built-in SRAM as a memory heap */ - rt_memheap_init(&system_heap, - "system", - (void *)HEAP_BEGIN, - (rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN); -} - -void *sram_malloc(unsigned long size) -{ - return rt_memheap_alloc(&system_heap, size); -} - -void sram_free(void *ptr) -{ - rt_memheap_free(ptr); -} - -void *sram_realloc(void *ptr, unsigned long size) -{ - return rt_memheap_realloc(&system_heap, ptr, size); -} - -#endif diff --git a/bsp/lpc408x/applications/sram.h b/bsp/lpc408x/applications/sram.h deleted file mode 100644 index 3aee2aab0b..0000000000 --- a/bsp/lpc408x/applications/sram.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2013-05-19 Bernard The first version for LPC40xx - */ - -#ifndef __SRAM_H__ -#define __SRAM_H__ - -void *sram_malloc(unsigned long nbytes); -void sram_free(void *ptr); -void *sram_realloc(void *ptr, unsigned long nbytes); - -#endif diff --git a/bsp/lpc408x/applications/startup.c b/bsp/lpc408x/applications/startup.c deleted file mode 100644 index cb99fc16ff..0000000000 --- a/bsp/lpc408x/applications/startup.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2009-01-05 Bernard first implementation - * 2010-03-04 Magicoe for LPC17xx - */ - -#include -#include - -#include "board.h" - -extern int rt_application_init(void); -extern void sram_init(void); -/** - * This function will startup RT-Thread RTOS. - */ -void rtthread_startup(void) -{ - /* initialize board */ - rt_hw_board_init(); - - /* show version */ - rt_show_version(); - -#ifdef RT_USING_HEAP -#if LPC_EXT_SDRAM - rt_system_heap_init((void *)LPC_EXT_SDRAM_BEGIN, (void *)LPC_EXT_SDRAM_END); - sram_init(); -#else - rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); -#endif -#endif - /* initialize scheduler system */ - rt_system_scheduler_init(); - /* initialize system timer*/ - rt_system_timer_init(); - /* initialize application */ - rt_application_init(); - - /* initialize timer thread */ - rt_system_timer_thread_init(); - - /* initialize idle thread */ - rt_thread_idle_init(); - - /* start scheduler */ - rt_system_scheduler_start(); - - /* never reach here */ - return ; -} - -int main(void) -{ - /* disable interrupt first */ - rt_hw_interrupt_disable(); - - /* startup RT-Thread RTOS */ - rtthread_startup(); - - return 0; -} diff --git a/bsp/lpc408x/drivers/Kconfig b/bsp/lpc408x/drivers/Kconfig index 248cbb088f..bf14b67519 100644 --- a/bsp/lpc408x/drivers/Kconfig +++ b/bsp/lpc408x/drivers/Kconfig @@ -1,21 +1,45 @@ -config RT_USING_UART0 - bool "Enable UART0" - default y +menu "Hardware Drivers Config" -config RT_USING_UART2 - bool "Enable UART2" - default n + menu "On-chip Peripheral Drivers" -config RT_USING_UART4 - bool "Enable UART4" - default n + config BSP_USING_EMAC + bool "EMAC driver" + select RT_USING_LWIP + default n -config BSP_DRV_CLCD - bool "CLCD driver" - depends on PKG_USING_GUIENGINE - default y + config BSP_USING_HWTIMER0 + bool "Using timer0" + select RT_USING_HWTIMER + default n -config BSP_DRV_EMAC - bool "EMAC driver" - depends on RT_USING_LWIP - default y + menu "UART Drivers" + config BSP_USING_UART0 + bool "Enable UART0 P0.2/P0.3(T/R)" + select RT_USING_SERIAL + default y + + config BSP_USING_UART2 + bool "Enable UART2 P2.8/P0.11(T/R)" + select RT_USING_SERIAL + default n + + endmenu + + endmenu + + menu "Onboard Peripheral Drivers" + + config BSP_USING_SDRAM + bool "Enable sdram" + default n + + config BSP_USING_LED + bool "Enable LED" + default n + endmenu + + menu "Offboard Peripheral Drivers" + + endmenu + +endmenu diff --git a/bsp/lpc408x/drivers/SConscript b/bsp/lpc408x/drivers/SConscript index e5f4cd4945..8c7c4435b2 100644 --- a/bsp/lpc408x/drivers/SConscript +++ b/bsp/lpc408x/drivers/SConscript @@ -1,14 +1,28 @@ from building import * cwd = GetCurrentDir() -src = Glob('*.c') - -# remove no need file. -if GetDepend('RT_USING_LWIP') == False: - SrcRemove(src, 'drv_emac.c') - CPPPATH = [cwd] +# add the general drivers. +src = Split(""" +board.c +""") + +if GetDepend(['BSP_USING_EMAC']): + src += ['drv_emac.c'] + +if GetDepend(['BSP_USING_HWTIMER0']): + src += ['drv_hwtimer.c'] + +if GetDepend(['BSP_USING_LED']): + src += ['drv_led.c'] + +if GetDepend(['BSP_USING_SDRAM']): + src += ['drv_sdram.c'] + +if GetDepend('BSP_USING_UART0') or GetDepend('BSP_USING_UART2'): + src += ['drv_uart.c'] + group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) Return('group') diff --git a/bsp/lpc408x/applications/board.c b/bsp/lpc408x/drivers/board.c similarity index 60% rename from bsp/lpc408x/applications/board.c rename to bsp/lpc408x/drivers/board.c index 2deb02d930..8db9473876 100644 --- a/bsp/lpc408x/applications/board.c +++ b/bsp/lpc408x/drivers/board.c @@ -8,19 +8,14 @@ * 2009-01-05 Bernard first implementation */ -#include -#include +#include -#include "board.h" -#include "drv_uart.h" -#ifdef LPC_EXT_SDRAM -#include "drv_sdram.h" +#if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP) + #include "drv_sdram.h" + extern void rt_hw_sdram_init(void); + static struct rt_memheap system_heap; #endif -/** - * This is the timer interrupt service routine. - * - */ void SysTick_Handler(void) { /* enter interrupt */ @@ -52,14 +47,22 @@ void rt_hw_board_init() /* set pend exception priority */ NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); - /*init uart device*/ - rt_hw_uart_init(); - rt_console_set_device(RT_CONSOLE_DEVICE_NAME); +#ifdef RT_USING_HEAP -#ifdef LPC_EXT_SDRAM - rt_kprintf("Initialize SDRAM ..."); - lpc_sdram_hw_init(); - rt_kprintf("done!\n"); +#if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP) + rt_hw_sdram_init(); + rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END); + rt_memheap_init(&system_heap, "sdram", (void *)HEAP_BEGIN, ((rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN)); +#else + rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); +#endif + +#endif /* RT_USING_HEAP */ + +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif +#ifdef RT_USING_CONSOLE + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif - // rt_components_board_init(); } diff --git a/bsp/lpc408x/drivers/board.h b/bsp/lpc408x/drivers/board.h new file mode 100644 index 0000000000..1cc74d0fd6 --- /dev/null +++ b/bsp/lpc408x/drivers/board.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2009-09-22 Bernard add board.h to this bsp + * 2010-02-04 Magicoe add board.h to LPC176x bsp + * 2013-12-18 Bernard porting to LPC4088 bsp + */ + +#ifndef __BOARD_H__ +#define __BOARD_H__ + +#include "LPC407x_8x_177x_8x.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* SRAM allocation for Peripherals */ +#define USB_RAM_BASE 0x20000000 +#define MCI_RAM_BASE 0x20002000 +#define ETH_RAM_BASE 0x20004000 + +/* Internal SRAM memory size[Kbytes] <16-256>, Default: 64*/ +#define SRAM_SIZE 64 * 1024 +#define SRAM_END (0x10000000 + SRAM_SIZE) + +#ifdef __CC_ARM + extern int Image$$RW_IRAM1$$ZI$$Limit; + #define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit) +#elif __ICCARM__ + #pragma section="HEAP" + #define HEAP_BEGIN (__segment_end("HEAP")) +#else + extern int __bss_end; + #define HEAP_BEGIN ((void *)&__bss_end) +#endif +#define HEAP_END SRAM_END + +void rt_hw_board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __BOARD_H__ */ diff --git a/bsp/lpc408x/drivers/drv_emac.c b/bsp/lpc408x/drivers/drv_emac.c index 7e38830f2c..7ea47d52ed 100644 --- a/bsp/lpc408x/drivers/drv_emac.c +++ b/bsp/lpc408x/drivers/drv_emac.c @@ -459,7 +459,7 @@ struct pbuf *lpc_emac_rx(rt_device_t dev) return p; } -int lpc_emac_hw_init(void) +int rt_hw_emac_init(void) { rt_event_init(&tx_event, "tx_event", RT_IPC_FLAG_FIFO); rt_sem_init(&sem_lock, "eth_lock", 1, RT_IPC_FLAG_FIFO); @@ -490,7 +490,7 @@ int lpc_emac_hw_init(void) eth_device_init(&(lpc_emac_device.parent), "e0"); return 0; } -INIT_DEVICE_EXPORT(lpc_emac_hw_init); +INIT_DEVICE_EXPORT(rt_hw_emac_init); #ifdef RT_USING_FINSH #include diff --git a/bsp/lpc408x/drivers/drv_emac.h b/bsp/lpc408x/drivers/drv_emac.h index efaa0ac8e3..7d67eae178 100644 --- a/bsp/lpc408x/drivers/drv_emac.h +++ b/bsp/lpc408x/drivers/drv_emac.h @@ -8,8 +8,8 @@ * 2013-05-19 Bernard porting from LPC17xx drivers. */ -#ifndef __DRV_EMAC_H__ -#define __DRV_EMAC_H__ +#ifndef DRV_EMAC_H__ +#define DRV_EMAC_H__ #include "board.h" @@ -20,7 +20,6 @@ #define ETH_MAX_FLEN 1536 /* Max. Ethernet Frame Size */ - /* MAC Configuration Register 1 */ #define MAC1_REC_EN 0x00000001 /* Receive Enable */ #define MAC1_PASS_ALL 0x00000002 /* Pass All Receive Frames */ @@ -282,6 +281,6 @@ #define DP83848C_DEF_ADR 0x0F00 /* Default PHY device address */ #define DP83848C_ID 0x20005C90 /* PHY Identifier */ -int lpc_emac_hw_init(void); +int rt_hw_emac_init(void); -#endif +#endif /* DRV_EMAC_H__ */ diff --git a/bsp/lpc408x/drivers/drv_hwtimer.c b/bsp/lpc408x/drivers/drv_hwtimer.c index 7946a7058a..fa09f87d76 100644 --- a/bsp/lpc408x/drivers/drv_hwtimer.c +++ b/bsp/lpc408x/drivers/drv_hwtimer.c @@ -50,7 +50,7 @@ static rt_err_t timer_start(rt_hwtimer_t *timer, rt_uint32_t t, rt_hwtimer_mode_ match.MatchChannel = 0; match.IntOnMatch = ENABLE; match.ResetOnMatch = ENABLE; - match.StopOnMatch = (opmode == HWTIMER_MODE_ONESHOT)? ENABLE : DISABLE; + match.StopOnMatch = (opmode == HWTIMER_MODE_ONESHOT) ? ENABLE : DISABLE; match.ExtMatchOutputType = 0; match.MatchValue = t; @@ -84,7 +84,7 @@ static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg) uint32_t pre; clk = CLKPWR_GetCLK(CLKPWR_CLKTYPE_PER); - pre = clk / *((uint32_t*)arg) - 1; + pre = clk / *((uint32_t *)arg) - 1; tim->PR = pre; } break; @@ -126,7 +126,7 @@ static const struct rt_hwtimer_ops _ops = static rt_hwtimer_t _timer0; -int lpc_hwtimer_init(void) +int rt_hw_hwtimer_init(void) { _timer0.info = &_info; _timer0.ops = &_ops; @@ -145,5 +145,6 @@ void TIMER0_IRQHandler(void) } } -INIT_BOARD_EXPORT(lpc_hwtimer_init); -#endif +INIT_BOARD_EXPORT(rt_hw_hwtimer_init); + +#endif /* RT_USING_HWTIMER */ diff --git a/bsp/lpc408x/drivers/drv_hwtimer.h b/bsp/lpc408x/drivers/drv_hwtimer.h index b45b27dc06..21c5a25eeb 100644 --- a/bsp/lpc408x/drivers/drv_hwtimer.h +++ b/bsp/lpc408x/drivers/drv_hwtimer.h @@ -1,8 +1,16 @@ -#ifndef __DRV_HWTIMER_H__ -#define __DRV_HWTIMER_H__ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2015-09-02 heyuanjie87 the first version + */ +#ifndef DRV_HWTIMER_H__ +#define DRV_HWTIMER_H__ -int stm32_hwtimer_init(void); +int rt_hw_hwtimer_init(void); - -#endif +#endif /* DRV_HWTIMER_H__ */ diff --git a/bsp/lpc408x/drivers/drv_led.c b/bsp/lpc408x/drivers/drv_led.c index dcbe76a7b8..d7df12ba82 100644 --- a/bsp/lpc408x/drivers/drv_led.c +++ b/bsp/lpc408x/drivers/drv_led.c @@ -122,7 +122,7 @@ static rt_err_t rt_led_control(rt_device_t dev, int cmd, void *args) return RT_EOK; } -int rt_led_hw_init(void) +int rt_hw_led_init(void) { led.parent.type = RT_Device_Class_Char; led.parent.rx_indicate = RT_NULL; @@ -141,7 +141,8 @@ int rt_led_hw_init(void) rt_led_init(&led.parent); return 0; } -INIT_DEVICE_EXPORT(rt_led_hw_init); +INIT_DEVICE_EXPORT(rt_hw_led_init); + #ifdef RT_USING_FINSH #include void led_test(rt_uint32_t led_num, rt_uint32_t value) diff --git a/bsp/lpc408x/drivers/drv_led.h b/bsp/lpc408x/drivers/drv_led.h index e69de29bb2..f3a958c9b5 100644 --- a/bsp/lpc408x/drivers/drv_led.h +++ b/bsp/lpc408x/drivers/drv_led.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2015-09-02 heyuanjie87 the first version + */ + +#ifndef DRV_LED_H__ +#define DRV_LED_H__ + +int rt_hw_led_init(void); + +#endif diff --git a/bsp/lpc408x/drivers/drv_lpccan.c b/bsp/lpc408x/drivers/drv_lpccan.c deleted file mode 100644 index 85d6511284..0000000000 --- a/bsp/lpc408x/drivers/drv_lpccan.c +++ /dev/null @@ -1,1086 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2015-06-30 aubrcool@qq.com first version - */ -#include -#include -#include -#include - -#ifdef RT_USING_CAN - -#include "lpc_types.h" -#include "lpc_can.h" -#include "lpc_pinsel.h" -#include "lpc_exti.h" -#include "lpc_clkpwr.h" - -struct lpccandata -{ - en_CAN_unitId id; -}; - -static LPC_CAN_TypeDef* lcpcan_get_reg_base(rt_uint32_t id) -{ - LPC_CAN_TypeDef* pCan; - - switch (id) - { - case CAN_ID_1: - pCan = LPC_CAN1; - break; - - case CAN_ID_2: - pCan = LPC_CAN2; - break; - default: - pCan = NULL; - } - return pCan; -} - -static void lpccan_irqstate_init(rt_uint32_t id) -{ - LPC_CAN_TypeDef* pCan = lcpcan_get_reg_base(id); - volatile rt_int32_t i; - - pCan->MOD = 1; // Enter Reset Mode - pCan->IER = 0; // Disable All CAN Interrupts - pCan->GSR = 0; - - /* Request command to release Rx, Tx buffer and clear data overrun */ - //pCan->CMR = CAN_CMR_AT | CAN_CMR_RRB | CAN_CMR_CDO; - pCan->CMR = (1 << 1) | (1 << 2) | (1 << 3); - - /* Read to clear interrupt pending in interrupt capture register */ - i = pCan->ICR; - i = i; - - pCan->MOD = 0;// Return Normal operating -} - -static rt_err_t lpccan_baud_set(rt_uint32_t id, rt_uint32_t baud) -{ - uint32_t result = 0; - uint8_t NT, TSEG1, TSEG2; - uint32_t CANPclk = 0; - uint32_t BRP; - LPC_CAN_TypeDef* pCan = lcpcan_get_reg_base(id); - - CANPclk = CLKPWR_GetCLK(CLKPWR_CLKTYPE_PER); - result = CANPclk / baud; - - /* Calculate suitable nominal time value - * NT (nominal time) = (TSEG1 + TSEG2 + 3) - * NT <= 24 - * TSEG1 >= 2*TSEG2 - */ - for(NT = 24; NT > 0; NT = NT-2) - { - if ((result % NT) == 0) - { - BRP = result / NT - 1; - NT--; - TSEG2 = (NT/3) - 1; - TSEG1 = NT -(NT/3) - 1; - break; - } - } - - /* Enter reset mode */ - pCan->MOD = 0x01; - /* Set bit timing - * Default: SAM = 0x00; - * SJW = 0x03; - */ - pCan->BTR = (TSEG2 << 20) | (TSEG1 << 16) | (3 << 14) | BRP; - /* Return to normal operating */ - pCan->MOD = 0; - - return RT_EOK; -} - -static void lpccan_init_alut_ram(void) -{ - //Reset CANAF value - LPC_CANAF->AFMR = 0x01; - //clear ALUT RAM - rt_memset((void *)LPC_CANAF_RAM->mask, 0, 2048); - LPC_CANAF->SFF_sa = 0; - LPC_CANAF->SFF_GRP_sa = 0; - LPC_CANAF->EFF_sa = 0; - LPC_CANAF->EFF_GRP_sa = 0; - LPC_CANAF->ENDofTable = 0; - LPC_CANAF->AFMR = 0x00; - // Set AF Mode - CAN_SetAFMode(CAN_NORMAL); -} - -#ifdef RT_USING_LPCCAN1 -static void lpccan1_turnon_clk(void) -{ - CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCAN1, ENABLE); -} - -static void lpccan1_filter_init(struct rt_can_device *can) -{ -} - -static void lpccan1_hw_init(uint32_t baud, CAN_MODE_Type mode) -{ - if(mode != CAN_SELFTEST_MODE) - { -#ifndef LPCCAN1_USEING_GPIO_SECOND - PINSEL_ConfigPin (0, 0, 1); - PINSEL_ConfigPin (0, 1, 1); -#else - PINSEL_ConfigPin (0, 21, 4); - PINSEL_ConfigPin (0, 22, 4); -#endif - } - lpccan1_turnon_clk(); - lpccan_irqstate_init(CAN_1); - lpccan_init_alut_ram(); - lpccan1_turnon_clk(); - lpccan_baud_set(CAN_1, baud); - CAN_ModeConfig(CAN_1, mode, ENABLE); - if(mode == CAN_SELFTEST_MODE) - { - //CAN_ModeConfig(CAN_1, CAN_TEST_MODE, ENABLE); - CAN_SetAFMode(CAN_ACC_BP); - } -} -#endif /*RT_USING_LPCCAN1*/ - -#ifdef RT_USING_LPCCAN2 -static void lpccan2_turnon_clk(void) -{ - CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCAN2, ENABLE); -} - -static void lpccan2_filter_init(struct rt_can_device *can) -{ -} - -static void lpccan2_hw_init(uint32_t baud, CAN_MODE_Type mode) -{ - if(mode != CAN_SELFTEST_MODE) - { -#ifndef LPCCAN2_USEING_GPIO_SECOND - PINSEL_ConfigPin (0, 4, 2); - PINSEL_ConfigPin (0, 5, 2); -#else - PINSEL_ConfigPin (2, 7, 1); - PINSEL_ConfigPin (2, 8, 1); -#endif - } - lpccan2_turnon_clk(); - lpccan_irqstate_init(CAN_2); -#ifndef RT_USING_LPCCAN1 - lpccan_init_alut_ram(); -#endif /*RT_USING_LPCCAN1*/ - lpccan_baud_set(CAN_2, baud); - CAN_ModeConfig(CAN_2, mode, ENABLE); - if(mode == CAN_SELFTEST_MODE) - { - CAN_SetAFMode(CAN_ACC_BP); - } -} -#endif /*RT_USING_LPCCAN2*/ - -static rt_err_t configure(struct rt_can_device *can, struct can_configure *cfg) -{ - CAN_MODE_Type mode; - rt_uint32_t canid; - - switch(cfg->mode) - { - case RT_CAN_MODE_NORMAL: - mode = CAN_OPERATING_MODE; - break; - case RT_CAN_MODE_LISEN: - mode = CAN_LISTENONLY_MODE; - break; - case RT_CAN_MODE_LOOPBACKANLISEN: - mode = CAN_SELFTEST_MODE; - break; - default: - return RT_EIO; - } - - canid = ((struct lpccandata *) can->parent.user_data)->id; -#ifdef RT_USING_LPCCAN1 - if(canid == CAN_1) - { - lpccan1_hw_init(cfg->baud_rate, mode); - lpccan1_filter_init(can); - } -#endif /*RT_USING_LPCCAN1*/ -#ifdef RT_USING_LPCCAN2 -#ifdef RT_USING_LPCCAN1 - else -#endif /*RT_USING_LPCCAN1*/ - { - lpccan2_hw_init(cfg->baud_rate, mode); - lpccan2_filter_init(can); - } -#endif /*RT_USING_LPCCAN2*/ - return RT_EOK; -} - -static CAN_ERROR findfilter(struct lpccandata* plpccan, struct rt_can_filter_item* pitem, rt_int32_t* pos) -{ - extern uint16_t CANAF_FullCAN_cnt; - extern uint16_t CANAF_std_cnt; - extern uint16_t CANAF_gstd_cnt; - extern uint16_t CANAF_ext_cnt; - extern uint16_t CANAF_gext_cnt; - - rt_uint32_t buf0 = 0, buf1 = 0; - rt_int16_t cnt1 = 0, cnt2 = 0, bound1 = 0; - CAN_ID_FORMAT_Type format; - *pos = -1; - if(pitem->ide) - { - format = EXT_ID_FORMAT; - } - else - { - format = STD_ID_FORMAT; - } - if(pitem->mode) - { - rt_uint32_t id = pitem->id; - if(format == STD_ID_FORMAT) - { - id &= 0x07FF; - - id |= plpccan->id << 13;/* Add controller number */ - - if (CANAF_std_cnt == 0) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - else if (CANAF_std_cnt == 1) - { - cnt2 = (CANAF_FullCAN_cnt + 1) >> 1; - if(id != LPC_CANAF_RAM->mask[cnt2] >> 16) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - } - else - { - cnt1 = (CANAF_FullCAN_cnt+1)>>1; - - bound1 = ((CANAF_FullCAN_cnt+1)>>1)+((CANAF_std_cnt+1)>>1); - - while (cnt1 < bound1) - { - /* Loop through standard existing IDs */ - if (((LPC_CANAF_RAM->mask[cnt1] >> 16) & 0xE7FF) == id) - { - *pos = cnt1 * 2; - return CAN_OK; - } - - if ((LPC_CANAF_RAM->mask[cnt1] & 0x0000E7FF) == id) - { - *pos = cnt1 * 2 + 1; - return CAN_OK; - } - if (((LPC_CANAF_RAM->mask[cnt1] >> 16) & 0xE7FF) > id) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - - if ((LPC_CANAF_RAM->mask[cnt1] & 0x0000E7FF) > id) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - cnt1++; - } - return CAN_ENTRY_NOT_EXIT_ERROR; - } - } - /*********** Add Explicit Extended Identifier Frame Format entry *********/ - else - { - /* Add controller number */ - id |= plpccan->id << 29; - - cnt1 = ((CANAF_FullCAN_cnt+1) >> 1) + (((CANAF_std_cnt + 1) >> 1) + CANAF_gstd_cnt); - - cnt2 = 0; - - while (cnt2 < CANAF_ext_cnt) - { - /* Loop through extended existing masks*/ - if (LPC_CANAF_RAM->mask[cnt1] == id) - { - *pos = cnt2; - return CAN_OK; - } - if (LPC_CANAF_RAM->mask[cnt1] > id) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - cnt1++; - cnt2++; - } - } - } - else - { - rt_uint32_t lowerID = pitem->id; - rt_uint32_t upperID = pitem->mask; - rt_uint32_t LID,UID; - if(lowerID > upperID) - return CAN_CONFLICT_ID_ERROR; - if(format == STD_ID_FORMAT) - { - lowerID &=0x7FF; //mask ID - upperID &=0x7FF; - cnt1 = ((CANAF_FullCAN_cnt+1)>>1) + ((CANAF_std_cnt + 1) >> 1); - if(CANAF_gstd_cnt == 0) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - else - { - bound1 = ((CANAF_FullCAN_cnt+1)>>1) + ((CANAF_std_cnt + 1) >> 1) + CANAF_gstd_cnt; - while(cnt1 < bound1) - { - //compare controller first - while((LPC_CANAF_RAM->mask[cnt1] >> 29) < (plpccan->id))//increase until meet greater or equal controller - cnt1++; - buf0 = LPC_CANAF_RAM->mask[cnt1]; - if((LPC_CANAF_RAM->mask[cnt1] >> 29) > (plpccan->id)) //meet greater controller - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - else //meet equal controller - { - LID = (buf0 >> 16)&0x7FF; - UID = buf0 & 0x7FF; - if (upperID == LID && lowerID == UID) - { - *pos = cnt1; - return CAN_OK; - } - if (upperID < LID) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - else if (lowerID >= UID) - { - cnt1 ++; - } - else - return CAN_CONFLICT_ID_ERROR; - } - } - if(cnt1 >= bound1) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - } - } - /*********Add Group of Extended Identifier Frame Format************/ - else - { - lowerID &= 0x1FFFFFFF; //mask ID - upperID &= 0x1FFFFFFF; - cnt1 = ((CANAF_FullCAN_cnt+1)>>1) + ((CANAF_std_cnt + 1) >> 1) + CANAF_gstd_cnt + CANAF_ext_cnt; - //if this is the first Group standard ID entry - if(CANAF_gext_cnt == 0) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - else - { - bound1 = ((CANAF_FullCAN_cnt+1)>>1) + ((CANAF_std_cnt + 1) >> 1) + CANAF_gstd_cnt \ - + CANAF_ext_cnt + (CANAF_gext_cnt<<1); - while(cnt1 < bound1) - { - while((LPC_CANAF_RAM->mask[cnt1] >>29)< plpccan->id ) //increase until meet greater or equal controller - cnt1++; - buf0 = LPC_CANAF_RAM->mask[cnt1]; - buf1 = LPC_CANAF_RAM->mask[cnt1+1]; - if((LPC_CANAF_RAM->mask[cnt1] >> 29) > plpccan->id ) //meet greater controller - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - else //meet equal controller - { - LID = buf0 & 0x1FFFFFFF; //mask ID - UID = buf1 & 0x1FFFFFFF; - if (upperID == LID && lowerID == UID) - { - *pos = cnt1; - return CAN_OK; - } - if (upperID < LID) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - else if (lowerID >= UID) - { - //load next entry to compare - cnt1 +=2; - } - else - return CAN_CONFLICT_ID_ERROR; - } - } - if(cnt1 >= bound1) - { - return CAN_ENTRY_NOT_EXIT_ERROR; - } - } - } - } - return CAN_ENTRY_NOT_EXIT_ERROR; -} - -static rt_err_t setfilter(struct lpccandata* plpccan,struct rt_can_filter_config *pconfig) -{ - struct rt_can_filter_item* pitem = pconfig->items; - rt_uint32_t count = pconfig->count; - rt_int32_t pos; - CAN_ID_FORMAT_Type format; - CAN_ERROR lpccanres; - while(count) - { - if(pitem->ide) - { - format = EXT_ID_FORMAT; - } - else - { - format = STD_ID_FORMAT; - } - lpccanres = findfilter(plpccan, pitem, &pos); - if(pconfig->actived && lpccanres != CAN_OK) - { - if(pitem->mode) - { - lpccanres = CAN_LoadGroupEntry(plpccan->id, pitem->id, pitem->mask, format); - } - else - { - lpccanres = CAN_LoadExplicitEntry(plpccan->id, pitem->id, format); - } - } - else if(!pconfig->actived && lpccanres == CAN_OK) - { - AFLUT_ENTRY_Type type; - if(pitem->mode) - { - if(format == EXT_ID_FORMAT) - { - type = GROUP_EXTEND_ENTRY; - } - else - { - type = GROUP_STANDARD_ENTRY; - } - } - else - { - if(format == EXT_ID_FORMAT) - { - type = EXPLICIT_EXTEND_ENTRY; - } - else - { - type = EXPLICIT_STANDARD_ENTRY; - } - } - lpccanres = CAN_RemoveEntry(type, (rt_uint16_t)(pos)); - } - else if(!pconfig->actived && lpccanres != CAN_OK) - { - lpccanres = CAN_OK; - } - if(lpccanres != CAN_OK) - { - return RT_EIO; - } - pitem++; - count--; - } - return RT_EOK; -} - -static rt_err_t control(struct rt_can_device *can, int cmd, void *arg) -{ - struct lpccandata* plpccan; - rt_uint32_t argval; - CAN_MODE_Type mode; - - plpccan = (struct lpccandata* ) can->parent.user_data; - RT_ASSERT(plpccan != RT_NULL); - - switch (cmd) - { - case RT_DEVICE_CTRL_CLR_INT: - argval = (rt_uint32_t) arg; - if(argval == RT_DEVICE_FLAG_INT_RX) - { - CAN_IRQCmd(plpccan->id, CANINT_RIE, DISABLE); - CAN_IRQCmd(plpccan->id, CANINT_DOIE, DISABLE); - } - else if(argval == RT_DEVICE_FLAG_INT_TX) - { - CAN_IRQCmd(plpccan->id, CANINT_TIE1, DISABLE); - CAN_IRQCmd(plpccan->id, CANINT_TIE2, DISABLE); - CAN_IRQCmd(plpccan->id, CANINT_TIE3, DISABLE); - } - else if(argval == RT_DEVICE_CAN_INT_ERR) - { - CAN_IRQCmd(plpccan->id, CANINT_EIE, DISABLE); - } - break; - - case RT_DEVICE_CTRL_SET_INT: - argval = (rt_uint32_t) arg; - if(argval == RT_DEVICE_FLAG_INT_RX) - { - CAN_IRQCmd(plpccan->id, CANINT_RIE, ENABLE); - CAN_IRQCmd(plpccan->id, CANINT_DOIE, ENABLE); - } - else if(argval == RT_DEVICE_FLAG_INT_TX) - { - CAN_IRQCmd(plpccan->id, CANINT_TIE1, ENABLE); - CAN_IRQCmd(plpccan->id, CANINT_TIE2, ENABLE); - CAN_IRQCmd(plpccan->id, CANINT_TIE3, ENABLE); - } - else if(argval == RT_DEVICE_CAN_INT_ERR) - { - CAN_IRQCmd(plpccan->id, CANINT_EIE, ENABLE); - } - break; - - case RT_CAN_CMD_SET_FILTER: - return setfilter(plpccan, (struct rt_can_filter_config*) arg); - - case RT_CAN_CMD_SET_MODE: - argval = (rt_uint32_t) arg; - if(argval != RT_CAN_MODE_NORMAL || - argval != RT_CAN_MODE_LISEN) - { - return RT_ERROR; - } - if(argval != can->config.mode) - { - can->config.mode = argval; - switch(argval) - { - case RT_CAN_MODE_NORMAL: - mode = CAN_OPERATING_MODE; - break; - case RT_CAN_MODE_LISEN: - mode = CAN_LISTENONLY_MODE; - break; - case RT_CAN_MODE_LOOPBACKANLISEN: - mode = CAN_SELFTEST_MODE; - break; - default: - return RT_EIO; - } - CAN_ModeConfig(plpccan->id, mode, ENABLE); - if(mode == CAN_SELFTEST_MODE) - { - //CAN_ModeConfig(CAN_1, CAN_TEST_MODE, ENABLE); - CAN_SetAFMode(CAN_ACC_BP); - } - } - break; - - case RT_CAN_CMD_SET_BAUD: - argval = (rt_uint32_t) arg; - if(argval != can->config.baud_rate) - { - can->config.baud_rate = argval; - return lpccan_baud_set(plpccan->id, (rt_uint32_t) arg); - } - break; - - case RT_CAN_CMD_SET_PRIV: - argval = (rt_uint32_t) arg; - if(argval != RT_CAN_MODE_PRIV || - argval != RT_CAN_MODE_NOPRIV) - { - return RT_ERROR; - } - if(argval != can->config.privmode) - { - can->config.privmode = argval; - CAN_ModeConfig(plpccan->id, CAN_TXPRIORITY_MODE, ENABLE); - } - break; - - case RT_CAN_CMD_GET_STATUS: - { - can->status.rcverrcnt = 0; - can->status.snderrcnt = 0; - can->status.errcode = 0; - if(arg != &can->status) - { - rt_memcpy(arg,&can->status,sizeof(can->status)); - } - } - break; - - } - return RT_EOK; -} - -static int sendmsg(struct rt_can_device *can, const void* buf, rt_uint32_t boxno) -{ - struct lpccandata* plpccan; - LPC_CAN_TypeDef* pCan; - struct rt_can_msg* pmsg; - rt_uint32_t SR_Mask; - rt_uint32_t CMRMsk; - - plpccan = (struct lpccandata* ) can->parent.user_data; - RT_ASSERT(plpccan != RT_NULL); - - pCan = lcpcan_get_reg_base(plpccan->id); - RT_ASSERT(pCan != RT_NULL); - - pmsg = (struct rt_can_msg*) buf; - - if(boxno > 2) - { - return RT_ERROR; - } - - CMRMsk = 0x01 | (0x01 << (boxno + 5)); - SR_Mask = 0x01 <<(boxno * 8 + 2); - - if(pCan->SR & SR_Mask) - { - volatile unsigned int *pTFI = (&pCan->TFI1 + 0 + 4 * boxno); - volatile unsigned int *pTID = (&pCan->TFI1 + 1 + 4 * boxno); - volatile unsigned int *pTDA = (&pCan->TFI1 + 2 + 4 * boxno); - volatile unsigned int *pTDB = (&pCan->TFI1 + 3 + 4 * boxno); - rt_uint32_t data; - - /* Transmit Channel 1 is available */ - /* Write frame informations and frame data into its CANxTFI1, - * CANxTID1, CANxTDA1, CANxTDB1 register */ - *pTFI &= ~ 0x000F0000; - *pTFI |= (pmsg->len) << 16; - if(pmsg->rtr == REMOTE_FRAME) - { - *pTFI |= (1 << 30); //set bit RTR - } - else - { - *pTFI &= ~(1 << 30); - } - - if(pmsg->ide == EXT_ID_FORMAT) - { - *pTFI |= (((uint32_t)1) << 31); //set bit FF - } - else - { - *pTFI &= ~(((uint32_t)1) << 31); - } - if(can->config.privmode) - { - *pTFI &= ~0x000000FF; - *pTFI |= pmsg->priv; - } - /* Write CAN ID*/ - *pTID = pmsg->id; - /*Write first 4 data bytes*/ - data = (pmsg->data[0]) | (((pmsg->data[1]))<< 8) | ((pmsg->data[2]) << 16) | ((pmsg->data[3]) << 24); - *pTDA = data; - /*Write second 4 data bytes*/ - data = (pmsg->data[4]) | (((pmsg->data[5])) << 8) | ((pmsg->data[6]) << 16) | ((pmsg->data[7]) << 24); - *pTDB = data; - /*Write transmission request*/ - pCan->CMR = CMRMsk; - return RT_EOK; - } - else - { - return RT_ERROR; - } -} - -static int recvmsg(struct rt_can_device *can, void* buf, rt_uint32_t boxno) -{ - struct lpccandata* plpccan; - LPC_CAN_TypeDef* pCan; - - plpccan = (struct lpccandata* ) can->parent.user_data; - RT_ASSERT(plpccan != RT_NULL); - pCan = lcpcan_get_reg_base(plpccan->id); - RT_ASSERT(pCan != RT_NULL); - - //CAN_ReceiveMsg - //check status of Receive Buffer - if((pCan->SR &0x00000001)) - { - uint32_t data; - struct rt_can_msg* pmsg = (struct rt_can_msg*) buf; - - /* Receive message is available */ - /* Read frame informations */ - pmsg->ide = (uint8_t)(((pCan->RFS) & 0x80000000) >> 31); - pmsg->rtr = (uint8_t)(((pCan->RFS) & 0x40000000) >> 30); - pmsg->len = (uint8_t)(((pCan->RFS) & 0x000F0000) >> 16); - /* Read CAN message identifier */ - pmsg->id = pCan->RID; - /* Read the data if received message was DATA FRAME */ - if (!pmsg->rtr) - { - /* Read first 4 data bytes */ - data = pCan->RDA; - pmsg->data[0] = data & 0x000000FF; - pmsg->data[1] = (data & 0x0000FF00) >> 8; - pmsg->data[2] = (data & 0x00FF0000) >> 16; - pmsg->data[3] = (data & 0xFF000000) >> 24; - /* Read second 4 data bytes */ - if(pmsg->len > 4) - { - data = pCan->RDB; - pmsg->data[4] = data & 0x000000FF; - pmsg->data[5] = (data & 0x0000FF00) >> 8; - pmsg->data[6] = (data & 0x00FF0000) >> 16; - pmsg->data[7] = (data & 0xFF000000) >> 24; - } - pmsg->hdr = 0; - /*release receive buffer*/ - pCan->CMR = 0x04; - } - else - { - /* Received Frame is a Remote Frame, not have data, we just receive - * message information only */ - pCan->CMR = 0x04; /*release receive buffer*/ - return SUCCESS; - } - } - else - { - // no receive message available - return ERROR; - } - return RT_EOK; -} - -static const struct rt_can_ops canops = -{ - configure, - control, - sendmsg, - recvmsg, -}; - -#ifdef RT_USING_LPCCAN1 -#ifdef RT_CAN_USING_LED -#endif -static struct lpccandata lpccandata1 = -{ - CAN_ID_1, -}; -static struct rt_can_device lpccan1; -#endif /*RT_USINGLPCCAN1*/ - -#ifdef RT_USING_LPCCAN2 -#ifdef RT_CAN_USING_LED -#endif -static struct lpccandata lpccandata2 = -{ - CAN_ID_2, -}; -static struct rt_can_device lpccan2; -#endif /*RT_USINGLPCCAN2*/ - -/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/ -/*********************************************************************//** - * @brief Event Router IRQ Handler - * @param[in] None - * @return None - **********************************************************************/ -void CAN_IRQHandler(void) -{ - rt_uint32_t IntStatus; - rt_interrupt_enter(); -#ifdef RT_USING_LPCCAN1 - IntStatus = CAN_IntGetStatus(CAN_1); - //check receive interrupt - if((IntStatus >> 0) & 0x01) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_RX_IND | 0<<8); - } - //check Transmit Interrupt interrupt1 - if((IntStatus >> 1) & 0x01) - { - rt_uint32_t state = 0; - state = CAN_GetCTRLStatus(CAN_1, CANCTRL_STS); - if(state & (0x01 << 3)) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_DONE | 0<<8); - } - else - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_FAIL | 0<<8); - } - } - //check Error Warning Interrupt - if((IntStatus >> 2) & 0x01) - { - rt_uint32_t errtype; - rt_uint32_t state; - - errtype = (IntStatus >> 16); - if(errtype & 0x1F && lpccan1.status.lasterrtype == (errtype & 0x1F)) - { - switch((errtype & 0x1F)) - { - case 00011: // Start of Frame - case 00010: // ID28 ... ID21 - case 00110: //ID20 ... ID18 - case 00100: // SRTR Bit - case 00101: // IDE bit - case 00111: // ID17 ... 13 - case 01111: // ID12 ... ID5 - case 01110: // ID4 ... ID0 - case 01100: // RTR Bit - case 01011: // Data Length Code - case 01010: // Data Field - lpccan1.status.formaterrcnt++; - break; - case 01101: // Reserved Bit 1 - case 01001: // Reserved Bit 0 - lpccan1.status.bitpaderrcnt++; - break; - case 01000: // CRC Sequence - case 11000: // CRC Delimiter - lpccan1.status.crcerrcnt++; - break; - case 11001: // Acknowledge Slot - case 11011: // Acknowledge Delimiter - lpccan1.status.ackerrcnt++; - break; - case 11010: // End of Frame - case 10010: // Intermission - lpccan1.status.formaterrcnt++; - break; - } - lpccan1.status.lasterrtype = errtype & 0x1F; - } - - state = CAN_GetCTRLStatus(CAN_1, CANCTRL_GLOBAL_STS); - lpccan1.status.rcverrcnt = (state >> 16) & 0xFF; - lpccan1.status.snderrcnt = (state >> 24) & 0xFF; - lpccan1.status.errcode = (state >> 5) & 0x06; - } - //check Data Overrun Interrupt Interrupt - if((IntStatus >> 3) & 0x01) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_RXOF_IND | 0<<8); - } - //check Transmit Interrupt interrupt2 - if((IntStatus >> 9) & 0x01) - { - rt_uint32_t state = 0; - state = CAN_GetCTRLStatus(CAN_1, CANCTRL_STS); - if(state & (0x01 << 11)) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_DONE | 1<<8); - } - else - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_FAIL | 1<<8); - } - } - //check Transmit Interrupt interrupt3 - if((IntStatus >> 10) & 0x01) - { - rt_uint32_t state = 0; - state = CAN_GetCTRLStatus(CAN_1, CANCTRL_STS); - if(state & (0x01 << 19)) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_DONE | 2<<8); - } - else - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_FAIL | 2<<8); - } - } -#endif /*RT_USING_LPCCAN1*/ - -#ifdef RT_USING_LPCCAN2 - IntStatus = CAN_IntGetStatus(CAN_2); - //check receive interrupt - if((IntStatus >> 0) & 0x01) - { - rt_hw_can_isr(&lpccan2,RT_CAN_EVENT_RX_IND | 0<<8); - } - //check Transmit Interrupt interrupt1 - if((IntStatus >> 1) & 0x01) - { - rt_uint32_t state = 0; - state = CAN_GetCTRLStatus(CAN_2, CANCTRL_STS); - if(state & (0x01 << 3)) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_DONE | 0<<8); - } - else - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_FAIL | 0<<8); - } - } - - //check Error Warning Interrupt - if((IntStatus >> 2) & 0x01) - { - rt_uint32_t errtype; - errtype = (IntStatus >> 16); - if(errtype & 0x1F && lpccan2.status.lasterrtype == (errtype & 0x1F)) - { - switch((errtype & 0x1F)) - { - case 00011: // Start of Frame - case 00010: // ID28 ... ID21 - case 00110: //ID20 ... ID18 - case 00100: // SRTR Bit - case 00101: // IDE bit - case 00111: // ID17 ... 13 - case 01111: // ID12 ... ID5 - case 01110: // ID4 ... ID0 - case 01100: // RTR Bit - case 01011: // Data Length Code - case 01010: // Data Field - lpccan2.status.formaterrcnt++; - break; - case 01101: // Reserved Bit 1 - case 01001: // Reserved Bit 0 - lpccan2.status.bitpaderrcnt++; - break; - case 01000: // CRC Sequence - case 11000: // CRC Delimiter - lpccan2.status.crcerrcnt++; - break; - case 11001: // Acknowledge Slot - case 11011: // Acknowledge Delimiter - lpccan2.status.ackerrcnt++; - break; - case 11010: // End of Frame - case 10010: // Intermission - lpccan2.status.formaterrcnt++; - break; - } - lpccan2.status.lasterrtype = errtype & 0x1F; - } - rt_uint32_t state = 0; - state = CAN_GetCTRLStatus(CAN_2, CANCTRL_GLOBAL_STS); - lpccan2.status.rcverrcnt = (state >> 16) & 0xFF; - lpccan2.status.snderrcnt = (state >> 24) & 0xFF; - lpccan2.status.errcode = (state >> 5) & 0x06; - } - - //check Data Overrun Interrupt Interrupt - if((IntStatus >> 3) & 0x01) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_RXOF_IND | 0<<8); - } - - //check Transmit Interrupt interrupt2 - if((IntStatus >> 9) & 0x01) - { - rt_uint32_t state = 0; - state = CAN_GetCTRLStatus(CAN_2, CANCTRL_STS); - if(state & (0x01 << 11)) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_DONE | 1<<8); - } - else - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_FAIL | 1<<8); - } - } - - //check Transmit Interrupt interrupt3 - if((IntStatus >> 10) & 0x01) - { - rt_uint32_t state = 0; - state = CAN_GetCTRLStatus(CAN_2, CANCTRL_STS); - if(state & (0x01 << 19)) - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_DONE | 2<<8); - } - else - { - rt_hw_can_isr(&lpccan1,RT_CAN_EVENT_TX_FAIL | 2<<8); - } - } -#endif /*RT_USING_LPCCAN2*/ - rt_interrupt_leave(); -} - -int lpc_can_init(void) -{ -#ifdef RT_USING_LPCCAN1 - lpccan1.config.baud_rate=CAN1MBaud; - lpccan1.config.msgboxsz=16; - lpccan1.config.sndboxnumber=3; - lpccan1.config.mode=RT_CAN_MODE_NORMAL; - lpccan1.config.privmode=0; - -#ifdef RT_CAN_USING_LED -#endif - - lpccan1.config.ticks = 50; - -#ifdef RT_CAN_USING_HDR -#endif - - //Enable CAN Interrupt - NVIC_EnableIRQ(CAN_IRQn); - rt_hw_can_register(&lpccan1, "lpccan1", &canops, &lpccandata1); -#endif /*RT_USING_LPCCAN1*/ - -#ifdef RT_USING_LPCCAN2 - lpccan2.config.baud_rate=CAN1MBaud; - lpccan2.config.msgboxsz=16; - lpccan2.config.sndboxnumber=3; - lpccan2.config.mode=RT_CAN_MODE_NORMAL; - lpccan2.config.privmode=0; - -#ifdef RT_CAN_USING_LED -#endif - - lpccan2.config.ticks = 50; - -#ifdef RT_CAN_USING_HDR -#endif - - //Enable CAN Interrupt - NVIC_EnableIRQ(CAN_IRQn); - -#ifdef RT_CAN_USING_HDR -#endif - - rt_hw_can_register(&lpccan2, "lpccan2", &canops, &lpccandata2); -#endif /*RT_USING_LPCCAN2*/ - - return RT_EOK; -} -INIT_BOARD_EXPORT(lpc_can_init); - -#endif /*RT_USING_CAN*/ diff --git a/bsp/lpc408x/drivers/drv_lpccan.h b/bsp/lpc408x/drivers/drv_lpccan.h deleted file mode 100644 index 9dda61a1f6..0000000000 --- a/bsp/lpc408x/drivers/drv_lpccan.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2015-06-30 aubrcool@qq.com first version - */ - -#ifndef DRV_LPCCAN_H_ -#define DRV_LPCCAN_H_ -#include -#include - -#define LPC_CAN_AF_STD_INIT(id) \ - RT_CAN_FILTER_ITEM_INIT(id,0,0,0,0xFFFFFFFF) -#define LPC_CAN_AF_EXT_INIT(id) \ - RT_CAN_FILTER_ITEM_INIT(id,1,0,0,0xFFFFFFFF) -#define LPC_CAN_AF_STD_GRP_INIT(id1,id2) \ - RT_CAN_FILTER_ITEM_INIT(id1,0,0,1,id2) -#define LPC_CAN_AF_EXT_GRP_INIT(id1,id2) \ - RT_CAN_FILTER_ITEM_INIT(id1,1,0,1,id2) - -#endif /*DRV_LPCCAN_H_*/ diff --git a/bsp/lpc408x/drivers/drv_sdram.c b/bsp/lpc408x/drivers/drv_sdram.c index 515659f244..0bb9ec6eb3 100644 --- a/bsp/lpc408x/drivers/drv_sdram.c +++ b/bsp/lpc408x/drivers/drv_sdram.c @@ -8,20 +8,14 @@ * 2013-05-19 Bernard The first version for LPC40xx */ +#include + +#ifdef BSP_USING_SDRAM #include "drv_sdram.h" #include #include -#define SDRAM_BASE_ADDR 0xA0000000 -#define SDRAM_SIZE 0x2000000 - -/******************************************************************************************* -* @sdram_gpio_config() -* @ void -* @ֵvoid -* @ SDRAMܽúڲ -*********************************************************************************************/ static void sdram_gpio_config(void) { LPC_IOCON->P3_0 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* D0 @ P3.0 */ @@ -78,7 +72,7 @@ static void sdram_gpio_config(void) LPC_IOCON->P2_29 = (1 << 0 | 0 << 3 | 0 << 5 | 1 << 9); /* DQM[1] @ P2.29 */ } -void lpc_sdram_hw_init(void) +void rt_hw_sdram_init(void) { volatile uint32_t i; volatile uint32_t dwtemp; @@ -88,7 +82,7 @@ void lpc_sdram_hw_init(void) TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL; TIM_ConfigStruct.PrescaleValue = 1; - // Set configuration for Tim_config and Tim_MatchConfig + /* Set configuration for Tim_config and Tim_MatchConfig */ TIM_Init(LPC_TIM0, TIM_TIMER_MODE, &TIM_ConfigStruct); LPC_SC->PCONP |= 0x00000800; @@ -97,53 +91,55 @@ void lpc_sdram_hw_init(void) LPC_EMC->Config = 0x00000000; sdram_gpio_config(); - //LPC_SC->EMCCLKSEL = 1; //ƵһƵʣ60Mhz - LPC_EMC->DynamicRP = EMC_NS2CLK(20); /* 20ns, */ - LPC_EMC->DynamicRAS = /*EMC_NS2CLK(42, nsPerClk);*/ 15; /* 42ns to 100K ns, */ - LPC_EMC->DynamicSREX = 1 - 1; /* tSRE, 1clk, */ - LPC_EMC->DynamicAPR = 2 - 1; /* Not found!!! Estimated as 2clk, */ - LPC_EMC->DynamicDAL = EMC_NS2CLK(20) + 2; /* tDAL = tRP + tDPL = 20ns + 2clk */ - LPC_EMC->DynamicWR = 2 - 1; /* 2CLK, */ - LPC_EMC->DynamicRC = EMC_NS2CLK(63); /* H57V2562GTR-75C tRC=63ns(min)*/ - LPC_EMC->DynamicRFC = EMC_NS2CLK(63); /* H57V2562GTR-75C tRFC=tRC */ - LPC_EMC->DynamicXSR = 0x0000000F; /* exit self-refresh to active, ֪Ϊ */ - LPC_EMC->DynamicRRD = EMC_NS2CLK(63); /* 3clk, tRRD=15ns(min) */ - LPC_EMC->DynamicMRD = 2 - 1; /* 2clk, tMRD=2clk(min) */ - LPC_EMC->DynamicReadConfig = 0x00000001; /* Command delayed strategy, using EMCCLKDELAY */ + LPC_EMC->DynamicRP = EMC_NS2CLK(20); /* 20ns */ + LPC_EMC->DynamicRAS = 15; /* EMC_NS2CLK(42, nsPerClk),42ns to 100K ns */ + LPC_EMC->DynamicSREX = 1 - 1; /* tSRE, 1clk */ + LPC_EMC->DynamicAPR = 2 - 1; /* Not found!!! Estimated as 2clk */ + LPC_EMC->DynamicDAL = EMC_NS2CLK(20) + 2; /* tDAL = tRP + tDPL = 20ns + 2clk */ + LPC_EMC->DynamicWR = 2 - 1; /* 2CLK */ + LPC_EMC->DynamicRC = EMC_NS2CLK(63); /* H57V2562GTR-75C tRC=63ns(min)*/ + LPC_EMC->DynamicRFC = EMC_NS2CLK(63); /* H57V2562GTR-75C tRFC=tRC */ + LPC_EMC->DynamicXSR = 0x0000000F; /* exit self-refresh to active */ + LPC_EMC->DynamicRRD = EMC_NS2CLK(63); /* 3clk, tRRD=15ns(min) */ + LPC_EMC->DynamicMRD = 2 - 1; /* 2clk, tMRD=2clk(min) */ + + LPC_EMC->DynamicReadConfig = 0x00000001; /* Command delayed strategy, using EMCCLKDELAY */ /* H57V2562GTR-75C: tCL=3CLK, tRCD=20ns(min), 3 CLK=24ns */ LPC_EMC->DynamicRasCas0 = 0x303; /* For Manley lpc1778 SDRAM: H57V2562GTR-75C, 256Mb, 16Mx16, 4 banks, row=13, column=9 */ #ifdef SDRAM_CONFIG_16BIT - LPC_EMC->DynamicConfig0 = 0x680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */ + LPC_EMC->DynamicConfig0 = 0x680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */ #elif defined SDRAM_CONFIG_32BIT - LPC_EMC->DynamicConfig0 = 0x4680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */ + LPC_EMC->DynamicConfig0 = 0x4680; /* 256Mb, 16Mx16, 4 banks, row=13, column=9, RBC */ #endif TIM_Waitms(100); - LPC_EMC->DynamicControl = 0x00000183; /* Issue NOP command */ - TIM_Waitms(200); /* wait 200ms */ + LPC_EMC->DynamicControl = 0x00000183; /* Issue NOP command */ + TIM_Waitms(200); /* wait 200ms */ - LPC_EMC->DynamicControl = 0x00000103; /* Issue PALL command */ + LPC_EMC->DynamicControl = 0x00000103; /* Issue PALL command */ - LPC_EMC->DynamicRefresh = 0x00000002; /* ( n * 16 ) -> 32 clock cycles */ - for (i = 0; i < 0x80; i++); /* wait 128 AHB clock cycles */ + LPC_EMC->DynamicRefresh = 0x00000002; /* ( n * 16 ) -> 32 clock cycles */ + for (i = 0; i < 0x80; i++); /* wait 128 AHB clock cycles */ LPC_EMC->DynamicRefresh = EMC_SDRAM_REFRESH(64); - LPC_EMC->DynamicControl = 0x00000083; /* Issue MODE command */ + LPC_EMC->DynamicControl = 0x00000083; /* Issue MODE command */ #ifdef SDRAM_CONFIG_16BIT - wtemp = *((volatile uint16_t *)(SDRAM_BASE | (0x33 << 12))); /* 8 burst, 3 CAS latency */ + wtemp = *((volatile uint16_t *)(EXT_SDRAM_BEGIN | (0x33 << 12))); /* 8 burst, 3 CAS latency */ #elif defined SDRAM_CONFIG_32BIT - dwtemp = *((volatile uint32_t *)(SDRAM_BASE | (0x32 << 13))); /* 4 burst, 3 CAS latency */ + dwtemp = *((volatile uint32_t *)(SDRAM_BASE | (0x32 << 13))); /* 4 burst, 3 CAS latency */ #endif - LPC_EMC->DynamicControl = 0x00000000; /* Issue NORMAL command */ + LPC_EMC->DynamicControl = 0x00000000; /* Issue NORMAL command */ - LPC_EMC->DynamicConfig0 |= 0x80000; /* enable buffer */ + LPC_EMC->DynamicConfig0 |= 0x80000; /* enable buffer */ TIM_Waitms(1); TIM_DeInit(LPC_TIM0); } + +#endif /* BSP_USING_SDRAM */ diff --git a/bsp/lpc408x/drivers/drv_sdram.h b/bsp/lpc408x/drivers/drv_sdram.h index 21c0791f32..74ceab2d18 100644 --- a/bsp/lpc408x/drivers/drv_sdram.h +++ b/bsp/lpc408x/drivers/drv_sdram.h @@ -8,24 +8,25 @@ * 2013-05-19 Bernard The first version for LPC40xx */ -#ifndef __DRV_SDRAM_H__ -#define __DRV_SDRAM_H__ +#ifndef DRV_SDRAM_H__ +#define DRV_SDRAM_H__ #include -#define SDRAM_CONFIG_16BIT //use the 16 bitSDRAM -//#define SDRAM_CONFIG_32BIT //use the 32 bitSDRAM +#define SDRAM_CONFIG_16BIT /* use the 16 bitSDRAM */ +//#define SDRAM_CONFIG_32BIT /* use the 32 bitSDRAM */ #ifdef SDRAM_CONFIG_16BIT -#define SDRAM_SIZE 0x2000000 // 256Mbit -#elif defined SDRAM_CONFIG_32BIT // -#define SDRAM_SIZE 0x4000000 // 512Mbit + #define EXT_SDRAM_SIZE 0x2000000 /* 256Mbit */ +#elif defined SDRAM_CONFIG_32BIT + #define EXT_SDRAM_SIZE 0x4000000 /* 512Mbit */ #else -error Wrong SDRAM config, check ex_sdram.h + error Wrong SDRAM config, check ex_sdram.h #endif -#define SDRAM_BASE 0xA0000000 /* CS0 */ +#define EXT_SDRAM_BEGIN 0xA0000000 /* CS0 */ +#define EXT_SDRAM_END (EXT_SDRAM_BEGIN + EXT_SDRAM_SIZE) -void lpc_sdram_hw_init(void); +void rt_hw_sdram_init(void); -#endif +#endif /* DRV_SDRAM_H__ */ diff --git a/bsp/lpc408x/drivers/drv_uart.c b/bsp/lpc408x/drivers/drv_uart.c index 8360ca17c6..09a518f4ab 100644 --- a/bsp/lpc408x/drivers/drv_uart.c +++ b/bsp/lpc408x/drivers/drv_uart.c @@ -8,12 +8,12 @@ * 2013-05-18 Bernard The first version for LPC40xx */ -#include #include #include - #include "board.h" +#ifdef RT_USING_SERIAL + struct lpc_uart { LPC_UART_TypeDef *UART; @@ -48,7 +48,6 @@ static rt_err_t lpc_configure(struct rt_serial_device *serial, struct serial_con /*enable and reset FIFO*/ uart->UART->FCR = 0x07; - return RT_EOK; } @@ -104,11 +103,7 @@ static const struct rt_uart_ops lpc_uart_ops = lpc_getc, }; -#ifdef RT_USING_UART0 -/* UART0 device driver structure */ -#if RTTHREAD_VERSION < 20000 /* RT-Thread 1.x */ -struct serial_ringbuffer uart0_int_rx; -#endif +#ifdef BSP_USING_UART0 struct lpc_uart uart0 = { @@ -128,14 +123,9 @@ void UART0_IRQHandler(void) IIR &= 0x0e; switch (IIR) { - case 0x04: case 0x0C: - #if RTTHREAD_VERSION < 20000 - rt_hw_serial_isr(&serial0); - #else rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND); - #endif break; case 0x06: tmp = LPC_UART0->LSR; @@ -148,11 +138,8 @@ void UART0_IRQHandler(void) rt_interrupt_leave(); } #endif -#ifdef RT_USING_UART2 -/* UART2 device driver structure */ -#if RTTHREAD_VERSION < 20000 /* RT-Thread 1.x */ -struct serial_ringbuffer uart2_int_rx; -#endif + +#ifdef BSP_USING_UART2 struct lpc_uart uart2 = { @@ -174,11 +161,7 @@ void UART2_IRQHandler(void) { case 0x04: case 0x0C: - #if RTTHREAD_VERSION < 20000 - rt_hw_serial_isr(&serial2); - #else rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND); - #endif break; case 0x06: tmp = LPC_UART2->LSR; @@ -193,66 +176,19 @@ void UART2_IRQHandler(void) } #endif -#ifdef RT_USING_UART4 -/* UART4 device driver structure */ -#if RTTHREAD_VERSION < 20000 /* RT-Thread 1.x */ -struct serial_ringbuffer uart4_int_rx; -#endif - -struct lpc_uart uart4 = -{ - LPC_UART4, - UART4_IRQn, -}; -struct rt_serial_device serial4; - -void UART4_IRQHandler(void) -{ - volatile uint32_t IIR, tmp; - - /* enter interrupt */ - rt_interrupt_enter(); - - IIR = LPC_UART4->IIR; - IIR &= 0x0e; - switch (IIR) - { - case 0x04: - case 0x0C: - #if RTTHREAD_VERSION < 20000 - rt_hw_serial_isr(&serial4); - #else - rt_hw_serial_isr(&serial4, RT_SERIAL_EVENT_RX_IND); - #endif - break; - case 0x06: - tmp = LPC_UART4->LSR; - break; - default : - tmp = LPC_UART4->LSR; - break; - } - - /* leave interrupt */ - rt_interrupt_leave(); -} -#endif - -void rt_hw_uart_init(void) +int rt_hw_uart_init(void) { + rt_err_t ret = RT_EOK; struct lpc_uart *uart; struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; -#ifdef RT_USING_UART0 +#ifdef BSP_USING_UART0 uart = &uart0; serial0.ops = &lpc_uart_ops; serial0.config = config; - #if RTTHREAD_VERSION < 20000 - serial0.int_rx = &uart0_int_rx; - #endif serial0.parent.user_data = uart; - + /* * Initialize UART0 pin connect * P0.2: U0_TXD @@ -273,19 +209,16 @@ void rt_hw_uart_init(void) NVIC_EnableIRQ(uart->UART_IRQn); /* register UART0 device */ - rt_hw_serial_register(&serial0, "uart0", - RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, - uart); + ret = rt_hw_serial_register(&serial0, "uart0", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, + uart); #endif -#ifdef RT_USING_UART2 +#ifdef BSP_USING_UART2 uart = &uart2; serial2.ops = &lpc_uart_ops; serial2.config = config; - #if RTTHREAD_VERSION < 20000 - serial2.int_rx = &uart2_int_rx; - #endif serial2.parent.user_data = uart; /* @@ -307,42 +240,13 @@ void rt_hw_uart_init(void) NVIC_EnableIRQ(uart->UART_IRQn); /* register UART2 device */ - rt_hw_serial_register(&serial2, "uart2", - RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, - uart); + ret = rt_hw_serial_register(&serial2, "uart2", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, + uart); #endif -#ifdef RT_USING_UART4 - uart = &uart4; - - serial4.ops = &lpc_uart_ops; - serial4.config = config; - #if RTTHREAD_VERSION < 20000 - serial4.int_rx = &uart4_int_rx; - #endif - serial4.parent.user_data = uart; - - /* - * Initialize UART2 pin connect - * P5.4: U2_TXD - * P5.3: U2_RXD - */ - LPC_IOCON->P5_4 &= ~0x07; - LPC_IOCON->P5_3 &= ~0x07; - LPC_IOCON->P5_4 |= 0x04; - LPC_IOCON->P5_3 |= 0x04; - - /* enable the uart4 power and clock */ - LPC_SC->PCONP |= 0x01 << 8; - /* preemption = 1, sub-priority = 1 */ - NVIC_SetPriority(uart->UART_IRQn, ((0x01 << 3) | 0x01)); - - /* Enable Interrupt for UART channel */ - NVIC_EnableIRQ(uart->UART_IRQn); - - /* register UART2 device */ - rt_hw_serial_register(&serial4, "uart4", - RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, - uart); -#endif + return ret; } +INIT_BOARD_EXPORT(rt_hw_uart_init); + +#endif /* RT_USING_SERIAL */ diff --git a/bsp/lpc408x/drivers/drv_uart.h b/bsp/lpc408x/drivers/drv_uart.h index aee8a379ed..6fbe0535a5 100644 --- a/bsp/lpc408x/drivers/drv_uart.h +++ b/bsp/lpc408x/drivers/drv_uart.h @@ -8,8 +8,8 @@ * 2014-01-05 NongXiaoming The first version for LPC40xx */ -#ifndef __UART_H__ -#define __UART_H__ +#ifndef DRV_UART_H__ +#define DRV_UART_H__ void rt_hw_uart_init(void); diff --git a/bsp/lpc408x/rtthread-lpc408x.ld b/bsp/lpc408x/drivers/linker_scripts/link.lds similarity index 95% rename from bsp/lpc408x/rtthread-lpc408x.ld rename to bsp/lpc408x/drivers/linker_scripts/link.lds index 746f3948eb..ddf10a2c20 100644 --- a/bsp/lpc408x/rtthread-lpc408x.ld +++ b/bsp/lpc408x/drivers/linker_scripts/link.lds @@ -6,8 +6,8 @@ /* Program Entry, set to mark it as "used" and avoid gc */ MEMORY { - CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000 - DATA (rw) : ORIGIN = 0x10000000, LENGTH = 0x00010000 + CODE (rx) : ORIGIN = 0x00000000, LENGTH = 512k /* 512k flash */ + DATA (rw) : ORIGIN = 0x10000000, LENGTH = 64k /* 64k sram */ } ENTRY(Reset_Handler) _system_stack_size = 0x200; @@ -38,6 +38,7 @@ SECTIONS __vsymtab_end = .; . = ALIGN(4); + /* section information for initial. */ . = ALIGN(4); __rt_init_start = .; KEEP(*(SORT(.rti_fn*))) diff --git a/bsp/lpc408x/rtthread-lpc408x.sct b/bsp/lpc408x/drivers/linker_scripts/link.sct similarity index 100% rename from bsp/lpc408x/rtthread-lpc408x.sct rename to bsp/lpc408x/drivers/linker_scripts/link.sct diff --git a/bsp/lpc408x/project.uvopt b/bsp/lpc408x/project.uvopt index bfe099d207..b3e8bc92df 100644 --- a/bsp/lpc408x/project.uvopt +++ b/bsp/lpc408x/project.uvopt @@ -21,7 +21,7 @@ - RT-Thread LPC408x + rtthread 0x4 ARM-ADS @@ -43,7 +43,7 @@ 79 66 8 - .\build\ + .\build\keil\List\ 1 @@ -75,17 +75,7 @@ 0 1 - 0 - - SARMCM3.DLL - -MPU - DCM.DLL - -pCM4 - SARMCM3.DLL - -MPU - TCM.DLL - -pCM4 - + 8 0 1 @@ -97,16 +87,19 @@ 1 1 1 - 0 + 1 1 1 1 0 1 0 + 1 + 1 + 0 0 0 - 7 + 6 @@ -123,7 +116,12 @@ 0 JL2CM3 - -U4294967295 -O78 -S0 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO11 -FD10000000 -FC800 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 + -U30000299 -O4303 -S0 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD10000000 -FC800 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 + + + 0 + UL2CM3 + UL2CM3(-O4303 -S0 -C0 -FO7 -FD10000000 -FC800 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000) diff --git a/bsp/lpc408x/project.uvoptx b/bsp/lpc408x/project.uvoptx new file mode 100644 index 0000000000..9505c2dd20 --- /dev/null +++ b/bsp/lpc408x/project.uvoptx @@ -0,0 +1,177 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + rtthread + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\build\keil\List\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 0 + 0 + 1 + + 8 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + JL2CM3 + -U30000299 -O14 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight JTAG-DP") -D00(4BA00477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512.FLM -FS00 -FL080000 -FP0($$Device:LPC4088FET208$Flash\LPC_IAP_512.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FN1 -FCFE0 -FD10000000 -FF0LPC_IAP_512 -FL080000 -FS00 -FP0($$Device:LPC4088FET208$Flash\LPC_IAP_512.FLM) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + +
diff --git a/bsp/lpc408x/project.uvproj b/bsp/lpc408x/project.uvproj index 77e8969074..65b2b2c276 100644 --- a/bsp/lpc408x/project.uvproj +++ b/bsp/lpc408x/project.uvproj @@ -4,7 +4,7 @@
### uVision Project, (C) Keil Software
- RT-Thread LPC408x + rtthread 0x4 ARM-ADS @@ -27,6 +27,7 @@ SFD\NXP\LPC407x_8x_177x_8x\LPC408x_7x.SFR + 0 0 @@ -40,21 +41,21 @@ 0 1 - .\build\ - rtthread-lpc + .\build\keil\Obj\ + rtthread 1 0 0 1 - 1 - .\build\ + 0 + .\build\keil\List\ 1 0 0 0 0 - + fromelf --bin !L --output rtthread.bin 0 0 @@ -94,6 +95,7 @@ 3 + 1 SARMCM3.DLL @@ -123,20 +125,23 @@ 1 1 0 + 1 1 1 - 0 + 1 1 1 1 0 1 0 + 1 + 0 0 - 7 + 6 @@ -158,14 +163,18 @@ 1 0 0 - 0 + 1 1 4099 - 0 + 1 Segger\JL2CM3.dll "" () + + + + 0 @@ -344,11 +353,13 @@ 0 0 0 + 0 + 0 - CORE_M4, RT_USING_ARM_LIBC + CORE_M4 - drivers;applications;.;Libraries/Drivers/include;Libraries/Device/NXP/LPC407x_8x_177x_8x/Include;Libraries/CMSIS/Include;../../include;../../libcpu/arm/cortex-m4;../../libcpu/arm/common;../../components/drivers/include;../../components/drivers/include;../../components/drivers/include;../../components/libc/pthreads;../../components/libc/time;../../components/libc/compilers/armlibc;../../components/finsh + .;..\..\include;applications;.;drivers;Libraries\Device\NXP\LPC407x_8x_177x_8x\Include;Libraries\CMSIS\Include;Libraries\Drivers\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m4;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh @@ -360,6 +371,7 @@ 0 0 0 + 0 @@ -376,10 +388,11 @@ 0 0x00000000 0x10000000 + - --keep *.o(.rti_fn.*) --keep *.o(FSymTab) --keep *.o(VSymTab) + --keep *.o(.rti_fn.*) --keep *.o(FSymTab) @@ -387,40 +400,110 @@ - Drivers + Kernel - drv_hwtimer.c + clock.c 1 - drivers/drv_hwtimer.c + ..\..\src\clock.c - drv_led.c + components.c 1 - drivers/drv_led.c + ..\..\src\components.c - drv_lpccan.c + cpu.c 1 - drivers/drv_lpccan.c + ..\..\src\cpu.c - drv_sdram.c + device.c 1 - drivers/drv_sdram.c + ..\..\src\device.c - drv_uart.c + idle.c 1 - drivers/drv_uart.c + ..\..\src\idle.c + + + + + ipc.c + 1 + ..\..\src\ipc.c + + + + + irq.c + 1 + ..\..\src\irq.c + + + + + kservice.c + 1 + ..\..\src\kservice.c + + + + + memheap.c + 1 + ..\..\src\memheap.c + + + + + mempool.c + 1 + ..\..\src\mempool.c + + + + + object.c + 1 + ..\..\src\object.c + + + + + scheduler.c + 1 + ..\..\src\scheduler.c + + + + + signal.c + 1 + ..\..\src\signal.c + + + + + thread.c + 1 + ..\..\src\thread.c + + + + + timer.c + 1 + ..\..\src\timer.c @@ -428,382 +511,315 @@ Applications - application.c + main.c 1 - applications/application.c + applications\main.c + + + Drivers board.c 1 - applications/board.c + drivers\board.c - canapp.c + drv_uart.c 1 - applications/canapp.c - - - - - sram.c - 1 - applications/sram.c - - - - - startup.c - 1 - applications/startup.c + drivers\drv_uart.c Libraries - - - lpc_adc.c - 1 - Libraries/Drivers/source/lpc_adc.c - - - - - lpc_bod.c - 1 - Libraries/Drivers/source/lpc_bod.c - - - - - lpc_can.c - 1 - Libraries/Drivers/source/lpc_can.c - - - - - lpc_clkpwr.c - 1 - Libraries/Drivers/source/lpc_clkpwr.c - - - - - lpc_crc.c - 1 - Libraries/Drivers/source/lpc_crc.c - - - - - lpc_dac.c - 1 - Libraries/Drivers/source/lpc_dac.c - - - - - lpc_eeprom.c - 1 - Libraries/Drivers/source/lpc_eeprom.c - - - - - lpc_emc.c - 1 - Libraries/Drivers/source/lpc_emc.c - - - - - lpc_exti.c - 1 - Libraries/Drivers/source/lpc_exti.c - - - - - lpc_gpdma.c - 1 - Libraries/Drivers/source/lpc_gpdma.c - - - - - lpc_gpio.c - 1 - Libraries/Drivers/source/lpc_gpio.c - - - - - lpc_i2c.c - 1 - Libraries/Drivers/source/lpc_i2c.c - - - - - lpc_i2s.c - 1 - Libraries/Drivers/source/lpc_i2s.c - - - - - lpc_iap.c - 1 - Libraries/Drivers/source/lpc_iap.c - - - - - lpc_lcd.c - 1 - Libraries/Drivers/source/lpc_lcd.c - - - - - lpc_mcpwm.c - 1 - Libraries/Drivers/source/lpc_mcpwm.c - - - - - lpc_nvic.c - 1 - Libraries/Drivers/source/lpc_nvic.c - - - - - lpc_pinsel.c - 1 - Libraries/Drivers/source/lpc_pinsel.c - - - - - lpc_pwm.c - 1 - Libraries/Drivers/source/lpc_pwm.c - - - - - lpc_qei.c - 1 - Libraries/Drivers/source/lpc_qei.c - - - - - lpc_rtc.c - 1 - Libraries/Drivers/source/lpc_rtc.c - - - - - lpc_ssp.c - 1 - Libraries/Drivers/source/lpc_ssp.c - - - - - lpc_systick.c - 1 - Libraries/Drivers/source/lpc_systick.c - - - - - lpc_timer.c - 1 - Libraries/Drivers/source/lpc_timer.c - - - - - lpc_uart.c - 1 - Libraries/Drivers/source/lpc_uart.c - - - - - lpc_wwdt.c - 1 - Libraries/Drivers/source/lpc_wwdt.c - - system_LPC407x_8x_177x_8x.c 1 - Libraries/Device/NXP/LPC407x_8x_177x_8x/Source/Templates/system_LPC407x_8x_177x_8x.c + Libraries\Device\NXP\LPC407x_8x_177x_8x\Source\Templates\system_LPC407x_8x_177x_8x.c startup_LPC407x_8x_177x_8x.s 2 - Libraries/Device/NXP/LPC407x_8x_177x_8x/Source/Templates/ARM/startup_LPC407x_8x_177x_8x.s + Libraries\Device\NXP\LPC407x_8x_177x_8x\Source\Templates\ARM\startup_LPC407x_8x_177x_8x.s + + + + + lpc_adc.c + 1 + Libraries\Drivers\source\lpc_adc.c + + + + + lpc_bod.c + 1 + Libraries\Drivers\source\lpc_bod.c + + + + + lpc_can.c + 1 + Libraries\Drivers\source\lpc_can.c + + + + + lpc_clkpwr.c + 1 + Libraries\Drivers\source\lpc_clkpwr.c + + + + + lpc_crc.c + 1 + Libraries\Drivers\source\lpc_crc.c + + + + + lpc_dac.c + 1 + Libraries\Drivers\source\lpc_dac.c + + + + + lpc_eeprom.c + 1 + Libraries\Drivers\source\lpc_eeprom.c + + + + + lpc_emc.c + 1 + Libraries\Drivers\source\lpc_emc.c + + + + + lpc_exti.c + 1 + Libraries\Drivers\source\lpc_exti.c + + + + + lpc_gpdma.c + 1 + Libraries\Drivers\source\lpc_gpdma.c + + + + + lpc_gpio.c + 1 + Libraries\Drivers\source\lpc_gpio.c + + + + + lpc_i2c.c + 1 + Libraries\Drivers\source\lpc_i2c.c + + + + + lpc_i2s.c + 1 + Libraries\Drivers\source\lpc_i2s.c + + + + + lpc_iap.c + 1 + Libraries\Drivers\source\lpc_iap.c + + + + + lpc_lcd.c + 1 + Libraries\Drivers\source\lpc_lcd.c + + + + + lpc_mcpwm.c + 1 + Libraries\Drivers\source\lpc_mcpwm.c + + + + + lpc_nvic.c + 1 + Libraries\Drivers\source\lpc_nvic.c + + + + + lpc_pinsel.c + 1 + Libraries\Drivers\source\lpc_pinsel.c + + + + + lpc_pwm.c + 1 + Libraries\Drivers\source\lpc_pwm.c + + + + + lpc_qei.c + 1 + Libraries\Drivers\source\lpc_qei.c + + + + + lpc_rtc.c + 1 + Libraries\Drivers\source\lpc_rtc.c + + + + + lpc_ssp.c + 1 + Libraries\Drivers\source\lpc_ssp.c + + + + + lpc_systick.c + 1 + Libraries\Drivers\source\lpc_systick.c + + + + + lpc_timer.c + 1 + Libraries\Drivers\source\lpc_timer.c + + + + + lpc_uart.c + 1 + Libraries\Drivers\source\lpc_uart.c + + + + + lpc_wwdt.c + 1 + Libraries\Drivers\source\lpc_wwdt.c - Kernel - - - clock.c - 1 - ../../src/clock.c - - - - - components.c - 1 - ../../src/components.c - - - - - device.c - 1 - ../../src/device.c - - - - - idle.c - 1 - ../../src/idle.c - - - - - ipc.c - 1 - ../../src/ipc.c - - - - - irq.c - 1 - ../../src/irq.c - - - - - kservice.c - 1 - ../../src/kservice.c - - - - - mem.c - 1 - ../../src/mem.c - - - - - memheap.c - 1 - ../../src/memheap.c - - - - - mempool.c - 1 - ../../src/mempool.c - - - - - object.c - 1 - ../../src/object.c - - - - - scheduler.c - 1 - ../../src/scheduler.c - - - - - signal.c - 1 - ../../src/signal.c - - - - - thread.c - 1 - ../../src/thread.c - - - - - timer.c - 1 - ../../src/timer.c - - - - - CORTEX-M4 - - - cpuport.c - 1 - ../../libcpu/arm/cortex-m4/cpuport.c - - - - - context_rvds.S - 2 - ../../libcpu/arm/cortex-m4/context_rvds.S - - + cpu backtrace.c 1 - ../../libcpu/arm/common/backtrace.c + ..\..\libcpu\arm\common\backtrace.c div0.c 1 - ../../libcpu/arm/common/div0.c + ..\..\libcpu\arm\common\div0.c showmem.c 1 - ../../libcpu/arm/common/showmem.c + ..\..\libcpu\arm\common\showmem.c + + + + + cpuport.c + 1 + ..\..\libcpu\arm\cortex-m4\cpuport.c + + + + + context_rvds.S + 2 + ..\..\libcpu\arm\cortex-m4\context_rvds.S + + + + + Filesystem + + + dfs.c + 1 + ..\..\components\dfs\src\dfs.c + + + + + dfs_file.c + 1 + ..\..\components\dfs\src\dfs_file.c + + + + + dfs_fs.c + 1 + ..\..\components\dfs\src\dfs_fs.c + + + + + dfs_posix.c + 1 + ..\..\components\dfs\src\dfs_posix.c + + + + + devfs.c + 1 + ..\..\components\dfs\filesystems\devfs\devfs.c + + + + + dfs_elm.c + 1 + ..\..\components\dfs\filesystems\elmfat\dfs_elm.c + + + + + ff.c + 1 + ..\..\components\dfs\filesystems\elmfat\ff.c @@ -811,197 +827,65 @@ DeviceDrivers - serial.c + pin.c 1 - ../../components/drivers/serial/serial.c + ..\..\components\drivers\misc\pin.c - can.c + serial.c 1 - ../../components/drivers/can/can.c + ..\..\components\drivers\serial\serial.c completion.c 1 - ../../components/drivers/src/completion.c + ..\..\components\drivers\src\completion.c dataqueue.c 1 - ../../components/drivers/src/dataqueue.c + ..\..\components\drivers\src\dataqueue.c pipe.c 1 - ../../components/drivers/src/pipe.c + ..\..\components\drivers\src\pipe.c + + + + + ringblk_buf.c + 1 + ..\..\components\drivers\src\ringblk_buf.c ringbuffer.c 1 - ../../components/drivers/src/ringbuffer.c + ..\..\components\drivers\src\ringbuffer.c waitqueue.c 1 - ../../components/drivers/src/waitqueue.c + ..\..\components\drivers\src\waitqueue.c workqueue.c 1 - ../../components/drivers/src/workqueue.c - - - - - pthreads - - - mqueue.c - 1 - ../../components/libc/pthreads/mqueue.c - - - - - pthread.c - 1 - ../../components/libc/pthreads/pthread.c - - - - - pthread_attr.c - 1 - ../../components/libc/pthreads/pthread_attr.c - - - - - pthread_barrier.c - 1 - ../../components/libc/pthreads/pthread_barrier.c - - - - - pthread_cond.c - 1 - ../../components/libc/pthreads/pthread_cond.c - - - - - pthread_mutex.c - 1 - ../../components/libc/pthreads/pthread_mutex.c - - - - - pthread_rwlock.c - 1 - ../../components/libc/pthreads/pthread_rwlock.c - - - - - pthread_spin.c - 1 - ../../components/libc/pthreads/pthread_spin.c - - - - - pthread_tls.c - 1 - ../../components/libc/pthreads/pthread_tls.c - - - - - sched.c - 1 - ../../components/libc/pthreads/sched.c - - - - - semaphore.c - 1 - ../../components/libc/pthreads/semaphore.c - - - - - clock_time.c - 1 - ../../components/libc/time/clock_time.c - - - - - posix_sleep.c - 1 - ../../components/libc/time/posix_sleep.c - - - - - libc - - - libc.c - 1 - ../../components/libc/compilers/armlibc/libc.c - - - - - libc_syms.c - 1 - ../../components/libc/compilers/armlibc/libc_syms.c - - - - - mem_std.c - 1 - ../../components/libc/compilers/armlibc/mem_std.c - - - - - stdio.c - 1 - ../../components/libc/compilers/armlibc/stdio.c - - - - - stubs.c - 1 - ../../components/libc/compilers/armlibc/stubs.c - - - - - time.c - 1 - ../../components/libc/compilers/armlibc/time.c + ..\..\components\drivers\src\workqueue.c @@ -1011,112 +895,42 @@ shell.c 1 - ../../components/finsh/shell.c + ..\..\components\finsh\shell.c symbol.c 1 - ../../components/finsh/symbol.c + ..\..\components\finsh\symbol.c cmd.c 1 - ../../components/finsh/cmd.c + ..\..\components\finsh\cmd.c msh.c 1 - ../../components/finsh/msh.c + ..\..\components\finsh\msh.c msh_cmd.c 1 - ../../components/finsh/msh_cmd.c + ..\..\components\finsh\msh_cmd.c msh_file.c 1 - ../../components/finsh/msh_file.c - - - - - finsh_compiler.c - 1 - ../../components/finsh/finsh_compiler.c - - - - - finsh_error.c - 1 - ../../components/finsh/finsh_error.c - - - - - finsh_heap.c - 1 - ../../components/finsh/finsh_heap.c - - - - - finsh_init.c - 1 - ../../components/finsh/finsh_init.c - - - - - finsh_node.c - 1 - ../../components/finsh/finsh_node.c - - - - - finsh_ops.c - 1 - ../../components/finsh/finsh_ops.c - - - - - finsh_parser.c - 1 - ../../components/finsh/finsh_parser.c - - - - - finsh_var.c - 1 - ../../components/finsh/finsh_var.c - - - - - finsh_vm.c - 1 - ../../components/finsh/finsh_vm.c - - - - - finsh_token.c - 1 - ../../components/finsh/finsh_token.c + ..\..\components\finsh\msh_file.c diff --git a/bsp/lpc408x/project.uvprojx b/bsp/lpc408x/project.uvprojx index c9a4fc4fbf..2ca6ba93d8 100644 --- a/bsp/lpc408x/project.uvprojx +++ b/bsp/lpc408x/project.uvprojx @@ -1,45 +1,43 @@ - 2.1 -
### uVision Project, (C) Keil Software
- - RT-Thread LPC408X + rtthread 0x4 ARM-ADS - 5060422::V5.06 update 4 (build 422)::ARMCC + 5060528::V5.06 update 5 (build 528)::ARMCC + 0 - ARMCM4 - ARM - ARM.CMSIS.5.0.0 + LPC4088FET208 + NXP + Keil.LPC4000_DFP.2.1.0 http://www.keil.com/pack/ - IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M4") CLOCK(12000000) ESEL ELITTLE - - - UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + IRAM(0x10000000,0x10000) IRAM2(0x20000000,0x8000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 -FP0($$Device:LPC4088FET208$Flash\LPC_IAP_512.FLM)) 0 - $$Device:ARMCM4$Device\ARM\ARMCM4\Include\ARMCM4.h - - - - - - - - - - $$Device:ARMCM4$Device\ARM\SVD\ARMCM4.svd + $$Device:LPC4088FET208$Device\Include\LPC407x_8x_177x_8x.h + + + + + + + + + + $$Device:LPC4088FET208$SVD\LPC408x_7x.svd 0 0 - - - - - + + + + + 0 0 @@ -47,22 +45,22 @@ 0 1 - .\build\ + .\build\keil\Obj\ rtthread 1 0 0 1 0 - .\build\ + .\build\keil\List\ 1 0 0 0 0 - - + + 0 0 0 @@ -71,8 +69,8 @@ 0 0 - - + + 0 0 0 @@ -81,15 +79,15 @@ 1 0 - fromelf --bin !L --output rtthread-mdk.bin - + fromelf --bin !L --output rtthread.bin + 0 0 0 0 0 - + 0 @@ -103,8 +101,8 @@ 0 0 3 - - + + 1 @@ -138,10 +136,10 @@ 1 BIN\UL2CM3.DLL "" () - - - - + + + + 0 @@ -174,7 +172,7 @@ 0 0 "Cortex-M4" - + 0 0 0 @@ -182,16 +180,16 @@ 1 0 0 - 0 - 0 + 2 + 1 0 8 0 - 1 + 0 0 0 3 - 3 + 4 0 0 0 @@ -208,7 +206,7 @@ 0 0 1 - 0 + 1 0 @@ -242,13 +240,13 @@ 0 - 0x20000000 - 0x20000 + 0x10000000 + 0x10000 1 0x0 - 0x40000 + 0x80000 0 @@ -302,11 +300,11 @@ 0 - 0x0 - 0x0 + 0x20000000 + 0x8000 - + 1 @@ -333,9 +331,9 @@ 0 --library_interface=armcc --library_type=standardlib --diag_suppress=66,1296,186 - CORE_M4, RT_USING_ARM_LIBC - - applications;.;drivers;Libraries\Device\NXP\LPC407x_8x_177x_8x\Include;Libraries\CMSIS\Include;Libraries\Drivers\include;..\..\include;..\..\libcpu\arm\cortex-m4;..\..\libcpu\arm\common;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\libc\pthreads;..\..\components\libc\time + CORE_M4 + + .;..\..\include;applications;.;drivers;Libraries\Device\NXP\LPC407x_8x_177x_8x\Include;Libraries\CMSIS\Include;Libraries\Drivers\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m4;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh @@ -350,10 +348,10 @@ 0 0 - - - - + + + + @@ -365,44 +363,132 @@ 0 0x00000000 0x10000000 - - .\rtthread-lpc408x.sct - - - --keep *.o(FSymTab) --keep *.o(VSymTab) - - + + .\drivers\linker_scripts\link.sct + + + --keep *.o(.rti_fn.*) --keep *.o(FSymTab) + + + + Kernel + + + clock.c + 1 + ..\..\src\clock.c + + + + + components.c + 1 + ..\..\src\components.c + + + + + cpu.c + 1 + ..\..\src\cpu.c + + + + + device.c + 1 + ..\..\src\device.c + + + + + idle.c + 1 + ..\..\src\idle.c + + + + + ipc.c + 1 + ..\..\src\ipc.c + + + + + irq.c + 1 + ..\..\src\irq.c + + + + + kservice.c + 1 + ..\..\src\kservice.c + + + + + memheap.c + 1 + ..\..\src\memheap.c + + + + + mempool.c + 1 + ..\..\src\mempool.c + + + + + object.c + 1 + ..\..\src\object.c + + + + + scheduler.c + 1 + ..\..\src\scheduler.c + + + + + signal.c + 1 + ..\..\src\signal.c + + + + + thread.c + 1 + ..\..\src\thread.c + + + + + timer.c + 1 + ..\..\src\timer.c + + + Applications - application.c + main.c 1 - applications\application.c - - - board.c - 1 - applications\board.c - - - canapp.c - 1 - applications\canapp.c - - - sram.c - 1 - applications\sram.c - - - startup.c - 1 - applications\startup.c + applications\main.c @@ -410,25 +496,12 @@ Drivers - drv_hwtimer.c + board.c 1 - drivers\drv_hwtimer.c - - - drv_led.c - 1 - drivers\drv_led.c - - - drv_lpccan.c - 1 - drivers\drv_lpccan.c - - - drv_sdram.c - 1 - drivers\drv_sdram.c + drivers\board.c + + drv_uart.c 1 @@ -444,136 +517,190 @@ 1 Libraries\Device\NXP\LPC407x_8x_177x_8x\Source\Templates\system_LPC407x_8x_177x_8x.c + + startup_LPC407x_8x_177x_8x.s 2 Libraries\Device\NXP\LPC407x_8x_177x_8x\Source\Templates\ARM\startup_LPC407x_8x_177x_8x.s + + lpc_adc.c 1 Libraries\Drivers\source\lpc_adc.c + + lpc_bod.c 1 Libraries\Drivers\source\lpc_bod.c + + lpc_can.c 1 Libraries\Drivers\source\lpc_can.c + + lpc_clkpwr.c 1 Libraries\Drivers\source\lpc_clkpwr.c + + lpc_crc.c 1 Libraries\Drivers\source\lpc_crc.c + + lpc_dac.c 1 Libraries\Drivers\source\lpc_dac.c + + lpc_eeprom.c 1 Libraries\Drivers\source\lpc_eeprom.c + + lpc_emc.c 1 Libraries\Drivers\source\lpc_emc.c + + lpc_exti.c 1 Libraries\Drivers\source\lpc_exti.c + + lpc_gpdma.c 1 Libraries\Drivers\source\lpc_gpdma.c + + lpc_gpio.c 1 Libraries\Drivers\source\lpc_gpio.c + + lpc_i2c.c 1 Libraries\Drivers\source\lpc_i2c.c + + lpc_i2s.c 1 Libraries\Drivers\source\lpc_i2s.c + + lpc_iap.c 1 Libraries\Drivers\source\lpc_iap.c + + lpc_lcd.c 1 Libraries\Drivers\source\lpc_lcd.c + + lpc_mcpwm.c 1 Libraries\Drivers\source\lpc_mcpwm.c + + lpc_nvic.c 1 Libraries\Drivers\source\lpc_nvic.c + + lpc_pinsel.c 1 Libraries\Drivers\source\lpc_pinsel.c + + lpc_pwm.c 1 Libraries\Drivers\source\lpc_pwm.c + + lpc_qei.c 1 Libraries\Drivers\source\lpc_qei.c + + lpc_rtc.c 1 Libraries\Drivers\source\lpc_rtc.c + + lpc_ssp.c 1 Libraries\Drivers\source\lpc_ssp.c + + lpc_systick.c 1 Libraries\Drivers\source\lpc_systick.c + + lpc_timer.c 1 Libraries\Drivers\source\lpc_timer.c + + lpc_uart.c 1 Libraries\Drivers\source\lpc_uart.c + + lpc_wwdt.c 1 @@ -582,108 +709,41 @@ - Kernel + cpu - clock.c + backtrace.c 1 - ..\..\src\clock.c - - - device.c - 1 - ..\..\src\device.c - - - idle.c - 1 - ..\..\src\idle.c - - - ipc.c - 1 - ..\..\src\ipc.c - - - irq.c - 1 - ..\..\src\irq.c - - - kservice.c - 1 - ..\..\src\kservice.c - - - mem.c - 1 - ..\..\src\mem.c - - - memheap.c - 1 - ..\..\src\memheap.c - - - mempool.c - 1 - ..\..\src\mempool.c - - - object.c - 1 - ..\..\src\object.c - - - scheduler.c - 1 - ..\..\src\scheduler.c - - - signal.c - 1 - ..\..\src\signal.c - - - thread.c - 1 - ..\..\src\thread.c - - - timer.c - 1 - ..\..\src\timer.c + ..\..\libcpu\arm\common\backtrace.c + + + + + div0.c + 1 + ..\..\libcpu\arm\common\div0.c + + + + + showmem.c + 1 + ..\..\libcpu\arm\common\showmem.c - - - CORTEX-M4 cpuport.c 1 ..\..\libcpu\arm\cortex-m4\cpuport.c + + context_rvds.S 2 ..\..\libcpu\arm\cortex-m4\context_rvds.S - - backtrace.c - 1 - ..\..\libcpu\arm\common\backtrace.c - - - div0.c - 1 - ..\..\libcpu\arm\common\div0.c - - - showmem.c - 1 - ..\..\libcpu\arm\common\showmem.c - @@ -694,41 +754,43 @@ 1 ..\..\components\dfs\src\dfs.c + + dfs_file.c 1 ..\..\components\dfs\src\dfs_file.c + + dfs_fs.c 1 ..\..\components\dfs\src\dfs_fs.c + + dfs_posix.c 1 ..\..\components\dfs\src\dfs_posix.c - - poll.c - 1 - ..\..\components\dfs\src\poll.c - - - select.c - 1 - ..\..\components\dfs\src\select.c - + + devfs.c 1 ..\..\components\dfs\filesystems\devfs\devfs.c + + dfs_elm.c 1 ..\..\components\dfs\filesystems\elmfat\dfs_elm.c + + ff.c 1 @@ -739,46 +801,62 @@ DeviceDrivers - - can.c - 1 - ..\..\components\drivers\can\can.c - pin.c 1 ..\..\components\drivers\misc\pin.c + + serial.c 1 ..\..\components\drivers\serial\serial.c + + completion.c 1 ..\..\components\drivers\src\completion.c + + dataqueue.c 1 ..\..\components\drivers\src\dataqueue.c + + pipe.c 1 ..\..\components\drivers\src\pipe.c + + + + ringblk_buf.c + 1 + ..\..\components\drivers\src\ringblk_buf.c + + + ringbuffer.c 1 ..\..\components\drivers\src\ringbuffer.c + + waitqueue.c 1 ..\..\components\drivers\src\waitqueue.c + + workqueue.c 1 @@ -794,198 +872,49 @@ 1 ..\..\components\finsh\shell.c + + symbol.c 1 ..\..\components\finsh\symbol.c + + cmd.c 1 ..\..\components\finsh\cmd.c + + msh.c 1 ..\..\components\finsh\msh.c + + msh_cmd.c 1 ..\..\components\finsh\msh_cmd.c + + msh_file.c 1 ..\..\components\finsh\msh_file.c - - finsh_compiler.c - 1 - ..\..\components\finsh\finsh_compiler.c - - - finsh_error.c - 1 - ..\..\components\finsh\finsh_error.c - - - finsh_heap.c - 1 - ..\..\components\finsh\finsh_heap.c - - - finsh_init.c - 1 - ..\..\components\finsh\finsh_init.c - - - finsh_node.c - 1 - ..\..\components\finsh\finsh_node.c - - - finsh_ops.c - 1 - ..\..\components\finsh\finsh_ops.c - - - finsh_parser.c - 1 - ..\..\components\finsh\finsh_parser.c - - - finsh_var.c - 1 - ..\..\components\finsh\finsh_var.c - - - finsh_vm.c - 1 - ..\..\components\finsh\finsh_vm.c - - - finsh_token.c - 1 - ..\..\components\finsh\finsh_token.c - - - - - libc - - - libc.c - 1 - ..\..\components\libc\compilers\armlibc\libc.c - - - mem_std.c - 1 - ..\..\components\libc\compilers\armlibc\mem_std.c - - - stdio.c - 1 - ..\..\components\libc\compilers\armlibc\stdio.c - - - stubs.c - 1 - ..\..\components\libc\compilers\armlibc\stubs.c - - - time.c - 1 - ..\..\components\libc\compilers\armlibc\time.c - - - - - pthreads - - - mqueue.c - 1 - ..\..\components\libc\pthreads\mqueue.c - - - pthread.c - 1 - ..\..\components\libc\pthreads\pthread.c - - - pthread_attr.c - 1 - ..\..\components\libc\pthreads\pthread_attr.c - - - pthread_barrier.c - 1 - ..\..\components\libc\pthreads\pthread_barrier.c - - - pthread_cond.c - 1 - ..\..\components\libc\pthreads\pthread_cond.c - - - pthread_mutex.c - 1 - ..\..\components\libc\pthreads\pthread_mutex.c - - - pthread_rwlock.c - 1 - ..\..\components\libc\pthreads\pthread_rwlock.c - - - pthread_spin.c - 1 - ..\..\components\libc\pthreads\pthread_spin.c - - - pthread_tls.c - 1 - ..\..\components\libc\pthreads\pthread_tls.c - - - sched.c - 1 - ..\..\components\libc\pthreads\sched.c - - - semaphore.c - 1 - ..\..\components\libc\pthreads\semaphore.c - - - clock_time.c - 1 - ..\..\components\libc\time\clock_time.c - - - posix_sleep.c - 1 - ..\..\components\libc\time\posix_sleep.c - - - - - - - - - - - - + + + -
diff --git a/bsp/lpc408x/rtconfig.h b/bsp/lpc408x/rtconfig.h index 2b046180b4..4459cfd3a5 100644 --- a/bsp/lpc408x/rtconfig.h +++ b/bsp/lpc408x/rtconfig.h @@ -8,19 +8,16 @@ #define RT_NAME_MAX 8 #define RT_ALIGN_SIZE 4 -/* RT_THREAD_PRIORITY_8 is not set */ #define RT_THREAD_PRIORITY_32 -/* RT_THREAD_PRIORITY_256 is not set */ #define RT_THREAD_PRIORITY_MAX 32 -#define RT_TICK_PER_SECOND 100 +#define RT_TICK_PER_SECOND 1000 +#define RT_USING_OVERFLOW_CHECK +#define RT_USING_HOOK +#define RT_USING_IDLE_HOOK +#define RT_IDEL_HOOK_LIST_SIZE 4 +#define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG #define RT_DEBUG_COLOR -#define RT_USING_OVERFLOW_CHECK -#define RT_DEBUG_INIT 0 -#define RT_DEBUG_THREAD 0 -#define RT_USING_HOOK -#define IDLE_THREAD_STACK_SIZE 512 -/* RT_USING_TIMER_SOFT is not set */ /* Inter-Thread communication */ @@ -29,38 +26,34 @@ #define RT_USING_EVENT #define RT_USING_MAILBOX #define RT_USING_MESSAGEQUEUE -/* RT_USING_SIGNALS is not set */ /* Memory Management */ #define RT_USING_MEMPOOL #define RT_USING_MEMHEAP -/* RT_USING_NOHEAP is not set */ -#define RT_USING_SMALL_MEM -/* RT_USING_SLAB is not set */ -/* RT_USING_MEMHEAP_AS_HEAP is not set */ -/* RT_USING_MEMTRACE is not set */ +#define RT_USING_MEMHEAP_AS_HEAP #define RT_USING_HEAP /* Kernel Device Object */ #define RT_USING_DEVICE -/* RT_USING_INTERRUPT_INFO is not set */ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart0" -/* RT_USING_MODULE is not set */ +#define RT_VER_NUM 0x40001 #define ARCH_ARM #define ARCH_ARM_CORTEX_M #define ARCH_ARM_CORTEX_M4 /* RT-Thread Components */ -/* RT_USING_COMPONENTS_INIT is not set */ +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 2048 +#define RT_MAIN_THREAD_PRIORITY 10 /* C++ features */ -/* RT_USING_CPLUSPLUS is not set */ /* Command shell */ @@ -73,10 +66,10 @@ #define FINSH_THREAD_PRIORITY 20 #define FINSH_THREAD_STACK_SIZE 4096 #define FINSH_CMD_SIZE 80 -/* FINSH_USING_AUTH is not set */ #define FINSH_USING_MSH #define FINSH_USING_MSH_DEFAULT -/* FINSH_USING_MSH_ONLY is not set */ +#define FINSH_USING_MSH_ONLY +#define FINSH_ARG_MAX 10 /* Device virtual file system */ @@ -92,152 +85,108 @@ #define RT_DFS_ELM_CODE_PAGE 936 #define RT_DFS_ELM_WORD_ACCESS #define RT_DFS_ELM_USE_LFN_0 -/* RT_DFS_ELM_USE_LFN_1 is not set */ -/* RT_DFS_ELM_USE_LFN_2 is not set */ -/* RT_DFS_ELM_USE_LFN_3 is not set */ #define RT_DFS_ELM_USE_LFN 0 #define RT_DFS_ELM_MAX_LFN 255 #define RT_DFS_ELM_DRIVES 2 #define RT_DFS_ELM_MAX_SECTOR_SIZE 4096 -/* RT_DFS_ELM_USE_ERASE is not set */ #define RT_DFS_ELM_REENTRANT #define RT_USING_DFS_DEVFS -/* RT_USING_DFS_NET is not set */ -/* RT_USING_DFS_ROMFS is not set */ -/* RT_USING_DFS_RAMFS is not set */ -/* RT_USING_DFS_UFFS is not set */ -/* RT_USING_DFS_JFFS2 is not set */ -/* RT_USING_DFS_NFS is not set */ /* Device Drivers */ #define RT_USING_DEVICE_IPC +#define RT_PIPE_BUFSZ 512 #define RT_USING_SERIAL #define RT_SERIAL_USING_DMA -#define RT_USING_CAN -/* RT_USING_HWTIMER is not set */ -/* RT_USING_CPUTIME is not set */ -/* RT_USING_I2C is not set */ +#define RT_SERIAL_RB_BUFSZ 64 #define RT_USING_PIN -/* RT_USING_MTD_NOR is not set */ -/* RT_USING_MTD_NAND is not set */ -/* RT_USING_RTC is not set */ -/* RT_USING_SDIO is not set */ -/* RT_USING_SPI is not set */ -/* RT_USING_WDT is not set */ -/* RT_USING_WIFI is not set */ + +/* Using WiFi */ + /* Using USB */ -/* RT_USING_USB_HOST is not set */ -/* RT_USING_USB_DEVICE is not set */ /* POSIX layer and C standard library */ -#define RT_USING_LIBC -#define RT_USING_PTHREADS -#define RT_USING_POSIX -/* RT_USING_POSIX_MMAP is not set */ -/* RT_USING_POSIX_TERMIOS is not set */ -/* RT_USING_POSIX_AIO is not set */ -/* HAVE_SYS_SIGNALS is not set */ -/* Network stack */ +/* Network */ + +/* Socket abstraction layer */ + /* light weight TCP/IP stack */ -/* RT_USING_LWIP is not set */ /* Modbus master and slave stack */ -/* RT_USING_MODBUS is not set */ + +/* AT commands */ + /* VBUS(Virtual Software BUS) */ -/* RT_USING_VBUS is not set */ /* Utilities */ -/* RT_USING_LOGTRACE is not set */ -/* RT_USING_RYM is not set */ /* ARM CMSIS */ -/* RT_USING_CMSIS_OS is not set */ -/* RT_USING_RTT_CMSIS is not set */ /* RT-Thread online packages */ -/* system packages */ - -/* RT-Thread GUI Engine */ - -/* PKG_USING_GUIENGINE is not set */ -/* PKG_USING_PERSIMMON is not set */ -/* PKG_USING_LWEXT4 is not set */ -/* PKG_USING_PARTITION is not set */ -/* PKG_USING_SQLITE is not set */ -/* PKG_USING_RTI is not set */ - /* IoT - internet of things */ -/* PKG_USING_PAHOMQTT is not set */ -/* PKG_USING_WEBCLIENT is not set */ -/* PKG_USING_MONGOOSE is not set */ -/* PKG_USING_WEBTERMINAL is not set */ -/* PKG_USING_CJSON is not set */ -/* PKG_USING_LJSON is not set */ -/* PKG_USING_EZXML is not set */ -/* PKG_USING_NANOPB is not set */ -/* PKG_USING_GAGENT_CLOUD is not set */ /* Wi-Fi */ /* Marvell WiFi */ -/* PKG_USING_WLANMARVELL is not set */ /* Wiced WiFi */ -/* PKG_USING_WLAN_WICED is not set */ -/* PKG_USING_COAP is not set */ -/* PKG_USING_NOPOLL is not set */ -/* PKG_USING_NETUTILS is not set */ + +/* IoT Cloud */ + /* security packages */ -/* PKG_USING_MBEDTLS is not set */ -/* PKG_USING_libsodium is not set */ -/* PKG_USING_TINYCRYPT is not set */ /* language packages */ -/* PKG_USING_JERRYSCRIPT is not set */ -/* PKG_USING_MICROPYTHON is not set */ /* multimedia packages */ -/* PKG_USING_OPENMV is not set */ /* tools packages */ -/* PKG_USING_CMBACKTRACE is not set */ -/* PKG_USING_EASYLOGGER is not set */ -/* PKG_USING_SYSTEMVIEW is not set */ -/* PKG_USING_IPERF is not set */ + +/* system packages */ + + +/* peripheral libraries and drivers */ + /* miscellaneous packages */ -/* PKG_USING_FASTLZ is not set */ -/* PKG_USING_MINILZO is not set */ -/* PKG_USING_QUICKLZ is not set */ -/* example package: hello */ +/* samples: kernel and components samples */ -/* PKG_USING_HELLO is not set */ -/* PKG_USING_MULTIBUTTON is not set */ #define SOC_LPC4088 -/* RT_USING_UART0 is not set */ -#define RT_USING_UART1 + +/* Hardware Drivers Config */ + +/* On-chip Peripheral Drivers */ + + +/* UART Drivers */ + +#define BSP_USING_UART0 + +/* Onboard Peripheral Drivers */ + + +/* Offboard Peripheral Drivers */ + #endif diff --git a/bsp/lpc408x/rtconfig.py b/bsp/lpc408x/rtconfig.py index ba797aab63..030719b339 100644 --- a/bsp/lpc408x/rtconfig.py +++ b/bsp/lpc408x/rtconfig.py @@ -4,14 +4,13 @@ import os ARCH='arm' CPU='cortex-m4' CROSS_TOOL='keil' -BOARD_NAME = 'lpc408x' if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if CROSS_TOOL == 'gcc': PLATFORM = 'gcc' - EXEC_PATH = r'D:/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin' + EXEC_PATH = r'D:/xxx' elif CROSS_TOOL == 'keil': PLATFORM = 'armcc' EXEC_PATH = 'D:/Keil' @@ -33,17 +32,18 @@ if PLATFORM == 'gcc': CXX = PREFIX + 'g++' AS = PREFIX + 'gcc' AR = PREFIX + 'ar' - LINK = PREFIX + 'g++' + LINK = PREFIX + 'gcc' TARGET_EXT = 'elf' SIZE = PREFIX + 'size' OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' - DEVICE = ' -mcpu=cortex-m4 -mthumb' + DEVICE = ' -mcpu=' + CPU + ' -mthumb ' CFLAGS = DEVICE AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' - LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-' + BOARD_NAME + '.map,-cref,-u,Reset_Handler -T rtthread-' + BOARD_NAME + '.ld' - + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T drivers/linker_scripts/link.lds' + CXXFLAGS = CFLAGS + CPATH = '' LPATH = '' @@ -53,8 +53,6 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' - CXXFLAGS = CFLAGS - POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': @@ -66,17 +64,16 @@ elif PLATFORM == 'armcc': LINK = 'armlink' TARGET_EXT = 'axf' - DEVICE = ' --cpu Cortex-M4.fp' - CFLAGS = DEVICE + ' --apcs=interwork' - AFLAGS = DEVICE - LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread_' + \ - BOARD_NAME + '.map --scatter rtthread-' + BOARD_NAME + '.sct' + DEVICE = ' --cpu ' + CPU + '.fp ' + CFLAGS = '-c ' + DEVICE + ' --apcs=interwork' + AFLAGS = DEVICE + ' --apcs=interwork ' + LFLAGS = DEVICE + ' --scatter "drivers/linker_scripts/link.sct" --info sizes --info totals --info unused --info veneers --list rtthread.map --strict' - CFLAGS += ' -I' + EXEC_PATH + '/ARM/RV31/INC' - LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/RV31/LIB' + CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCC/INC' + LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/ARMCC/LIB' CXXFLAGS = CFLAGS - EXEC_PATH += '/arm/bin40/' + EXEC_PATH += '/arm/armcc/bin/' if BUILD == 'debug': CFLAGS += ' -g -O0' diff --git a/bsp/lpc408x/template.uvopt b/bsp/lpc408x/template.uvopt index bfe099d207..b3e8bc92df 100644 --- a/bsp/lpc408x/template.uvopt +++ b/bsp/lpc408x/template.uvopt @@ -21,7 +21,7 @@ - RT-Thread LPC408x + rtthread 0x4 ARM-ADS @@ -43,7 +43,7 @@ 79 66 8 - .\build\ + .\build\keil\List\ 1 @@ -75,17 +75,7 @@ 0 1 - 0 - - SARMCM3.DLL - -MPU - DCM.DLL - -pCM4 - SARMCM3.DLL - -MPU - TCM.DLL - -pCM4 - + 8 0 1 @@ -97,16 +87,19 @@ 1 1 1 - 0 + 1 1 1 1 0 1 0 + 1 + 1 + 0 0 0 - 7 + 6 @@ -123,7 +116,12 @@ 0 JL2CM3 - -U4294967295 -O78 -S0 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO11 -FD10000000 -FC800 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 + -U30000299 -O4303 -S0 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD10000000 -FC800 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 + + + 0 + UL2CM3 + UL2CM3(-O4303 -S0 -C0 -FO7 -FD10000000 -FC800 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000) diff --git a/bsp/lpc408x/template.uvoptx b/bsp/lpc408x/template.uvoptx new file mode 100644 index 0000000000..9505c2dd20 --- /dev/null +++ b/bsp/lpc408x/template.uvoptx @@ -0,0 +1,177 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + rtthread + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\build\keil\List\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 0 + 0 + 1 + + 8 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + JL2CM3 + -U30000299 -O14 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight JTAG-DP") -D00(4BA00477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512.FLM -FS00 -FL080000 -FP0($$Device:LPC4088FET208$Flash\LPC_IAP_512.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FN1 -FCFE0 -FD10000000 -FF0LPC_IAP_512 -FL080000 -FS00 -FP0($$Device:LPC4088FET208$Flash\LPC_IAP_512.FLM) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + +
diff --git a/bsp/lpc408x/template.uvproj b/bsp/lpc408x/template.uvproj index 68d0e0934d..ebbbafc7dd 100644 --- a/bsp/lpc408x/template.uvproj +++ b/bsp/lpc408x/template.uvproj @@ -7,7 +7,7 @@ - RT-Thread LPC408x + rtthread 0x4 ARM-ADS @@ -30,6 +30,7 @@ SFD\NXP\LPC407x_8x_177x_8x\LPC408x_7x.SFR + 0 0 @@ -43,21 +44,21 @@ 0 1 - .\build\ - rtthread-lpc + .\build\keil\Obj\ + rtthread 1 0 0 1 - 1 - .\build\ + 0 + .\build\keil\List\ 1 0 0 0 0 - + fromelf --bin !L --output rtthread.bin 0 0 @@ -97,6 +98,7 @@ 3 + 1 SARMCM3.DLL @@ -126,20 +128,23 @@ 1 1 0 + 1 1 1 - 0 + 1 1 1 1 0 1 0 + 1 + 0 0 - 7 + 6 @@ -161,14 +166,18 @@ 1 0 0 - 0 + 1 1 4099 - 0 + 1 Segger\JL2CM3.dll "" () + + + + 0 @@ -347,6 +356,8 @@ 0 0 0 + 0 + 0 @@ -363,6 +374,7 @@ 0 0 0 + 0 @@ -379,6 +391,7 @@ 0 0x00000000 0x10000000 + diff --git a/bsp/lpc408x/template.uvprojx b/bsp/lpc408x/template.uvprojx index b985d37e18..3367c1d559 100644 --- a/bsp/lpc408x/template.uvprojx +++ b/bsp/lpc408x/template.uvprojx @@ -7,22 +7,23 @@ - RT-Thread LPC408X + rtthread 0x4 ARM-ADS 5060528::V5.06 update 5 (build 528)::ARMCC + 0 - ARMCM4 - ARM - ARM.CMSIS.5.0.0 + LPC4088FET208 + NXP + Keil.LPC4000_DFP.2.1.0 http://www.keil.com/pack/ - IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M4") CLOCK(12000000) ESEL ELITTLE + IRAM(0x10000000,0x10000) IRAM2(0x20000000,0x8000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE - UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000) + UL2CM3(-S0 -C0 -P0 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 -FP0($$Device:LPC4088FET208$Flash\LPC_IAP_512.FLM)) 0 - $$Device:ARMCM4$Device\ARM\ARMCM4\Include\ARMCM4.h + $$Device:LPC4088FET208$Device\Include\LPC407x_8x_177x_8x.h @@ -32,7 +33,7 @@ - $$Device:ARMCM4$Device\ARM\SVD\ARMCM4.svd + $$Device:LPC4088FET208$SVD\LPC408x_7x.svd 0 0 @@ -47,14 +48,14 @@ 0 1 - .\build\ + .\build\keil\Obj\ rtthread 1 0 0 1 0 - .\build\ + .\build\keil\List\ 1 0 0 @@ -81,7 +82,7 @@ 1 0 - fromelf --bin !L --output rtthread-mdk.bin + fromelf --bin !L --output rtthread.bin 0 0 @@ -182,16 +183,16 @@ 1 0 0 - 0 - 0 + 2 + 1 0 8 0 - 1 + 0 0 0 3 - 3 + 4 0 0 0 @@ -208,7 +209,7 @@ 0 0 1 - 0 + 1 0 @@ -242,13 +243,13 @@ 0 - 0x20000000 - 0x20000 + 0x10000000 + 0x10000 1 0x0 - 0x40000 + 0x80000 0 @@ -302,8 +303,8 @@ 0 - 0x0 - 0x0 + 0x20000000 + 0x8000 @@ -366,7 +367,7 @@ 0x00000000 0x10000000 - .\rtthread-lpc408x.sct + .\drivers\linker_scripts\link.sct @@ -380,14 +381,7 @@ - - - - - - - - +