⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_cpu_c.c

📁 嵌入式系统内核模拟器
💻 C
字号:
/*Example,porting ucosii to simuos 20041123*/
/*Author:lmjx 
**Email :limiao@yeah.net
**You can FREE use this copy for LEARN or EDUCATE purpose.
**For more information access www.mshowtec.com
**/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

#include "../example/includes.h"

/*
*********************************************************************************************************
   Global variables
*********************************************************************************************************
*/
INT32U curTick = 0;

/*********************************************************************************************************
   uCOS-II Functions
*********************************************************************************************************
*/

void *OSTaskStkInit(void (*task) (void *pd), void *pdata, void *ptos, INT16U opt)
{
    OS_STK *stk;

    stk = (OS_STK *) ptos;  
    *--stk = (INT32U) pdata;
    *--stk = (INT32U) task;	

    return stk;
}


// OSTaskCreateHook **********************************************************
// This hook is invoked during task creation. MUST NOT BE DEFINED BY THE APPLICATION.
void OSTaskCreateHook(OS_TCB * pTcb)
{
    simuTaskCreate( *(pTcb->OSTCBStkPtr),(void *) *(pTcb->OSTCBStkPtr + 1));
    //ADD YOUR OWN HOOK CODE HERE IF NECESSARY
}

// OSTaskIdleHook ************************************************************
// This hook is invoked from the idle task. MUST NOT BE DEFINED BY THE APPLICATION.
void OSTaskIdleHook()
{   
    
}

/*
*******************************************************************************
   Hook functions (user hookable)
*******************************************************************************
*/

#if OS_CPU_HOOKS_EN > 0

/*
void OSInitHookBegin()                  MUST NOT BE DEFINED BY THE APPLICATION, see above.
*/

// OSInitHookEnd *************************************************************
// This hook is invoked at the end of the OS initialization.
void OSInitHookEnd()
{
}

/*
void OSTaskCreateHook(OS_TCB * pTcb)    MUST NOT BE DEFINED BY THE APPLICATION, see above.
*/

// OSTaskDelHook *************************************************************
// This hook is invoked during task deletion.
void OSTaskDelHook(OS_TCB * pTcb)
{
}

// OSTCBInitHook
// This hook is invoked during TCB initialization
void OSTCBInitHook(OS_TCB * ptcb)
{
}

/*
void OSTaskIdleHook()                   MUST NOT BE DEFINED BY THE APPLICATION, see above.
*/

// OSTaskStatHook ************************************************************
// This hook is invoked by the statistical task every second.
void OSTaskStatHook()
{
}

// OSTimeTickHook ************************************************************
// This hook is invoked during a time tick.
void OSTimeTickHook()
{
}

// OSTaskSwHook **************************************************************
// This hook is invoked during a task switch.
// OSTCBCur points to the current task (being switched out).
// OSTCBHighRdy points on the new task (being switched in).
void OSTaskSwHook()
{
}

#else
#pragma message("INFO: Hook functions must be defined in the application")
#endif

/*
*******************************************************************************
   Internal Task switch functions
*******************************************************************************
*/

// OSStartHighRdy *************************************************************
// Start first task
void OSStartHighRdy(void)
{   
    OSRunning++;

    simuSchedule(); 

     while(OSRunning)
    {   
    	simuWin32ThreadSwitch();
    }
}

void OSTickISR(void)
{
	curTick++;
	OSTimeTick();
}


// OSCtxSw ********************************************************************
// Task context switch
void OSCtxSw(void)
{   
    simuSchedule(); 
}

// OSIntCtxSw *****************************************************************
// Interrupt context switch
void OSIntCtxSw(void)
{   
    simuSchedule();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -