?? os_cpu_c.c
字號:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
*
* MC9S12DP256/DG128 Specific code
* SMALL MEMORY MODEL
*
* File : OS_CPU_C.C
* By : Jean J. Labrosse
*******************************************************************************************************/
/********************************************************************
//
// Author: CaiXinBo \\\\\\\ //
// ( o o ) //
//----------------------oOO----(_)----OOo-----------------------//
FileName: OS_CPU_C.C
Created Date: 23/5/2006 9:45
Modify Date:
Purpose:
*********************************************************************/
#include "mc9s12dg128.h"
#define OS_CPU_GLOBALS
#include "includes.h"
void OSTickISR(void)
{
asm{
ldaa $30 //save ppage to stack
psha
}
OSIntEnter();
OS_SAVE_SP();
CRGFLG &=0xEF; // clear the interrupt flag
OSTimeTick();
OSIntExit(); // exit interrupt and task switch
asm{
pula
staa $30 //restore ppage from stack
nop
rti
}
}
OS_STK *OSTaskStkInit(void (*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt)
{
INT16U *stk;
stk = (INT16U *)ptos; // Load stack pointer
*--stk = opt; // opt There is one byte blank
*--stk = (INT16U)(task); // PC for use of opt in task
*--stk = (INT16U)(task); // PC
*--stk = (INT16U)(0x1122); // Y
*--stk = (INT16U)(0x3344); // X
((INT8U *)stk)--; // Only one byte needed for A
*(INT8U *)stk = (INT8U)(((INT16U)pdata)>>8); // A
((INT8U *)stk)--; // Only one byte needed for B
*(INT8U *)stk = (INT8U)(pdata); // B
((INT8U *)stk)--; // Only one byte needed for CCR
*(INT8U *)stk = (INT8U)(0x00); // CCR
((INT8U *)stk)--; // Only one byte needed for PPAGE
*(INT8U *)stk = *(INT8U *)pdata; // PPAGE
return ((OS_STK *)stk);
}
/*$PAGE*/
/******************************************
* START HIGHEST PRIORITY TASK READY-TO-RUN
*******************************************/
void OSStartHighRdy(void)
{
OSTaskSwHook(); // Call Hook function
asm{
ldx OSTCBCur // Load the value in OSTCBCur or the TCB's address to x
lds 0,x // Load the value pointed by OSTCBCur to sp
ldaa OSRunning
inca // OSRunning = 1
staa OSRunning
pula
staa $30 //restore ppage from stack
nop
rti
}
}
/**********************************************
* INTERRUPT LEVEL CONTEXT SWITCH
**********************************************/
void OSIntCtxSw(void)
{
/* asm{
leas 4,sp // Adjust the sp
ldx OSTCBCur // Get the TCB's address
sts 0,x // Save the sp to TCB's first word
} */
OSTaskSwHook(); // Call Hook function
OSTCBCur = OSTCBHighRdy; // Change OSTCBCur and OSPrioCur
OSPrioCur = OSPrioHighRdy;
asm{
ldx OSTCBCur // Get the new task's TCB's address
lds 0,x // Load the new task's sp to sp register from its TCB
pula
staa $30 //restore ppage from stack
nop
rti
}
}
/*******************************************
* TASK LEVEL CONTEXT SWITCH
******************************************/
void OSCtxSw(void)
{
asm{
ldaa $30 //save ppage to stack
psha
ldx OSTCBCur // Get the TCB's address
sts 0,x // Save the sp to TCB's first word
}
OSTaskSwHook(); // Call Hook function
OSTCBCur = OSTCBHighRdy; // Change OSTCBCur and OSPrioCur
OSPrioCur = OSPrioHighRdy;
asm{
ldx OSTCBCur // Get the new task's TCB's address
lds 0,x // Load the new task's sp to sp register from its TCB
pula
staa $30 //restore ppage from stack
nop
rti
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -