Library of hardware declarations and utility functions for the ELEC350/1 Practicals and Coursework

Dependents:   Task618-mbedos-F429ZI Task621-mbedos_FZ429ZI Task622-mbedos-FZ429ZI Task632-mbedos-FZ429 ... more

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Wed Nov 22 15:18:12 2017 +0000
Parent:
3:768d30157488
Child:
5:58ba1a6dbf60
Commit message:
Error codes using LEDs

Changed in this revision

sample_hardware.cpp Show annotated file Show diff for this revision Revisions of this file
sample_hardware.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/sample_hardware.cpp	Tue Nov 21 13:23:36 2017 +0000
+++ b/sample_hardware.cpp	Wed Nov 22 15:18:12 2017 +0000
@@ -39,4 +39,22 @@
     
     //Output the ADC
     printf("ADC: %f\n\r", adcIn.read());
+}
+
+void errorCode(ELEC350_ERROR_CODE err)
+{
+            switch (err) {
+              case OK:
+                greenLED = 1;
+                wait(1.0);
+                greenLED = 0;
+                return;                
+              case FATAL:
+                while(1) {
+                    redLED = 1;
+                    wait(0.1);
+                    redLED = 0;
+                    wait(0.1);                
+                }
+            };
 }
\ No newline at end of file
--- a/sample_hardware.hpp	Tue Nov 21 13:23:36 2017 +0000
+++ b/sample_hardware.hpp	Wed Nov 22 15:18:12 2017 +0000
@@ -1,5 +1,7 @@
 #ifndef __sample_hardware__
 #define __sample_hardware__
+enum ELEC350_ERROR_CODE {OK, FATAL};
+
 extern DigitalOut onBoardLED;
 extern DigitalOut redLED;
 extern DigitalOut yellowLED;
@@ -12,5 +14,6 @@
 extern AnalogIn adcIn;
 
 extern void post();
+extern void errorCode(ELEC350_ERROR_CODE err);
 
 #endif
\ No newline at end of file