Luc Derrien / Mbed 2 deprecated L475_robot_1_v1

Dependencies:   mbed nRF24L01P

Revision:
2:e309f19062b7
Parent:
1:5be2682710c6
Child:
3:fdd8560c4739
diff -r 5be2682710c6 -r e309f19062b7 main.cpp
--- a/main.cpp	Wed Jan 19 23:53:19 2011 +0000
+++ b/main.cpp	Fri Dec 04 08:16:27 2020 +0000
@@ -3,42 +3,49 @@
 
 Serial pc(USBTX, USBRX); // tx, rx
 
-nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10);    // mosi, miso, sck, csn, ce, irq
+//Définition des E/S de la liaison SPI vers le module nRF24L01+
+nRF24L01P my_nrf24l01p(D11, D12, D13, A3, D9, A0);    // mosi, miso, sck, csn, ce, irq
 
-DigitalOut myled1(LED1);
-DigitalOut myled2(LED2);
+DigitalOut myled1(D4);
+DigitalOut myled2(D5);
 
 int main() {
 
-// The nRF24L01+ supports transfers from 1 to 32 bytes, but Sparkfun's
-//  "Nordic Serial Interface Board" (http://www.sparkfun.com/products/9019)
-//  only handles 4 byte transfers in the ATMega code.
+// Nombre de caractères transmis à chaque envoi
 #define TRANSFER_SIZE   4
 
     char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE];
     int txDataCnt = 0;
     int rxDataCnt = 0;
+    
+    pc.baud(115200); // Débit de la liaison série PC
 
     my_nrf24l01p.powerUp();
+    
+    my_nrf24l01p.setRfFrequency(2416); // Définition de la fréquence du canal d'E/R
+    my_nrf24l01p.setAirDataRate(NRF24L01P_DATARATE_1_MBPS); // Définition du débit de la communication RF
+    
 
-    // Display the (default) setup of the nRF24L01+ chip
+    // Affichage de l'état de la configuration du nRF24L01+ 
     pc.printf( "nRF24L01+ Frequency    : %d MHz\r\n",  my_nrf24l01p.getRfFrequency() );
     pc.printf( "nRF24L01+ Output power : %d dBm\r\n",  my_nrf24l01p.getRfOutputPower() );
     pc.printf( "nRF24L01+ Data Rate    : %d kbps\r\n", my_nrf24l01p.getAirDataRate() );
     pc.printf( "nRF24L01+ TX Address   : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
-    pc.printf( "nRF24L01+ RX Address   : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
+    pc.printf( "nRF24L01+ RX Address   : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() ); 
+    
 
     pc.printf( "Type keys to test transfers:\r\n  (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE );
 
     my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
-
     my_nrf24l01p.setReceiveMode();
     my_nrf24l01p.enable();
+    
 
     while (1) {
 
         // If we've received anything over the host serial link...
         if ( pc.readable() ) {
+            
 
             // ...add it to the transmit buffer
             txData[txDataCnt++] = pc.getc();
@@ -56,7 +63,7 @@
             myled1 = !myled1;
         }
 
-        // If we've received anything in the nRF24L01+...
+        // If we've received anything in the nRF24L01+2...
         if ( my_nrf24l01p.readable() ) {
 
             // ...read the data into the receive buffer