MailBox solution

Dependencies:   ELEC350-Practicals-FZ429

Fork of Task633Solution-mbedos54 by Nicholas Outram

Revision:
13:f129e1339350
Parent:
12:6441be7b83c2
--- a/main.cpp	Mon Apr 03 14:28:21 2017 +0000
+++ b/main.cpp	Tue Nov 14 18:24:27 2017 +0000
@@ -2,6 +2,7 @@
 #include "string.h"
 #include <stdio.h>
 #include <ctype.h>
+#include "sample_hardware.hpp"
 
 #define SWITCH1_RELEASE 1
 
@@ -9,22 +10,8 @@
 void thread2();
 void switchISR();
 
-//Analogue inputs
-AnalogIn adcIn(A0);
-
-//Digital outputs
-DigitalOut onBoardLED(LED1);
-DigitalOut redLED(D7);
-DigitalOut yellowLED(D6);
-DigitalOut greenLED(D5);
-
-//Digital inputs
-DigitalIn  onBoardSwitch(USER_BUTTON);
-DigitalIn  sw1(D4);                         //CONSIDER CHANGING THIS TO AN INTERRUPT
-DigitalIn  sw2(D3);
-
 //Threads
-Thread *t1;
+Thread t1;
 
 //Class type
 class message_t {
@@ -58,8 +45,8 @@
     //Read sample - make a copy
     float sample = adcIn;
     //Grab switch state
-    uint32_t switch1State = sw1;
-    uint32_t switch2State = sw2;
+    uint32_t switch1State = SW1;
+    uint32_t switch2State = SW2;
     
     //Allocate a block from the memory pool
     message_t *message = mail_box.alloc();
@@ -131,20 +118,15 @@
 
 // Main thread
 int main() {
-    redLED    = 0;
-    yellowLED = 0;
-    greenLED  = 0;
-           
-    //Start message
-    printf("Welcome\n");           
-   
+    //Power on self-test
+    post();
+              
     //Hook up timer interrupt   
     Ticker timer; 
     timer.attach(&adcISR, 0.1);
                
     //Threads
-    t1 = new Thread();
-    t1->start(thread1); 
+    t1.start(thread1); 
     
     printf("Main Thread\n");
     while (true) {