2017-08-17 23:31:52 +08:00
|
|
|
/*
|
|
|
|
* File : application.c
|
2012-02-16 23:58:52 +08:00
|
|
|
* This file is part of RT-Thread RTOS
|
2017-08-17 23:31:52 +08:00
|
|
|
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
2012-02-16 23:58:52 +08:00
|
|
|
*
|
2017-08-17 23:31:52 +08:00
|
|
|
* 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.
|
2012-02-16 23:58:52 +08:00
|
|
|
*
|
2017-08-17 23:31:52 +08:00
|
|
|
* 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:
|
2012-02-16 23:58:52 +08:00
|
|
|
* Date Author Notes
|
2017-08-17 23:31:52 +08:00
|
|
|
* 2009-01-05 Bernard the first version
|
2012-02-16 23:58:52 +08:00
|
|
|
*/
|
2012-10-15 08:51:09 +08:00
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
2017-08-17 23:31:52 +08:00
|
|
|
#ifdef RT_USING_DFS
|
|
|
|
#include <dfs_fs.h>
|
2017-10-31 16:20:02 +08:00
|
|
|
#include <dfs.h>
|
2017-08-17 23:31:52 +08:00
|
|
|
#include "floppy.h"
|
2017-08-20 20:24:07 +08:00
|
|
|
#ifdef RT_USING_MODULE
|
|
|
|
#include <rtm.h>
|
|
|
|
#endif
|
|
|
|
extern int elm_init(void);
|
2017-08-17 23:31:52 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* components initialization for simulator */
|
|
|
|
void components_init(void)
|
2012-10-15 08:51:09 +08:00
|
|
|
{
|
2017-08-17 23:31:52 +08:00
|
|
|
#ifdef RT_USING_DFS
|
|
|
|
rt_floppy_init();
|
|
|
|
/* initialize the device file system */
|
|
|
|
dfs_init();
|
2012-10-15 08:51:09 +08:00
|
|
|
|
2017-08-17 23:31:52 +08:00
|
|
|
#ifdef RT_USING_DFS_ELMFAT
|
|
|
|
/* initialize the elm chan FatFS file system*/
|
|
|
|
elm_init();
|
2012-10-15 08:51:09 +08:00
|
|
|
#endif
|
2017-08-20 20:24:07 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_MODULE
|
2018-10-21 20:21:38 +08:00
|
|
|
rt_system_dlmodule_init();
|
2017-08-20 20:24:07 +08:00
|
|
|
#endif
|
2012-10-15 08:51:09 +08:00
|
|
|
#endif
|
|
|
|
}
|
2017-08-17 23:31:52 +08:00
|
|
|
void rt_init_thread_entry(void *parameter)
|
2012-10-15 08:51:09 +08:00
|
|
|
{
|
2017-08-17 23:31:52 +08:00
|
|
|
components_init();
|
2012-10-15 08:51:09 +08:00
|
|
|
|
2017-08-17 23:31:52 +08:00
|
|
|
/* File system Initialization */
|
|
|
|
#ifdef RT_USING_DFS
|
2012-10-15 08:51:09 +08:00
|
|
|
{
|
|
|
|
|
2017-08-17 23:31:52 +08:00
|
|
|
#ifdef RT_USING_DFS_ELMFAT
|
|
|
|
/* mount sd card fatfs as root directory */
|
|
|
|
if (dfs_mount("floppy", "/", "elm", 0, 0) == 0)
|
|
|
|
rt_kprintf("fatfs initialized!\n");
|
|
|
|
else
|
|
|
|
rt_kprintf("fatfs initialization failed!\n");
|
2012-10-15 08:51:09 +08:00
|
|
|
#endif
|
|
|
|
}
|
2017-08-17 23:31:52 +08:00
|
|
|
#endif
|
2012-10-15 08:51:09 +08:00
|
|
|
}
|
2012-02-16 23:58:52 +08:00
|
|
|
|
2017-08-17 23:31:52 +08:00
|
|
|
int rt_application_init()
|
2012-02-16 23:58:52 +08:00
|
|
|
{
|
2017-08-17 23:31:52 +08:00
|
|
|
rt_thread_t tid;
|
2012-10-15 08:51:09 +08:00
|
|
|
|
2017-08-17 23:31:52 +08:00
|
|
|
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);
|
2012-10-15 08:51:09 +08:00
|
|
|
|
|
|
|
return 0;
|
2012-02-16 23:58:52 +08:00
|
|
|
}
|