Shift reg led (ICRS)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
je310
Date:
Wed Jun 17 15:57:58 2015 +0000
Commit message:
hello world;

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 000000000000 -r 9ff3d26e2cb8 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 17 15:57:58 2015 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+ 
+SPI spi(p11, p12, p13); // mosi, miso, sclk
+DigitalOut cs(p8);
+DigitalOut fire(p29);
+DigitalOut step(p26);
+DigitalOut dir(p27);
+int main() {
+    // Chip must be deselected
+    fire = 1;
+    cs = 1;
+ 
+    // Setup the spi for 8 bit data, high steady state clock,
+    // second edge capture, with a 1MHz clock rate
+    spi.format(8,3);
+    spi.frequency(1000000);
+    char myChar = 0x01;
+    int count = 0;
+    int skip = 0;
+    dir = 1;
+    step = 1;
+ 
+    // Send 0x8f, the command to read the WHOAMI register
+    
+    
+    for(int i = 0; i<8; i++){
+        spi.write(myChar);
+    }
+    
+    while(1){
+        fire = 0;
+        step = 0;
+        wait_us(250);
+        fire = 1;
+        step = 1;
+        wait_us(10);
+        if(count == 80 && skip == 0){
+            if(myChar != 0x80){
+                myChar = myChar << 1;
+            }
+            else{
+                myChar = 0x01;
+                skip = 1;
+            }
+                
+            
+            for(int i = 0; i<8; i++){
+                spi.write(myChar);
+            }
+            count =0;
+        }
+        
+        count++;
+        if(skip ==1){
+            //count = 20;    
+            skip = 0;
+        }
+    
+    }
+
+}
\ No newline at end of file
diff -r 000000000000 -r 9ff3d26e2cb8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jun 17 15:57:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cbbeb26dbd92
\ No newline at end of file