-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplication.c
145 lines (120 loc) · 3.07 KB
/
application.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
* 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 <rtthread.h>
#include <finsh.h>
#include <stm32f10x.h>
#include "board.h"
#include "netbuffer.h"
#include "lcd.h"
#include "rtc.h"
#include "setup.h"
#include "codec.h"
#ifdef RT_USING_DFS
/* dfs init */
#include <dfs_init.h>
/* dfs filesystem:ELM FatFs filesystem init */
#include <dfs_elm.h>
/* dfs Filesystem APIs */
#include <dfs_fs.h>
#endif
#ifdef RT_USING_LWIP
#include <lwip/sys.h>
#include <lwip/api.h>
#include <netif/ethernetif.h>
#endif
#ifdef RT_USING_RTGUI
extern void radio_rtgui_init(void);
#endif
extern void brightness_set(unsigned int value);
extern void ftpd_start(); /* @see ftpd.c */
/* thread phase init */
void rt_init_thread_entry(void *parameter)
{
/* Filesystem Initialization */
#ifdef RT_USING_DFS
{
extern void ff_convert_init();
/* init the device filesystem */
dfs_init();
/* init the elm FAT filesystam*/
elm_init();
/* mount sd card fat partition 1 as SD directory */
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
rt_kprintf("SD File System initialized!\n");
else
rt_kprintf("SD File System init failed!\n");
#ifdef RT_DFS_ELM_USE_LFN
ff_convert_init();
#endif
}
#endif
/* load_setup(); */
/* RTGUI Initialization */
#ifdef RT_USING_RTGUI
{
extern void rt_hw_key_init(void);
extern void remote_init(void);
extern void rtgui_touch_hw_init(void);
radio_rtgui_init();
rt_hw_key_init();
rtgui_touch_hw_init();
remote_init();
brightness_set(radio_setup.lcd_brightness);
//PCM1770_VolumeSet(radio_setup.default_volume);
}
#endif
/* start RTC */
rt_hw_rtc_init();
/* LwIP Initialization */
#ifdef RT_USING_LWIP
{
extern void lwip_sys_init(void);
extern void rt_hw_dm9000_init(void);
eth_system_device_init();
/* register ethernetif device */
rt_hw_dm9000_init();
/* init all device */
rt_device_init_all();
/* init lwip system */
lwip_sys_init();
rt_kprintf("TCP/IP initialized!\n");
}
#endif
#if STM32_EXT_SRAM
/* init netbuf worker */
net_buf_init(320 * 1024);
#endif
/* TODO(CXF): start ftp and agent */
ftpd_start();
}
int rt_application_init()
{
rt_thread_t init_thread;
#if (RT_THREAD_PRIORITY_MAX == 32)
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, 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;
}
/*@}*/