update: bsp/stm32f107 add RT_USING_COMPONENTS_INIT.
This commit is contained in:
parent
7bec8a242b
commit
5c17c2e698
|
@ -28,10 +28,5 @@ Export('RTT_ROOT')
|
|||
Export('rtconfig')
|
||||
|
||||
# prepare building environment
|
||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
|
||||
|
||||
# build program
|
||||
env.Program(TARGET, objs)
|
||||
|
||||
# end building
|
||||
EndBuilding(TARGET)
|
||||
objs = PrepareBuilding(env, RTT_ROOT)
|
||||
DoBuilding(TARGET, objs)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* File : application.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
@ -21,67 +21,42 @@
|
|||
#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 "stm32_eth.h"
|
||||
#endif
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
#include <components.h>
|
||||
#endif /* RT_USING_COMPONENTS_INIT */
|
||||
|
||||
void rt_init_thread_entry(void* parameter)
|
||||
{
|
||||
/* Filesystem Initialization */
|
||||
#ifdef RT_USING_DFS
|
||||
{
|
||||
/* init the device filesystem */
|
||||
dfs_init();
|
||||
{
|
||||
extern void rt_platform_init(void);
|
||||
rt_platform_init();
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DFS_ELMFAT
|
||||
/* init the elm chan FatFs filesystam*/
|
||||
elm_init();
|
||||
|
||||
/* init sdcard driver */
|
||||
rt_hw_msd_init();
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
/* initialization RT-Thread Components */
|
||||
rt_components_init();
|
||||
#endif
|
||||
|
||||
/* Filesystem Initialization */
|
||||
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
|
||||
{
|
||||
/* 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();
|
||||
|
||||
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
|
||||
#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
|
||||
}
|
||||
|
||||
int rt_application_init()
|
||||
int rt_application_init(void)
|
||||
{
|
||||
rt_thread_t init_thread;
|
||||
|
||||
|
@ -96,7 +71,9 @@ int rt_application_init()
|
|||
#endif
|
||||
|
||||
if (init_thread != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(init_thread);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* File : startup.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||
* COPYRIGHT (C) 2006 - 2013, RT-Thread Develop Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
@ -15,8 +15,6 @@
|
|||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "board.h"
|
||||
|
||||
/**
|
||||
|
@ -26,17 +24,16 @@
|
|||
/*@{*/
|
||||
|
||||
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;
|
||||
#define STM32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
|
||||
#elif __ICCARM__
|
||||
#pragma section="HEAP"
|
||||
#define STM32_SRAM_BEGIN (__segment_end("HEAP"))
|
||||
#else
|
||||
extern int __bss_end;
|
||||
#define STM32_SRAM_BEGIN (&__bss_end)
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -50,11 +47,11 @@ extern int __bss_end;
|
|||
*******************************************************************************/
|
||||
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);
|
||||
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) ;
|
||||
while (1) ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,69 +59,56 @@ void assert_failed(u8* file, u32 line)
|
|||
*/
|
||||
void rtthread_startup(void)
|
||||
{
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
/* init tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
/* init kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_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*)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
|
||||
rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END);
|
||||
#endif
|
||||
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
/* init all device */
|
||||
rt_device_init_all();
|
||||
/* 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 application */
|
||||
rt_application_init();
|
||||
|
||||
/* init timer thread */
|
||||
rt_system_timer_thread_init();
|
||||
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* File : board.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2009 RT-Thread Develop Team
|
||||
* COPYRIGHT (C) 2006 - 2013 RT-Thread Develop Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
@ -33,62 +33,42 @@
|
|||
void NVIC_Configuration(void)
|
||||
{
|
||||
#ifdef VECT_TAB_RAM
|
||||
/* Set the Vector Table base location at 0x20000000 */
|
||||
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
|
||||
/* Set the Vector Table base location at 0x20000000 */
|
||||
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
|
||||
#else /* VECT_TAB_FLASH */
|
||||
/* Set the Vector Table base location at 0x08000000 */
|
||||
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
|
||||
/* Set the Vector Table base location at 0x08000000 */
|
||||
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : SysTick_Configuration
|
||||
* Description : Configures the SysTick for OS tick.
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void SysTick_Configuration(void)
|
||||
{
|
||||
RCC_ClocksTypeDef rcc_clocks;
|
||||
rt_uint32_t cnts;
|
||||
|
||||
RCC_GetClocksFreq(&rcc_clocks);
|
||||
|
||||
cnts = (rt_uint32_t)rcc_clocks.HCLK_Frequency / RT_TICK_PER_SECOND;
|
||||
|
||||
SysTick_Config(cnts);
|
||||
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the timer interrupt service routine.
|
||||
*
|
||||
*/
|
||||
void rt_hw_timer_handler(void)
|
||||
{
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
rt_tick_increase();
|
||||
rt_tick_increase();
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will initial STM32 board.
|
||||
*/
|
||||
void rt_hw_board_init()
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
/* NVIC Configuration */
|
||||
NVIC_Configuration();
|
||||
/* NVIC Configuration */
|
||||
NVIC_Configuration();
|
||||
|
||||
/* Configure the SysTick */
|
||||
SysTick_Configuration();
|
||||
/* Configure the SysTick */
|
||||
SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND );
|
||||
|
||||
rt_hw_usart_init();
|
||||
rt_console_set_device(CONSOLE_DEVICE);
|
||||
rt_hw_usart_init();
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* File : board.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2009, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
@ -40,27 +40,9 @@
|
|||
#define STM32_SRAM_SIZE 64
|
||||
#define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024)
|
||||
|
||||
// <o> Console on USART: <0=> no console <1=>USART 1 <2=>USART 2 <3=> USART 3
|
||||
// <i>Default: 1
|
||||
#define STM32_CONSOLE_USART 1
|
||||
|
||||
void rt_hw_board_init(void);
|
||||
|
||||
#if STM32_CONSOLE_USART == 0
|
||||
#define CONSOLE_DEVICE "no"
|
||||
#elif STM32_CONSOLE_USART == 1
|
||||
#define CONSOLE_DEVICE "uart1"
|
||||
#elif STM32_CONSOLE_USART == 2
|
||||
#define CONSOLE_DEVICE "uart2"
|
||||
#elif STM32_CONSOLE_USART == 3
|
||||
#define CONSOLE_DEVICE "uart3"
|
||||
#endif
|
||||
|
||||
void rt_hw_usart_init(void);
|
||||
|
||||
/* SD Card init function */
|
||||
void rt_hw_msd_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
#include "stm32_eth.h"
|
||||
#endif /* RT_USING_LWIP */
|
||||
|
||||
void rt_platform_init(void)
|
||||
{
|
||||
#ifdef RT_USING_LWIP
|
||||
/* initialize eth interface */
|
||||
rt_hw_stm32_eth_init();
|
||||
#endif /* RT_USING_LWIP */
|
||||
|
||||
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
|
||||
/* init sdcard driver */
|
||||
{
|
||||
extern void rt_hw_msd_init(void);
|
||||
rt_hw_msd_init();
|
||||
}
|
||||
#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
|
||||
}
|
|
@ -343,7 +343,7 @@
|
|||
<MiscControls />
|
||||
<Define>STM32F10X_CL, USE_STDPERIPH_DRIVER</Define>
|
||||
<Undefine />
|
||||
<IncludePath>.;..\..\components\CMSIS\Include;..\..\components\dfs;..\..\components\dfs\include;..\..\components\finsh;..\..\components\net\lwip\src;..\..\components\net\lwip\src\arch\include;..\..\components\net\lwip\src\include;..\..\components\net\lwip\src\include\ipv4;..\..\components\net\lwip\src\include\netif;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m3;Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;Libraries\STM32F10x_StdPeriph_Driver\inc;applications;drivers</IncludePath>
|
||||
<IncludePath>.;..\..\components\CMSIS\Include;..\..\components\dfs;..\..\components\dfs\include;..\..\components\finsh;..\..\components\init;..\..\components\net\lwip\src;..\..\components\net\lwip\src\arch\include;..\..\components\net\lwip\src\include;..\..\components\net\lwip\src\include\ipv4;..\..\components\net\lwip\src\include\netif;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m3;Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;Libraries\STM32F10x_StdPeriph_Driver\inc;applications;drivers</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
@ -413,6 +413,13 @@
|
|||
<FilePath>drivers\msd.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>platform.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>drivers\platform.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>serial.c</FileName>
|
||||
|
@ -884,6 +891,16 @@
|
|||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Components</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>components.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\components\init\components.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>LwIP</GroupName>
|
||||
<Files>
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
/* #define RT_USING_TIMER_SOFT */
|
||||
#define RT_TIMER_THREAD_PRIO 4
|
||||
#define RT_TIMER_THREAD_STACK_SIZE 512
|
||||
#define RT_TIMER_TICK_PER_SECOND 10
|
||||
|
||||
/* SECTION: IPC */
|
||||
/* Using Semaphore*/
|
||||
|
@ -66,6 +65,14 @@
|
|||
/* the buffer size of console*/
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
|
||||
// <string name="RT_CONSOLE_DEVICE_NAME" description="console device name" default="uart3" />
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart1"
|
||||
// </section>
|
||||
|
||||
// <section name="RT_USING_COMPONENTS_INIT" description="Using components init" default="true" >
|
||||
#define RT_USING_COMPONENTS_INIT
|
||||
// </section>
|
||||
|
||||
/* SECTION: finsh, a C-Express shell */
|
||||
#define RT_USING_FINSH
|
||||
/* Using symbol table */
|
||||
|
|
Loading…
Reference in New Issue