diff options
| author | Grissiom <[email protected]> | 2015-01-05 11:19:42 +0800 |
|---|---|---|
| committer | Grissiom <[email protected]> | 2015-01-06 10:46:31 +0800 |
| commit | 959f6c695fdea80d6bbd9146770eda95e0a2dfa9 (patch) | |
| tree | e77defd5ec352e9eac8d620058519649f19d4ba1 | |
| parent | 5542af8b7c1ec7359616d2e2521a5654547554b2 (diff) | |
lpc43xx: move the application code into its own space
| -rw-r--r-- | bsp/lpc43xx/M0/SConscript | 16 | ||||
| -rw-r--r-- | bsp/lpc43xx/M0/applications/SConscript (renamed from bsp/lpc43xx/applications/SConscript) | 0 | ||||
| -rw-r--r-- | bsp/lpc43xx/M0/applications/application.c (renamed from bsp/lpc43xx/applications/application.c) | 5 | ||||
| -rw-r--r-- | bsp/lpc43xx/M0/applications/board.h | 59 | ||||
| -rw-r--r-- | bsp/lpc43xx/M0/applications/startup.c (renamed from bsp/lpc43xx/applications/startup.c) | 0 | ||||
| -rw-r--r-- | bsp/lpc43xx/M0/rtconfig.h | 4 | ||||
| -rw-r--r-- | bsp/lpc43xx/M4/SConscript | 16 | ||||
| -rw-r--r-- | bsp/lpc43xx/M4/applications/SConscript | 13 | ||||
| -rw-r--r-- | bsp/lpc43xx/M4/applications/application.c | 113 | ||||
| -rw-r--r-- | bsp/lpc43xx/M4/applications/board.h (renamed from bsp/lpc43xx/drivers/board.h) | 1 | ||||
| -rw-r--r-- | bsp/lpc43xx/M4/applications/startup.c | 74 | ||||
| -rw-r--r-- | bsp/lpc43xx/M4/rtconfig.h | 3 |
12 files changed, 287 insertions, 17 deletions
diff --git a/bsp/lpc43xx/M0/SConscript b/bsp/lpc43xx/M0/SConscript index e2c31c0755..285e5c295f 100644 --- a/bsp/lpc43xx/M0/SConscript +++ b/bsp/lpc43xx/M0/SConscript @@ -2,12 +2,16 @@ from building import * cwd = GetCurrentDir() objs = [] -list = os.listdir(os.path.join(cwd, '..')) -for d in list: - if (d != 'M4' and d != 'M0'): - path = os.path.join(cwd, '..', d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(path, 'SConscript')) +for d in os.listdir(os.path.join(cwd, '..')): + if d not in ('M0', 'M4'): + path = os.path.join(cwd, '..', d, 'SConscript') + if os.path.isfile(path): + objs = objs + SConscript(path) + +for d in os.listdir(cwd): + p = os.path.join(cwd, d, 'SConscript'); + if os.path.isfile(p): + objs = objs + SConscript(p) Return('objs') diff --git a/bsp/lpc43xx/applications/SConscript b/bsp/lpc43xx/M0/applications/SConscript index 01eb940dfb..01eb940dfb 100644 --- a/bsp/lpc43xx/applications/SConscript +++ b/bsp/lpc43xx/M0/applications/SConscript diff --git a/bsp/lpc43xx/applications/application.c b/bsp/lpc43xx/M0/applications/application.c index e40ad02e48..e49f1dd767 100644 --- a/bsp/lpc43xx/applications/application.c +++ b/bsp/lpc43xx/M0/applications/application.c @@ -49,12 +49,12 @@ static void led_thread_entry(void *parameter) { /* led0 on */ led_value = 1; - led_dev->write(led_dev, 0, &led_value, 1); + led_dev->write(led_dev, 1, &led_value, 1); rt_thread_delay(RT_TICK_PER_SECOND / 2); /* sleep 0.5 second and switch to other thread */ /* led0 off */ led_value = 0; - led_dev->write(led_dev, 0, &led_value, 1); + led_dev->write(led_dev, 1, &led_value, 1); rt_thread_delay(RT_TICK_PER_SECOND / 2); } } @@ -82,3 +82,4 @@ int rt_application_init(void) } return 0; } + diff --git a/bsp/lpc43xx/M0/applications/board.h b/bsp/lpc43xx/M0/applications/board.h new file mode 100644 index 0000000000..c19d0dc4ba --- /dev/null +++ b/bsp/lpc43xx/M0/applications/board.h @@ -0,0 +1,59 @@ +/* + * File : board.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2009, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * 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 "LPC43xx.h" +#include <rtthread.h> + +/* disable SDRAM in default */ +#ifndef LPC_EXT_SDRAM +#define LPC_EXT_SDRAM 0 +#endif + +// <RDTConfigurator URL="http://www.rt-thread.com/eclipse"> + +// <integer name="LPC_EXT_SDRAM" description="Begin Address of External SDRAM" default="0xA0000000" /> +#define LPC_EXT_SDRAM_BEGIN 0xA0000000 +// <integer name="LPC_EXT_SDRAM_END" description="End Address of External SDRAM" default="0xA2000000" /> +#define LPC_EXT_SDRAM_END 0xA2000000 + +// <bool name="RT_USING_UART0" description="Using UART0" default="true" /> +// <bool name="RT_USING_UART1" description="Using UART1" default="true" /> +//#define RT_USING_UART1 +// <bool name="RT_USING_UART2" description="Using UART2" default="true" /> +//#define RT_USING_UART2 + +// </RDTConfigurator> + +#ifdef __CC_ARM +extern int Image$$RW_IRAM2$$ZI$$Limit; +#define HEAP_BEGIN ((void *)&Image$$RW_IRAM2$$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*)(0x10080000 + 0x8000) + +void rt_hw_board_init(void); +int rt_hw_board_heap_init(void); + + +#endif diff --git a/bsp/lpc43xx/applications/startup.c b/bsp/lpc43xx/M0/applications/startup.c index f6cf534b03..f6cf534b03 100644 --- a/bsp/lpc43xx/applications/startup.c +++ b/bsp/lpc43xx/M0/applications/startup.c diff --git a/bsp/lpc43xx/M0/rtconfig.h b/bsp/lpc43xx/M0/rtconfig.h index 84fc28028c..a1ac5509ab 100644 --- a/bsp/lpc43xx/M0/rtconfig.h +++ b/bsp/lpc43xx/M0/rtconfig.h @@ -24,6 +24,7 @@ #define RT_DEBUG // <bool name="RT_DEBUG_INIT" description="debug init enable" default=0 /> #define RT_DEBUG_INIT 0 +//#define RT_DEBUG_SCHEDULER 1 // <bool name="RT_THREAD_DEBUG" description="Thread debug enable" default="false" /> // #define RT_THREAD_DEBUG // <bool name="RT_USING_OVERFLOW_CHECK" description="Thread stack over flow detect" default="true" /> @@ -33,7 +34,7 @@ // <bool name="RT_USING_HOOK" description="Using hook functions" default="true" /> #define RT_USING_HOOK // <section name="RT_USING_TIMER_SOFT" description="Using software timer which will start a thread to handle soft-timer" default="true" > -#define RT_USING_TIMER_SOFT +//#define RT_USING_TIMER_SOFT // <integer name="RT_TIMER_THREAD_PRIO" description="The priority level of timer thread" default="4" /> #define RT_TIMER_THREAD_PRIO 4 // <integer name="RT_TIMER_THREAD_STACK_SIZE" description="The stack size of timer thread" default="512" /> @@ -96,6 +97,7 @@ #define RT_CONSOLEBUF_SIZE 128 // <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart" /> #define RT_CONSOLE_DEVICE_NAME "uart0" +#define RT_USING_UART0 // </section> // <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" /> diff --git a/bsp/lpc43xx/M4/SConscript b/bsp/lpc43xx/M4/SConscript index e2c31c0755..285e5c295f 100644 --- a/bsp/lpc43xx/M4/SConscript +++ b/bsp/lpc43xx/M4/SConscript @@ -2,12 +2,16 @@ from building import * cwd = GetCurrentDir() objs = [] -list = os.listdir(os.path.join(cwd, '..')) -for d in list: - if (d != 'M4' and d != 'M0'): - path = os.path.join(cwd, '..', d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(path, 'SConscript')) +for d in os.listdir(os.path.join(cwd, '..')): + if d not in ('M0', 'M4'): + path = os.path.join(cwd, '..', d, 'SConscript') + if os.path.isfile(path): + objs = objs + SConscript(path) + +for d in os.listdir(cwd): + p = os.path.join(cwd, d, 'SConscript'); + if os.path.isfile(p): + objs = objs + SConscript(p) Return('objs') diff --git a/bsp/lpc43xx/M4/applications/SConscript b/bsp/lpc43xx/M4/applications/SConscript new file mode 100644 index 0000000000..773b8d0422 --- /dev/null +++ b/bsp/lpc43xx/M4/applications/SConscript @@ -0,0 +1,13 @@ +Import('RTT_ROOT') +Import('rtconfig') +from building import * + +cwd = os.path.join(str(Dir('#')), 'applications') +src = Glob('*.c') +CPPPATH = [cwd, str(Dir('#'))] + +group = DefineGroup('Applications', src, + depend = [''], CPPPATH = CPPPATH, + CPPDEFINES = ['BOOT_PROCESSOR']) + +Return('group') diff --git a/bsp/lpc43xx/M4/applications/application.c b/bsp/lpc43xx/M4/applications/application.c new file mode 100644 index 0000000000..72e0234d85 --- /dev/null +++ b/bsp/lpc43xx/M4/applications/application.c @@ -0,0 +1,113 @@ +/* + * File : application.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2014, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2014-07-13 xiaonong port for lpc43xx + */ + +#include <rtthread.h> +#include <board.h> +#include <rtdevice.h> +#include "drv_led.h" + +#ifdef RT_USING_FINSH +#include <finsh.h> +#include <shell.h> +#endif + +static const unsigned char _M0_CODE[] SECTION("M0_CODE") = { +#include "M0_CODE.h" +}; + +static void _boot_M0(void) +{ + volatile uint32_t u32REG, u32Val; + + LPC_CREG->M0APPMEMMAP = (uint32_t)&_M0_CODE[0]; + + // Release Slave from reset, first read status + u32REG = LPC_RGU->RESET_ACTIVE_STATUS1; + + // If the M0 is being held in reset, release it... + // 1 = no reset, 0 = reset + while(!(u32REG & (1u << 24))) + { + u32Val = (~(u32REG) & (~(1 << 24))); + LPC_RGU->RESET_CTRL1 = u32Val; + u32REG = LPC_RGU->RESET_ACTIVE_STATUS1; + } + + rt_kprintf("M0 boot to %p\n", &_M0_CODE[0]); +} + +/* thread phase init */ +void rt_init_thread_entry(void *parameter) +{ +#ifdef RT_USING_FINSH + /* initialize finsh */ + finsh_system_init(); + finsh_set_device(RT_CONSOLE_DEVICE_NAME); +#endif + + _boot_M0(); +} + +/*the led thread*/ +ALIGN(RT_ALIGN_SIZE) +static rt_uint8_t led_stack[ 512 ]; +static struct rt_thread led_thread; +static void led_thread_entry(void *parameter) +{ + rt_uint8_t led_value = 0; + rt_device_t led_dev; + rt_led_hw_init(); + led_dev = rt_device_find("led"); + if (led_dev == RT_NULL) + { + rt_kprintf("can not find the led device!\n"); + return; + } + while (1) + { + /* led0 on */ + led_value = 1; + led_dev->write(led_dev, 0, &led_value, 1); + rt_thread_delay(RT_TICK_PER_SECOND / 2); /* sleep 0.5 second and switch to other thread */ + + /* led0 off */ + led_value = 0; + led_dev->write(led_dev, 0, &led_value, 1); + rt_thread_delay(RT_TICK_PER_SECOND / 2); + } +} + +int rt_application_init(void) +{ + rt_thread_t tid; + rt_err_t result; + 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); + /* init led thread */ + result = rt_thread_init(&led_thread, + "led", + led_thread_entry, + RT_NULL, + (rt_uint8_t *)&led_stack[0], + sizeof(led_stack), + 20, + 5); + if (result == RT_EOK) + { + rt_thread_startup(&led_thread); + } + return 0; +} diff --git a/bsp/lpc43xx/drivers/board.h b/bsp/lpc43xx/M4/applications/board.h index 393dc30c91..465ccef2cc 100644 --- a/bsp/lpc43xx/drivers/board.h +++ b/bsp/lpc43xx/M4/applications/board.h @@ -33,7 +33,6 @@ #define LPC_EXT_SDRAM_END 0xA2000000 // <bool name="RT_USING_UART0" description="Using UART0" default="true" /> -#define RT_USING_UART0 // <bool name="RT_USING_UART1" description="Using UART1" default="true" /> //#define RT_USING_UART1 // <bool name="RT_USING_UART2" description="Using UART2" default="true" /> diff --git a/bsp/lpc43xx/M4/applications/startup.c b/bsp/lpc43xx/M4/applications/startup.c new file mode 100644 index 0000000000..f6cf534b03 --- /dev/null +++ b/bsp/lpc43xx/M4/applications/startup.c @@ -0,0 +1,74 @@ +/* + * File : startup.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2009, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2009-01-05 Bernard first implementation + * 2014-07-13 xiaonong for LPC43xx + */ + +#include <rthw.h> +#include <rtthread.h> + +#include "board.h" + +extern int rt_application_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/lpc43xx/M4/rtconfig.h b/bsp/lpc43xx/M4/rtconfig.h index 84fc28028c..fb65f5bf3d 100644 --- a/bsp/lpc43xx/M4/rtconfig.h +++ b/bsp/lpc43xx/M4/rtconfig.h @@ -95,7 +95,8 @@ // <integer name="RT_CONSOLEBUF_SIZE" description="The buffer size for console output" default="128" /> #define RT_CONSOLEBUF_SIZE 128 // <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart" /> -#define RT_CONSOLE_DEVICE_NAME "uart0" +#define RT_CONSOLE_DEVICE_NAME "uart3" +#define RT_USING_UART3 // </section> // <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" /> |
