2010-04-14 08:31:17 +08:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* 2010-04-09 fify for M16C
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
|
|
|
#include "iom16c62p.h"
|
|
|
|
#include "board.h"
|
|
|
|
#include "bsp.h"
|
|
|
|
|
2011-09-01 16:05:21 +08:00
|
|
|
extern void rt_hw_interrupt_init(void);
|
2010-04-14 08:31:17 +08:00
|
|
|
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 RT_USING_HEAP
|
2012-04-14 15:04:27 +08:00
|
|
|
#if (defined (__ICCM16C__))
|
2010-04-14 08:31:17 +08:00
|
|
|
#pragma section="DATA16_HEAP"
|
2012-04-14 15:04:27 +08:00
|
|
|
#elif (defined (__GNUC__))
|
|
|
|
extern unsigned char user_ram_end;
|
2010-04-14 08:31:17 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will startup RT-Thread RTOS.
|
|
|
|
*/
|
|
|
|
void rtthread_startup(void)
|
|
|
|
{
|
2011-09-01 16:05:21 +08:00
|
|
|
/* init hardware interrupt */
|
|
|
|
rt_hw_interrupt_init();
|
|
|
|
|
2010-04-14 08:31:17 +08:00
|
|
|
/* 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
|
|
|
|
#ifdef __ICCM16C__
|
2011-09-01 16:05:21 +08:00
|
|
|
rt_system_heap_init(__segment_begin("DATA16_HEAP"), __segment_end("DATA16_HEAP"));
|
2012-04-14 15:04:27 +08:00
|
|
|
#elif (defined (__GNUC__))
|
|
|
|
rt_system_heap_init((void*)&user_ram_end, (void*)M16C62P_SRAM_END);
|
2010-04-14 08:31:17 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* init scheduler system */
|
|
|
|
rt_system_scheduler_init();
|
|
|
|
|
|
|
|
#ifdef RT_USING_DEVICE
|
|
|
|
/* init all device */
|
|
|
|
rt_device_init_all();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* init application */
|
|
|
|
rt_application_init();
|
|
|
|
|
|
|
|
#ifdef RT_USING_FINSH
|
|
|
|
/* init finsh */
|
|
|
|
finsh_system_init();
|
|
|
|
finsh_set_device("uart0");
|
|
|
|
#endif
|
|
|
|
|
2011-09-01 16:05:21 +08:00
|
|
|
/* init timer thread */
|
|
|
|
rt_system_timer_thread_init();
|
2012-04-14 19:29:42 +08:00
|
|
|
|
2010-04-14 08:31:17 +08:00
|
|
|
/* 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 */
|
2011-09-01 16:05:21 +08:00
|
|
|
system_init();
|
2010-04-14 08:31:17 +08:00
|
|
|
|
|
|
|
/* startup RT-Thread RTOS */
|
|
|
|
rtthread_startup();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|