📄 ds.c
字号:
/************************************************************************/
/* */
/* FUNCTION "DS_Reset_Performance_Timer" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to reset a timer to an intial state. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* NU_Reset_Performance_Timer Reset a performance timer */
/* */
/* ROUTINES CALLED */
/* */
/* None */
/* */
/* INPUTS */
/* */
/* task_id The task ID of the timer */
/* timer_id The ID of the timer */
/* */
/* OUTPUTS */
/* */
/* The task timer is reset */
/* */
/************************************************************************/
void DS_Reset_Performance_Timer(signed int task_id, signed int timer_id)
{
struct DS_TIMER_INFO_STRUCT
*timer_ptr; /* Pointer to the timer info*/
signed int ones = -1; /* All ones used for min val*/
/* Build a pointer to the timer. */
switch (timer_id)
{
case NU_EXECUTION_TIME_TIMER:
/* Build a pointer to the execution timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_execution_timer;
break;
case NU_SUSPENSION_TIME_TIMER:
/* Build a pointer to the suspension timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_suspended_timer;
break;
case NU_READY_WAIT_TIME_TIMER:
/* Build a pointer to the ready but waiting timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_readywait_timer;
break;
case NU_USER_TIMER_1:
/* Build a pointer to the user's frist timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_user_timer_1;
break;
case NU_USER_TIMER_2:
/* Build a pointer to the user's second timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_user_timer_2;
break;
case NU_USER_TIMER_3:
/* Build a pointer to the user's third timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_user_timer_3;
break;
default:
/* Never gets here. */
timer_ptr = NU_NULL;
}
/* Now reset the fields of the timer. */
timer_ptr -> ds_max_time = 0;
timer_ptr -> ds_min_time = (unsigned int) ones;
timer_ptr -> ds_timer_stat = DS_TIMER_NOT_STARTED;
timer_ptr -> ds_accum_time = 0;
timer_ptr -> ds_accum_count = 0;
timer_ptr -> ds_timer_start = 0;
} /* DS_Reset_Performance_Timer */
/************************************************************************/
/* */
/* FUNCTION "DS_Retrieve_Performance_Info" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to retrieve information from a specific */
/* performance timer structure. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* NU_Retrieve_Performance_Info Retrieve performance info */
/* */
/* ROUTINES CALLED */
/* */
/* None */
/* */
/* INPUTS */
/* */
/* task_id The task ID of the timer */
/* timer_id The ID of the timer */
/* Addresses of outputs */
/* */
/* OUTPUTS */
/* */
/* max_time Maximum time delta */
/* min_time Minimum time delta */
/* accum_time Accumulated delta times */
/* accum_count Accumulated delta count */
/* */
/************************************************************************/
void DS_Retrieve_Performance_Info(signed int task_id, signed int timer_id,
unsigned int *max_time, unsigned int *min_time,
unsigned int *accum_time, unsigned int *accum_count)
{
struct DS_TIMER_INFO_STRUCT
*timer_ptr; /* Pointer to the timer info*/
/* Build a pointer to the timer. */
switch (timer_id)
{
case NU_EXECUTION_TIME_TIMER:
/* Build a pointer to the execution timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_execution_timer;
break;
case NU_SUSPENSION_TIME_TIMER:
/* Build a pointer to the suspension timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_suspended_timer;
break;
case NU_READY_WAIT_TIME_TIMER:
/* Build a pointer to the ready but waiting timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_readywait_timer;
break;
case NU_USER_TIMER_1:
/* Build a pointer to the user's frist timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_user_timer_1;
break;
case NU_USER_TIMER_2:
/* Build a pointer to the user's second timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_user_timer_2;
break;
case NU_USER_TIMER_3:
/* Build a pointer to the user's third timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_user_timer_3;
break;
default:
/* Never gets here. */
timer_ptr = NU_NULL;
}
/* Now retrieve the fields of the timer. */
*max_time = timer_ptr -> ds_max_time;
*min_time = timer_ptr -> ds_min_time;
*accum_time= timer_ptr -> ds_accum_time;
*accum_count=timer_ptr -> ds_accum_count;
} /* DS_Retrieve_Performance_Info */
/************************************************************************/
/* */
/* FUNCTION "DS_Start_Performance_Timer" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function starts a performance timer. The time between */
/* invocation of this routine and the DS_Stop_Performance_Timer */
/* routine is the time measurment. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* NU_Start_Performance_Timer Start performance timer */
/* */
/* ROUTINES CALLED */
/* */
/* CLD_Read_Clock Read system clock */
/* */
/* INPUTS */
/* */
/* task_id The task ID of the timer */
/* timer_id The ID of the timer */
/* */
/* OUTPUTS */
/* */
/* return(status) */
/* */
/************************************************************************/
signed int DS_Start_Performance_Timer(signed int task_id, signed int timer_id)
{
signed int status; /* Return status of call */
struct DS_TIMER_INFO_STRUCT
*timer_ptr; /* Pointer to the timer info*/
/* Build a pointer to the timer. */
switch (timer_id)
{
case NU_EXECUTION_TIME_TIMER:
/* Build a pointer to the execution timer for this task. */
timer_ptr = &DS_Timer_List[task_id].ds_execution_timer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -