application.c 2.0 KB
Newer Older
M
Ming, Bai 已提交
1
/*
mysterywolf's avatar
mysterywolf 已提交
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
 * 2009-01-05     Bernard      the first version
 */

/**
 * @addtogroup STM32
 */
/*@{*/

#include <board.h>
#include <rtthread.h>

19 20 21 22 23
#ifdef RT_USING_FINSH
#include <shell.h>
#include <finsh.h>
#endif

M
Ming, Bai 已提交
24 25
#ifdef RT_USING_DFS
/* dfs init */
S
SummerGift 已提交
26
#include <dfs.h>
M
Ming, Bai 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39
/* dfs filesystem:ELM filesystem init */
#include <dfs_elm.h>
/* dfs Filesystem APIs */
#include <dfs_fs.h>
#endif

#ifdef RT_USING_LWIP
#include <lwip/sys.h>
#include <lwip/api.h>
#include <netif/ethernetif.h>
#include "stm32f2x7_eth.h"
#endif

40
void rt_init_thread_entry(void *parameter)
M
Ming, Bai 已提交
41
{
42
    /* Filesystem Initialization */
M
Ming, Bai 已提交
43
#ifdef RT_USING_DFS
44 45
    {
        /* init sdcard driver */
46
#if STM32_USE_SDIO
47
        rt_hw_sdcard_init();
48
#else
49
        rt_hw_msd_init();
50 51
#endif

52 53
        /* init the device filesystem */
        dfs_init();
M
Ming, Bai 已提交
54 55

#ifdef RT_USING_DFS_ELMFAT
56 57 58 59 60 61 62 63 64 65
        /* init the elm chan FatFs filesystam*/
        elm_init();

        /* mount sd card fat partition 1 as root directory */
        if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
        {
            rt_kprintf("File System initialized!\n");
        }
        else
            rt_kprintf("File System initialzation failed!\n");
M
Ming, Bai 已提交
66
#endif
67
    }
M
Ming, Bai 已提交
68 69
#endif

70
    /* LwIP Initialization */
M
Ming, Bai 已提交
71
#ifdef RT_USING_LWIP
72 73
    {
        extern void lwip_sys_init(void);
M
Ming, Bai 已提交
74

75 76
        /* register ethernetif device */
        eth_system_device_init();
77

78 79
        /* initialize eth interface */
        rt_hw_stm32_eth_init();
M
Ming, Bai 已提交
80

81 82 83 84
        /* init lwip system */
        lwip_sys_init();
        rt_kprintf("TCP/IP initialized!\n");
    }
M
Ming, Bai 已提交
85
#endif
86

87
    rt_hw_rtc_init();
88 89

#ifdef RT_USING_FINSH
90 91
    /* init finsh */
    finsh_system_init();
92
#endif
M
Ming, Bai 已提交
93 94 95 96
}

int rt_application_init()
{
97
    rt_thread_t tid;
M
Ming, Bai 已提交
98

99 100 101
    tid = rt_thread_create("init",
                           rt_init_thread_entry, RT_NULL,
                           2048, RT_THREAD_PRIORITY_MAX / 3, 20);
M
Ming, Bai 已提交
102

103 104
    if (tid != RT_NULL)
        rt_thread_startup(tid);
M
Ming, Bai 已提交
105

106
    return 0;
M
Ming, Bai 已提交
107 108 109
}

/*@}*/