Wixel SDK
Functions | Variables
radio_com.h File Reference
#include <radio_link.h>

Go to the source code of this file.

Functions

void radioComInit (void)
 
uint8 radioComRxAvailable (void)
 
uint8 radioComRxReceiveByte (void)
 
void radioComTxService (void)
 
uint8 radioComTxAvailable (void)
 
void radioComTxSendByte (uint8 byte)
 
void radioComTxControlSignals (uint8 controlSignals)
 
uint8 radioComRxControlSignals (void)
 

Variables

BIT radioComRxEnforceOrdering
 

Detailed Description

The radio_com.lib library provides reliable, ordered delivery and reception of a stream of bytes between two devices. This library depends on radio_link.lib. For many applications, this library is easier to use than radio_link.lib because this library takes care of dividing the stream of bytes into packets.

This library depends on radio_link.lib, which depends on radio_mac.lib, which uses an interrupt. For this library to work, you must write include <radio_com.h> in the source file that contains your main() function.

This library has the same limitations as radio_link.lib: It does not work if there are more than two Wixels broadcasting on the same channel. For wireless communication between more than two Wixels, you can use radio_queue.lib (see radio_queue.h).

This library also supports sending 8 control signals to the other Wixel and receiving 8 control signals from the other Wixel.

Definition in file radio_com.h.

Function Documentation

void radioComInit ( void  )

Initializes the radio_com.lib library and the lower-level libraries that it depends on. This must be called before any of the other radioCom* functions.

Definition at line 32 of file radio_com.c.

uint8 radioComRxAvailable ( void  )
Returns
The number of bytes in the RX buffer.

You can use this function to see if any bytes have been received, and then use radioComRxReceiveByte() to actually get the byte and process it.

Definition at line 103 of file radio_com.c.

uint8 radioComRxControlSignals ( void  )
Returns
The state of the eight virtual RX control signals. Each bit represents a different control signal.

The values of these eight control lines are zero by default, but they can be set wirelessly by the other Wixel.

Note that these signals (the RX signals) are independent of the signals transmitted to other Wixel (the TX signals).

The meaning of these control signals (e.g. their mapping to RS-232 control signals) is determined by higher-level code.

Definition at line 125 of file radio_com.c.

uint8 radioComRxReceiveByte ( void  )
Returns
A byte from the RX buffer.

Bytes are returned in the order they were received from the other Wixel.

This is a non-blocking function: you must call radioComRxAvailable() before calling this function and be sure not to read too many bytes. The number of times you call this should not exceed the last value returned by radioComRxAvailable().

Definition at line 111 of file radio_com.c.

uint8 radioComTxAvailable ( void  )
Returns
The number of bytes available in the TX buffer.

Definition at line 197 of file radio_com.c.

void radioComTxControlSignals ( uint8  controlSignals)
Parameters
controlSignalsThe state of the eight virtual TX control signals. Each bit represents a different control signal.

The values of these eight control lines are transmitted to the other Wixel.

Note that these signals (the TX signals) are independent of the signals received from the other Wixel (the RX signals).

The meaning of these control signals (e.g. their mapping to RS-232 control signals) is determined by higher-level code.

Definition at line 235 of file radio_com.c.

void radioComTxSendByte ( uint8  byte)

Adds a byte to the TX buffer, which means it will be eventually sent to the other Wixel over the radio.

Parameters
byteThe byte to send.

This is a non-blocking function: you must call radioComTxAvailable() before calling this function and be sure not to add too many bytes to the buffer. The number of times you call this should not exceed the last value returned by radioComTxAvailable().

If you call this function, you must also call radioComTxService() regularly.

Definition at line 216 of file radio_com.c.

void radioComTxService ( void  )

This function must be called regularly if you want to send data or control signals to the other Wixel.

Definition at line 155 of file radio_com.c.

Variable Documentation

BIT radioComRxEnforceOrdering

This is a configuration option for the radio_com.lib library that can be set by higher-level code. The default value is 0.

When this bit is 1, the radio_com library guarantees that the higher-level code receives notifications of changed control signals via radioComRxControlSignals() and receives data bytes via radioComRxAvailable() and radioComRxReceiveByte() in the same order that these two pieces of information were received from the radio. If this bit is 1, higher-level code must call radioComRxControlSignals() regularly, or else it will not be able to receive bytes using radioComRxAvailable() and radioComRxReceiveByte().

When this bit is 0, the higher-level code does not have to call radioComRxControlSignals() regularly.

We recommend that if you call radioComRxControlSignals(), you should call it regularly and set radioComRxEnforceOrdering to 1 at the beginning of your program. If you are not using the control signals, you should leave this bit at 0.

Definition at line 7 of file radio_com.c.