2014-11-12 01:09:43 +08:00
|
|
|
/*
|
2021-03-29 07:02:36 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2014-11-12 01:09:43 +08:00
|
|
|
*
|
2021-03-29 07:02:36 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2014-11-12 01:09:43 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2009-01-05 Bernard the first version
|
|
|
|
* 2013-07-12 aozima update for auto initial.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-03-29 07:02:36 +08:00
|
|
|
* @addtogroup
|
2014-11-12 01:09:43 +08:00
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
#include <board.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS
|
|
|
|
/* dfs filesystem:ELM filesystem init */
|
|
|
|
#include <dfs_elm.h>
|
|
|
|
/* dfs Filesystem APIs */
|
|
|
|
#include <dfs_fs.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_RTGUI
|
|
|
|
#include <rtgui/rtgui.h>
|
|
|
|
#include <rtgui/rtgui_server.h>
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
#include <rtgui/driver.h>
|
|
|
|
#include <rtgui/calibration.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef RT_USING_RTGUI
|
|
|
|
rt_bool_t cali_setup(void)
|
|
|
|
{
|
|
|
|
rt_kprintf("cali setup entered\n");
|
|
|
|
return RT_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cali_store(struct calibration_data *data)
|
|
|
|
{
|
|
|
|
rt_kprintf("cali finished (%d, %d), (%d, %d)\n",
|
|
|
|
data->min_x,
|
|
|
|
data->max_x,
|
|
|
|
data->min_y,
|
|
|
|
data->max_y);
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_RTGUI */
|
|
|
|
|
|
|
|
void rt_init_thread_entry(void* parameter)
|
|
|
|
{
|
2021-12-17 15:34:17 +08:00
|
|
|
|
2014-11-12 01:09:43 +08:00
|
|
|
#ifdef RT_USING_MODULE
|
|
|
|
rt_system_module_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_FINSH
|
2021-12-17 15:34:17 +08:00
|
|
|
/* initialize finsh */
|
|
|
|
finsh_system_init();
|
2022-01-03 06:51:44 +08:00
|
|
|
#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
|
2021-12-17 15:34:17 +08:00
|
|
|
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
2021-11-24 21:57:12 +08:00
|
|
|
#endif
|
2014-11-12 01:09:43 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_LWIP
|
2021-12-17 15:34:17 +08:00
|
|
|
/* initialize lwip stack */
|
|
|
|
/* register ethernetif device */
|
|
|
|
eth_system_device_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
|
2021-12-17 15:34:17 +08:00
|
|
|
/* initialize lwip system */
|
|
|
|
lwip_system_init();
|
|
|
|
rt_kprintf("TCP/IP initialized!\n");
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS
|
2021-12-17 15:34:17 +08:00
|
|
|
/* initialize the device file system */
|
|
|
|
dfs_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_ELMFAT
|
2021-12-17 15:34:17 +08:00
|
|
|
/* initialize the elm chan FatFS file system*/
|
|
|
|
elm_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP)
|
2021-12-17 15:34:17 +08:00
|
|
|
/* initialize NFSv3 client file system */
|
|
|
|
nfs_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_YAFFS2
|
2021-12-17 15:34:17 +08:00
|
|
|
dfs_yaffs2_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_UFFS
|
2021-12-17 15:34:17 +08:00
|
|
|
dfs_uffs_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_JFFS2
|
2021-12-17 15:34:17 +08:00
|
|
|
dfs_jffs2_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_ROMFS
|
2021-12-17 15:34:17 +08:00
|
|
|
dfs_romfs_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_RAMFS
|
2021-12-17 15:34:17 +08:00
|
|
|
dfs_ramfs_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_DEVFS
|
2021-12-17 15:34:17 +08:00
|
|
|
devfs_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
#endif /* end of RT_USING_DFS */
|
|
|
|
|
|
|
|
#ifdef RT_USING_RTGUI
|
2021-12-17 15:34:17 +08:00
|
|
|
rtgui_system_server_init();
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_USB_HOST
|
2022-01-26 10:46:57 +08:00
|
|
|
rt_usb_host_init("usbh");
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_FINSH
|
2022-01-03 06:51:44 +08:00
|
|
|
#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
|
2014-11-12 01:09:43 +08:00
|
|
|
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
|
2021-11-24 21:57:12 +08:00
|
|
|
#endif
|
2014-11-12 01:09:43 +08:00
|
|
|
#endif /* RT_USING_FINSH */
|
|
|
|
|
|
|
|
/* Filesystem Initialization */
|
|
|
|
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
|
|
|
|
/* 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");
|
|
|
|
#endif /* RT_USING_DFS */
|
|
|
|
|
|
|
|
#ifdef RT_USING_RTGUI
|
|
|
|
{
|
|
|
|
extern void rt_hw_lcd_init();
|
|
|
|
extern void rtgui_touch_hw_init(void);
|
|
|
|
|
|
|
|
rt_device_t lcd;
|
|
|
|
|
|
|
|
/* init lcd */
|
|
|
|
rt_hw_lcd_init();
|
|
|
|
|
|
|
|
/* init touch panel */
|
|
|
|
rtgui_touch_hw_init();
|
|
|
|
|
|
|
|
/* find lcd device */
|
|
|
|
lcd = rt_device_find("lcd");
|
|
|
|
|
|
|
|
/* set lcd device as rtgui graphic driver */
|
|
|
|
rtgui_graphic_set_device(lcd);
|
|
|
|
|
|
|
|
#ifndef RT_USING_COMPONENTS_INIT
|
|
|
|
/* init rtgui system server */
|
|
|
|
rtgui_system_server_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
calibration_set_restore(cali_setup);
|
|
|
|
calibration_set_after(cali_store);
|
|
|
|
calibration_init();
|
|
|
|
}
|
|
|
|
#endif /* #ifdef RT_USING_RTGUI */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-12 02:12:03 +08:00
|
|
|
rt_align(RT_ALIGN_SIZE)
|
2014-11-12 01:09:43 +08:00
|
|
|
static rt_uint8_t led_stack[ 512 ];
|
|
|
|
static struct rt_thread led_thread;
|
|
|
|
static void led_thread_entry(void* parameter)
|
|
|
|
{
|
|
|
|
unsigned int count=0;
|
|
|
|
|
|
|
|
// rt_hw_led_init();
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* led1 on */
|
|
|
|
#ifndef RT_USING_FINSH
|
|
|
|
rt_kprintf("led on, count : %d\r\n",count);
|
|
|
|
#endif
|
|
|
|
count++;
|
|
|
|
|
|
|
|
rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */
|
|
|
|
|
|
|
|
/* led1 off */
|
|
|
|
#ifndef RT_USING_FINSH
|
|
|
|
rt_kprintf("led off\r\n");
|
|
|
|
#endif
|
|
|
|
rt_thread_delay( RT_TICK_PER_SECOND/2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int rt_application_init(void)
|
|
|
|
{
|
|
|
|
rt_thread_t init_thread;
|
|
|
|
#if 1
|
|
|
|
rt_err_t result;
|
|
|
|
/* init led thread */
|
|
|
|
result = rt_thread_init(&led_thread,
|
|
|
|
"led",
|
|
|
|
led_thread_entry,
|
|
|
|
RT_NULL,
|
|
|
|
(rt_uint8_t*)&led_stack[0],
|
|
|
|
sizeof(led_stack),
|
|
|
|
20,
|
|
|
|
5);
|
|
|
|
if (result == RT_EOK)
|
|
|
|
{
|
|
|
|
rt_thread_startup(&led_thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#if (RT_THREAD_PRIORITY_MAX == 32)
|
|
|
|
init_thread = rt_thread_create("init",
|
|
|
|
rt_init_thread_entry, RT_NULL,
|
|
|
|
1024, 8, 20);
|
|
|
|
#else
|
|
|
|
init_thread = rt_thread_create("init",
|
|
|
|
rt_init_thread_entry, RT_NULL,
|
|
|
|
2048, 80, 20);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (init_thread != RT_NULL)
|
|
|
|
rt_thread_startup(init_thread);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*@}*/
|