当有按键的时候,将 TxPayloadBuffer[]的数据发送出去
SW1_Data_ADDR |= SW1_MASK; // Write a 1 so we can read the switch
if (!(SW1_Data_ADDR & SW1_MASK))
{
// Transmit a packet when the "Switch 1" button is pressed.
nRED_LED_Data_ADDR &= ~nRED_LED_MASK; // Red LED On
Delay(DELAY_COUNT); // Give the user a chance to see the LED.
// This also guarantees the receiver has been running for at least 1ms.
// Stop receiving so that we can transmit
RadioAbort();
RadioSetPtr(TxPayloadBuffer); // Set the transmit buffer
RadioBlockingTransmit(0, PAYLOAD_LENGTH); // Send it
++TransmittedCount;
nRED_LED_Data_ADDR |= nRED_LED_MASK; // Red LED Off
// Wait for user to release the "Switch 1" button.
SW1_Data_ADDR |= SW1_MASK; // Write a 1 so we can read the switch
while(!(SW1_Data_ADDR & SW1_MASK));
RadioSetPtr(RxPayloadBuffer); // Set the receive buffer
RadioStartReceive(); // Restart the receiver
Delay(SWITCH_DEBOUCE); // Debounce switch
}
|