2013-01-08 22:40:58 +08:00
|
|
|
/*
|
2018-10-16 13:00:37 +08:00
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
2013-01-08 22:40:58 +08:00
|
|
|
*
|
2018-10-16 13:00:37 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2013-01-08 22:40:58 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2009-01-05 Bernard the first version
|
2013-07-12 23:08:46 +08:00
|
|
|
* 2013-07-12 aozima update for auto initial.
|
2013-01-08 22:40:58 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup STM32
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
#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>
|
2013-02-24 18:16:16 +08:00
|
|
|
#include <rtgui/calibration.h>
|
2013-01-08 22:40:58 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "led.h"
|
|
|
|
|
|
|
|
ALIGN(RT_ALIGN_SIZE)
|
|
|
|
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_hw_led_on(0);
|
|
|
|
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_hw_led_off(0);
|
|
|
|
rt_thread_delay( RT_TICK_PER_SECOND/2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-24 18:16:16 +08:00
|
|
|
#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",
|
2013-07-12 23:08:46 +08:00
|
|
|
data->min_x,
|
|
|
|
data->max_x,
|
|
|
|
data->min_y,
|
|
|
|
data->max_y);
|
2013-02-24 18:16:16 +08:00
|
|
|
}
|
2013-07-12 23:08:46 +08:00
|
|
|
#endif /* RT_USING_RTGUI */
|
2013-02-24 18:16:16 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
void rt_init_thread_entry(void* parameter)
|
|
|
|
{
|
2013-07-12 23:08:46 +08:00
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
/* initialization RT-Thread Components */
|
|
|
|
rt_components_init();
|
2013-01-08 22:40:58 +08:00
|
|
|
#endif
|
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
/* 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 */
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_RTGUI
|
2013-07-12 23:08:46 +08:00
|
|
|
{
|
|
|
|
extern void rt_hw_lcd_init();
|
|
|
|
extern void rtgui_touch_hw_init(void);
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
rt_device_t lcd;
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
/* init lcd */
|
|
|
|
rt_hw_lcd_init();
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
/* init touch panel */
|
|
|
|
rtgui_touch_hw_init();
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
/* find lcd device */
|
|
|
|
lcd = rt_device_find("lcd");
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
/* set lcd device as rtgui graphic driver */
|
|
|
|
rtgui_graphic_set_device(lcd);
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-09-03 20:09:45 +08:00
|
|
|
#ifndef RT_USING_COMPONENTS_INIT
|
2013-07-12 23:08:46 +08:00
|
|
|
/* init rtgui system server */
|
|
|
|
rtgui_system_server_init();
|
2013-09-03 20:09:45 +08:00
|
|
|
#endif
|
2013-02-24 18:16:16 +08:00
|
|
|
|
|
|
|
calibration_set_restore(cali_setup);
|
|
|
|
calibration_set_after(cali_store);
|
|
|
|
calibration_init();
|
2013-07-12 23:08:46 +08:00
|
|
|
}
|
2013-01-08 22:40:58 +08:00
|
|
|
#endif /* #ifdef RT_USING_RTGUI */
|
|
|
|
}
|
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
int rt_application_init(void)
|
2013-01-08 22:40:58 +08:00
|
|
|
{
|
2013-07-12 23:08:46 +08:00
|
|
|
rt_thread_t init_thread;
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
rt_err_t result;
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
/* init led thread */
|
2013-07-12 23:08:46 +08:00
|
|
|
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)
|
|
|
|
{
|
2013-01-08 22:40:58 +08:00
|
|
|
rt_thread_startup(&led_thread);
|
2013-07-12 23:08:46 +08:00
|
|
|
}
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
#if (RT_THREAD_PRIORITY_MAX == 32)
|
2013-07-12 23:08:46 +08:00
|
|
|
init_thread = rt_thread_create("init",
|
|
|
|
rt_init_thread_entry, RT_NULL,
|
|
|
|
2048, 8, 20);
|
2013-01-08 22:40:58 +08:00
|
|
|
#else
|
2013-07-12 23:08:46 +08:00
|
|
|
init_thread = rt_thread_create("init",
|
|
|
|
rt_init_thread_entry, RT_NULL,
|
|
|
|
2048, 80, 20);
|
2013-01-08 22:40:58 +08:00
|
|
|
#endif
|
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
if (init_thread != RT_NULL)
|
|
|
|
rt_thread_startup(init_thread);
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-07-12 23:08:46 +08:00
|
|
|
return 0;
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*@}*/
|