// Config 0 (default) : EM2xx/EM3xx @ 115200 bps with RTS/CTS flow control
#define ASH_HOST_CONFIG_DEFAULT \
{ \
"/dev/ttyS0", /* serial port name */ \
115200, /* baud rate (bits/second) */ \
1, /* stop bits */ \
true, /* true enables RTS/CTS flow control, false XON/XOFF */ \
256, /* max bytes to buffer before writing to serial port */ \
256, /* max bytes to read ahead from serial port */ \
0, /* trace output control bit flags */ \
3, /* max frames sent without being ACKed (1-7) */ \
true, /* enables randomizing DATA frame payloads */ \
800, /* adaptive rec'd ACK timeout initial value */ \
400, /* " " " " " minimum value */ \
2400, /* " " " " " maximum value */ \
2500, /* time allowed to receive RSTACK after ncp is reset */ \
RX_FREE_LWM, /* if free buffers < limit, host receiver isn't ready */ \
RX_FREE_HWM, /* if free buffers > limit, host receiver is ready */ \
480, /* time until a set nFlag must be resent (max 2032) */ \
ASH_RESET_METHOD_RST, /* method used to reset ncp */ \
ASH_NCP_TYPE_EM2XX_EM3XX /* type of ncp processor */ \
}
/** @brief Configuration parameters: values must be defined before calling ashResetNcp()
* or ashStart(). Note that all times are in milliseconds.
*/
typedef struct {
char serialPort[ASH_PORT_LEN]; /*!< serial port name */
uint32_t baudRate; /*!< baud rate (bits/second) */
uint8_t stopBits; /*!< stop bits */
uint8_t rtsCts; /*!< true enables RTS/CTS flow control, false XON/XOFF */
uint16_t outBlockLen; /*!< max bytes to buffer before writing to serial port */
uint16_t inBlockLen; /*!< max bytes to read ahead from serial port */
uint8_t traceFlags; /*!< trace output control bit flags */
uint8_t txK; /*!< max frames sent without being ACKed (1-7) */
uint8_t randomize; /*!< enables randomizing DATA frame payloads */
uint16_t ackTimeInit; /*!< adaptive rec'd ACK timeout initial value */
uint16_t ackTimeMin; /*!< adaptive rec'd ACK timeout minimum value */
uint16_t ackTimeMax; /*!< adaptive rec'd ACK timeout maximum value */
uint16_t timeRst; /*!< time allowed to receive RSTACK after ncp is reset */
uint8_t nrLowLimit; /*!< if free buffers < limit, host receiver isn't ready */
uint8_t nrHighLimit; /*!< if free buffers > limit, host receiver is ready */
uint16_t nrTime; /*!< time until a set nFlag must be resent (max 2032) */
uint8_t resetMethod; /*!< method used to reset ncp */
uint8_t ncpType; /*!< type of ncp processor */
} AshHostConfig;
将宏赋给变量
// Host configuration structure
AshHostConfig ashHostConfig = ASH_HOST_CONFIG_DEFAULT;
结构体成员traceFlags就是调试开关,具体宏要在初始化时候写进ASH_HOST_CONFIG_DEFAULT即可!
// Bits in traceFlags to enable various host trace outputs
#define TRACE_FRAMES_BASIC 1 /*!< frames sent and received */
#define TRACE_FRAMES_VERBOSE 2 /*!< basic frames + internal variables */
#define TRACE_EVENTS 4 /*!< events */
#define TRACE_EZSP 8 /*!< EZSP commands, responses and callbacks */
#define TRACE_EZSP_VERBOSE 16 /*!< additional EZSP information */
#define ashReadConfig(member) \
(ashHostConfig.member)
Debug函数
void ashTraceFrame(bool sent)
{
uint8_t flags;
ashCountFrame(sent);
**flags = ashReadConfig(traceFlags);**
if (flags & (TRACE_FRAMES_BASIC | TRACE_FRAMES_VERBOSE)) {
ezspPrintElapsedTime();
if (sent) {
ezspDebugPrintf("Tx ");
ashPrintFrame(readTxControl());
if (flags & TRACE_FRAMES_VERBOSE) {
ashPrintStatus();
}
ezspDebugPrintf(" \r\n");
} else {
ezspDebugPrintf(" ");
ashPrintFrame(readRxControl());
if (flags & TRACE_FRAMES_VERBOSE) {
ashPrintStatus();
}
ezspDebugPrintf(" Rx\r\n");
}
}
}