mirror of
https://github.com/flyingcys/realtek_ameba.git
synced 2024-10-31 17:34:18 +00:00
简化启动代码
This commit is contained in:
parent
39aa6d5724
commit
fec197191b
1 changed files with 12 additions and 110 deletions
|
@ -9,113 +9,7 @@
|
|||
|
||||
#include "ameba_soc.h"
|
||||
#include "build_info.h"
|
||||
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_LWIP
|
||||
#include <wlan_dev.h>
|
||||
#endif
|
||||
|
||||
#ifndef RT_MAIN_THREAD_STACK_SIZE
|
||||
#define RT_MAIN_THREAD_STACK_SIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef RT_USING_HEAP
|
||||
/* if there is not enable heap, we should use static thread and stack. */
|
||||
ALIGN(8)
|
||||
static rt_uint8_t main_stack[RT_MAIN_THREAD_STACK_SIZE];
|
||||
struct rt_thread main_thread;
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
extern int amebaz_wifi_init(rt_wlan_mode_t mode);
|
||||
#endif
|
||||
|
||||
/* the system main thread */
|
||||
void main_thread_entry(void *parameter)
|
||||
{
|
||||
extern int main(void);
|
||||
extern int $Super$$main(void);
|
||||
|
||||
/* RT-Thread components initialization */
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
if(amebaz_wifi_init(WIFI_STATION) != RT_EOK)
|
||||
rt_kprintf("amebaz_wifi_start failed...\n");
|
||||
#endif
|
||||
|
||||
/* invoke system main function */
|
||||
#if defined (__CC_ARM)
|
||||
$Super$$main(); /* for ARMCC. */
|
||||
#elif defined(__ICCARM__) || defined(__GNUC__)
|
||||
main();
|
||||
#endif
|
||||
}
|
||||
|
||||
void rt_application_init(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
tid = rt_thread_create("main", main_thread_entry, RT_NULL,
|
||||
RT_MAIN_THREAD_STACK_SIZE, RT_THREAD_PRIORITY_MAX / 3, 20);
|
||||
RT_ASSERT(tid != RT_NULL);
|
||||
#else
|
||||
rt_err_t result;
|
||||
|
||||
tid = &main_thread;
|
||||
result = rt_thread_init(tid, "main", main_thread_entry, RT_NULL,
|
||||
main_stack, sizeof(main_stack), RT_THREAD_PRIORITY_MAX / 3, 20);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* if not define RT_USING_HEAP, using to eliminate the warning */
|
||||
(void)result;
|
||||
#endif
|
||||
|
||||
rt_thread_startup(tid);
|
||||
}
|
||||
|
||||
int rtthread_startup(void)
|
||||
{
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
/* board level initalization
|
||||
* NOTE: please initialize heap inside board initialization.
|
||||
*/
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show RT-Thread version */
|
||||
rt_show_version();
|
||||
|
||||
/* timer system initialization */
|
||||
rt_system_timer_init();
|
||||
|
||||
/* scheduler system initialization */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
#ifdef RT_USING_SIGNALS
|
||||
/* signal system initialization */
|
||||
rt_system_signal_init();
|
||||
#endif
|
||||
|
||||
/* create init_thread */
|
||||
rt_application_init();
|
||||
|
||||
/* timer thread initialization */
|
||||
rt_system_timer_thread_init();
|
||||
|
||||
/* idle thread initialization */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "rtconfig.h"
|
||||
|
||||
void APP_Start(void)
|
||||
{
|
||||
|
@ -139,9 +33,17 @@ void APP_Start(void)
|
|||
"mov sp, r0\n"
|
||||
);
|
||||
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
#ifdef RT_USING_USER_MAIN
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
#else
|
||||
extern int main(void);
|
||||
extern int $Super$$main(void);
|
||||
/* invoke system main function */
|
||||
#if defined (__CC_ARM)
|
||||
$Super$$main(); /* for ARMCC. */
|
||||
#elif defined(__ICCARM__) || defined(__GNUC__)
|
||||
main();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue