第11章 参考手册.docVIP

  • 1
  • 0
  • 约4.72万字
  • 约 73页
  • 2017-08-15 发布于河南
  • 举报
第11章 参考手册.doc

第11章 参考手册 本章提供了uC/OS-Ⅱ的用户指南。每一个用户可以调用的内核函数都按字母顺序加以说明,包括: 函数的功能描述 函数原型 函数名称及源代码 函数使用到的常量 函数参数 函数返回值 特殊说明和注意点 OSInit( ) Void OSInit(void); 所属文件 调用者 开关量 OS_CORE.C 启动代码 无 OSinit()初始化uC/OS-Ⅱ,对这个函数的调用必须在调用OSStart()函数之前,而OSStart()函数真正开始运行多任务。 注意/警告:必须先于OSStart()函数的调用 范例:void main (void) {…… OSInit(); // 初始化 uC/OS-II . OSStart(); //启动多任务内核 } void OSInit (void) { #if OS_VERSION = 204 OSInitHookBegin(); //Call port specific initialization code #endif OS_InitMisc(); //Initialize miscellaneous variables OS_InitRdyList(); // Initialize the Ready List OS_InitTCBList(); // Initialize the free list of OS_TCBs OS_InitEventList(); // Initialize the free list of OS_EVENTs #if (OS_VERSION = 251) (OS_FLAG_EN 0) (OS_MAX_FLAGS 0) OS_FlagInit(); // Initialize the event flag structures #endif #if (OS_MEM_EN 0) (OS_MAX_MEM_PART 0) OS_MemInit(); // Initialize the memory manager #endif #if (OS_Q_EN 0) (OS_MAX_QS 0) OS_QInit(); // Initialize the message queue structures */ #endif OS_InitTaskIdle(); // Create the Idle Task #if OS_TASK_STAT_EN 0 OS_InitTaskStat(); //Create the Statistic Task #endif #if OS_VERSION = 204 OSInitHookEnd(); // Call port specific init. code #endif } OSIntEnter( ) Void OSIntEnter(void); 所属文件 调用者 开关量 OS_CORE.C 中断 无 OSIntEnter()通知uC/OS-Ⅱ一个中断处理函数正在执行,这有助于uC/OS-Ⅱ掌握中断嵌套的情况。OSIntEnter()函数通常和OSIntExit()函数联合使用。 注意/警告:在任务级不能调用该函数。 如果用户使用的微处理器有存储器直接加1的单条指令的话,将全程变量OSIntNesting直接加1,可以避免调用函数所带来的额外的开销! 如果用户使用的微处理器没有这样的指令,必须先将OSIntNesting读入寄存器,再将寄存器加1,然后再写回到变量OSIatNesting中去,就不如调用OSIntEnter()。OSIntNesting是共享资源。OSIntEnter()把上述三条指令用开中断、关中断保护起来,以保证处理OSIntNesting时的排它性。直接给OSIntNesting加1比调用OSIntEnter()快得多,可能时,直接加1更好。当心的是,在有些情况下,从OSIntEnter()返回时,会把中断开了。这种情况,在调用OSIntEnter()之前要先清中断源,否则中断将连续反复打入,用户应用程序就会崩溃! //源代码 void OSIntEnter (void) { if (OSRunning == TRUE) { if (OSIntNesting 255u) { //Increment ISR nesting level OSIntNesting++; } } } //51移植 void O

文档评论(0)

1亿VIP精品文档

相关文档