summaryrefslogtreecommitdiff
path: root/bsp/lpc54608-LPCXpresso/applications/application.c
blob: c282a290e98b50dc11026ce52837ccb9cca16dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * File      : application.c
 * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
 *
 *  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.
 *
 * Change Logs:
 * Date           Author       Notes
 * 2017-08-08     Yang        the first version
 */

#include <rtthread.h>
#ifdef RT_USING_FINSH
#include <shell.h>
#include <finsh.h>
#endif

/* thread phase init */
void rt_init_thread_entry(void *parameter)
{
    /* Initialization RT-Thread Components */
#ifdef RT_USING_COMPONENTS_INIT
    rt_components_init();
#elif defined(RT_USING_FINSH)
    finsh_system_init();
#endif
}

void build_dump(void)
{
#if    defined(__CC_ARM)
    rt_kprintf("using MDK\n");
#elif  defined(__IAR_SYSTEMS_ICC__)
    rt_kprintf("using IAR\n");
#elif  defined(__GNUC__)
    rt_kprintf("using GCC\n");
#else
    rt_kprintf("unkown Compiler\n");
#endif
}

void link_dump(void)
{
#ifdef __GNUC__
    extern unsigned int _sdata;
    extern unsigned int _edata;
    extern unsigned int _sidata;

    extern unsigned int _sbss;
    extern unsigned int _ebss;
    
    #define DUMP_VAR(__VAR) \
        rt_kprintf("%-20s %p\n", #__VAR, &__VAR)
    
    DUMP_VAR(_sdata);
    DUMP_VAR(_edata);
    DUMP_VAR(_sidata);
    DUMP_VAR(_sbss);
    DUMP_VAR(_ebss);
#endif
}

int rt_application_init(void)
{
    rt_thread_t tid;
    
    build_dump();
    link_dump();
    
    tid = rt_thread_create("init",
                           rt_init_thread_entry, RT_NULL,
                           2048, RT_THREAD_PRIORITY_MAX / 3, 20);
    if (tid != RT_NULL) rt_thread_startup(tid);

    return 0;
}