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#
Function Documentation#
ashEncodeByte#
uint8_t ashEncodeByte (uint8_t len, uint8_t byte, uint8_t * offset)
Builds an ASH frame.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | 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. |
uint8_t | 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. |
uint8_t * | 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.
ashDecodeByte#
sl_zigbee_ezsp_status_t ashDecodeByte (uint8_t byte, uint8_t * out, uint8_t * outLen)
Decodes and validates an ASH frame.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | N/A | byte | the next byte of data to add to the frame |
uint8_t * | N/A | out | pointer to where to write an output byte |
uint8_t * | 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
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.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | N/A | seed | zero initializes the random sequence a non-zero value continues from a previous invocation |
uint8_t * | N/A | buf | pointer to the array whose contents will be randomized |
uint8_t | 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
ashStartAckTimer#
void ashStartAckTimer (void )
Sets ashAckTimer to the specified period and starts it running.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
ashAckTimerHasExpired#
bool ashAckTimerHasExpired (void )
Indicates whether or not ashAckTimer has expired.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
If the timer is stopped then it is not expired.
Returns
bool
ashAdjustAckPeriod#
void ashAdjustAckPeriod (bool expired)
Adapts the acknowledgement timer period to the observed ACK delay.
Type | Direction | Argument Name | Description |
---|---|---|---|
bool | 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.
ashStartNrTimer#
void ashStartNrTimer (void )
Starts the Not Ready timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | 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.
ashNrTimerHasExpired#
bool ashNrTimerHasExpired (void )
Tests whether the Not Ready timer has expired or has stopped.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
If expired, it is stopped.
Returns
true if the Not Ready timer has expired or stopped