fertiges programm

Dependencies:   mbed nRF24L01P

Fork of nRF24L01P_Hello_World by Owen Edwards

Files at this revision

API Documentation at this revision

Comitter:
thorb3n
Date:
Tue Jan 05 15:12:38 2016 +0000
Parent:
1:5be2682710c6
Commit message:
FERTIG;

Changed in this revision

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 5be2682710c6 -r 0b023bf05e0d main.cpp
--- a/main.cpp	Wed Jan 19 23:53:19 2011 +0000
+++ b/main.cpp	Tue Jan 05 15:12:38 2016 +0000
@@ -1,26 +1,34 @@
 #include "mbed.h"
 #include "nRF24L01P.h"
-
+#define IWDG_START 0x0000CCCC
+#define IWDG_WRITE_ACCESS 0x00005555
+#define IWDG_PR_PR_0 7
+#define IWDG_RELOAD 512*100
+#define IWDG_REFRESH 0xAAAA
 Serial pc(USBTX, USBRX); // tx, rx
 
-nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10);    // mosi, miso, sck, csn, ce, irq
+nRF24L01P my_nrf24l01p(D4,D5,D3,D10,D8,D9);    // mosi, miso, sck, csn, ce, irq
+
 
-DigitalOut myled1(LED1);
-DigitalOut myled2(LED2);
-
-int main() {
-
+int main()
+{
+//                          
+    //              pLATHALTER FÜR ANSHCALTEN ÜBER GPIO
+        //
+        
 // 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.
-#define TRANSFER_SIZE   4
+#define TRANSFER_SIZE   2
 
     char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE];
     int txDataCnt = 0;
     int rxDataCnt = 0;
 
     my_nrf24l01p.powerUp();
-
+    my_nrf24l01p.setAirDataRate(250);
+    my_nrf24l01p.setTxAddress(0xE7E7E7E7E1,5);
+    my_nrf24l01p.setRxAddress(0xE7E7E7E7E7,5,0);
     // Display the (default) setup of the nRF24L01+ chip
     pc.printf( "nRF24L01+ Frequency    : %d MHz\r\n",  my_nrf24l01p.getRfFrequency() );
     pc.printf( "nRF24L01+ Output power : %d dBm\r\n",  my_nrf24l01p.getRfOutputPower() );
@@ -32,11 +40,26 @@
 
     my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
 
-    my_nrf24l01p.setReceiveMode();
+    my_nrf24l01p.setTransmitMode();
     my_nrf24l01p.enable();
-
+    txData[1] = 2;
+    txData[0] = 23;
+    txDataCnt =1;
+    IWDG->KR=IWDG_START;
+    IWDG->KR=IWDG_WRITE_ACCESS;
+    IWDG->PR=IWDG_PR_PR_0;
+    IWDG->RLR=IWDG_RELOAD;
+    while(IWDG->SR) {
+        wait(0.1);
+    }
+    my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt );
+    wait(1);
+    IWDG->KR=IWDG_REFRESH; /* (6) */
+    pc.printf("go to sleep");
+    deepsleep();
     while (1) {
 
+        /*
         // If we've received anything over the host serial link...
         if ( pc.readable() ) {
 
@@ -53,7 +76,7 @@
             }
 
             // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
-            myled1 = !myled1;
+           // myled1 = !myled1;
         }
 
         // If we've received anything in the nRF24L01+...
@@ -69,7 +92,8 @@
             }
 
             // Toggle LED2 (to help debug nRF24L01+ -> Host communication)
-            myled2 = !myled2;
+            //myled2 = !myled2;
         }
+        */
     }
 }
diff -r 5be2682710c6 -r 0b023bf05e0d mbed.bld
--- a/mbed.bld	Wed Jan 19 23:53:19 2011 +0000
+++ b/mbed.bld	Tue Jan 05 15:12:38 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
+http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file