Wireless / Mbed 2 deprecated spi_buttons_leds

Dependencies:   mbed nRF24L01P

Revision:
0:c2ab34dc9018
Child:
1:cedd9360f5c7
diff -r 000000000000 -r c2ab34dc9018 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 04 11:09:22 2018 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+
+//Init Pins
+SPI spi(D11, D12, D13);
+DigitalOut cs(D10, 1);
+
+void green() {
+    cs = 1;
+    cs = 0;
+    spi.write(0x46);
+    spi.write(0x09);
+    spi.write(0x15);
+    cs = 1;
+}
+
+void red() {
+    cs = 1;
+    cs = 0;
+    spi.write(0x46);
+    spi.write(0x09);
+    spi.write(0x2A);
+    cs = 1;
+}
+
+void read() {
+    cs = 0;
+    
+    spi.write(0x47);  
+    spi.write(0x09);
+    int data = spi.write(0x01);
+    cs = 1;
+    
+    printf("Data: %d\n\r",(data));
+    
+    //if((data & 0x00) == 0x80){
+//        green();
+//    } else {
+//        red();
+//    }
+}
+
+int main() {    
+    // alles aan: 01000110 00000000 00000000
+    // alles uit: 01000110 00000000 11111111
+    // Chip must be deselected
+    printf("Initializing. \n\r");
+    cs = 1;
+ 
+    // Select the device by seting chip select low
+    cs = 0;
+ 
+    // Send 0x8f, the command to read the WHOAMI register
+    spi.write(0x46);
+    spi.write(0x00);
+    spi.write(0x00);
+  
+    // Deselect the device
+    cs = 1;
+    printf("Starting \n\r");
+    while (true) {
+//        green();
+        read();
+//        wait(1);
+//        red();
+//        read();
+        wait(0.25);
+    }
+}
\ No newline at end of file