Program to test nrF24 module / RF transmission

Dependencies:   MOD24_NRF nRF24

Revision:
1:b96e529849d1
Parent:
0:4762540bcced
Child:
2:68d03c147aff
diff -r 4762540bcced -r b96e529849d1 main.cpp
--- a/main.cpp	Thu Sep 23 12:33:38 2021 +0000
+++ b/main.cpp	Tue Dec 14 15:03:53 2021 +0000
@@ -10,56 +10,17 @@
 /****************************************************************************/
 
 #include "mbed.h"
+#include "voiture_auto.h"
+#include "rplidar.h"
 #include "MOD24_NRF.h"
-#define TRANSFER_SIZE   8
-
-nRF24L01P       my_mod(PC_12, PC_11, PC_10, PH_1, PH_0, PD_2);
-// MOSI, MISO, SCK, CSN, CE, IRQ
-
-Serial          pc(USBTX, USBRX);
-DigitalIn       my_bp(USER_BUTTON);
-
-char k;
-char    dataToSend[TRANSFER_SIZE] = {0xAA, 0x01, 0x10, 0xF0,0xAA, 0x01, 0x10, 0xF0};
-char    dataReceived[TRANSFER_SIZE] = {0};
-char    rxDataCnt;
+#include "nRF24.h"
 
 int main() {
-    pc.printf("Test\r\n");
-    my_mod.setRfFrequency(2400);
-    wait_ms(100);
-    my_mod.powerUp();
-    
-    // Display the (default) setup of the nRF24L01+ chip
-    pc.printf( "nRF24L01+ Frequency    : %d MHz\r\n",  my_mod.getRfFrequency() );
-    pc.printf( "nRF24L01+ Output power : %d dBm\r\n",  my_mod.getRfOutputPower() );
-    pc.printf( "nRF24L01+ Data Rate    : %d kbps\r\n", my_mod.getAirDataRate() );
-
-    pc.printf( "Transfers are grouped into %d characters\r\n", TRANSFER_SIZE );
-
-    my_mod.setTransferSize( TRANSFER_SIZE );
-
-    my_mod.setReceiveMode();
-    my_mod.enable();
+    debug_pc.printf("Test\r\n");
+    initVoiture();
+    initNRF24();
     
     while(1) {
-        if ( my_mod.readable() ) {
-
-            // ...read the data into the receive buffer
-            rxDataCnt = my_mod.read( NRF24L01P_PIPE_P0, dataReceived, TRANSFER_SIZE);
-
-            // Display the receive buffer contents via the host serial link
-            pc.printf("\tD = ");
-            for ( int i = 0; i < rxDataCnt; i++ ) {
-                pc.printf(" %x \t", dataReceived[i]);
-            }
-            pc.printf("\r\n");
-        }   
-        if(my_bp == 0){
-            my_mod.setRfFrequency(2400);
-            my_mod.write( NRF24L01P_PIPE_P0, dataToSend, TRANSFER_SIZE );
-            pc.printf( "SENDED\r\n");
-            wait_ms(100);
-        }         
+        testNRF24();
     }
 }