radio echo app

Dependents:   JNP3_IOT_6_RADIO_ECHO_FIXED2

Revision:
1:781a7eef8610
Parent:
0:8ae48233b4e4
Child:
2:3012f09dfcc2
--- a/nRF24L01P.cpp	Wed Jan 19 22:59:48 2011 +0000
+++ b/nRF24L01P.cpp	Tue Nov 15 15:47:58 2016 +0000
@@ -555,6 +555,18 @@
 
 }
 
+void nRF24L01P::enableAutoRetransmit(int delay, int count) {
+	delay = (0x00F0 & (delay << 4));
+	count = (0x000F & count);
+
+	setRegister(_NRF24L01P_REG_SETUP_RETR, delay|count);
+
+}
+
+int nRF24L01P::getRetrCount(){
+	return getRegister(_NRF24L01P_REG_OBSERVE_TX) & 0x0F;
+}
+
 void nRF24L01P::setRxAddress(unsigned long long address, int width, int pipe) {
 
     if ( ( pipe < NRF24L01P_PIPE_P0 ) || ( pipe > NRF24L01P_PIPE_P5 ) ) {
@@ -835,6 +847,8 @@
 
 
 int nRF24L01P::write(int pipe, char *data, int count) {
+	
+	Timer timeout;
 
     // Note: the pipe number is ignored in a Transmit / write
 
@@ -870,14 +884,20 @@
     wait_us(_NRF24L01P_TIMING_Thce_us);
     disable();
 
-    while ( !( getStatusRegister() & _NRF24L01P_STATUS_TX_DS ) ) {
-
-        // Wait for the transfer to complete
+	//timeout.start();
+    while ( !( getStatusRegister() & (_NRF24L01P_STATUS_TX_DS | _NRF24L01P_STATUS_MAX_RT) ) ) {
 
     }
+    //timeout.stop();
+    //timeout.reset();
+    
+    if(getStatusRegister() & _NRF24L01P_STATUS_MAX_RT)
+    	count = -1;
+    
 
     // Clear the Status bit
     setRegister(_NRF24L01P_REG_STATUS, _NRF24L01P_STATUS_TX_DS);
+    setRegister(_NRF24L01P_REG_STATUS, _NRF24L01P_STATUS_MAX_RT);
 
     if ( originalMode == _NRF24L01P_MODE_RX ) {