????д???????????????
???????????? ???????[ 2013/8/14 11:30:19 ] ????????
;/**************************************************************************************
;* ????????: OSIntCtxSw
;*
;* ????????: ?ж???????л?
;*
;* ?? ??: None
;*
;* ?? ?? ?: None
;***************************************************************************************/
OSIntCtxSw
PUSH {R4?? R5}
LDR R4?? =NVIC_INT_CTRL ;????PendSV?? (causes context switch)
LDR R5?? =NVIC_PENDSVSET
STR R5?? [R4]
POP {R4?? R5}
BX LR
NOP
;/**************************************************************************************
;* ????????: OSPendSV
;*
;* ????????: OSPendSV is used to cause a context switch.
;*
;* ?? ??: None
;*
;* ?? ?? ?: None
;***************************************************************************************/
PendSV_Handler
CPSID I ; Prevent interruption during context switch
MRS R0?? PSP ; PSP is process stack pointer ???????PSP???????????????????????ο?CM3????е?????-????
CBZ R0?? PendSV_Handler_Nosave ; Skip register save the first time
SUBS R0?? R0?? #0x20
STM R0?? {R4-R11} ; Save remaining regs r4-11 on process stack
LDR R1?? =OSCurTCB
LDR R1?? [R1]
STR R0?? [R1] ; R0 is SP of process being switched out
PendSV_Handler_Nosave
PUSH {R14} ; Save LR exc_return value
LDR R0?? =OSTaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0?? =OSCurTCB ;OSCurTCB=OSNewTCB;
LDR R1?? =OSNewTCB
LDR R2?? [R1]
STR R2?? [R0]
LDR R0?? [R2] ; R0 is new process SP; SP = OSCurTCB;
LDM R0?? {R4-R11} ; Restore r4-11 from new process stac
ADD R0?? R0?? #0x20
MSR PSP?? R0
ORR LR?? LR?? #0x04
CPSIE I ; Exception return will restore remaining context
BX LR
end
????????????????????????飺
typedef struct taskControlBlock
{
/*???????????*/
OS_STK *pStackTop;
/*????????*/
PRIO_TYPE CurPriority;
/*??????*/
uint8 TaskStat;
/*????????????*/
int32 TCBDelay;
} TCB;
/*??????е?????*/
TCB *OSCurTCB;
/*???????????е?????*/
TCB *OSNewTCB;
/*???OS?????е?????*/
uint8 TaskNUM=0;
TCB OSTCBTable[MAX_TASK_NUM];
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11