SDI lab / Mbed 2 deprecated Test_Burst_2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Brianmic
Date:
Mon Jan 20 20:11:21 2014 +0000
Commit message:
Test_burst_byhand

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 20 20:11:21 2014 +0000
@@ -0,0 +1,91 @@
+#include "mbed.h"
+ 
+DigitalOut redLed( LED_RED ); // Led used to signal errors
+DigitalOut greenLed( LED_GREEN );
+DigitalOut spiSS( PTD0 ); // Slave select is handled by GPIO
+Serial PC (USBTX, USBRX);
+ 
+int main() {
+    redLed = 1;
+    greenLed = 1;
+    // Create SPI master instance, 8bit, CPOL=0, CPHA=1, 100kHz
+    SPI spiMaster( PTD2, PTD3, PTD1 ); // mosi, miso, sclk
+    spiMaster.format( 8, 1 );
+    spiMaster.frequency( 100000 );
+    
+    PC.baud(115200);
+    // Deselect slave
+    spiSS = 1;
+    // Forever
+    wait(1);
+    
+    while( 1 ) {
+        uint8_t data[16];
+        // Burst write
+        spiSS = 0;
+        spiMaster.write( '#' );
+        spiMaster.write( 0x07 ); // write RAM burst
+        spiMaster.write( 0x01 ); // AA1
+        spiMaster.write( 0x02 ); // AA2
+        spiMaster.write( 0x03 ); // AA3
+        
+        spiMaster.write( 0x01 );
+        spiMaster.write( 0x01 );
+        
+        spiMaster.write( 0x55 ); //buco
+        spiMaster.write( 0x55 ); //@
+        
+        spiMaster.write( 0x02 );
+        spiMaster.write( 0x02 );
+        
+        spiMaster.write( 0x55 ); //buco
+        spiMaster.write( 0x55 ); //@
+        
+        spiMaster.write( 0x03 );
+        spiMaster.write( 0x03 );
+        
+        spiMaster.write( 0x55 ); //buco
+        spiMaster.write( 0x55 ); //@
+        
+        spiMaster.write( '#' ); //#
+        
+        spiSS = 1;
+        
+        wait(1);
+        
+        spiSS = 0;
+        spiMaster.write( '#' );
+        spiMaster.write( 0x05 ); // write RAM burst
+        spiMaster.write( 0x01 ); // AA1
+        spiMaster.write( 0x02 ); // AA2
+        spiMaster.write( 0x03 ); // AA3
+        
+        spiMaster.write( 0x01 ); //buco
+        spiMaster.write( 0x01 ); //@
+       
+        data[0] = spiMaster.write( 0x55 ); //DD1 1
+        data[1] = spiMaster.write( 0x55 ); //DD2 1
+        
+        spiMaster.write( 0x01 ); //buco
+        spiMaster.write( 0x01 ); //@
+       
+        data[2] = spiMaster.write( 0x55 ); //DD1 2
+        data[3] = spiMaster.write( 0x55 ); //DD2 2
+        
+        spiMaster.write( 0x01 ); //buco
+        spiMaster.write( 0x01 ); //@
+       
+        data[4] = spiMaster.write( 0x55 ); //DD1 3
+        data[5] = spiMaster.write( '#' ); //DD2 3
+        
+        for(int i = 0; i<3 ; i++)
+        {
+            PC.printf("%d.%d\r\n", data[2*i], data[2*i+1]);
+        }        
+        
+        spiSS = 1;
+        wait(2);
+
+    }
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jan 20 20:11:21 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file