GroupA / Mbed 2 deprecated Lab_6_WaG

Dependencies:   mbed

Fork of WaG by GroupA

Revision:
18:0e281922212c
Parent:
16:dfa9eb1a808d
Child:
20:d23bcd97f2c5
diff -r 75d567b60214 -r 0e281922212c display.cpp
--- a/display.cpp	Thu Mar 01 17:31:04 2018 +0000
+++ b/display.cpp	Fri Mar 02 22:18:47 2018 +0000
@@ -1,14 +1,14 @@
 /******************************************************************************
 * EECS 397
 *
-* Assignment Name: Lab 4: display_nums2
+* Assignment Name: Lab 5: WaG
 * 
 * Authors: Sam Morrison and Phong Nguyen 
 * File name: display.cpp
 * Purpose: Contain function definitions
 * 
-* Created: 02/21/2018
-* Last Modified: 02/27/2018
+* Created: 03/01/2018
+* Last Modified: 03/02/2018
 *
 ******************************************************************************/
 #include "mbed.h"
@@ -17,10 +17,13 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "spi.h"
 
 //#define VERSION1
 #define VERSION2
 
+extern SPI wag_spi;
+extern spi_cfg as1107;
 
 /*
  * void initial_setup(DigitalOut SS, int data_length, int frequency);
@@ -40,48 +43,19 @@
 */
 void initial_setup(DigitalOut SS, int data_length, int frequency) {
     SS = 1; 
-    spi.format(data_length, 0);
-    spi.frequency(frequency);
-    
-    SS = 0;
-    spi.write(0x0C01); //normal operation
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x090F); //decode to bits 0:3
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x0F00); //set to normal mode
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x0A0F); //intensity set to max
-    SS = 1;
+    wag_spi.format(data_length, 0);
+    wag_spi.frequency(frequency);
     
-    SS = 0;
-    spi.write(0x0B04); //display digits 0:4
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x0100); //set digit 1 to 0
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x0200); //set digit 2 to 0
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x0300); //set digit 3 to 0
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x0400); //set digit 4 to 0
-    SS = 1;
-    
-    SS = 0;
-    spi.write(0x0500); //set digit 5 to 0
-    SS = 1;
+    spi_send(as1107, 0x0C01);
+    spi_send(as1107, 0x090F);
+    spi_send(as1107, 0x0F00);
+    spi_send(as1107, 0x0A0F);
+    spi_send(as1107, 0x0B04);
+    spi_send(as1107, 0x0100);
+    spi_send(as1107, 0x0200);
+    spi_send(as1107, 0x0300);
+    spi_send(as1107, 0x0400);
+    spi_send(as1107, 0x0500);
 }
 
 
@@ -169,9 +143,6 @@
         // command has following form: 0x0[place]0[value]
         // the value converted to int is 16 * 16 * place + value
         command = 16 * 16 * i + bcd[i - 1]; 
-        
-        SS = 0;
-        spi.write(command);
-        SS = 1;
+        spi_send(as1107, command);
     }
 }
\ No newline at end of file