2011-12-27 15:44:29 +08:00
|
|
|
/***************************************************************************//**
|
2012-02-20 12:35:01 +08:00
|
|
|
* @file startup.c
|
2011-12-27 15:44:29 +08:00
|
|
|
* @brief This file is part of RT-Thread RTOS
|
|
|
|
* COPYRIGHT (C) 2011, RT-Thread Development Team
|
|
|
|
* @author Bernard, onelife
|
|
|
|
* @version 0.4 beta
|
|
|
|
*******************************************************************************
|
2011-02-17 11:33:15 +08:00
|
|
|
* @section License
|
2011-12-27 15:44:29 +08:00
|
|
|
* 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
|
|
|
|
*******************************************************************************
|
2011-02-17 11:33:15 +08:00
|
|
|
* @section Change Logs
|
|
|
|
* Date Author Notes
|
2011-12-27 15:44:29 +08:00
|
|
|
* 2006-08-31 Bernard first implementation
|
|
|
|
* 2010-12-29 onelife Modify for EFM32
|
|
|
|
* 2011-12-20 onelife Add RTGUI initialization routine
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************//**
|
|
|
|
* @addtogroup efm32
|
|
|
|
* @{
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
2011-02-17 11:33:15 +08:00
|
|
|
#include "board.h"
|
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* External variables --------------------------------------------------------*/
|
2011-02-17 11:33:15 +08:00
|
|
|
#ifdef __CC_ARM
|
|
|
|
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
|
|
|
#elif __ICCARM__
|
|
|
|
#pragma section="HEAP"
|
|
|
|
#else
|
|
|
|
extern int __bss_end;
|
|
|
|
#endif
|
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* External function prototypes ----------------------------------------------*/
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* Private functions ---------------------------------------------------------*/
|
2012-02-20 12:35:01 +08:00
|
|
|
#ifdef RT_DEBUG
|
2011-12-27 15:44:29 +08:00
|
|
|
/***************************************************************************//**
|
2011-02-17 11:33:15 +08:00
|
|
|
* @brief
|
2011-12-27 15:44:29 +08:00
|
|
|
* Reports the name of the source file and the source line number where the
|
|
|
|
* assert error has occurred.
|
2011-02-17 11:33:15 +08:00
|
|
|
*
|
|
|
|
* @details
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
*
|
|
|
|
* @param[in] file
|
2011-12-27 15:44:29 +08:00
|
|
|
* Pointer to the source file name
|
2011-02-17 11:33:15 +08:00
|
|
|
*
|
|
|
|
* @param[in] line
|
2011-12-27 15:44:29 +08:00
|
|
|
* Assert error line source number
|
|
|
|
******************************************************************************/
|
2012-02-20 12:35:01 +08:00
|
|
|
void assert_failed(uint8_t * file, uint32_t line)
|
2011-02-17 11:33:15 +08:00
|
|
|
{
|
2011-12-27 15:44:29 +08:00
|
|
|
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
|
|
|
rt_kprintf(" file %s\r\n", file);
|
|
|
|
rt_kprintf(" line %d\r\n", line);
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
while (1) ;
|
2011-02-17 11:33:15 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/***************************************************************************//**
|
2011-02-17 11:33:15 +08:00
|
|
|
* @brief
|
2011-12-27 15:44:29 +08:00
|
|
|
* Startup RT-Thread
|
2011-02-17 11:33:15 +08:00
|
|
|
*
|
|
|
|
* @details
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
*
|
2011-12-27 15:44:29 +08:00
|
|
|
******************************************************************************/
|
2011-02-17 11:33:15 +08:00
|
|
|
void rtthread_startup(void)
|
|
|
|
{
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init board */
|
|
|
|
rt_hw_board_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_HEAP
|
2011-12-27 15:44:29 +08:00
|
|
|
#ifdef __CC_ARM
|
|
|
|
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)EFM32_SRAM_END);
|
|
|
|
#elif __ICCARM__
|
2011-02-17 11:33:15 +08:00
|
|
|
rt_system_heap_init(__segment_end("HEAP"), (void*)EFM32_SRAM_END);
|
2011-12-27 15:44:29 +08:00
|
|
|
#else
|
|
|
|
/* init memory system */
|
|
|
|
rt_system_heap_init((void*)&__bss_end, (void*)EFM32_SRAM_END);
|
|
|
|
#endif
|
2011-02-17 11:33:15 +08:00
|
|
|
#endif
|
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* enable interrupt */
|
|
|
|
rt_hw_interrupt_enable(0x0UL);
|
|
|
|
|
|
|
|
/* init drivers */
|
|
|
|
rt_hw_driver_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* show version */
|
|
|
|
rt_show_version();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init tick */
|
|
|
|
rt_system_tick_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init kernel object */
|
|
|
|
rt_system_object_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init timer system */
|
|
|
|
rt_system_timer_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init scheduler system */
|
|
|
|
rt_system_scheduler_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init all devices */
|
|
|
|
rt_device_init_all();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init finsh */
|
2011-02-17 11:33:15 +08:00
|
|
|
#ifdef RT_USING_FINSH
|
2011-12-27 15:44:29 +08:00
|
|
|
finsh_system_init();
|
|
|
|
finsh_set_device(CONSOLE_DEVICE);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Initialize gui server */
|
|
|
|
#ifdef RT_USING_RTGUI
|
|
|
|
rtgui_system_server_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* init timer thread */
|
|
|
|
rt_system_timer_thread_init();
|
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init idle thread */
|
|
|
|
rt_thread_idle_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init application */
|
|
|
|
rt_application_init();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* start scheduler */
|
|
|
|
rt_system_scheduler_start();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* never reach here */
|
|
|
|
return ;
|
2011-02-17 11:33:15 +08:00
|
|
|
}
|
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/***************************************************************************//**
|
2011-02-17 11:33:15 +08:00
|
|
|
* @brief
|
2011-12-27 15:44:29 +08:00
|
|
|
* Program entry point
|
2011-02-17 11:33:15 +08:00
|
|
|
*
|
|
|
|
* @details
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
*
|
2011-12-27 15:44:29 +08:00
|
|
|
******************************************************************************/
|
2011-02-17 11:33:15 +08:00
|
|
|
int main(void)
|
|
|
|
{
|
2011-12-27 15:44:29 +08:00
|
|
|
/* disable interrupt first */
|
|
|
|
rt_hw_interrupt_disable();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* init system setting */
|
|
|
|
SystemInit();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/* startup RT-Thread RTOS */
|
|
|
|
rtthread_startup();
|
2011-02-17 11:33:15 +08:00
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
return 0;
|
2011-02-17 11:33:15 +08:00
|
|
|
}
|
|
|
|
|
2011-12-27 15:44:29 +08:00
|
|
|
/***************************************************************************//**
|
2011-02-17 11:33:15 +08:00
|
|
|
* @}
|
2011-12-27 15:44:29 +08:00
|
|
|
******************************************************************************/
|