Using the Driver
9.3.3
ID Repeat Message Format
Sending messages using ID repeat format is simple. Fill the transmit buffer and, when the driver is not
busy, invoke the Echo_SendIDRepeat service with the desired number of IDs to be repeated as a parameter.
9.4
Receiving Messages
For receiving messages, the driver is flexible enough to accommodate a number of buffers defined in the
header file. The scheme employed provides a globally accessible pointer for the next full receive data
buffer.
The pointer is updated after calling Echo_DriverStatus(). If a message is available in the buffers, the status
bit MsgReadyis set and the pointer echoNextMessage is updated. If that message has a checksum error, the
Checksumstatus bit is also set. If no messages are waiting, echoNextMessage is undefined and the status
bit MsgReadyis cleared.
Internally, there is a temporary receive buffer that the Echo driver uses for partially received messages and
associated processing. This is copied to a free buffer when the reception is complete. If no free buffers
exist, the message will be discarded and the Overrunstatus bit is set.
When the application has finished using the buffer at echoNextMessage, it must clear the buffer full bit to
return it to the pool before the next message will be released to it. If the buffer full bit is not cleared,
subsequent calls to Echo_DriverStatus()will not update the echoNextMessagepointer.
Background
Rx Buffer
Foreground
Rx Buffers
copy
FreePtr
NextPtr
Figure 10. Receive Buffering
9.4.1
Timeouts
If the length is corrupted or part of a message is lost, the driver can remain in a waiting state for the next
byte of a message to arrive. Consequently, parts of future messages can be mistakenly read as part of this
message. To avoid this, the timer provides a timeout mechanism while receiving.
The timeout is measured in bit-times and must clearly be greater than 8 bits (to allow a full byte to arrive
and be transferred out of Echo onto the SPI). This is defined in the driver header file:
ECHO_RX_TIMEOUT_BITS.
If a timeout occurs, both the Timeoutand Errorstatus bits are set.
Software Drivers for MC33696, Rev. 1
16
Freescale Semiconductor