⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ds.c

📁 NecluesRTX RTOS的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
        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 get here.  */
        timer_ptr =  NU_NULL;
    }

    /* Determine the current state of the timer.  */
    if (timer_ptr -> ds_timer_stat == DS_TIMER_NOT_STARTED)
    {
    
        /* Mark the timer as started.  */
        timer_ptr -> ds_timer_stat =  DS_TIMER_STARTED;

        /* Now set the current time field of the timer.  */
        timer_ptr -> ds_timer_start =  CLD_Read_Clock();
        
        /* Set the status to successful.  */
        status =  NU_SUCCESS;
    }
    else
    {
    
        /* Set the status to NU_PER_TIMER_STARTED to indicate that the
           timer was already started.  */
        status =  NU_PER_TIMER_STARTED;
    }
    
    /* Return the status to the caller.  */
    return(status);
}                                           /* DS_Start_Performance_Timer */



/************************************************************************/
/*                                                                      */
/*  FUNCTION                              "DS_Stop_Performance_Timer"   */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function stops a performance timer.  The time between      */
/*      invocation of this routine and the DS_Start_Performance_Timer   */
/*      routine is the time measurment.                                 */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*       NU_Stop_Performance_Timer          Stop 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_Stop_Performance_Timer(signed int task_id, signed int timer_id)
{

signed int         status;                  /* The status of this call  */
struct DS_TIMER_INFO_STRUCT 
                  *timer_ptr;               /* Pointer to the timer info*/
unsigned int       delta;                   /* Delta between stop/start */


    /* 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 get here.  */
        timer_ptr =  NU_NULL;
    }

    /* Determine the current state of the timer.  */
    if (timer_ptr -> ds_timer_stat == DS_TIMER_STARTED)
    {
    
        /* Mark the timer as stopped.  */
        timer_ptr -> ds_timer_stat =  DS_TIMER_NOT_STARTED;

        /* Now update the fields of the timer.  */
        delta =  CLD_Read_Clock() - timer_ptr -> ds_timer_start;

        if (delta > timer_ptr -> ds_max_time)
            timer_ptr -> ds_max_time =  delta;
    
        if (delta < timer_ptr -> ds_min_time)
            timer_ptr -> ds_min_time =  delta;
     
        timer_ptr -> ds_accum_time =  timer_ptr -> ds_accum_time + delta;
        timer_ptr -> ds_accum_count++;
        
        /* Set the status to successful.  */
        status =  NU_SUCCESS;
    }
    else
    {
    
        /* Set the status to NU_PER_TIMER_STOPPED to indicate that the
           timer was already stopped.  */
        status =  NU_PER_TIMER_STOPPED;
    }
    
    /* Return the status to the caller.  */
    return(status);
}                                           /* end of DS_Stop_Timer     */


/* End of performance timer conditional compilation.  */
#endif


/* Conditional compile the history saving/retrieving routines.  */
#ifdef  NU_ENABLE_HISTORY

/************************************************************************/
/*                                                                      */
/*  FUNCTION                         "DS_Retrieve_Next_History_Entry"   */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function retrieves information from the next entry in      */
/*      the history log.                                                */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*       NU_Retrieve_Next_History_Entry     Get next history entry      */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      None                                                            */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*                                          Pointers to outputs         */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*      sequence                            The sequence of the event   */
/*                                             0 for the first envent   */
/*      event                               Event ID                    */
/*      param_1                             First parameter             */
/*      param_2                             Second parameter            */
/*      time                                Time of the event           */
/*      return(status)                                                  */
/*                                                                      */
/************************************************************************/
signed int  DS_Retrieve_Next_History_Entry(signed int *sequence,
             signed int *event, unsigned int *param_1, unsigned int *param_2,
             unsigned int *time)
{

signed int         status;                  /* Status of request        */

    /* Determine if the history has been turned off.  Otherwise the 
       request is invalid.  */
    if (DS_History_On == NU_FALSE) 
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -