技术交流QQ群【JAVA,C++,Python,.NET,BigData,AI】:170933152
在uC/OS-II中,通常在进入中断时需要使用OSIntEnter() ;退出中断前使用OSIntExit();
分析一下OSIntEnter() 的代码
void OSIntEnter (void)
{
if (OSRunning == OS_TRUE) {
if (OSIntNesting < 255u) {
OSIntNesting++; /* Increment ISR nesting level */
}
}
}</span>
这个函数的作用是对全局变量OSIntNesting增1,OSIntNesting为中断嵌套深度。
再看看OSIntExit()
void OSIntExit (void)
{
#if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0u;
#endif
if (OSRunning == OS_TRUE) {
OS_ENTER_CRITICAL();
if (OSIntNesting > 0u) { /* Pr