Ash#
Use the Asynchronous Serial Host (ASH) Framework interfaces on a host microcontroller when it communicates with an Ember chip via EZSP-UART.
See ash-protocol.h for source code.
See ash-common.h for source code.
Variables#
set false to start decoding a new frame
rec'd ack timer (msecs)
rec'd ack timer period (msecs)
not ready timer (16 msec units)
Functions#
Builds an ASH frame.
Decodes and validates an ASH frame.
Randomizes array contents by XORing with an 8-bit pseudo random sequence.
Sets ashAckTimer to the specified period and starts it running.
Indicates whether or not ashAckTimer has expired.
Adapts the acknowledgement timer period to the observed ACK delay.
Starts the Not Ready timer.
Tests whether the Not Ready timer has expired or has stopped.
Macros#
Stops and clears ashAckTimer.
Indicates whether or not ashAckTimer is currently running.
Indicates whether or not ashAckTimer is currently running.
Sets the acknowledgement timer period (in msec) and stops the timer.
Returns the acknowledgement timer period (in msec).
Sets the acknowledgement timer period (in msec), and starts the timer running.
log2 of msecs per NR timer unit
Stops the Not Ready timer.
Indicates whether or not ashNrTimer is currently running.
protocol version
frame delimiter
byte stuffing escape byte
flow control byte - means resume transmission
flow control byte - means suspend transmission
replaces bytes w framing, overrun or overflow errors
frame cancel byte
wake signal byte (also means NCP data pending)
XOR mask used in byte stuffing.
ash min data field len
ash max data field len
with control
control plus data field, but not CRC
ash max frame len
ash crc len
ash min frame with crc len
ash max frame with crc len
longest non-data frame received
longest non-data frame sent
longest non-data frame received
longest non-data frame sent
ash dframe mask
ash control data
ash shframe mask
ash control ack
ash control nak
ash control rst
ash control rstack
ash control error
acknowledge frame number
ash acknum bit
retransmitted frame flag
ash rflag bit
receiver not ready flag
ash nflag bit
flag reserved for future use
ash pflag bit
DATA frame number.
ash frmnum bit
ash get rflag(ctl)
ash get nflag(ctl)
ash get frmnum(ctl)
ash get acknum(ctl)
ash frame len data min
control
control
control
control, version, reset reason
control, version, error
mask to frame number modulus
increment in frame number modulus
within range lo and hi
Variable Documentation#
ashDecodeInProgress#
bool ashDecodeInProgress
set false to start decoding a new frame
193
of file platform/service/legacy_common_ash/inc/ash-common.h
ashAckTimer#
uint16_t ashAckTimer
rec'd ack timer (msecs)
196
of file platform/service/legacy_common_ash/inc/ash-common.h
ashAckPeriod#
uint16_t ashAckPeriod
rec'd ack timer period (msecs)
197
of file platform/service/legacy_common_ash/inc/ash-common.h
ashNrTimer#
uint8_t ashNrTimer
not ready timer (16 msec units)
198
of file platform/service/legacy_common_ash/inc/ash-common.h
Function Documentation#
ashEncodeByte#
uint8_t ashEncodeByte (uint8_t len, uint8_t byte, uint8_t * offset)
Builds an ASH frame.
N/A | len | new frame flag / length of the frame to be encoded. A non-zero value begins a new frame, so all subsequent calls must use zero. The length includes control byte and data field, but not the flag or crc. This function does not validate the length. |
N/A | byte | the next byte of data to add to the frame. Note that in general the same byte of data may have to be passed more than once as escape bytes, the CRC and the end flag byte are output. |
N/A | offset | pointer to the offset of the next input byte. (If the frame data is the array data[], the next byte would be data[offset].) Is set to 0 when starting a new frame (ie, len is non-zero). Is set to 0xFF when the last byte of the frame is returned. |
Byte stuffs the control and data fields as required, computes and appends the CRC and adds the ending flag byte. Called with the next byte to encode, this function may return several output bytes before it's ready for the next byte.
Returns
next encoded output byte in frame.
53
of file platform/service/legacy_common_ash/inc/ash-common.h
ashDecodeByte#
sl_zigbee_ezsp_status_t ashDecodeByte (uint8_t byte, uint8_t * out, uint8_t * outLen)
Decodes and validates an ASH frame.
N/A | byte | the next byte of data to add to the frame |
N/A | out | pointer to where to write an output byte |
N/A | outLen | number of bytes output so far |
Data is passed to it one byte at a time. Decodes byte stuffing, checks crc, finds the end flag and (if enabled) terminates the frame early on CAN or SUB bytes. The number of bytes output will not exceed the max valid frame length, which does not include the flag or the crc.
Returns
status of frame decoding
::SL_ZIGBEE_EZSP_SUCCESS
::SL_ZIGBEE_EZSP_ASH_IN_PROGRESS
::SL_ZIGBEE_EZSP_ASH_CANCELLED
::SL_ZIGBEE_EZSP_ASH_BAD_CRC
::SL_ZIGBEE_EZSP_ASH_COMM_ERROR
::SL_ZIGBEE_EZSP_ASH_TOO_SHORT
::SL_ZIGBEE_EZSP_ASH_TOO_LONG
76
of file platform/service/legacy_common_ash/inc/ash-common.h
ashRandomizeArray#
uint8_t ashRandomizeArray (uint8_t seed, uint8_t * buf, uint8_t len)
Randomizes array contents by XORing with an 8-bit pseudo random sequence.
N/A | seed | zero initializes the random sequence a non-zero value continues from a previous invocation |
N/A | buf | pointer to the array whose contents will be randomized |
N/A | len | number of bytes in the array to modify |
This reduces the likelihood that byte-stuffing will greatly increase the size of the payload. (This could happen if a DATA frame contained repeated instances of the same reserved byte value.)
Returns
last value of the sequence. If a buffer is processed in two or more chunks, as with linked buffers, this value should be passed back as the value of the seed argument
95
of file platform/service/legacy_common_ash/inc/ash-common.h
ashStartAckTimer#
void ashStartAckTimer (void )
Sets ashAckTimer to the specified period and starts it running.
N/A |
101
of file platform/service/legacy_common_ash/inc/ash-common.h
ashAckTimerHasExpired#
bool ashAckTimerHasExpired (void )
Indicates whether or not ashAckTimer has expired.
N/A |
If the timer is stopped then it is not expired.
Returns
bool
127
of file platform/service/legacy_common_ash/inc/ash-common.h
ashAdjustAckPeriod#
void ashAdjustAckPeriod (bool expired)
Adapts the acknowledgement timer period to the observed ACK delay.
N/A | expired | true if timer has expired |
If the timer is not running, it does nothing. If the timer has expired, the timeourt period is doubled. If the timer has not expired, the elapsed time is fed into simple IIR filter: T[n+1] = (7*T[n] + elapsedTime) / 8 The timeout period, ashAckPeriod, is limited such that: ASH_xxx_TIME_DATA_MIN <= ashAckPeriod <= ASH_xxx_TIME_DATA_MAX, where xxx is either HOST or NCP.
The acknowledgement timer is always stopped by this function.
145
of file platform/service/legacy_common_ash/inc/ash-common.h
ashStartNrTimer#
void ashStartNrTimer (void )
Starts the Not Ready timer.
N/A |
On the host, this times nFlag refreshing when the host doesn't have room for callbacks for a prolonged period.
On the NCP, if this times out the NCP resumes sending callbacks.
175
of file platform/service/legacy_common_ash/inc/ash-common.h
ashNrTimerHasExpired#
bool ashNrTimerHasExpired (void )
Tests whether the Not Ready timer has expired or has stopped.
N/A |
If expired, it is stopped.
Returns
true if the Not Ready timer has expired or stopped
186
of file platform/service/legacy_common_ash/inc/ash-common.h
Macro Definition Documentation#
ashStopAckTimer#
#define ashStopAckTimerValue:
(void)
Stops and clears ashAckTimer.
108
of file platform/service/legacy_common_ash/inc/ash-common.h
ashAckTimerIsRunning#
#define ashAckTimerIsRunningValue:
()
Indicates whether or not ashAckTimer is currently running.
The timer may be running even if expired.
114
of file platform/service/legacy_common_ash/inc/ash-common.h
ashAckTimerIsNotRunning#
#define ashAckTimerIsNotRunningValue:
()
Indicates whether or not ashAckTimer is currently running.
The timer may be running even if expired.
120
of file platform/service/legacy_common_ash/inc/ash-common.h
ashSetAckPeriod#
#define ashSetAckPeriodValue:
(msec)
Sets the acknowledgement timer period (in msec) and stops the timer.
151
of file platform/service/legacy_common_ash/inc/ash-common.h
ashGetAckPeriod#
#define ashGetAckPeriodValue:
()
Returns the acknowledgement timer period (in msec).
157
of file platform/service/legacy_common_ash/inc/ash-common.h
ashSetAndStartAckTimer#
#define ashSetAndStartAckTimerValue:
(msec)
Sets the acknowledgement timer period (in msec), and starts the timer running.
162
of file platform/service/legacy_common_ash/inc/ash-common.h
ASH_NR_TIMER_BIT#
#define ASH_NR_TIMER_BITValue:
4
log2 of msecs per NR timer unit
166
of file platform/service/legacy_common_ash/inc/ash-common.h
ashStopNrTimer#
#define ashStopNrTimerValue:
()
Stops the Not Ready timer.
179
of file platform/service/legacy_common_ash/inc/ash-common.h
ashNrTimerIsNotRunning#
#define ashNrTimerIsNotRunningValue:
()
Indicates whether or not ashNrTimer is currently running.
191
of file platform/service/legacy_common_ash/inc/ash-common.h
ASH_VERSION#
#define ASH_VERSIONValue:
2
protocol version
35
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FLAG#
#define ASH_FLAGValue:
0x7E
frame delimiter
39
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_ESC#
#define ASH_ESCValue:
0x7D
byte stuffing escape byte
40
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_XON#
#define ASH_XONValue:
0x11
flow control byte - means resume transmission
41
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_XOFF#
#define ASH_XOFFValue:
0x13
flow control byte - means suspend transmission
42
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_SUB#
#define ASH_SUBValue:
0x18
replaces bytes w framing, overrun or overflow errors
43
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CAN#
#define ASH_CANValue:
0x1A
frame cancel byte
44
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_WAKE#
#define ASH_WAKEValue:
0xFF
wake signal byte (also means NCP data pending)
48
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FLIP#
#define ASH_FLIPValue:
0x20
XOR mask used in byte stuffing.
51
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_MIN_DATA_FIELD_LEN#
#define ASH_MIN_DATA_FIELD_LENValue:
EZSP_MIN_FRAME_LENGTH
ash min data field len
55
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_MAX_DATA_FIELD_LEN#
#define ASH_MAX_DATA_FIELD_LENValue:
EZSP_MAX_FRAME_LENGTH
ash max data field len
56
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_MIN_DATA_FRAME_LEN#
#define ASH_MIN_DATA_FRAME_LENValue:
(ASH_MIN_DATA_FIELD_LEN + 1)
with control
57
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_MIN_FRAME_LEN#
#define ASH_MIN_FRAME_LENValue:
1
control plus data field, but not CRC
58
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_MAX_FRAME_LEN#
#define ASH_MAX_FRAME_LENValue:
(ASH_MAX_DATA_FIELD_LEN + 1)
ash max frame len
59
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CRC_LEN#
#define ASH_CRC_LENValue:
2
ash crc len
60
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_MIN_FRAME_WITH_CRC_LEN#
#define ASH_MIN_FRAME_WITH_CRC_LENValue:
(ASH_MIN_FRAME_LEN + ASH_CRC_LEN)
ash min frame with crc len
61
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_MAX_FRAME_WITH_CRC_LEN#
#define ASH_MAX_FRAME_WITH_CRC_LENValue:
(ASH_MAX_FRAME_LEN + ASH_CRC_LEN)
ash max frame with crc len
62
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_NCP_SHFRAME_RX_LEN#
#define ASH_NCP_SHFRAME_RX_LENValue:
2
longest non-data frame received
65
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_NCP_SHFRAME_TX_LEN#
#define ASH_NCP_SHFRAME_TX_LENValue:
3
longest non-data frame sent
66
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_HOST_SHFRAME_RX_LEN#
#define ASH_HOST_SHFRAME_RX_LENValue:
3
longest non-data frame received
67
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_HOST_SHFRAME_TX_LEN#
#define ASH_HOST_SHFRAME_TX_LENValue:
2
longest non-data frame sent
68
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_DFRAME_MASK#
#define ASH_DFRAME_MASKValue:
0x80
ash dframe mask
89
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CONTROL_DATA#
#define ASH_CONTROL_DATAValue:
0x00
ash control data
90
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_SHFRAME_MASK#
#define ASH_SHFRAME_MASKValue:
0xE0
ash shframe mask
92
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CONTROL_ACK#
#define ASH_CONTROL_ACKValue:
0x80
ash control ack
93
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CONTROL_NAK#
#define ASH_CONTROL_NAKValue:
0xA0
ash control nak
94
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CONTROL_RST#
#define ASH_CONTROL_RSTValue:
0xC0
ash control rst
95
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CONTROL_RSTACK#
#define ASH_CONTROL_RSTACKValue:
0xC1
ash control rstack
96
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_CONTROL_ERROR#
#define ASH_CONTROL_ERRORValue:
0xC2
ash control error
97
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_ACKNUM_MASK#
#define ASH_ACKNUM_MASKValue:
0x07
acknowledge frame number
99
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_ACKNUM_BIT#
#define ASH_ACKNUM_BITValue:
0
ash acknum bit
100
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_RFLAG_MASK#
#define ASH_RFLAG_MASKValue:
0x08
retransmitted frame flag
101
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_RFLAG_BIT#
#define ASH_RFLAG_BITValue:
3
ash rflag bit
102
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_NFLAG_MASK#
#define ASH_NFLAG_MASKValue:
0x08
receiver not ready flag
103
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_NFLAG_BIT#
#define ASH_NFLAG_BITValue:
3
ash nflag bit
104
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_PFLAG_MASK#
#define ASH_PFLAG_MASKValue:
0x10
flag reserved for future use
105
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_PFLAG_BIT#
#define ASH_PFLAG_BITValue:
4
ash pflag bit
106
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRMNUM_MASK#
#define ASH_FRMNUM_MASKValue:
0x70
DATA frame number.
107
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRMNUM_BIT#
#define ASH_FRMNUM_BITValue:
4
ash frmnum bit
108
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_GET_RFLAG#
#define ASH_GET_RFLAGValue:
(ctl)
ash get rflag(ctl)
109
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_GET_NFLAG#
#define ASH_GET_NFLAGValue:
(ctl)
ash get nflag(ctl)
110
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_GET_FRMNUM#
#define ASH_GET_FRMNUMValue:
(ctl)
ash get frmnum(ctl)
111
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_GET_ACKNUM#
#define ASH_GET_ACKNUMValue:
(ctl)
ash get acknum(ctl)
112
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRAME_LEN_DATA_MIN#
#define ASH_FRAME_LEN_DATA_MINValue:
(ASH_MIN_DATA_FIELD_LEN + 1)
ash frame len data min
116
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRAME_LEN_ACK#
#define ASH_FRAME_LEN_ACKValue:
1
control
117
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRAME_LEN_NAK#
#define ASH_FRAME_LEN_NAKValue:
1
control
118
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRAME_LEN_RST#
#define ASH_FRAME_LEN_RSTValue:
1
control
119
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRAME_LEN_RSTACK#
#define ASH_FRAME_LEN_RSTACKValue:
3
control, version, reset reason
120
of file platform/service/legacy_common_ash/inc/ash-protocol.h
ASH_FRAME_LEN_ERROR#
#define ASH_FRAME_LEN_ERRORValue:
3
control, version, error
121
of file platform/service/legacy_common_ash/inc/ash-protocol.h
MOD8#
#define MOD8Value:
(n)
mask to frame number modulus
124
of file platform/service/legacy_common_ash/inc/ash-protocol.h
INC8#
#define INC8Value:
(n)
increment in frame number modulus
125
of file platform/service/legacy_common_ash/inc/ash-protocol.h
WITHIN_RANGE#
#define WITHIN_RANGEValue:
(lo, n, hi)
within range lo and hi
127
of file platform/service/legacy_common_ash/inc/ash-protocol.h