void _OS_InitDelay (OS_TTIMER_TYPE Delay) { char temp; temp = 0; // This variable used to prevent FSR changing if (Delay) temp = 1; // when checking Delay after FSR set to task->Timer // See "if (temp & 1)" below _OS_SET_FSR_CUR_TASK(); _OS_bTaskCanContinue = 0; _OS_bTaskDelay = 0; // Clear bDelay to prevent timer changing in interrupt if (temp & 1) { Delay ^= -1; Delay ++; _OS_CurTask->Timer = Delay; _OS_SET_FSR_CUR_TASK(); _OS_bTaskDelay = 1; _OS_bTaskReady = 1; } }
void _OS_JumpToTask (void) { _OS_STORE_SP(); _OS_Restore_TaskSP(); _OS_SET_FSR_CUR_TASK(); _OS_SET_PC(); }
void _OS_ReturnSave (void) { _OS_SET_FSR_CUR_TASK(); _OS_SAVE_PC(); _OS_Store_TaskSP(); _OS_bTaskReady = 1; _OS_RESTORE_SP(); }
void _OS_ClrReadySetClrCanContinue (void) { _OS_SET_FSR_CUR_TASK(); _OS_SAVE_PC(); _OS_PUSH(); _OS_Store_TaskSP2(); _OS_Flags.bEventError = 0; _OS_bTaskReady = 0; #if defined(OS_ENABLE_TTIMERS) if (!_OS_bTaskDelay) _OS_bTaskCanContinue = 0; if (_OS_Temp & 0x01) _OS_bTaskCanContinue = 1; #endif }
void _OS_InitDelay (OS_TTIMER_TYPE Delay) { _OS_bTaskCanContinue = 0; _OS_bTaskDelay = 0; _OS_CurTask->State = _OS_State; // Clear bDelay to prevent timer changing in interrupt if (Delay) { Delay = -Delay; _OS_CurTask->Timer = Delay; _OS_SET_FSR_CUR_TASK(); _OS_bTaskDelay = 1; _OS_bTaskReady = 1; } _OS_CurTask->State = _OS_State; // Set flags Ready รจ Delay }
void _OS_JumpToTask (void) { _OS_SET_FSR_CUR_TASK(); (OS_RAM_NEAR char)_OS_State = _postinc; _OS_SET_PC(); }
void _OS_CheckEvent (OST_UINT bEvent) { //------------------------------------------------------------------------------ #if OS_PRIORITY_LEVEL == OS_PRIORITY_DISABLED //------------------------------------------------------------------------------ _OS_Flags.bTimeout = 0; _OS_SET_FSR_CUR_TASK(); if (bEvent) { #ifdef OS_ENABLE_TTIMERS _OS_bTaskDelay = 0; // Clear bDelay in temporary variable _OS_State #endif return; } #ifdef OS_ENABLE_TTIMERS if (_OS_bTaskTimeout && _OS_bTaskCanContinue) { _OS_Flags.bTimeout = 1; return; } #endif _PIC16E_POP(); //------------------------------------------------------------------------------ #else //------------------------------------------------------------------------------ _OS_Flags.bTimeout = 0; _OS_SET_FSR_CUR_TASK(); if (bEvent) { if (_OS_bTaskReady) { #ifdef OS_ENABLE_TTIMERS _OS_bTaskDelay = 0; // Clear bDelay in temporary variable _OS_State #endif #if OS_PRIORITY_LEVEL == OS_PRIORITY_EXTENDED _OS_Flags.bEventOK = 1; #endif return; } _OS_bTaskReady = 1; } else { _OS_bTaskReady = 0; } #ifdef OS_ENABLE_TTIMERS if (_OS_bTaskTimeout && _OS_bTaskCanContinue) { _OS_bTaskReady = 1; _OS_Flags.bTimeout = 1; #if OS_PRIORITY_LEVEL == OS_PRIORITY_EXTENDED _OS_Flags.bEventOK = 1; #endif return; } #endif _PIC16E_POP(); //------------------------------------------------------------------------------ #endif //------------------------------------------------------------------------------ }
void _OS_CheckEvent (void) { //------------------------------------------------------------------------------ #if OS_PRIORITY_LEVEL == OS_PRIORITY_DISABLED //------------------------------------------------------------------------------ _OS_Flags.bTimeout = 0; _OS_SET_FSR_CUR_TASK(); if (bEvent) { #ifdef OS_ENABLE_TTIMERS _OS_bTaskDelay = 0; #endif return; } #ifdef OS_ENABLE_TTIMERS if (_OS_bTaskTimeout && _OS_bTaskCanContinue) { _OS_Flags.bTimeout = 1; return; } #endif _OS_POP(); //------------------------------------------------------------------------------ #else //------------------------------------------------------------------------------ _OS_Flags.bTimeout = 0; _OS_SET_FSR_CUR_TASK(); if (bEvent) { if (_OS_bTaskReady) { #ifdef OS_ENABLE_TTIMERS _OS_bTaskDelay = 0; #endif #if OS_PRIORITY_LEVEL == OS_PRIORITY_EXTENDED _OS_Flags.bEventOK = 1; #endif return; } _OS_bTaskReady = 1; } else { _OS_bTaskReady = 0; } #ifdef OS_ENABLE_TTIMERS if (_OS_bTaskTimeout && _OS_bTaskCanContinue) { _OS_bTaskReady = 1; _OS_Flags.bTimeout = 1; #if OS_PRIORITY_LEVEL == OS_PRIORITY_EXTENDED _OS_Flags.bEventOK = 1; #endif return; } #endif _OS_POP(); //------------------------------------------------------------------------------ #endif //------------------------------------------------------------------------------ }