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; } }
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 }