git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2084 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
ea8e676f51
commit
6e369b0233
|
@ -0,0 +1,11 @@
|
||||||
|
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)
|
||||||
|
|
||||||
|
Return('group')
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* File : application.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, 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 the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup STM32
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
#include <board.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#ifdef RT_USING_DFS
|
||||||
|
/* dfs init */
|
||||||
|
#include <dfs_init.h>
|
||||||
|
/* dfs filesystem:ELM filesystem init */
|
||||||
|
#include <dfs_elm.h>
|
||||||
|
/* dfs Filesystem APIs */
|
||||||
|
#include <dfs_fs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_LWIP
|
||||||
|
#include <lwip/sys.h>
|
||||||
|
#include <lwip/api.h>
|
||||||
|
#include <netif/ethernetif.h>
|
||||||
|
#include "stm32f2x7_eth.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void rt_init_thread_entry(void* parameter)
|
||||||
|
{
|
||||||
|
/* 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 sd card fat partition 1 as root directory */
|
||||||
|
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
||||||
|
{
|
||||||
|
rt_kprintf("File System initialized!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rt_kprintf("File System initialzation failed!\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* LwIP Initialization */
|
||||||
|
#ifdef RT_USING_LWIP
|
||||||
|
{
|
||||||
|
extern void lwip_sys_init(void);
|
||||||
|
|
||||||
|
/* register ethernetif device */
|
||||||
|
eth_system_device_init();
|
||||||
|
|
||||||
|
/* initialize eth interface */
|
||||||
|
rt_hw_stm32_eth_init();
|
||||||
|
|
||||||
|
/* re-init device driver */
|
||||||
|
rt_device_init_all();
|
||||||
|
|
||||||
|
/* init lwip system */
|
||||||
|
lwip_sys_init();
|
||||||
|
rt_kprintf("TCP/IP initialized!\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int rt_application_init()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@}*/
|
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
* File : startup.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://openlab.rt-thread.com/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2006-08-31 Bernard first implementation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include <stm32f2xx.h>
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup STM32
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
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
|
||||||
|
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||||
|
#elif __ICCARM__
|
||||||
|
#pragma section="HEAP"
|
||||||
|
#else
|
||||||
|
extern int __bss_end;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : assert_failed
|
||||||
|
* Description : Reports the name of the source file and the source line number
|
||||||
|
* where the assert error has occurred.
|
||||||
|
* Input : - file: pointer to the source file name
|
||||||
|
* - line: assert error line source number
|
||||||
|
* Output : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void assert_failed(u8* file, u32 line)
|
||||||
|
{
|
||||||
|
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||||
|
rt_kprintf(" file %s\r\n", file);
|
||||||
|
rt_kprintf(" line %d\r\n", line);
|
||||||
|
|
||||||
|
while (1) ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will startup RT-Thread RTOS.
|
||||||
|
*/
|
||||||
|
void rtthread_startup(void)
|
||||||
|
{
|
||||||
|
/* init board */
|
||||||
|
rt_hw_board_init();
|
||||||
|
|
||||||
|
/* show version */
|
||||||
|
rt_show_version();
|
||||||
|
|
||||||
|
/* init tick */
|
||||||
|
rt_system_tick_init();
|
||||||
|
|
||||||
|
/* init kernel object */
|
||||||
|
rt_system_object_init();
|
||||||
|
|
||||||
|
/* init timer system */
|
||||||
|
rt_system_timer_init();
|
||||||
|
|
||||||
|
#ifdef RT_USING_HEAP
|
||||||
|
#if STM32_EXT_SRAM
|
||||||
|
rt_system_heap_init((void*)STM32_EXT_SRAM_BEGIN, (void*)STM32_EXT_SRAM_END);
|
||||||
|
#else
|
||||||
|
#ifdef __CC_ARM
|
||||||
|
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)STM32_SRAM_END);
|
||||||
|
#elif __ICCARM__
|
||||||
|
rt_system_heap_init(__segment_end("HEAP"), (void*)STM32_SRAM_END);
|
||||||
|
#else
|
||||||
|
/* init memory system */
|
||||||
|
rt_system_heap_init((void*)&__bss_end, (void*)STM32_SRAM_END);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* init scheduler system */
|
||||||
|
rt_system_scheduler_init();
|
||||||
|
|
||||||
|
#ifdef RT_USING_DFS
|
||||||
|
/* init sdcard driver */
|
||||||
|
#if STM32_USE_SDIO
|
||||||
|
rt_hw_sdcard_init();
|
||||||
|
#else
|
||||||
|
rt_hw_msd_init();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rt_hw_rtc_init();
|
||||||
|
|
||||||
|
/* init all device */
|
||||||
|
rt_device_init_all();
|
||||||
|
|
||||||
|
/* init application */
|
||||||
|
rt_application_init();
|
||||||
|
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
/* init finsh */
|
||||||
|
finsh_system_init();
|
||||||
|
finsh_set_device("uart1");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* init timer thread */
|
||||||
|
rt_system_timer_thread_init();
|
||||||
|
|
||||||
|
/* init 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();
|
||||||
|
|
||||||
|
/* init system setting */
|
||||||
|
SystemInit();
|
||||||
|
|
||||||
|
/* startup RT-Thread RTOS */
|
||||||
|
rtthread_startup();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@}*/
|
Loading…
Reference in New Issue