TEAMUSB / Mbed 2 deprecated SPI_Master_arch

Dependencies:   USBDevice mbed

Fork of SPI_HelloWorld_Mbed by mbed official

Revision:
3:849c7a28b185
Parent:
2:bae323a425ec
Child:
4:fb6fa24b502c
--- a/main.cpp	Tue Mar 10 16:46:32 2015 +0000
+++ b/main.cpp	Wed Mar 11 15:59:56 2015 +0000
@@ -1,18 +1,20 @@
 #include "mbed.h"
 #include "USBSerial.h"
- 
+
 SPI spi(P0_9, P0_8, P1_29); // mosi, miso, sclk
 USBSerial serial; 
+Serial pc(USBTX, USBRX);
 DigitalOut led(LED1);
+DigitalOut cs(P0_2);
  
 int main() {
 
     spi.format(8,0);
-    spi.frequency(10000);    
+    spi.frequency(1000000);    
     uint8_t i = 0; 
      
     while(1) {
-        
+        cs = 0;
         // Setup the spi for 8 bit data, high steady state clock,
         // second edge capture, with a 1MHz clock rate
         
@@ -23,12 +25,13 @@
         // Send a dummy byte to receive the contents of the WHOAMI register
         //int whoami = spi.write(0x00);
         //serial.printf("WHOAMI register = 0x%X\r\n", whoami);
+        wait(1.5);
         uint8_t receive = spi.write(i);
         serial.printf("send: 0x%X; received: = 0x%X\r\n", i, receive);
-        
-        wait(.5);
+        cs = 1;
+        wait(0.5);
         led = 1; 
-        wait(.5);
+        wait(1);
         led = 0;         
         i++;
     }