- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
打造自己的rtos(Build your own RTOS)
打造自己的rtos(Build your own RTOS)
I was learning to write good ~ ~ ~ ~ in the top, I will continue to reissue back ~ ~ ~
Chapter 1: function running
Chapter 1: function running
In general SCM system, it is the method of backstage (large cycle + interrupt) to process data and react.
Examples are as follows:
Makefile settings: run WinAvr in Mfile, set as follows
MCU Type: MEGA8
Optimization level: s
Debug format: AVR-COFF
C/C++ source file: selects the C file to be compiled
#include avr/io.h
Void fun1 (void)
{
Unsigned char i=0;
While (1)
{
PORTB=i++;
PORTC=0x01 (i%8);
}
}
Int main (void)
{
Fun1 ();
}
First, ask a question: if you want to call a function, is it really going to be just the way it is?
I believe learning C language you will answer, No! We have a way of using the function pointer variable function calls, if you are like me, the original textbook is Mr. Tan Haoqiangs C program design of the word, please find the books section 9.5.
Example: call function with function pointer variable
#include avr/io.h
Void fun1 (void)
{
Unsigned char i=0;
While (1)
{
PORTB=i++;
PORTC=0x01 (i%8);
}
}
Void (*pfun) (); / / pointer to function
Int main (void)
{
Pfun=fun1; / /
((*pfun)); / / function pointer
}
The second is to refer to pointer variables pointing to functions as function arguments
#include avr/io.h
Void fun1 (void)
{
Unsigned char i=0;
While (1)
{
PORTB=i++;
PORTC=0x01 (i%8);
}
}
Void RunFun (void) (*pfun) (/ /) function is obtained to transfer address
{
((*pfun)); / / RunFun, function pointer
}
Int main (void)
{
RunFun (fun1); / / the function pointer passed as a variable
}
Looking at the above two ways, many people might say, its really good, but what does it have to do with the RTOS we want? Ladies and gentlemen, please look down carefully.
Here is how GCC compiled the above code:
The compilation of RunFun (fun1) in main () is as follows
LDI, R24, lo8 (PM (fun1))
LDI, R25, Hi8 (PM (fun1))
Rcall RunFun
The compilation of void RunFun (void (*pfun)) is as follows
/
您可能关注的文档
- 工资为何悄悄被扣 曝工资被扣的十大方式(Why wages are quietly deducted exposure wages detained ten ways).doc
- 工作总结——青年干部培养(Summary of work -- training young cadres).doc
- 巨力集团扬子的管理经验(Juli group management experience of the Yangtze).doc
- 差异化应该注意什么(Differentiation should pay attention to what).doc
- 差异化营销--从战术到战略(Differentiated marketing from tactics to strategy).doc
- 工资待遇(Salary treatment).doc
- 布署还是部署(Deployment or deployment).doc
- 帆布包的来源打造的品牌理念(The origin of the canvas bag is the brand concept).doc
- 带好队伍的六项技术(Six techniques for bringing up a team).doc
- 帮扶工作计划(Aid work plan).doc
- 打造自己的万能系统(Build your own universal system).doc
- 打造执行力(Build execution).doc
- 打造易用安全电脑(Easy to use secure computer).doc
- 打造视觉冲击力迎接情绪消费时代的到来(Create visual impact to greet the era of emotional consumption).doc
- 打造高绩效团队的七个密码(Create seven passwords for high performance teams).doc
- 扣押工资留人管理是饮鸠止渴(The salary management is to keep people seized outright).doc
- 扩张,搜房网永远的主题--专访搜房控股董事长莫天全(Expansion -- the eternal theme of SouFun -- Interview with Mo Tianquan, chairman of SouFun Holdings)(Expansion, Soufangwang forever theme - interview with SouFun chairman Mo Tianquan (Expansion - the.doc
- 扶持中医药发展(Support the development of Chinese Medicine).doc
- 打造超级资源管理器(Build super explorer).doc
- 技能专业考试习题手机版(Skills, professional examination exercises, mobile phone version).doc
文档评论(0)