📄 tms.c
字号:
/* R. Pfaff - */
/* D. Lamie 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 */
/* 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;
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;
}
/* 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 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. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* 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 */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 03-01-1994 Modified protection logic to use */
/* system protection, changed */
/* function prototype, resulting */
/* in version 1.1 */
/* R. Pfaff - */
/* D. Lamie 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 */
/* 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;
}
/* Release protection. */
TCT_Unprotect();
/* Return the completion status. */
return(NU_SUCCESS);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -