application.c 2.0 KB
Newer Older
M
Ming, Bai 已提交
1 2 3
/*
 * File      : application.c
 * This file is part of RT-Thread RTOS
4
 * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
M
Ming, Bai 已提交
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      the first version
whj123999's avatar
whj123999 已提交
13
 * 2018-08-17     whj          remove finsh_set_device  add components 
M
Ming, Bai 已提交
14 15 16 17 18 19 20 21 22 23 24 25
 */

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

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

#ifdef RT_USING_DFS
#include <dfs_fs.h>
26
#include <dfs_elm.h>
M
Ming, Bai 已提交
27 28
#endif

29 30 31 32 33 34 35 36 37 38
#ifdef RT_USING_LWIP
#include <stm32_eth.h>
#include <netif/ethernetif.h>
extern int lwip_system_init(void);
#endif

#ifdef RT_USING_FINSH
#include <shell.h>
#include <finsh.h>
#endif
M
Ming, Bai 已提交
39 40 41

void rt_init_thread_entry(void* parameter)
{
whj123999's avatar
whj123999 已提交
42 43 44 45 46
#ifdef RT_USING_COMPONENTS_INIT
    /* initialization RT-Thread Components */
	rt_components_init();
#endif	
	
47 48 49 50
    {
        extern void rt_platform_init(void);
        rt_platform_init();
    }
M
Ming, Bai 已提交
51

52 53
    /* Filesystem Initialization */
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
54 55 56 57 58 59 60 61 62 63 64 65
	/* initialize the device file system */
	dfs_init();

	/* initialize the elm chan FatFS file system*/
	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
66
    {
67
        rt_kprintf("File System initialzation failed!\n");
M
Ming, Bai 已提交
68
    }
69
#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
70 71 72 73 74 75 76 77 78 79 80

#ifdef RT_USING_LWIP
	/* initialize lwip stack */
	/* register ethernetif device */
	eth_system_device_init();

	/* initialize lwip system */
	lwip_system_init();
	rt_kprintf("TCP/IP initialized!\n");
#endif

M
Ming, Bai 已提交
81 82
}

83
int rt_application_init(void)
M
Ming, Bai 已提交
84
{
85
    rt_thread_t tid;
M
Ming, Bai 已提交
86

87 88 89 90
    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);
M
Ming, Bai 已提交
91 92 93 94 95

    return 0;
}

/*@}*/