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

📄 ds.c

📁 NecluesRTX RTOS的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
    
        /* Now determine if there is anything in the history log.  */
        if (DS_Hist_Index_Sav != DS_Hist_Index)
        {
        
            /* Retrieve the contents of the current read pointer and 
               sequence number.  */
            *sequence =  DS_Hist_Sequence;
            *event =     DS_History[DS_Hist_Index_Sav].ds_event_id;
            *param_1=    DS_History[DS_Hist_Index_Sav].ds_param_1;
            *param_2=    DS_History[DS_Hist_Index_Sav].ds_param_2;
            *time =      DS_History[DS_Hist_Index_Sav].ds_time;

            /* Increment both the read and sequence indices and check
               for wrap around.  */
            DS_Hist_Index_Sav++;
            DS_Hist_Sequence++;
        
            if (DS_Hist_Index_Sav >= DS_MAX_HISTORY_ENTRIES)
                DS_Hist_Index_Sav =  0;
        }
        else
        
            /* Indicate that the current history entry is invalid.  */
            *event =  NU_NO_EVENT;     

        /* Successful completion.  */
        status =  NU_SUCCESS;
    }    
    else
    
        /* History saving is still enabled, cannot retrieve.  */
        status =  NU_HISTORY_NOT_STOPPED;
        
    /* Return the status to the caller.  */
    return(status);
}                                         /* DS_Retrieve_Next_History_Entry */



/************************************************************************/
/*                                                                      */
/*  FUNCTION                                  "DS_Make_History_Entry"   */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function places information into the next entry in         */
/*      the history log.                                                */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*       NU_*                               Nucleus service routines    */
/*       SK*                                Scheduler routines          */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      CLD_Read_Clock                      Read system clock           */
/*      IND_Set_Interrupt_Level             Set interrupt lockouts      */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      event                               Event ID                    */
/*      param_1                             First parameter             */
/*      param_2                             Second parameter            */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*                                          Updated history log         */
/*                                                                      */
/************************************************************************/
void    DS_Make_History_Entry(signed int event, unsigned int param_1,
         unsigned int param_2)
{

int                old_interrupt_level;     /* Previous interrupt level */


    /* Determine if the history has been turned on.  Otherwise the 
       request is invalid.  */
    if (DS_History_On == NU_TRUE)
    {
    
        /* Lockout interrupts.  */
        old_interrupt_level =  IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);

        /* Save the input values in the appropriate place.  */
        DS_History[DS_Hist_Index].ds_event_id= event;
        DS_History[DS_Hist_Index].ds_param_1 = param_1;
        DS_History[DS_Hist_Index].ds_param_2 = param_2;
        DS_History[DS_Hist_Index].ds_time  =   CLD_Read_Clock();

        /* Increment both the index and check for wrap around.  */
        DS_Hist_Index++;
        
        if (DS_Hist_Index >= DS_MAX_HISTORY_ENTRIES)
            DS_Hist_Index =  0;

        /* Determine if the new history index is on top of the read index.
           If so, push the read index to the next location.  */
        if (DS_Hist_Index == DS_Hist_Index_Sav)
        {

            /* Increment the read index.  */
            DS_Hist_Index_Sav++;
            
            /* Check for a wrap condition on the read index.  */
            if (DS_Hist_Index_Sav >= DS_MAX_HISTORY_ENTRIES)
                DS_Hist_Index_Sav =  0;
        }
        
        /* Restore previous interrupt level.  */
        IND_Set_Interrupt_Level(old_interrupt_level);
    }    
}                                           /* DS_Make_History_Entry    */



/************************************************************************/
/*                                                                      */
/*  FUNCTION                                  "DS_Start_History_Saving" */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function turns on history saving after it has been         */
/*      disabled.                                                       */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*       NU_Start_History_Saving            Turn on history saving      */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      None                                                            */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      None                                                            */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*                                          Updated history on flag     */
/*      return(status)                      Status of request           */
/*                                                                      */
/************************************************************************/
signed int  DS_Start_History_Saving()

{

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)
    {
    
        /* Turn on History saving.  */
        DS_History_On =  NU_TRUE;
    
        /* Mark as successful.  */
        status =  NU_SUCCESS;
    }    
    else
    
        /* History saving is still enabled, request is invalid.  */
        status =  NU_HISTORY_NOT_STOPPED;
        
    /* Return the status to the caller.  */
    return(status);
}                                           /* DS_Start_History_Saving  */


/************************************************************************/
/*                                                                      */
/*  FUNCTION                                   "DS_Stop_History_Saving" */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function turns off history saving after it has been        */
/*      enabled.                                                        */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*       NU_Stop_History_Saving             Turn off history saving     */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      None                                                            */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      None                                                            */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*                                          Updated history on flag     */
/*      return(status)                      Status of request           */
/*                                                                      */
/************************************************************************/
signed int DS_Stop_History_Saving()

{

signed int         status;                  /* Status of request        */

    /* Determine if the history has been turned on.  Otherwise the 
       request is invalid.  */
    if (DS_History_On == NU_TRUE)
    {
    
        /* Turn off History saving.  */
        DS_History_On =  NU_FALSE;
    
        /* Mark as successful.  */
        status =  NU_SUCCESS;
    }    
    else
    
        /* History saving is not enabled, request is invalid.  */
        status =  NU_HISTORY_NOT_STARTED;
        
    /* Return the status to the caller.  */
    return(status);
}                                           /* DS_Start_History_Saving  */

/* End of conditional compilation unit for system history.  */
#endif

⌨️ 快捷键说明

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