support auto initial.

This commit is contained in:
aozima 2013-07-12 23:08:46 +08:00
parent 8890e83aa9
commit c44b02f08c
4 changed files with 158 additions and 185 deletions

View File

@ -1,4 +1,3 @@
/* /*
* File : application.c * File : application.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
@ -11,6 +10,7 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2009-01-05 Bernard the first version * 2009-01-05 Bernard the first version
* 2013-07-12 aozima update for auto initial.
*/ */
/** /**
@ -21,21 +21,17 @@
#include <board.h> #include <board.h>
#include <rtthread.h> #include <rtthread.h>
#ifdef RT_USING_COMPONENTS_INIT
#include <components.h>
#endif /* RT_USING_COMPONENTS_INIT */
#ifdef RT_USING_DFS #ifdef RT_USING_DFS
/* dfs init */
#include <dfs_init.h>
/* dfs filesystem:ELM filesystem init */ /* dfs filesystem:ELM filesystem init */
#include <dfs_elm.h> #include <dfs_elm.h>
/* dfs Filesystem APIs */ /* dfs Filesystem APIs */
#include <dfs_fs.h> #include <dfs_fs.h>
#endif #endif
#ifdef RT_USING_LWIP
#include <lwip/sys.h>
#include <lwip/api.h>
#include <netif/ethernetif.h>
#endif
#ifdef RT_USING_RTGUI #ifdef RT_USING_RTGUI
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/rtgui_server.h> #include <rtgui/rtgui_server.h>
@ -89,20 +85,21 @@ void cali_store(struct calibration_data *data)
data->min_y, data->min_y,
data->max_y); data->max_y);
} }
#endif #endif /* RT_USING_RTGUI */
void rt_init_thread_entry(void* parameter) void rt_init_thread_entry(void* parameter)
{ {
#ifdef RT_USING_COMPONENTS_INIT
/* initialization RT-Thread Components */
rt_components_init();
#endif
#ifdef RT_USING_FINSH
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif /* RT_USING_FINSH */
/* Filesystem Initialization */ /* Filesystem Initialization */
#ifdef RT_USING_DFS #if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
{
/* init the device filesystem */
dfs_init();
#ifdef RT_USING_DFS_ELMFAT
/* init the elm chan FatFs filesystam*/
elm_init();
/* mount sd card fat partition 1 as root directory */ /* mount sd card fat partition 1 as root directory */
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
{ {
@ -110,37 +107,7 @@ void rt_init_thread_entry(void* parameter)
} }
else else
rt_kprintf("File System initialzation failed!\n"); rt_kprintf("File System initialzation failed!\n");
#endif #endif /* RT_USING_DFS */
}
#endif
/* LwIP Initialization */
#ifdef RT_USING_LWIP
{
extern void lwip_sys_init(void);
/* register ethernetif device */
eth_system_device_init();
#ifdef STM32F10X_CL
rt_hw_stm32_eth_init();
#else
/* STM32F103 */
#if STM32_ETH_IF == 0
rt_hw_enc28j60_init();
#elif STM32_ETH_IF == 1
rt_hw_dm9000_init();
#endif
#endif
/* re-init device driver */
rt_device_init_all();
/* init lwip system */
lwip_sys_init();
rt_kprintf("TCP/IP initialized!\n");
}
#endif
#ifdef RT_USING_RTGUI #ifdef RT_USING_RTGUI
{ {
@ -175,7 +142,7 @@ void rt_init_thread_entry(void* parameter)
#endif /* #ifdef RT_USING_RTGUI */ #endif /* #ifdef RT_USING_RTGUI */
} }
int rt_application_init() int rt_application_init(void)
{ {
rt_thread_t init_thread; rt_thread_t init_thread;
@ -184,8 +151,12 @@ int rt_application_init()
/* init led thread */ /* init led thread */
result = rt_thread_init(&led_thread, result = rt_thread_init(&led_thread,
"led", "led",
led_thread_entry, RT_NULL, led_thread_entry,
(rt_uint8_t*)&led_stack[0], sizeof(led_stack), 20, 5); RT_NULL,
(rt_uint8_t*)&led_stack[0],
sizeof(led_stack),
20,
5);
if (result == RT_EOK) if (result == RT_EOK)
{ {
rt_thread_startup(&led_thread); rt_thread_startup(&led_thread);

View File

@ -24,10 +24,6 @@
/*@{*/ /*@{*/
extern int rt_application_init(void); extern int rt_application_init(void);
#ifdef RT_USING_FINSH
extern void finsh_system_init(void);
extern void finsh_set_device(const char* device);
#endif
#ifdef __CC_ARM #ifdef __CC_ARM
extern int Image$$RW_IRAM1$$ZI$$Limit; extern int Image$$RW_IRAM1$$ZI$$Limit;
@ -96,12 +92,6 @@ void rtthread_startup(void)
/* init application */ /* init application */
rt_application_init(); rt_application_init();
#ifdef RT_USING_FINSH
/* init finsh */
finsh_system_init();
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
/* init idle thread */ /* init idle thread */
rt_thread_idle_init(); rt_thread_idle_init();

View File

@ -10,6 +10,7 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2009-01-05 Bernard first implementation * 2009-01-05 Bernard first implementation
* 2013-07-12 aozima update for auto initial.
*/ */
#include <rthw.h> #include <rthw.h>
@ -19,6 +20,10 @@
#include "stm32f10x_fsmc.h" #include "stm32f10x_fsmc.h"
#include "board.h" #include "board.h"
#ifdef RT_USING_COMPONENTS_INIT
#include <components.h>
#endif /* RT_USING_COMPONENTS_INIT */
/** /**
* @addtogroup STM32 * @addtogroup STM32
*/ */
@ -181,6 +186,10 @@ void rt_hw_board_init(void)
rt_hw_usart_init(); rt_hw_usart_init();
rt_console_set_device(RT_CONSOLE_DEVICE_NAME); rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
} }
/*@}*/ /*@}*/

View File

@ -56,6 +56,9 @@
/* Using Small MM */ /* Using Small MM */
#define RT_USING_SMALL_MEM #define RT_USING_SMALL_MEM
// <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" />
#define RT_USING_COMPONENTS_INIT
/* SECTION: Device System */ /* SECTION: Device System */
/* Using Device System */ /* Using Device System */
#define RT_USING_DEVICE #define RT_USING_DEVICE
@ -78,12 +81,12 @@
/* #define RT_USING_DFS */ /* #define RT_USING_DFS */
#define RT_USING_DFS_ELMFAT #define RT_USING_DFS_ELMFAT
#define RT_DFS_ELM_WORD_ACCESS
/* Reentrancy (thread safe) of the FatFs module. */ /* Reentrancy (thread safe) of the FatFs module. */
#define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_REENTRANT
/* Number of volumes (logical drives) to be used. */ /* Number of volumes (logical drives) to be used. */
#define RT_DFS_ELM_DRIVES 2 #define RT_DFS_ELM_DRIVES 2
/* #define RT_DFS_ELM_USE_LFN 1 */ /* #define RT_DFS_ELM_USE_LFN 1 */
/* #define RT_DFS_ELM_CODE_PAGE 936 */
#define RT_DFS_ELM_MAX_LFN 255 #define RT_DFS_ELM_MAX_LFN 255
/* Maximum sector size to be handled. */ /* Maximum sector size to be handled. */
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512 #define RT_DFS_ELM_MAX_SECTOR_SIZE 512