Professional Documents
Culture Documents
h>
#include <AIR430BoostETSI.h>
// -----------------------------------------------------------------------------
/**
* Global data
*/
// -----------------------------------------------------------------------------
// Debug print functions
void printTxData()
{
Serial.print("Transmitted: ");
Serial.println((char*)txData);
Serial.println();
}
void printRxData()
{
/**
* The following illustrates various information that can be obtained when
* receiving a message. This includes: the received data and associated
* status information (RSSI, LQI, and CRC_OK bit).
*/
Serial.print("RECEIVED: ");
Serial.print((char*)rxData);
Serial.println();
}
// -----------------------------------------------------------------------------
// Main example
void setup()
{
// The radio library uses the SPI library internally, this call initializes
// SPI/CSn and GDO0 lines. Also setup initial address, channel, and TX power.
Radio.begin(0x01, CHANNEL_1, POWER_MAX);
/**
* Setup LED for example demonstration purposes.
*
* Note: Set radio first to ensure that GDO2 line isn't being driven by the
* MCU as it is an output from the radio.
*/
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(PUSH2, INPUT_PULLUP);
digitalWrite(RED_LED, LOW); // set the LED Low
digitalWrite(GREEN_LED, LOW); //set the Green LED Low
}
void loop()
{
// Load the txData into the radio TX FIFO and transmit it to the broadcast
// address.
if(digitalRead(PUSH2)==0)
{
delay(200);
Radio.transmit(ADDRESS_BROADCAST, txData, 6);
printTxData(); // TX debug information
digitalWrite(GREEN_LED, HIGH);
}
else
{
//while (Radio.busy());
// Turn on the receiver and listen for incoming data. Timeout after 1 seconds.
// The receiverOn() method returns the number of bytes copied to rxData.
if (Radio.receiverOn(rxData, sizeof(rxData), 100) > 0)
{
/**
* Data has been received and has been copied to the rxData buffer provided
* to the receiverOn() method. At this point, rxData is available. See
* printRxData() for more information.
*/
digitalWrite(RED_LED, HIGH);
printRxData(); // RX debug information
}
}
digitalWrite(RED_LED, LOW);
digitalWrite(GREEN_LED, LOW);
/**
* Warning: ETSI regulations require duty cycling of 0.1% per hour. Changing
this
* may invalidate ETSI compliance. Some margin has been added. Please refer to
* Anaren's A110LR09 User's Manual for more information.
*/
//delay(500);
}