MailBox solution

Dependencies:   ELEC350-Practicals-FZ429

Fork of Task633Solution-mbedos54 by Nicholas Outram

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Tue Nov 14 18:24:27 2017 +0000
Parent:
12:6441be7b83c2
Commit message:
Updated for FZ429

Changed in this revision

ELEC350-Practicals-FZ429.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 6441be7b83c2 -r f129e1339350 ELEC350-Practicals-FZ429.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ELEC350-Practicals-FZ429.lib	Tue Nov 14 18:24:27 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/University-of-Plymouth-Stage-2-and-3/code/ELEC350-Practicals-FZ429/#3250ba797c16
diff -r 6441be7b83c2 -r f129e1339350 main.cpp
--- 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) {
diff -r 6441be7b83c2 -r f129e1339350 mbed-os.lib
--- a/mbed-os.lib	Mon Apr 03 14:28:21 2017 +0000
+++ b/mbed-os.lib	Tue Nov 14 18:24:27 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d
+https://github.com/ARMmbed/mbed-os/#78474a5129e18e136cc7e872adbaa5b74fbb8f6a