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

📄 probe_com.c

📁 uCOS-II V2.84 LM3S6965 TCPIP Demo
💻 C
📖 第 1 页 / 共 5 页
字号:
/*
*********************************************************************************************************
*                                      uC/Probe Communication
*
*                           (c) Copyright 2007; Micrium, Inc.; Weston, FL
*
*               All rights reserved.  Protected by international copyright laws.
*               Knowledge of the source code may NOT be used to develop a similar product.
*               Please help us continue to provide the Embedded community with the finest
*               software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*                                              uC/Probe
*
*                                      Communication: Generic
*
* Filename      : probe_com.c
* Version       : V1.20
* Programmer(s) : Brian Nagel
* Note(s)       : (1) This file contains code to respond to generic (non protocol-dependent)
*                     commands received by the target.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                             INCLUDE FILES
*********************************************************************************************************
*/

#define   PROBE_COM_GLOBALS
#include  <probe_com.h>


/*
*********************************************************************************************************
*                                             COMMANDS
*
* Note(s):  (1) The first word in all TX data segments is identical:
*
*                   (A)  A 2-byte format;
*                   (B)  A 1-byte status;
*                   (C)  A 1-byte modifier, currently unused.
*
*
*           (2) The first two bytes in all RX data segments is identical:
*                   (A)  A 2-byte format;
*
*           (3) The following data formats are currently defined:
*
*                   (A)  PROBE_COM_FMT_?X_QUERY.  The RX request queries the target about a particular
*                        setup parameter or capability.
*
*                   (B)  PROBE_COM_FMT_?X_SIMPLE_RD.  The RX request instructs the target to send
*                        data read from its memory, for a certain {memory address, data length} pair
*                        (which is given in the request).
*
*                   (C)  PROBE_COM_FMT_?X_SIMPLE_WR.  The RX request instructs the target to
*                        write certain data into its memory, for a certain {memory address, data length,
*                        data} triplet (which is given in the request).
*
*                   (D)  PROBE_COM_FMT_?X_MULTIPLE_RD.  The RX request instructs the target to send
*                        data read from its memory, for a certain set of {memory address, data length}
*                        pairs (which are given in the request).
*
*                   (E)  PROBE_COM_FMT_?X_STR_GET.  The RX request instructs the target to
*                        return a string that the user has stored in the target's string buffer.
*
**********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                            LOCAL DEFINES
*********************************************************************************************************
*/
                                                                /* --------------------- DATA FORMATS --------------------- */
#define  PROBE_COM_FMT_TX_ERROR               0x8000

#define  PROBE_COM_FMT_RX_QUERY               0x0001
#define  PROBE_COM_FMT_TX_QUERY               0x8001

#define  PROBE_COM_FMT_RX_SIMPLE_RD           0x0002
#define  PROBE_COM_FMT_TX_SIMPLE_RD           0x8002

#define  PROBE_COM_FMT_RX_SIMPLE_WR           0x0003
#define  PROBE_COM_FMT_TX_SIMPLE_WR           0x8003

#define  PROBE_COM_FMT_RX_MULTIPLE_RD         0x0007
#define  PROBE_COM_FMT_TX_MULTIPLE_RD         0x8007

#define  PROBE_COM_FMT_TX_MULTIPLE_RD_LO        0x07
#define  PROBE_COM_FMT_TX_MULTIPLE_RD_HI        0x80

#define  PROBE_COM_FMT_RX_STR_GET             0x0009
#define  PROBE_COM_FMT_TX_STR_GET             0x8009

                                                                /* ------------------- STATUS CONSTANTS ------------------- */
#define  PROBE_COM_STATUS_OK                    0x01
#define  PROBE_COM_STATUS_STR_NONE              0xF8
#define  PROBE_COM_STATUS_UNKNOWN_REQUEST       0xF9
#define  PROBE_COM_STATUS_QUERY_NOT_SUPPORTED   0xFC
#define  PROBE_COM_STATUS_TX_PKT_TOO_LARGE      0xFD
#define  PROBE_COM_STATUS_RX_PKT_WRONG_SIZE     0xFE
#define  PROBE_COM_STATUS_FAIL                  0xFF

                                                                /* ------------------------ QUERIES ----------------------- */
#define  PROBE_COM_QUERY_MAX_RX_SIZE          0x0101
#define  PROBE_COM_QUERY_MAX_TX_SIZE          0x0102

#define  PROBE_COM_QUERY_FMT_SUPPORT          0x1001

#define  PROBE_COM_QUERY_LIST_NUM_LISTS       0x1101
#define  PROBE_COM_QUERY_LIST_LIST_LENGTH     0x1102

                                                                /* ----------------------- MODIFIERS ---------------------- */
#define  PROBE_COM_MODIFIER_NONE                0x00
#define  PROBE_COM_MODIFIER_STR_HAVE            0x01


/*
*********************************************************************************************************
*                                           LOCAL CONSTANTS
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                          LOCAL DATA TYPES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                            LOCAL TABLES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                       LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/

#if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
static  CPU_INT32U              ProbeComStrBufWrIx;
static  CPU_INT32U              ProbeComStrBufRdIx;
static  CPU_CHAR                ProbeComStrBuf[PROBE_COM_STR_BUF_SIZE];
#endif


/*
*********************************************************************************************************
*                                      LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/

                                                                /* ------------ PROCESS REQUEST & FORM RESPONSE ----------- */
static  CPU_INT08U  ProbeCom_PktModifier    (void);

static  CPU_INT16U  ProbeCom_CmdError       (CPU_INT08U  *tx_buf, CPU_INT16U com_error);
static  CPU_INT16U  ProbeCom_CmdQuery       (CPU_INT08U  *rx_buf, CPU_INT08U *tx_buf, CPU_INT16U  rx_pkt_sz, CPU_INT16U  tx_buf_sz);
static  CPU_INT16U  ProbeCom_CmdSimpleRd    (CPU_INT08U  *rx_buf, CPU_INT08U *tx_buf, CPU_INT16U  rx_pkt_sz, CPU_INT16U  tx_buf_sz);
#if (PROBE_COM_SUPPORT_WR == DEF_TRUE)
static  CPU_INT16U  ProbeCom_CmdSimpleWr    (CPU_INT08U  *rx_buf, CPU_INT08U *tx_buf, CPU_INT16U  rx_pkt_sz, CPU_INT16U  tx_buf_sz);
#endif
static  CPU_INT16U  ProbeCom_CmdMultipleRd  (CPU_INT08U  *rx_buf, CPU_INT08U *tx_buf, CPU_INT16U  rx_pkt_sz, CPU_INT16U  tx_buf_sz);
#if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
static  CPU_INT16U  ProbeCom_CmdStrGet      (CPU_INT08U  *rx_buf, CPU_INT08U *tx_buf, CPU_INT16U  rx_pkt_sz, CPU_INT16U  tx_buf_sz);
#endif

                                                                /* ------------------ READ FROM RX PACKET ----------------- */
static  CPU_INT08U  ProbeCom_GetINT8U       (CPU_INT08U **buf);
static  CPU_INT16U  ProbeCom_GetINT16U      (CPU_INT08U **buf);
static  CPU_INT32U  ProbeCom_GetINT32U      (CPU_INT08U **buf);

                                                                /* ------------------- WRITE TO TX BUFFER ----------------- */
static  void        ProbeCom_StoINT8U       (CPU_INT08U **buf,    CPU_INT08U  data);
static  void        ProbeCom_StoINT16U      (CPU_INT08U **buf,    CPU_INT16U  data);
static  void        ProbeCom_StoINT32U      (CPU_INT08U **buf,    CPU_INT32U  data);

                                                                /* -------- DETERMINE IF STRING IS IN STRING BUFFER ------- */
#if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
static  CPU_BOOLEAN ProbeCom_StrRdy         (void);
#endif


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


/*
*********************************************************************************************************
*********************************************************************************************************
**                                          Global Functions
*********************************************************************************************************
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                Initialize uC/Probe Communication Module
*
* Description: This function initializes the module.
*
* Argument(s): None
*
* Returns    : None
*********************************************************************************************************
*/

void  ProbeCom_Init (void)
{
#if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
    ProbeComStrBufWrIx = 0;
    ProbeComStrBufRdIx = 0;

    ProbeCom_OS_Init();
#endif

#if (PROBE_COM_STAT_EN == DEF_ENABLED)
    ProbeCom_RxPktCtr     = 0;
    ProbeCom_TxPktCtr     = 0;
    ProbeCom_TxSymByteCtr = 0;
    ProbeCom_TxSymCtr     = 0;
    ProbeCom_ErrPktCtr    = 0;

#if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
    ProbeCom_TxStrCtr     = 0;
#endif
#endif
}


/*
*********************************************************************************************************
*                                         Parse Receive Packet
*
* Description: This routine is called after a complete packet has been received.
*
* Argument(s): None.

⌨️ 快捷键说明

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