1、RT进入main之前,

SystemInit函数初始化时钟。

2、main函数位于startup.c文件中。进行两个工作

系统开始前,rt_hw_interrupt_disable关闭所有中断。

之后使用rtthread_startup启动RTThread

3、函数rtthread_startup()完成的工作:

1、调用函数rt_hw_board_init 完成板子初始化工作

2、显示版本信息:rt_show_version

3、初始化系统滴答:rt_system_tick_init

4、系统内核对象初始化:rt_system_object_init

5、定时器初始化:rt_system_timer_init

6、系统堆栈初始化rt_system_heap_init

7、任务调度器初始化:rt_system_scheduler_init

8、rt_application_init //加入用户自定义的任务

9、FINSH模块初始化 ,

10、定时器线程初始化:rt_system_timer_thread_init

11、空闲任务初始化rt_thread_idle_init

12、开始任务调度,OS接管MCU:rt_system_scheduler_start

任务调度开始之后,OS就算是启动好了。之后的东西都是在OS的管理下运行了。

4、在RTT示例工程中添加外设驱动的方法:

  驱动头文件加入board.h

RT-thread系统的main函数位于startup.c文件中。

/**
* This function will startup RT-Thread RTOS.
*/
void rtthread_startup(void)
{
/* init board */
rt_hw_board_init();//NVIC_config, SysTick_config, serial_device register, set CONSOLE for output(rt_kprintf(...)) in board.c /* show version */
rt_show_version(); //show the version of rtthread by serial device(set to be console-device in board.c) in kservice.c /* init tick */
rt_system_tick_init(); //empty fucntion(since 1.1.0) in clock.c /* init kernel object */
rt_system_object_init();//empty fucntion(since 0.3.0) in object.c /* init timer system */
rt_system_timer_init(); //init rt_timer_list[0].next=rt_timer_list[0].prev=rt_timer_list[0](means rt_timer_list is empty) in timer.c rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END);//init system heap in mem.c /* init scheduler system */
rt_system_scheduler_init();//init the system scheduler, and init rt_thread_defunct(dead thread list) to be empty in scheduler.c /* init application */
rt_application_init(); //init all defined thread in application.c //#ifdef RT_USING_FINSH //replace finsh_set_device() after the function of rt_components_init() in rt_init_thread_entry() of application.c
/* init finsh */
//finsh_system_init(); //INIT_COMPONENT_EXPORT(finsh_system_init) in shell.c, so it needn't finsh_system_init here
//finsh_set_device( FINSH_DEVICE_NAME );//sets the input device of finsh shell(rt_device_open(dev, RT_DEVICE_OFLAG_RDWR |
RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM) in shell.c
//#endif /* init timer thread */
rt_system_timer_thread_init();//init system software timer thread(opened by #define RT_USING_TIMER_SOFT in rtconfig.h) in timer.c /* init idle thread */
rt_thread_idle_init(); //init idle thread(cleanup all dead thread), then start to be ready in idle.c /* start scheduler */
rt_system_scheduler_start(); //startup scheduler(first swith to the highest priority thread and enable interrupt )in scheduler.c /* never reach here */
return ;
}
int main(void)
{
/* disable interrupt first */
//enable interrupt(CPSIE I) when the first thread switch(rt_hw_context_switch_to) in lipcpu/cortex-m4/context_rvds.S
rt_hw_interrupt_disable(); /* startup RT-Thread RTOS */
rtthread_startup(); return ;
}

最新文章

  1. ORACLE 11gR2 DG(Physical Standby)日常维护01
  2. OSGEarth编译
  3. MySQL学习笔记十:日志管理
  4. PHP通用分页(Pager)类
  5. 爱挑剔的acm程序员 acmer
  6. iOS CGContextRef画图时的常用方法
  7. 向jboss写入服务器日志
  8. newman 3.0改变
  9. iOS 中的加密方式
  10. jQuery UI 多选下拉框插件:jquery-ui-multiselect
  11. 高性能网络I/O框架-netmap源码分析
  12. MYSQL 体系结构图-log (踏雪无痕) (UC技术博客)
  13. 什么是AAC音频格式 AAC-LC 和 AAC-HE的区别是什么
  14. hashcode的一些了解
  15. 解读“Deep Neural Decision Forests” 2015 Winner of the David Marr Prize
  16. 约会 倍增lca
  17. 【转】JS windows.open()详解
  18. DataTable内容导出为CSV文件
  19. maven 构建war包时排除web.xml
  20. windows media server 组件安装后流媒体服务器启动失败

热门文章

  1. Linux 进程状态 说明
  2. live555二次开发经验总结:RTSPClient客户端与RTSPServer服务器
  3. 高性能流媒体服务器EasyDSS前端重构(四)- webpack + video.js 打造流媒体服务器前端
  4. runsv
  5. 我的Android进阶之旅------>Android实现音乐示波器、均衡器、重低音和音场功能
  6. 我的Java开发学习之旅------>Java经典排序算法之希尔排序
  7. Android实现下拉导航选择菜单效果
  8. 高性能 Socket 组件 HP-Socket v3.2.1-RC1 公布
  9. 在maven 中部署SSM项目找不 Spring ContextLoaderListener 的解决办法
  10. Node.js学习笔记(2):基本模块