startup.c 1.5 KB
Newer Older
M
Ming, Bai 已提交
1
/*
2
 * Copyright (c) 2006-2021, RT-Thread Development Team
M
Ming, Bai 已提交
3
 *
4
 * SPDX-License-Identifier: Apache-2.0
M
Ming, Bai 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * Change Logs:
 * Date           Author       Notes
 * 2011-05-23     aozima       first implementation for PIC32.
 */

// Adds support for PIC32 Peripheral library functions and macros
#include <plib.h>
#include <rtthread.h>

extern int _ramfunc_end;
#define PIC32_SRAM_END (0xA0000000 + 1024UL*128) //795F512L 512K FLASH 128KB SRAM

#ifdef RT_USING_FINSH
19
extern int finsh_system_init(void);
M
Ming, Bai 已提交
20 21 22 23 24 25 26 27
extern void finsh_set_device(const char* device);
#endif

/**
 * This function will startup RT-Thread RTOS.
 */
void rtthread_startup(void)
{
28 29
    /* init board */
    rt_hw_board_init();
M
Ming, Bai 已提交
30

31 32
    /* show version */
    rt_show_version();
M
Ming, Bai 已提交
33

34 35
    /* init timer system */
    rt_system_timer_init();
M
Ming, Bai 已提交
36 37 38 39 40 41

#ifdef RT_USING_HEAP
    /* init memory system */
    rt_system_heap_init((void*)&_ramfunc_end, (void*)PIC32_SRAM_END);
#endif

42 43
    /* init scheduler system */
    rt_system_scheduler_init();
M
Ming, Bai 已提交
44

45 46
    /* init application */
    rt_application_init();
M
Ming, Bai 已提交
47 48

#ifdef RT_USING_FINSH
49 50
    /* init finsh */
    finsh_system_init();
M
Ming, Bai 已提交
51
#ifdef RT_USING_DEVICE
52
    finsh_set_device("uart1");
M
Ming, Bai 已提交
53 54 55 56 57 58
#endif
#endif

    /* init timer thread */
    rt_system_timer_thread_init();

59 60
    /* init idle thread */
    rt_thread_idle_init();
M
Ming, Bai 已提交
61

62 63
    /* start scheduler */
    rt_system_scheduler_start();
M
Ming, Bai 已提交
64

65 66
    /* never reach here */
    return ;
M
Ming, Bai 已提交
67 68 69 70
}

int main(void)
{
71 72
    /* disable interrupt first */
    rt_hw_interrupt_disable();
M
Ming, Bai 已提交
73

74 75
    /* startup RT-Thread RTOS */
    rtthread_startup();
M
Ming, Bai 已提交
76

77
    return 0;
M
Ming, Bai 已提交
78 79
}