Exemple #1
0
void Receiver()
{
  // Enable GDO interrupt and global interrupts.
  CC1101GdoEnable(gPhyInfo.gdo[0]);
  __enable_interrupt();
  
  while (true)
  {
    // Put the radio into an IDLE state.
    CC1101Idle(&gPhyInfo);
    
    // Flush the RX FIFO to prepare it for the next RF packet and turn on the
    // receiver.
    CC1101FlushRxFifo(&gPhyInfo);
    CC1101ReceiverOn(&gPhyInfo);
    
    /**
     *  On every reception, toggle the LED from off to on. This method uses a
     *  flag to determine when the interrupt has occurred and the End-Of-Packet
     *  (EOP) has been received.
     */
    P1OUT &= ~BIT0;
    while (!packetAvailable);
    P1OUT |= BIT0;
    
    // Read the data from the RX FIFO.
    CC1101ReadRxFifo(&gPhyInfo, rxData, sizeof(rxData)/sizeof(unsigned char));
    
    packetAvailable = false;
  }
}
Exemple #2
0
void Transmitter()
{
  while (true)
  {
    unsigned int i;
    
    // Increase the sequence number on every transmission. This is mainly used
    // to display differentiation between messages (demo purposes).
    txData[2]++;
    
    // Add delay between transmits for visual effect
    for (i = 0; i < 60000; i++);
    
    // Put the radio into an IDLE state.
    CC1101Idle(&gPhyInfo);
    
    // Flush the TX FIFO and then write new data to it. Transmit.
    CC1101FlushTxFifo(&gPhyInfo);
    CC1101WriteTxFifo(&gPhyInfo, txData, sizeof(txData)/sizeof(unsigned char));
    CC1101Transmit(&gPhyInfo);
    
    // On every transmission, toggle the LED from on to off.
    P1OUT |= BIT0;
    while (!CC1101GdoEvent(gPhyInfo.gdo[0], P2IN)); // Sync sent
    while (CC1101GdoEvent(gPhyInfo.gdo[0], P2IN));  // Transmit complete
    P1OUT &= ~BIT0;
  }
}
Exemple #3
0
unsigned char A110x2500Radio::receiverOn(uint8_t *dataField,
																				 uint8_t length,
																				 uint16_t timeout)
{
  if (!busy())
  {
    // Bring the radio out of a low power state.
    wakeup();
    
    // Set the receive buffer.
    Radio._dataStream.length = 0;
    Radio._dataStream.address = 0;
    Radio._dataStream.dataField = dataField;

    // Listen for a data stream.
    CC1101Idle(&gPhyInfo.cc1101);
    CC1101FlushRxFifo(&gPhyInfo.cc1101);
    CC1101ReceiverOn(&gPhyInfo.cc1101);
    
    // Listen for at most the timeout period or until a message is received.
    while (timeout-- > 0)
    {
      delay(1);
      if (gDataReceived)
      {
        gDataReceived = false;
        return Radio._dataStream.length;
      }
    }
  }
  
  return 0;    // No data stream received
}
Exemple #4
0
void A110x2500Radio::transmit(uint8_t address,
															uint8_t *dataField,
															uint8_t length)
{
  if (!busy())
  {
    // Bring the radio out of a low power state.
    wakeup();

    // Set the transmit buffer.
    Radio._dataStream.length = 0;
    Radio._dataStream.address = 0;
    Radio._dataStream.dataField = dataField;

    // Build and transmit a data stream.
    CC1101Idle(&gPhyInfo.cc1101);
    buildDataStream(address, Radio._dataStream.dataField, length);
    CC1101Transmit(&gPhyInfo.cc1101);
    gDataTransmitting = true;
  }
}