application.c 1.9 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 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * 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
 */

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

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

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

28 29 30 31 32 33 34 35 36 37
#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 已提交
38 39 40

void rt_init_thread_entry(void* parameter)
{
41 42 43 44
    {
        extern void rt_platform_init(void);
        rt_platform_init();
    }
M
Ming, Bai 已提交
45

46 47
    /* Filesystem Initialization */
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
48 49 50 51 52 53 54 55 56 57 58 59
	/* 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
60
    {
61
        rt_kprintf("File System initialzation failed!\n");
M
Ming, Bai 已提交
62
    }
63
#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

#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

#ifdef RT_USING_FINSH
	/* initialize finsh */
	finsh_system_init();
	finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
M
Ming, Bai 已提交
80 81
}

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

86 87 88 89
    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 已提交
90 91 92 93 94

    return 0;
}

/*@}*/