RF24: Minor power optimization (#1069)

This commit is contained in:
tekka
2018-04-04 20:48:36 +02:00
committed by Mikael Falkvidd
parent 3c0b2727a5
commit 2994d83e53

View File

@@ -302,13 +302,14 @@ LOCAL bool RF24_sendMessage(const uint8_t recipient, const void *buf, const uint
RF24_CMD_WRITE_TX_PAYLOAD, (uint8_t *)buf, len, false );
// go, TX starts after ~10us, CE high also enables PA+LNA on supported HW
RF24_ce(HIGH);
delayMicroseconds(10); // datasheet: Pulse CE at least 10us
RF24_ce(LOW);
// timeout counter to detect HW issues
uint16_t timeout = 0xFFFF;
do {
RF24_status = RF24_getStatus();
} while (!(RF24_status & ( _BV(RF24_MAX_RT) | _BV(RF24_TX_DS) )) && timeout--);
// timeout value after successful TX on 16Mhz AVR ~ 65500, i.e. msg is transmitted after ~36 loop cycles
RF24_ce(LOW);
// reset interrupts
RF24_setStatus(_BV(RF24_TX_DS) | _BV(RF24_MAX_RT) );
// Max retries exceeded