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

📄 probe_com.c

📁 lpc2478+ucosII+ucgui源码
💻 C
📖 第 1 页 / 共 5 页
字号:

static  void         ProbeCom_StoINT08U       (CPU_INT08U     **pbuf,
                                               CPU_INT08U       data);

static  void         ProbeCom_StoINT16U       (CPU_INT08U     **pbuf,
                                               CPU_INT16U       data);

#if 0
static  void         ProbeCom_StoINT32U       (CPU_INT08U     **pbuf,
                                               CPU_INT32U       data);
#endif

                                                                /* -------------- DETERMINE PKT MODIFIER -------------- */
#if (PROBE_COM_CFG_STR_REQ_EN == DEF_ENABLED)
static  CPU_BOOLEAN  ProbeCom_StrOutAvail     (void);
#endif


#if (PROBE_COM_CFG_TERMINAL_REQ_EN == DEF_ENABLED)
static  CPU_BOOLEAN  ProbeCom_TerminalOutAvail(void);

static  CPU_BOOLEAN  ProbeCom_TerminalExecDone(void);
#endif


/*
*********************************************************************************************************
*                                     LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                           ProbeCom_Init()
*
* Description : Initialize the module.
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : Application.
*
* Note(s)     : none.
*********************************************************************************************************
*/

void  ProbeCom_Init (void)
{
#if (PROBE_COM_CFG_STR_REQ_EN      == DEF_ENABLED)
    Mem_Clr((void     *)&ProbeCom_StrInBufData[0],
            (CPU_SIZE_T) PROBE_COM_CFG_STR_IN_BUF_SIZE);

    ProbeCom_BufInit(&ProbeCom_StrInBuf,
                     &ProbeCom_StrInBufData[0],
                      PROBE_COM_CFG_STR_IN_BUF_SIZE);

    Mem_Clr((void     *)&ProbeCom_StrOutBufData[0],
            (CPU_SIZE_T) PROBE_COM_CFG_STR_OUT_BUF_SIZE);

    ProbeCom_BufInit(&ProbeCom_StrOutBuf,
                     &ProbeCom_StrOutBufData[0],
                      PROBE_COM_CFG_STR_OUT_BUF_SIZE);
#endif


#if (PROBE_COM_CFG_TERMINAL_REQ_EN == DEF_ENABLED)
    ProbeCom_TerminalExecHandler   = (void        *)0;
    ProbeCom_TerminalExecuting     = (CPU_BOOLEAN  )DEF_NO;

    ProbeCom_TerminalInHandler     = (void        *)0;

    ProbeCom_TerminalOutBufPtr     = (CPU_INT08U  *)0;
    ProbeCom_TerminalOutBufIx      = (CPU_SIZE_T   )0;
    ProbeCom_TerminalOutBufLen     = (CPU_SIZE_T   )0;

    ProbeCom_OS_Init();
#endif


#if (PROBE_COM_CFG_STAT_EN         == DEF_ENABLED)
    ProbeCom_RxPktCtr              =  0;
    ProbeCom_TxPktCtr              =  0;

    ProbeCom_TxSymCtr              =  0;
    ProbeCom_TxSymByteCtr          =  0;
    ProbeCom_ErrPktCtr             =  0;

#if (PROBE_COM_CFG_STR_REQ_EN      == DEF_ENABLED)
    ProbeCom_StrRxCtr              =  0;
    ProbeCom_StrRxOvfErrCtr        =  0;

    ProbeCom_StrTxCtr              =  0;
    ProbeCom_StrTxOvfErrCtr        =  0;
#endif

#if (PROBE_COM_CFG_WR_REQ_EN       == DEF_ENABLED)
    ProbeCom_RxSymCtr              =  0;
    ProbeCom_RxSymByteCtr          =  0;
#endif
#endif

    ProbeCom_EndiannessTest        =  0x12345678L;
}


/*
*********************************************************************************************************
*                                          ProbeCom_StrRd()
*
* Description : Read input data.
*
* Argument(s) : pdest       Pointer to the destination buffer.
*
*               len         Length of the destination buffer, in octets/characters.
*
* Return(s)   : Number of octets/characters read.
*
* Caller(s)   : Application.
*
* Note(s)     : (1) This function implements a non-blocking read.  It will read as much data as fits
*                   into the buffer, up to 'len' bytes/characters.  The calling application should
*                   monitor the return value to see if more data needs to be read.
*
*               (2) Since this function never blocks, it should not be called in a tight loop without a
*                   delay.
*
*               (3) This function MAY be called from an ISR.
*********************************************************************************************************
*/

#if (PROBE_COM_CFG_STR_REQ_EN == DEF_ENABLED)
CPU_SIZE_T  ProbeCom_StrRd (CPU_INT08U  *pdest,
                            CPU_SIZE_T   len)
{
    CPU_SIZE_T  len_rd;


    len_rd = ProbeCom_BufRd(&ProbeCom_StrInBuf,
                             pdest,
                             len);

    return (len_rd);
}
#endif


/*
*********************************************************************************************************
*                                          ProbeCom_StrWr()
*
* Description : Write or buffer data for output.
*
* Argument(s) : psrc        Pointer to the source buffer.
*
*               len         Length of the source buffer, in octets/characters.
*
* Return(s)   : Number of octets/characters written or buffered.
*
* Caller(s)   : Application.
*
* Note(s)     : (1) This function implements a non-blocking write.  It will write as much data as fits
*                   into the buffer, up to 'len' bytes/characters.  The calling application should
*                   monitor the return value to see if more data from the buffer needs to be written.
*
*               (2) Since this function never blocks, it should not be called in a tight loop without a
*                   delay.
*
*               (3) This function MAY be called from an ISR.
*********************************************************************************************************
*/

#if (PROBE_COM_CFG_STR_REQ_EN == DEF_ENABLED)
CPU_SIZE_T  ProbeCom_StrWr (CPU_INT08U  *psrc,
                            CPU_SIZE_T   len)
{
    CPU_SIZE_T  len_wr;


    len_wr = ProbeCom_BufWr(&ProbeCom_StrOutBuf,
                             psrc,
                             len);

#if (PROBE_COM_CFG_STAT_EN == DEF_ENABLED)
    if (len_wr < len) {
        ProbeCom_StrTxOvfErrCtr++;
    }
#endif

    return (len_wr);
}
#endif


/*
*********************************************************************************************************
*                                       ProbeCom_TerminalOut()
*
* Description : Output data over terminal.
*
* Argument(s) : psrc        Pointer to the source buffer.
*
*               len         Length of source buffer, in octets/characters.
*
* Return(s)   : Number of octets/characters output.
*
* Caller(s)   : Application.
*
* Note(s)     : (1) This function implements a blocking write.  It will queue the request and wait until
*                   all of the data has been buffered or transmitted before returning.
*
*               (2) Terminal data may ONLY be output while a command is being executed.
*
*                   (a) Generic read/write functionality is provided by the string read/write functions
*                       (see 'ProbeCom_StrRd()', 'ProbeCom_StrWr()').
*
*               (3) This function MUST NOT be called from an ISR.
*********************************************************************************************************
*/

#if (PROBE_COM_CFG_TERMINAL_REQ_EN == DEF_ENABLED)
CPU_SIZE_T  ProbeCom_TerminalOut (CPU_INT08U  *psrc,
                                  CPU_SIZE_T   len)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR  cpu_sr;
#endif


                                                                /* ------------------- VALIDATE ARGS ------------------ */
    if (psrc == (CPU_INT08U *)0) {                              /* Validate NULL ptr.                                   */
        return ((CPU_SIZE_T)0);
    }

    if (len == (CPU_INT08U)0) {                                 /* Validate NULL len.                                   */
        return ((CPU_SIZE_T)0);
    }



                                                                /* ------------------- START OUTPUT ------------------- */
    CPU_CRITICAL_ENTER();
    if (ProbeCom_TerminalExecuting == DEF_NO) {                 /* Chk if cmd exec'ing.                                 */
        return ((CPU_SIZE_T)0);
    }

    if (ProbeCom_TerminalOutBufPtr != (CPU_INT08U *)0) {        /* Chk if out in progress.                              */
        return ((CPU_SIZE_T)0);
    }

    ProbeCom_TerminalOutBufPtr = (CPU_INT08U *)psrc;            /* Schedule output.                                     */
    ProbeCom_TerminalOutBufIx  = (CPU_SIZE_T  )0;
    ProbeCom_TerminalOutBufLen = (CPU_SIZE_T  )len;

    ProbeCom_OS_TerminalOutWait();                              /* Wait for output completion.                          */

    ProbeCom_TerminalOutBufPtr = (CPU_INT08U *)0;
    ProbeCom_TerminalOutBufIx  = (CPU_SIZE_T  )0;
    ProbeCom_TerminalOutBufLen = (CPU_SIZE_T  )0;
    CPU_CRITICAL_EXIT();



                                                                /* ----------------------- RTN ------------------------ */
    return (len);
}
#endif


/*
*********************************************************************************************************
*                                   ProbeCom_TerminalExecComplete()
*
* Description : Signal completion of command execution.
*
* Argument(s) : none.
*
* Return(s)   : The number of bytes in the data segment of the packet to transmit in response.
*
* Caller(s)   : Application.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#if (PROBE_COM_CFG_TERMINAL_REQ_EN == DEF_ENABLED)
void  ProbeCom_TerminalExecComplete (void)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR       cpu_sr;
#endif
    CPU_BOOLEAN  executing;


    CPU_CRITICAL_ENTER();
    executing = ProbeCom_TerminalExecuting;
    if (executing == DEF_YES) {
        ProbeCom_TerminalExecuting = DEF_NO;
    }
    CPU_CRITICAL_EXIT()
}

⌨️ 快捷键说明

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