From ffd65c60c4509e13a34fde4de80b15e463ed2a47 Mon Sep 17 00:00:00 2001 From: "dzzxzz@gmail.com" Date: Mon, 23 Apr 2012 10:29:50 +0000 Subject: [PATCH] using components initialize in mb9bf506 branch git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2101 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/mb9bf506r/applications/application.c | 51 ++++--- bsp/mb9bf506r/applications/startup.c | 39 ++--- bsp/mb9bf506r/drivers/board.h | 2 - bsp/mb9bf506r/project.ewp | 33 ++--- bsp/mb9bf506r/project.uvopt | 176 +++++++---------------- bsp/mb9bf506r/project.uvproj | 47 ++---- bsp/mb9bf506r/rtconfig.h | 152 ++++++++++++-------- 7 files changed, 200 insertions(+), 300 deletions(-) diff --git a/bsp/mb9bf506r/applications/application.c b/bsp/mb9bf506r/applications/application.c index 94ffe4819d..1bfdce9f04 100644 --- a/bsp/mb9bf506r/applications/application.c +++ b/bsp/mb9bf506r/applications/application.c @@ -15,12 +15,17 @@ /** * @addtogroup FM3 */ + /*@{*/ #include #include "board.h" #include "led.h" +#ifdef RT_USING_COMPONENTS_INIT +#include +#endif + #ifdef RT_USING_DFS /* dfs init */ #include @@ -32,40 +37,34 @@ void rt_init_thread_entry(void *parameter) { + /* LED Initialization */ + rt_hw_led_init(); + +#ifdef RT_USING_COMPONENTS_INIT + /* initialization RT-Thread Components */ + rt_components_init(); +#endif + /* Filesystem Initialization */ #ifdef RT_USING_DFS - { - /* init the device filesystem */ - dfs_init(); - -#ifdef RT_USING_DFS_ELMFAT - /* init the elm chan FatFs filesystam*/ - elm_init(); - - /* mount ELM FatFs on NAND flash as root directory */ - if (dfs_mount("nand", "/", "elm", 0, 0) == 0) - { - rt_kprintf("File System initialized!\n"); - } - else - rt_kprintf("File System initialzation failed!\n"); + /* mount nand fat partition 1 as root directory */ + if (dfs_mount("nand", "/", "elm", 0, 0) == 0) + rt_kprintf("File System initialized!\n"); + else + rt_kprintf("File System init failed!\n"); #endif - } -#endif - /* LED Initialization */ - rt_hw_led_init(); } -int rt_application_init() +int rt_application_init(void) { rt_thread_t tid; - - tid = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - 2048, 8, 20); + + 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; + + return 0; } /*@}*/ diff --git a/bsp/mb9bf506r/applications/startup.c b/bsp/mb9bf506r/applications/startup.c index 7cbb64d976..df9a93afb2 100644 --- a/bsp/mb9bf506r/applications/startup.c +++ b/bsp/mb9bf506r/applications/startup.c @@ -17,25 +17,13 @@ #include "board.h" -#ifdef RT_USING_FINSH -#include -#endif - /** * @addtogroup FM3 */ -extern struct serial_device uart0; -extern struct rt_device uart0_device; -extern struct serial_device uart2; -extern struct rt_device uart2_device; - /*@{*/ extern int rt_application_init(void); -#ifdef RT_USING_FINSH -extern void finsh_system_init(void); -#endif #ifdef __CC_ARM extern int Image$$RW_IRAM1$$ZI$$Limit; @@ -50,17 +38,12 @@ extern int __bss_end; */ void rtthread_startup(void) { - /* init board */ + /* initialize board */ rt_hw_board_init(); /* show version */ rt_show_version(); - /* init tick */ - rt_system_tick_init(); - /* init timer system */ - rt_system_timer_init(); - #ifdef RT_USING_HEAP #ifdef __CC_ARM rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END); @@ -75,27 +58,23 @@ void rtthread_startup(void) /* init scheduler system */ rt_system_scheduler_init(); +#ifdef RT_USING_DEVICE #ifdef RT_USING_DFS #ifdef RT_USING_DFS_UFFS rt_hw_nand_init(); #endif +#endif + /* initialize all device */ + rt_device_init_all(); #endif - /* init application */ + /* initialize application */ rt_application_init(); -#ifdef RT_USING_FINSH - /* init finsh */ - finsh_system_init(); -#ifdef RT_USING_DEVICE - finsh_set_device(FINSH_DEVICE_NAME); -#endif -#endif + /* initialize timer thread */ + rt_system_timer_thread_init(); - /* init timer thread */ - rt_system_timer_thread_init(); - - /* init idle thread */ + /* initialize idle thread */ rt_thread_idle_init(); /* start scheduler */ diff --git a/bsp/mb9bf506r/drivers/board.h b/bsp/mb9bf506r/drivers/board.h index b96f8a167a..960dac022b 100644 --- a/bsp/mb9bf506r/drivers/board.h +++ b/bsp/mb9bf506r/drivers/board.h @@ -16,8 +16,6 @@ #ifndef __BOARD_H__ #define __BOARD_H__ -#include "serial.h" - //Internal SRAM memory size[Kbytes] <8-64> //MB9BF500 : 32 //MB9BF504 : 32 diff --git a/bsp/mb9bf506r/project.ewp b/bsp/mb9bf506r/project.ewp index b708add684..68bc640b8d 100644 --- a/bsp/mb9bf506r/project.ewp +++ b/bsp/mb9bf506r/project.ewp @@ -294,16 +294,15 @@ @@ -1212,16 +1211,15 @@ @@ -1856,6 +1854,12 @@ $PROJ_DIR$\libraries\Device\FUJISTU\MB9BF50x\Source\system_mb9bf50x.c + + Components + + $PROJ_DIR$\..\..\components\init\components_init.c + + CORTEX-M3 @@ -1892,27 +1896,6 @@ $PROJ_DIR$\drivers\serial.c - - Filesystem - - $PROJ_DIR$\..\..\components\dfs\src\dfs.c - - - $PROJ_DIR$\..\..\components\dfs\filesystems\elmfat\dfs_elm.c - - - $PROJ_DIR$\..\..\components\dfs\src\dfs_file.c - - - $PROJ_DIR$\..\..\components\dfs\src\dfs_fs.c - - - $PROJ_DIR$\..\..\components\dfs\src\dfs_posix.c - - - $PROJ_DIR$\..\..\components\dfs\filesystems\elmfat\ff.c - - finsh diff --git a/bsp/mb9bf506r/project.uvopt b/bsp/mb9bf506r/project.uvopt index d1898ed6c2..0731e588cd 100644 --- a/bsp/mb9bf506r/project.uvopt +++ b/bsp/mb9bf506r/project.uvopt @@ -185,8 +185,8 @@ 0 48 0 - 43 - 43 + 3 + 12 0 applications\application.c application.c @@ -199,8 +199,8 @@ 0 0 0 - 78 - 109 + 66 + 89 0 applications\startup.c startup.c @@ -311,7 +311,7 @@ 0 0 0 - 138 + 139 149 0 libraries\Device\FUJISTU\MB9BF50x\Source\ARM\startup_mb9bf50x.S @@ -360,8 +360,8 @@ 0 0 0 - 140 - 159 + 141 + 148 0 ..\..\src\idle.c idle.c @@ -586,7 +586,7 @@ - Filesystem + finsh 0 0 0 @@ -601,8 +601,8 @@ 0 0 0 - ..\..\components\dfs\src\dfs.c - dfs.c + ..\..\components\finsh\cmd.c + cmd.c 6 @@ -615,8 +615,8 @@ 0 0 0 - ..\..\components\dfs\src\dfs_fs.c - dfs_fs.c + ..\..\components\finsh\finsh_compiler.c + finsh_compiler.c 6 @@ -629,8 +629,8 @@ 0 0 0 - ..\..\components\dfs\src\dfs_file.c - dfs_file.c + ..\..\components\finsh\finsh_error.c + finsh_error.c 6 @@ -643,8 +643,8 @@ 0 0 0 - ..\..\components\dfs\src\dfs_posix.c - dfs_posix.c + ..\..\components\finsh\finsh_heap.c + finsh_heap.c 6 @@ -657,8 +657,8 @@ 0 0 0 - ..\..\components\dfs\filesystems\elmfat\dfs_elm.c - dfs_elm.c + ..\..\components\finsh\finsh_init.c + finsh_init.c 6 @@ -671,103 +671,12 @@ 0 0 0 - ..\..\components\dfs\filesystems\elmfat\ff.c - ff.c - - - - - finsh - 0 - 0 - 0 - - 7 - 34 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - ..\..\components\finsh\cmd.c - cmd.c - - - 7 - 35 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - ..\..\components\finsh\finsh_compiler.c - finsh_compiler.c - - - 7 - 36 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - ..\..\components\finsh\finsh_error.c - finsh_error.c - - - 7 - 37 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - ..\..\components\finsh\finsh_heap.c - finsh_heap.c - - - 7 - 38 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - ..\..\components\finsh\finsh_init.c - finsh_init.c - - - 7 - 39 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 ..\..\components\finsh\finsh_node.c finsh_node.c - 7 - 40 + 6 + 34 1 0 0 @@ -780,8 +689,8 @@ finsh_ops.c - 7 - 41 + 6 + 35 1 0 0 @@ -794,8 +703,8 @@ finsh_parser.c - 7 - 42 + 6 + 36 1 0 0 @@ -808,8 +717,8 @@ finsh_token.c - 7 - 43 + 6 + 37 1 0 0 @@ -822,8 +731,8 @@ finsh_var.c - 7 - 44 + 6 + 38 1 0 0 @@ -836,8 +745,8 @@ finsh_vm.c - 7 - 45 + 6 + 39 1 0 0 @@ -850,8 +759,8 @@ shell.c - 7 - 46 + 6 + 40 1 0 0 @@ -865,4 +774,25 @@ + + Components + 0 + 0 + 0 + + 7 + 41 + 1 + 0 + 0 + 15 + 0 + 3 + 20 + 0 + ..\..\components\init\components_init.c + components_init.c + + + diff --git a/bsp/mb9bf506r/project.uvproj b/bsp/mb9bf506r/project.uvproj index b10a09c0e7..f7d84105e7 100644 --- a/bsp/mb9bf506r/project.uvproj +++ b/bsp/mb9bf506r/project.uvproj @@ -348,7 +348,7 @@ - .;..\..\components\dfs;..\..\components\dfs\include;..\..\components\finsh;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m3;applications;drivers;libraries\CMSIS\Include;libraries\CMSIS\RTOS;libraries\Device\FUJISTU\MB9BF50x\Include + .;..\..\components\finsh;..\..\components\init;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m3;applications;drivers;libraries\CMSIS\Include;libraries\CMSIS\RTOS;libraries\Device\FUJISTU\MB9BF50x\Include @@ -545,41 +545,6 @@ - - Filesystem - - - dfs.c - 1 - ..\..\components\dfs\src\dfs.c - - - dfs_fs.c - 1 - ..\..\components\dfs\src\dfs_fs.c - - - dfs_file.c - 1 - ..\..\components\dfs\src\dfs_file.c - - - dfs_posix.c - 1 - ..\..\components\dfs\src\dfs_posix.c - - - dfs_elm.c - 1 - ..\..\components\dfs\filesystems\elmfat\dfs_elm.c - - - ff.c - 1 - ..\..\components\dfs\filesystems\elmfat\ff.c - - - finsh @@ -650,6 +615,16 @@ + + Components + + + components_init.c + 1 + ..\..\components\init\components_init.c + + + diff --git a/bsp/mb9bf506r/rtconfig.h b/bsp/mb9bf506r/rtconfig.h index 9d2ba8c167..7b3db4e0aa 100644 --- a/bsp/mb9bf506r/rtconfig.h +++ b/bsp/mb9bf506r/rtconfig.h @@ -2,92 +2,128 @@ #ifndef __RTTHREAD_CFG_H__ #define __RTTHREAD_CFG_H__ -/* RT_NAME_MAX */ -#define RT_NAME_MAX 8 +// -/* RT_ALIGN_SIZE */ -#define RT_ALIGN_SIZE 8 - -/* PRIORITY_MAX */ +// +#define RT_NAME_MAX 8 +// +#define RT_ALIGN_SIZE 8 +// +// 8 +// 32 +// 256 +// #define RT_THREAD_PRIORITY_MAX 32 - -/* Tick per Second */ -#define RT_TICK_PER_SECOND 100 - -/* SECTION: RT_DEBUG */ -/* Thread Debug */ -#define RT_DEBUG +// +#define RT_TICK_PER_SECOND 100 +//
+// #define RT_DEBUG +// +// #define RT_THREAD_DEBUG +// #define RT_USING_OVERFLOW_CHECK +//
-/* Using Hook */ +// #define RT_USING_HOOK +//
+// #define RT_USING_TIMER_SOFT +// +#define RT_TIMER_THREAD_PRIO 8 +// +#define RT_TIMER_THREAD_STACK_SIZE 512 +// +#define RT_TIMER_TICK_PER_SECOND 10 +//
-/* SECTION: IPC */ -/* Using Semaphore */ +//
+// #define RT_USING_SEMAPHORE - -/* Using Mutex */ +// #define RT_USING_MUTEX - -/* Using Event */ +// #define RT_USING_EVENT - -/* Using MailBox */ +// #define RT_USING_MAILBOX - -/* Using Message Queue */ +// #define RT_USING_MESSAGEQUEUE +//
-/* SECTION: Memory Management */ -/* Using Memory Pool Management*/ +//
+// #define RT_USING_MEMPOOL - -/* Using Dynamic Heap Management */ +// #define RT_USING_HEAP - -/* Using Small MM */ +// #define RT_USING_SMALL_MEM +// +// #define RT_USING_SLAB +//
-/* SECTION: Device System */ -/* Using Device System */ +//
#define RT_USING_DEVICE -/* RT_USING_UART */ +// #define RT_USING_UART0 +// #define RT_UART_RX_BUFFER_SIZE 64 +//
-/* SECTION: Console options */ -/* #define RT_TINY_SIZE */ +//
#define RT_USING_CONSOLE -/* the buffer size of console */ -#define RT_CONSOLEBUF_SIZE 128 -/* the device used by console */ +// +#define RT_CONSOLEBUF_SIZE 128 +// #define RT_CONSOLE_DEVICE_NAME "uart0" +//
-/* SECTION: finsh, a C-Express shell */ -/* Using FinSH as Shell*/ +// +#define RT_USING_COMPONENTS_INIT +//
#define RT_USING_FINSH -/* Using symbol table */ +// #define FINSH_USING_SYMTAB +// #define FINSH_USING_DESCRIPTION -#define FINSH_THREAD_STACK_SIZE 1024 -#define FINSH_DEVICE_NAME RT_CONSOLE_DEVICE_NAME +// +#define FINSH_THREAD_STACK_SIZE 4096 +//
-/* SECTION: Device filesystem support */ -/* using DFS support */ -#define RT_USING_DFS +//
+// +// #define RT_USING_NEWLIB +// +// #define RT_USING_PTHREADS +//
+ +//
+// #define RT_USING_DFS +// +// #define DFS_USING_WORKDIR +// +#define DFS_FILESYSTEMS_MAX 2 +// +#define DFS_FD_MAX 4 +// #define RT_USING_DFS_ELMFAT -/* use long file name feature */ -/* #define RT_DFS_ELM_USE_LFN */ -/* the max number of file length */ -#define RT_DFS_ELM_MAX_LFN 32 -/* #define RT_USING_DFS_UFFS */ -/* #define RT_USING_DFS_DEVFS */ +// +// 1 +// 2 +// +#define RT_DFS_ELM_USE_LFN 1 +// +#define RT_DFS_ELM_MAX_LFN 64 +// +// #define RT_USING_DFS_YAFFS2 +// +// #define RT_USING_DFS_UFFS +// +// #define RT_USING_DFS_DEVFS +// +// #define RT_USING_DFS_NFS +// +#define RT_NFS_HOST_EXPORT "192.168.1.5:/" +//
-/* the max number of mounted filesystem */ -#define DFS_FILESYSTEMS_MAX 2 -/* the max number of opened files */ -#define DFS_FD_MAX 8 -/* using working directory */ -#define DFS_USING_WORKDIR +//
#endif