The uart interface, Configuration command formatting – Linx Technologies TRM-915-DTS User Manual

Page 9

Advertising
background image

– –

– –

12

13

The UART Interface

The module uses a standard UART interface for both data to be sent over
the air and for configuring the module. The CMD line is used to tell the
module if the data on the UART is for configuration or transmission. The
lines follow the standard UART naming convention, so RXD is the data
input into the module and TXD is the data output from the module.

The module has a 192 byte buffer for incoming data. The module can be
programmed to automatically transmit when the buffer reaches a limit or
based on the time between bytes on the UART. This allows the designer to
optimize the module for fixed length and variable length data. The module
supports streaming data as well. To optimize the module for streaming
data, regUARTMTU should be set to 144, and regTXTO should be set to a
value greater than 1 byte time at the current UART data rate.

If the buffer gets full or the timer set by regTXTO expires while the module
is still in the process of sending the previous packet over the RF link, the
module sets the CTS line high, indicating that the host should not send any
more data. Data sent by the host while CTS is high is lost.

Configuration Command Formatting

The DTS Series module contains several volatile and non-volatile registers
that control its configuration and operation. The volatile registers all
have non-volatile mirror registers that are used to determine the default
configuration when power is applied to the module. During normal
operation, the volatile registers are used to control the module.

Placing the module in the command mode allows these registers to be
programmed. Byte values in excess of 127 (0x80 or greater) must be
changed into a two-byte escape sequence of the format:

0xFE, [value - 128]

For example, the value 0x83 becomes 0xFE, 0x03. The function in Figure
11 pr
epends a 0xFF header and size specifier to a command sequence
and creates escape sequences as needed. It is assumed that *src is
populated with either the register number to read (one byte, pass 1 into
src_len) or the register number and value to write (two bytes, pass 2 into
src_len). It is also assumed that the *dest buffer has enough space for the
two header characters plus the encoded command and the null terminator.

int EscapeString(char *src, char src_len, char *dest)
{
// The following function copies and encodes the first
// src_len characters from *src into *dest. This
// encoding is necessary for module command formats.
// The resulting string is null terminated. The size
// of this string is the function return value.
// ---------------------------------------------------
char src_idx, dest_idx;
// Save space for the command header and size bytes
// ------------------------------------------------
dest_idx = 2;
// Loop through source string and copy/encode
// ------------------------------------------
for (src_idx = 0; src_idx < src_len; src_idx++)
{
if (src[src_idx] > 127)
{
dest[dest_idx++] = 0xFE;
}/*if*/
dest[dest_idx++] = (src[src_idx] & 0x7F);
}/*for*/
// Add null terminator
// -------------------
dest[dest_idx] = 0;
// Add command header
// ------------------
dest[0] = 0xFF;
dest[1] = dest_idx – 2;
// Return escape string size
// -------------------------
return dest_idx;
}

Figure 11: Command Conversion Code

Advertising
This manual is related to the following products: