RT-Thread OS的启动流程
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 ;
}
RT-Thread OS的启动流程的更多相关文章
- STM32 + RT Thread OS 学习笔记[二]
串口通讯例程 通过上面的练习,对STM32项目开发有了一个直观印象,接下来尝试对串口RS232进行操作. 1. 目标需求: 开机打开串口1,侦听上位机(使用电脑串口测试软件)发送的信息,然后原样输 ...
- STM32 + RT Thread OS 串口通讯
1. 创建项目 a) 禁用Finsh和console b) 默认情况下,项目文件包含了finsh,它使用COM1来通讯,另外,console输出(rt_kprintf)也使用了COM1.因 ...
- STM32 + RT Thread OS 学习笔记[三]
RTGUI 据说RTGUI是多线程的,因此与RT-Thread OS的耦合度较高,有可能要访问RT-Thread的线程控制块.如果要移植到其它OS,估计难度较大.目前还处于Alpha状态,最终将会包含 ...
- STM32 + RT Thread OS 学习笔记[四]
1. 补注 a) 硬件,打通通讯通道 若学习者购买了学习板,通常可以在学习板提供的示例代码中找到LCD的相关驱动代码,基本上,这里的驱动的所有代码都可以从里面找到. 从上面的示意图可见,M ...
- Tiny4412 Android 启动流程
Android系统的启动主要包括三个阶段: ①BootLoader启动 ②Linux Kernel启动 ③Android系统启动 前面我们大致分析了前面两个步骤,即u-boot和内核的启动流程(内核启 ...
- [SaltStack] salt-minion启动流程
SaltStack源码阅读 前面理了下salt-master的启动流程, 这次来看看salt-minion的启动流程. 启动salt-minion方法: /etc/init.d/salt-minion ...
- Android5 Zygote 与 SystemServer 启动流程分析
Android5 Zygote 与 SystemServer 启动流程分析 Android5 Zygote 与 SystemServer 启动流程分析 前言 zygote 进程 解析 zygoterc ...
- zookeeper启动流程简单梳理
等着測试童鞋完工,顺便里了下zookeeper的启动流程 zk3.4.6 启动脚本里面 nohup "$JAVA" "-Dzookeeper.log.dir=${ZOO_ ...
- 渣渣菜鸡的 ElasticSearch 源码解析 —— 启动流程(下)
关注我 转载请务必注明原创地址为:http://www.54tianzhisheng.cn/2018/08/12/es-code03/ 前提 上篇文章写完了 ES 流程启动的一部分,main 方法都入 ...
随机推荐
- 2009-04-19 22:40 SQL SERVER游标的讲解
游标和游标的优点 在数据库中,游标是一个十分重要的概念.游标提供了一种对从表中检索出的数据进行操作的灵活手段,就本质而言,游标实际上是一种能从包括多条数据记录的结 果集中每次提取一条记录的机制.游标总 ...
- 目标检测之hog(梯度方向直方图)---hog简介0
梯度直方图特征(HOG) 是一种对图像局部重叠区域的密集型描述符, 它通过计算局部区域的梯度方向直方图来构成特征.Hog特征结合SVM分类器已经被广泛应用于图像识别中,尤其在行人检测中获得了极大的成功 ...
- Epplus使用技巧
废话不说,直接开始. 创建Excel工作表 private static ExcelWorksheet CreateSheet(ExcelPackage p, string sheetName) { ...
- 1213 - Deadlock found when trying to get lock; try restarting transaction
1213 - Deadlock found when trying to get lock; try restarting transaction 出现这个原因要记住一点就是:innodb的行锁 和解 ...
- <转载> pycharm快捷键及一些常用设置
1.编辑(Editing ) Ctrl + Space 基本的代码完成(类.方法.属性)Ctrl + Alt + Space 快速导入任意类Ctrl + Shift + Enter 语句完成Ctrl ...
- 九度OJ 1169:比较奇偶数个数 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9459 解决:3146 题目描述: 第一行输入一个数,为n,第二行输入n个数,这n个数中,如果偶数比奇数多,输出NO,否则输出YES. 输入 ...
- vs2013工程技巧
1 vs工程输出了dll和lib,分别是什么,有什么用? 当设置工程property的Project Defaults的Configuration Type为dll时,不光会生成该动态链接库的dll文 ...
- LeetCode:矩形区域【223】
LeetCode:矩形区域[223] 题目描述 在二维平面上计算出两个由直线构成的矩形重叠后形成的总面积. 每个矩形由其左下顶点和右上顶点坐标表示,如图所示. 示例: 输入: -3, 0, 3, 4, ...
- 前端JSONPJIE解决跨域问题
解决同源策略的两个方法 1 . JSONP jsonp (将 JSON 数据填充进回调函数,这就是JSONP的JSON+Padding 的含义) jsonp是json用来跨域的一个东西,原理是通过sc ...
- Unity基本API总览