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

📄 probe_com.c

📁 官方的UCOSii的移植文件
💻 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.30
* Programmer(s) : BAN
* 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>


/*
*********************************************************************************************************
*                                            LOCAL DEFINES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                             DATA FORMATS
*
* 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.
*
**********************************************************************************************************
*/

#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
*
* Note(s):  (1) The following status constants are currently defined:
*
*                   (A)  PROBE_COM_STATUS_OK.  The target was able to respond to the command.
*
*                   (B)  PROBE_COM_STATUS_STR_NONE.  A PROBE_COM_FMT_RX_STR_GET packet is received,
*                        but the target has no string to send.
*
*                   (C)  PROBE_COM_STATUS_QUERY_NOT_SUPPORTED.  A PROBE_COM_FMT_RX_QUERY packet is
*                        received, but the query is not supported.
*
*                   (D)  PROBE_COM_STATUS_TX_PKT_TOO_LARGE.  The response to the request would be too
*                        large to fit into the target.
*
*                   (E)  PROBE_COM_STATUS_RX_PKT_WRONG_SIZE.  The request packet is not the expected
*                        size.
*
*                   (F)  PROBE_COM_STATUS_FAIL.  Another error occurred.
*
**********************************************************************************************************
*/

#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
*
* Note(s):  (1) The following queries are currently defined:
*
*                   (A)  PROBE_COM_QUERY_MAX_RX_SIZE.  The target responds with the data size of the
*                        largest packet it can receive.
*
*                   (B)  PROBE_COM_QUERY_MAX_TX_SIZE.  The target responds with the data size of the
*                        largest packet it can send.
*
*                   (C)  PROBE_COM_ENDIANNESS_TEST.  The target responds with a 4-byte data value.  On
*                        little-endian CPUs, this will be received as 0x12345678; on big-endian CPUs,
*                        this will be received as 0x87654321.
*
*                   (D)  PROBE_COM_QUERY_FMT_SUPPORT.  The target responds with a list of the formats
*                        the target can respond to.
*
**********************************************************************************************************
*/

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

                                                                /* ------------------- TARGET PROPERTIES ------------------ */
#define  PROBE_COM_QUERY_ENDIANNESS_TEST      0x0201

                                                                /* --------------- COMMUNICATION CAPABILITIES ------------- */
#define  PROBE_COM_QUERY_FMT_SUPPORT          0x1001

/*
*********************************************************************************************************
*                                               MODIFIERS
*
* Note(s):  (1) The following modifiers are currently defined:
*
*                   (A)  PROBE_COM_MODIFIER_NONE.  This is the generic modifier.
*
*                   (B)  PROBE_COM_MODIFIER_STR_HAVE.  The target indicates that it has a string to
*                        transmit.
*
**********************************************************************************************************
*/

#define  PROBE_COM_MODIFIER_NONE                0x00
#define  PROBE_COM_MODIFIER_STR_HAVE            0x01

/*
*********************************************************************************************************
*                                               HEADER SIZES
*
* Note(s):  (1) Every RX packet has a 2-byte "header".
*
*           (2) Every TX packet has a 4-byte "header".
**********************************************************************************************************
*/

#define  PROBE_COM_SIZE_RX_HEADER                  2
#define  PROBE_COM_SIZE_TX_HEADER                  4

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


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


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


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

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

static  CPU_INT32U  ProbeComEndiannessTest;

/*
*********************************************************************************************************
*                                      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

⌨️ 快捷键说明

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