Now caches the reading pipe 0 and re-sets it when starting to listen.

This commit is contained in:
maniacbug 2011-05-15 07:21:11 -07:00
parent e86c6b0f15
commit 1d28d28a29
2 changed files with 10 additions and 0 deletions

View File

@ -314,6 +314,9 @@ void RF24::startListening(void)
write_register(CONFIG, _BV(EN_CRC) | _BV(PWR_UP) | _BV(PRIM_RX)); write_register(CONFIG, _BV(EN_CRC) | _BV(PWR_UP) | _BV(PRIM_RX));
write_register(STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) ); write_register(STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
// Restore the pipe0 adddress
write_register(RX_ADDR_P0, reinterpret_cast<uint8_t*>(&pipe0_reading_address), 5);
// Flush buffers // Flush buffers
flush_rx(); flush_rx();
@ -495,6 +498,12 @@ void RF24::openReadingPipe(uint8_t child, uint64_t value)
const uint8_t child_pipe_enable[] = { const uint8_t child_pipe_enable[] = {
ERX_P0, ERX_P1, ERX_P2, ERX_P3, ERX_P4, ERX_P5 }; ERX_P0, ERX_P1, ERX_P2, ERX_P3, ERX_P4, ERX_P5 };
// If this is pipe 0, cache the address. This is needed because
// openWritingPipe() will overwrite the pipe 0 address, so
// startListening() will have to restore it.
if (child == 0)
pipe0_reading_address = value;
if (child < 5) if (child < 5)
{ {
// For pipes 2-5, only write the LSB // For pipes 2-5, only write the LSB

1
RF24.h
View File

@ -23,6 +23,7 @@ private:
uint8_t payload_size; /**< Fixed size of payloads */ uint8_t payload_size; /**< Fixed size of payloads */
boolean ack_payload_available; /**< Whether there is an ack payload waiting */ boolean ack_payload_available; /**< Whether there is an ack payload waiting */
uint8_t ack_payload_length; /**< Dynamic size of pending ack payload. Note: not used. */ uint8_t ack_payload_length; /**< Dynamic size of pending ack payload. Note: not used. */
uint64_t pipe0_reading_address; /**< Last address set on pipe 0 for reading. */
protected: protected:
/** /**