startup.c 2.5 KB
Newer Older
L
luohui2320@gmail.com 已提交
1 2 3 4 5
/*
 * File      : startup.c
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006, RT-Thread Develop Team
 *
W
weety 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
L
luohui2320@gmail.com 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 *
 * Change Logs:
 * Date           Author       Notes
 * 2011-01-13     weety      first version
 */

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

#include <at91sam926x.h>
#ifdef RT_USING_FINSH
#include <finsh.h>
#endif
extern void rt_application_init(void);

/**
 * @addtogroup at91sam9260
 */

/*@{*/
#if defined(__CC_ARM)
40
extern int Image$$ER_ZI$$ZI$$Limit;
A
ardafu 已提交
41
#define HEAP_BEGIN  (&Image$$ER_ZI$$ZI$$Limit)
L
luohui2320@gmail.com 已提交
42
#elif (defined (__GNUC__))
43
extern unsigned char __bss_end__;
A
ardafu 已提交
44
#define HEAP_BEGIN  (&__bss_end__)
45
#elif (defined (__ICCARM__))
A
ardafu 已提交
46 47
#pragma section=".noinit"
#define HEAP_BEGIN  (__section_end(".noinit"))
L
luohui2320@gmail.com 已提交
48 49
#endif

A
ardafu 已提交
50
#define HEAP_END    (0x24000000)
L
luohui2320@gmail.com 已提交
51 52 53 54

/**
 * This function will startup RT-Thread RTOS.
 */
A
ardafu 已提交
55
static void rtthread_startup(void)
L
luohui2320@gmail.com 已提交
56
{
A
ardafu 已提交
57 58
    /* initialize board */
    rt_hw_board_init();
L
luohui2320@gmail.com 已提交
59

A
ardafu 已提交
60 61
    /* show version */
    rt_show_version();
L
luohui2320@gmail.com 已提交
62

A
ardafu 已提交
63 64
#ifdef RT_USING_HEAP
    rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
L
luohui2320@gmail.com 已提交
65 66
#endif

A
ardafu 已提交
67 68 69 70 71 72
    /* initialize scheduler system */
    rt_system_scheduler_init();
    /* initialize system timer*/
    rt_system_timer_init();
    /* initialize application */
    rt_application_init();
L
luohui2320@gmail.com 已提交
73 74 75 76 77

#ifdef RT_USING_FINSH
	/* initialize finsh */
	finsh_system_init();
#ifdef RT_USING_DEVICE
78
	finsh_set_device(RT_CONSOLE_DEVICE_NAME);
L
luohui2320@gmail.com 已提交
79
#endif
L
luohui2320@gmail.com 已提交
80
#endif
A
ardafu 已提交
81 82 83
	
    /* initialize timer thread */
    rt_system_timer_thread_init();
L
luohui2320@gmail.com 已提交
84

A
ardafu 已提交
85 86
    /* initialize idle thread */
    rt_thread_idle_init();
L
luohui2320@gmail.com 已提交
87

A
ardafu 已提交
88 89
    /* start scheduler */
    rt_system_scheduler_start();
L
luohui2320@gmail.com 已提交
90

A
ardafu 已提交
91 92
    /* never reach here */
    return ;
L
luohui2320@gmail.com 已提交
93 94
}

L
luohui2320@gmail.com 已提交
95 96
int main(void)
{
A
ardafu 已提交
97 98 99 100 101
    /* disable interrupt first */
    rt_hw_interrupt_disable();

    /* startup RT-Thread RTOS */
    rtthread_startup();
L
luohui2320@gmail.com 已提交
102

A
ardafu 已提交
103
    return 0;
L
luohui2320@gmail.com 已提交
104 105
}

L
luohui2320@gmail.com 已提交
106
/*@}*/