.

Dependencies:   ISR_Mini-explorer RF24 mbed

Files at this revision

API Documentation at this revision

Comitter:
fabiofaria
Date:
Thu Jul 27 13:06:04 2017 +0000
Commit message:
.

Changed in this revision

ISR_Mini-explorer.lib Show annotated file Show diff for this revision Revisions of this file
RF24.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 59b3345b2b9e ISR_Mini-explorer.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ISR_Mini-explorer.lib	Thu Jul 27 13:06:04 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/fabiofaria/code/ISR_Mini-explorer/#d1443589406e
diff -r 000000000000 -r 59b3345b2b9e RF24.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RF24.lib	Thu Jul 27 13:06:04 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/akashvibhute/code/RF24/#ef74df512fed
diff -r 000000000000 -r 59b3345b2b9e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 27 13:06:04 2017 +0000
@@ -0,0 +1,86 @@
+#include "mbed.h"
+#include "robot.h" // Inicializa o robô. Este include deverá ser usado em todos os main.cpp!
+//#include "nRF24L01P.h"
+#include <RF24.h>
+
+#define TRANSFER_SIZE 1
+
+//nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTC13, PTC12, PTA13);
+RF24 radio(PTD2, PTD3, PTD1,  PTC12 ,PTC13);
+
+
+void config_init_nrf2()
+{
+      int resultado;
+      resultado = radio.begin();
+      
+      pc.printf( "Begin=%d\r\n",  resultado );
+  radio.setDataRate(RF24_1MBPS);
+  radio.setCRCLength(RF24_CRC_8);
+  radio.setPayloadSize(1);
+  radio.setChannel(101);
+  radio.setAutoAck(true);
+  radio.printDetails();
+
+  radio.openWritingPipe(0x314e6f6465);
+  radio.openReadingPipe(1,0x324e6f6465 );
+
+  radio.startListening();
+}
+
+int main()
+{
+    char txData, rxData;
+
+
+    initRobot();
+    pc.baud(9600);
+    config_init_nrf2(); // Should be after pc.baud()
+    
+    pc.printf( "Robot A\r\n" );
+    
+
+    // Desliga os LEDs.
+    q_led_red_fro = 1;  //Led Red Front
+    q_led_gre_fro = 1;  //Led Green Front
+    q_led_blu_fro = 1;  //Led Blue Front
+    q_led_red_rea = 1;  //Led Red Rear
+    q_led_gre_rea = 1;  //Led Green Rear
+    q_led_blu_rea = 1;  //Led Blue Rear
+
+    while (1) {
+
+        // If we've received anything over the host serial link...
+        if ( pc.readable() ) {
+
+            // ...add it to the transmit buffer
+            txData = pc.getc();
+        
+                // Send the transmitbuffer via the nRF24L01+
+                //pc.printf( "Vou enviar: %c\r\n",txData);
+                 radio.stopListening();
+                radio.write( &txData, sizeof(txData) );
+                radio.startListening();
+
+
+            // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
+            q_led_red_fro = !q_led_red_fro;
+        }
+
+        // If we've received anything in the nRF24L01+...
+        if (radio.available() ) {
+
+            // ...read the data into the receive buffer
+            //my_nrf24l01p.read( NRF24L01P_PIPE_P0, &rxData, sizeof( rxData ) );
+            radio.read( &rxData, sizeof(rxData) );
+
+ 
+
+                pc.putc( rxData );
+
+
+            // Toggle LED2 (to help debug nRF24L01+ -> Host communication)
+            q_led_red_rea = !q_led_red_rea;
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 59b3345b2b9e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 27 13:06:04 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a97add6d7e64
\ No newline at end of file