startup.c 1.5 KB
Newer Older
1 2 3
/*
 * File      : startup.c
 * This file is part of RT-Thread RTOS
N
nongxiaoming 已提交
4
 * COPYRIGHT (C) 2009, RT-Thread Development Team
5 6 7 8 9 10 11 12
 *
 * 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
N
nongxiaoming 已提交
13
 * 2014-07-13     xiaonong      for LPC43xx
14 15 16 17 18
 */

#include <rthw.h>
#include <rtthread.h>

N
nongxiaoming 已提交
19
#include "board.h"
20

N
nongxiaoming 已提交
21
extern int rt_application_init(void);
22 23 24 25 26 27

/**
 * This function will startup RT-Thread RTOS.
 */
void rtthread_startup(void)
{
N
nongxiaoming 已提交
28
    /* initialize board */
29 30 31 32 33 34
    rt_hw_board_init();

    /* show version */
    rt_show_version();

#ifdef RT_USING_HEAP
N
nongxiaoming 已提交
35 36 37 38 39 40
#if LPC_EXT_SDRAM
    rt_system_heap_init((void *)LPC_EXT_SDRAM_BEGIN, (void *)LPC_EXT_SDRAM_END);
    sram_init();
#else
    rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
#endif
41 42
#endif

N
nongxiaoming 已提交
43
    /* initialize scheduler system */
44 45
    rt_system_scheduler_init();

N
nongxiaoming 已提交
46 47
    /* initialize system timer*/
    rt_system_timer_init();
48

N
nongxiaoming 已提交
49
    /* initialize application */
50 51
    rt_application_init();

N
nongxiaoming 已提交
52
    /* initialize timer thread */
53 54
    rt_system_timer_thread_init();

N
nongxiaoming 已提交
55
    /* initialize idle thread */
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
    rt_thread_idle_init();

    /* start scheduler */
    rt_system_scheduler_start();

    /* never reach here */
    return ;
}

int main(void)
{
    /* disable interrupt first */
    rt_hw_interrupt_disable();

    /* startup RT-Thread RTOS */
    rtthread_startup();

    return 0;
}