📄 tms.c
字号:
#ifdef INCLUDE_PROVIEW _RTProf_DumpTimer(RT_PROF_DELETE_TIMER,timer,RT_PROF_FAIL);#endif } else { /* Clear the timer ID. */ timer -> tm_id = 0;#ifdef INCLUDE_PROVIEW _RTProf_DumpTimer(RT_PROF_DELETE_TIMER,timer,RT_PROF_OK);#endif /* INCLUDE_PROVIEW */ } /* Release protection. */ TCT_Unprotect(); /* Determine if an error was detected. */ if (status == NU_SUCCESS) { /* Protect against access to the list of created timers. */ TCT_Protect(&TMD_Created_List_Protect); /* Remove the timer from the list of created timers. */ CSC_Remove_From_List(&TMD_Created_Timers_List, &(timer -> tm_created)); /* Decrement the total number of created timers. */ TMD_Total_Timers--; /* Release protection against access to the list of created timers. */ TCT_Unprotect(); } /* Return to user mode */ NU_USER_MODE(); /* Return completion status. */ return(status);}/*************************************************************************//* *//* FUNCTION *//* *//* TMS_Reset_Timer *//* *//* DESCRIPTION *//* *//* This function resets the specified application timer. Note that *//* the timer must be in a disabled state prior to this call. The *//* timer is activated after it is reset if the enable parameter *//* specifies automatic activation. *//* *//* CALLED BY *//* *//* Application *//* TMSE_Reset_Timer Error checking shell *//* *//* CALLS *//* *//* [HIC_Make_History_Entry] Make entry in history log *//* [TCT_Check_Stack] Stack checking function *//* TCT_System_Protect Protect active list *//* TCT_Unprotect Release protection *//* TMS_Control_Timer Enable/disable timer *//* *//* INPUTS *//* *//* timer_ptr Timer control block pointer *//* expiration_routine Timer expiration routine *//* initial_time Initial expiration time *//* reschedule_time Reschedule expiration time *//* enable Automatic enable option *//* *//* OUTPUTS *//* *//* NU_NOT_DISABLED Timer not disabled first *//* NU_SUCCESS Successful completion *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Modified protection logic to use *//* system protection, changed *//* function prototype, resulting *//* in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/STATUS TMS_Reset_Timer(NU_TIMER *timer_ptr, VOID (*expiration_routine)(UNSIGNED), UNSIGNED initial_time, UNSIGNED reschedule_time, OPTION enable){R1 TM_APP_TCB *timer; /* Timer control block ptr */STATUS status; /* Completion status */NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* Move input timer pointer into internal pointer. */ timer = (TM_APP_TCB *) timer_ptr;#ifdef NU_ENABLE_STACK_CHECK /* Call stack checking function to check for an overflow condition. */ TCT_Check_Stack();#endif#ifdef NU_ENABLE_HISTORY /* Make an entry that corresponds to this function in the system history log. */ HIC_Make_History_Entry(NU_RESET_TIMER_ID, (UNSIGNED) timer, (UNSIGNED) expiration_routine, (UNSIGNED) initial_time);#endif /* Protect against access to the active timer list. */ TCT_System_Protect(); /* Determine if this timer is active. An active timer cannot be reset. */ if (timer -> tm_enabled) { /* Indicate that the timer is active by returning the proper status. */ status = NU_NOT_DISABLED;#ifdef INCLUDE_PROVIEW _RTProf_DumpTimer(RT_PROF_RESET_TIMER,timer,RT_PROF_FAIL);#endif /* INCLUDE_PROVIEW */ } else { /* Load the timer with the appropriate values. */ timer -> tm_expiration_routine = expiration_routine; timer -> tm_expirations = 0; timer -> tm_initial_time = initial_time; timer -> tm_reschedule_time = reschedule_time; /* Indicate successful completion status. */ status = NU_SUCCESS;#ifdef INCLUDE_PROVIEW _RTProf_DumpTimer(RT_PROF_RESET_TIMER,timer,RT_PROF_OK);#endif /* INCLUDE_PROVIEW */ } /* Release protection. */ TCT_Unprotect(); /* Determine if the timer needs to be enabled. */ if ((status == NU_SUCCESS) && (enable == NU_ENABLE_TIMER)) /* Activate the timer. */ TMS_Control_Timer(timer_ptr, NU_ENABLE_TIMER); /* Return to user mode */ NU_USER_MODE(); /* Return completion status. */ return(status);}/*************************************************************************//* *//* FUNCTION *//* *//* TMS_Control_Timer *//* *//* DESCRIPTION *//* *//* This function either enables or disables the specified timer. *//* If the timer is already in the desired state, simply leave it *//* alone. *//* *//* CALLED BY *//* *//* Application *//* TMSE_Control_Timer Error checking shell *//* *//* CALLS *//* *//* [HIC_Make_History_Entry] Make entry in history log *//* [TCT_Check_Stack] Stack checking function *//* TCT_System_Protect Protect the active list *//* TCT_Unprotect Release protection *//* TMC_Start_Timer Start a timer *//* TMC_Stop_Timer Stop a timer *//* *//* INPUTS *//* *//* app_timer Timer control block pointer *//* enable Disable/enable timer option *//* *//* OUTPUTS *//* *//* NU_SUCCESS If service is successful *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Modified protection logic to use *//* system protection, changed *//* function prototype, resulting *//* in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/STATUS TMS_Control_Timer(NU_TIMER *app_timer, OPTION enable){R1 TM_APP_TCB *timer; /* Timer control block ptr */TM_TCB *timer_ptr; /* Actual timer pointer */UNSIGNED time; /* Variable to hold request */NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* Move input timer pointer into internal pointer. */ timer = (TM_APP_TCB *) app_timer;#ifdef NU_ENABLE_STACK_CHECK /* Call stack checking function to check for an overflow condition. */ TCT_Check_Stack();#endif#ifdef NU_ENABLE_HISTORY /* Make an entry that corresponds to this function in the system history log. */ HIC_Make_History_Entry(NU_CONTROL_TIMER_ID, (UNSIGNED) timer, (UNSIGNED) enable, (UNSIGNED) 0);#endif /* Protect against simultaneous access to the active timer list. */ TCT_System_Protect(); /* Setup pointer to actual timer part of the control block. */ timer_ptr = &(timer -> tm_actual_timer); /* Determine what type of request is present. */ if ((enable == NU_ENABLE_TIMER) && (!timer -> tm_enabled)) { /* Enable timer request is present and timer is currently disabled. */ /* Determine how to setup the remaining field in the actual timer. */ if (timer -> tm_expirations) /* Use reschedule time since this timer has expired previously. */ time = timer -> tm_reschedule_time; else /* Use initial time since this timer has never expired. */ time = timer -> tm_initial_time; /* Mark the application timer as enabled. */ timer -> tm_enabled = NU_TRUE; /* Call the start timer routine to actually start the timer. */ TMC_Start_Timer(&(timer -> tm_actual_timer), time); } else if ((enable == NU_DISABLE_TIMER) && (timer -> tm_enabled)) { /* Disable timer request is present and timer is currently enabled. */ TMC_Stop_Timer(timer_ptr); /* Mark the timer as disabled. */ timer -> tm_enabled = NU_FALSE; }#ifdef INCLUDE_PROVIEW _RTProf_DumpTimer(RT_PROF_CONTROL_TIMER,timer,RT_PROF_OK);#endif /* INCLUDE_PROVIEW */ /* Release protection. */ TCT_Unprotect(); /* Return to user mode */ NU_USER_MODE(); /* Return the completion status. */ return(NU_SUCCESS);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -