Lab 6 code.

Dependencies:   mbed

Fork of WaG by GroupA

Revision:
8:d8bc78bda829
Parent:
7:161fe3793ddb
Child:
11:6751b9406142
--- a/main.cpp	Thu Feb 22 02:06:07 2018 +0000
+++ b/main.cpp	Thu Feb 22 03:10:01 2018 +0000
@@ -11,64 +11,21 @@
 *
 ******************************************************************************/
 #include "mbed.h"
+#include "io_pins.h"
+#include "display.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
+int data_length = 16;
+int frequency = 1000000;
+
 DigitalOut SS(CHIP_SELECT);
-
 SPI spi(MOSI, MISO, SCLK);
 Serial pc(USBTX, USBRX);
 
-bool num_range(char input[5]);
-int convert(int dec);
-char to_command(char input, int place);
-int bcd[4];
-
 int main(void) {
-    SS = 1; 
-    
-    spi.format(16,0);
-    spi.frequency(1000000);
-    
-    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;
-    
-    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
+    initial_setup(SS, data_length, frequency);
     
     float command = 0x0100;
     int input;
@@ -95,7 +52,7 @@
         command = atof(command_text); //converts string to float
         */
         
-        pc.printf("command: %s\n", command_text);
+        //pc.printf("command: %s\n", command_text);
         
         
         SS = 0;