support for auto ACK and retransmissions added
Dependents: JNP3_IOT_6_RADIO_ECHO_FIXED nRF24L01P_NET_GW nRF24L01P_NET_SENSOR Kubus ... more
Fork of nRF24L01P by
Diff: nRF24L01P.cpp
- Revision:
- 7:434a1c2ff406
- Parent:
- 6:5c0431c2ed79
- Child:
- 8:f8621be17645
--- a/nRF24L01P.cpp Mon Nov 06 08:43:40 2017 +0000 +++ b/nRF24L01P.cpp Sun Nov 12 18:53:35 2017 +0000 @@ -930,9 +930,10 @@ } - if(getStatusRegister() & _NRF24L01P_STATUS_MAX_RT) + if(getStatusRegister() & _NRF24L01P_STATUS_MAX_RT){ + flushTx(); count = -1; - + } // Clear the Status bit setRegister(_NRF24L01P_REG_STATUS, _NRF24L01P_STATUS_TX_DS); @@ -1035,6 +1036,36 @@ } +bool nRF24L01P::getRPD(){ + uint8_t rpd = getRegister(_NRF24L01P_REG_RPD); + return (rpd>0); +} + +uint8_t nRF24L01P::getRSSI(){ + uint8_t rssi =0; + for(int i=0; i<256; i++){ + rssi += getRPD(); + wait_us(50); + flushRx(); + } + return rssi; +} + +void nRF24L01P::flushRx(void) +{ + nCS_ = 0; + spi_.write(_NRF24L01P_SPI_CMD_FLUSH_RX); + nCS_ = 1; +} + +void nRF24L01P::flushTx(void) +{ + nCS_ = 0; + spi_.write(_NRF24L01P_SPI_CMD_FLUSH_TX); + nCS_ = 1; +} + + void nRF24L01P::setRegister(int regAddress, int regData) { //