Updated

Dependents:   PROJECTTEST

Files at this revision

API Documentation at this revision

Comitter:
Swabey89
Date:
Sat Jan 05 15:03:05 2019 +0000
Commit message:
Updated

Changed in this revision

switches.cpp Show annotated file Show diff for this revision Revisions of this file
switches.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/switches.cpp	Sat Jan 05 15:03:05 2019 +0000
@@ -0,0 +1,62 @@
+#include "switches.h"
+
+/*
+//Thread events
+osEvent evt1;
+osEvent evt2;
+
+//Thread ID
+osThreadId sw1functionid;
+osThreadId sw2functionid;
+osThreadId startid;
+
+InterruptIn sw1(PE_12);
+InterruptIn sw2(PE_14);
+
+SwitchDebounce* sm1;
+SwitchDebounce* sm2;
+
+//Date and Time Iniziliazation
+int dd=00;          //Reresents day
+int mm=00;          //Reresents month
+int yy=00;          //Reresents year
+
+int hh=00;          //Represents Hour 
+int minute=00;      //Represents minute
+int ss=00;          //Represents Seconds
+
+//Thread Iniziliazation
+Thread t1;
+Thread t2;
+Thread t3;
+*/
+
+//Interrupt service routine for handling the timeout
+void userswTimeOutHandler() {
+    userswTimeOut.detach();            //Stop the timeout counter firing
+
+    //Which event does this follow?
+    switch (userswState) {
+    case EDGE_RISEN:    
+        usersw.fall(&userswFallingEdge);  //Now wait for a falling edge
+        break;
+    case EDGE_FALLEN:
+        usersw.rise(&userswRisingEdge);   //Now wait for a rising edge
+        break;
+    } //end switch 
+}
+
+//Interrupt service routine for a rising edge (press)
+void userswRisingEdge() {
+    usersw.rise(NULL);             //Disable detecting more rising edges
+    userswState = EDGE_RISEN;      //Flag state
+    userswTimeOut.attach(&userswTimeOutHandler, 0.2);    //Start timeout timer
+}
+
+//Interrupt service routive for SW1 falling edge (release)
+void userswFallingEdge() {
+    usersw.fall(NULL);                         //Disable this interrupt    
+    SDqueue.call(SDmount);
+    userswState = EDGE_FALLEN;                 //Flag state
+    userswTimeOut.attach(&userswTimeOutHandler, 10);    //Start timeout counter 
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/switches.h	Sat Jan 05 15:03:05 2019 +0000
@@ -0,0 +1,24 @@
+#ifndef __switches_H__
+#define __switches_H__
+
+#include "main.h"
+#include "SDCard.hpp"
+
+/*
+#define t1signal 							1
+#define t2signal 							2
+#define SW1_FUNCTION_SIGNAL  	3
+#define SW2_FUNCTION_SIGNAL 	4
+#define startsignal 					5
+
+extern void sw1_Function();   
+extern void sw2_Function();
+extern void START();
+*/
+
+extern void userswTimeOutHandler();
+extern void userswRisingEdge();
+extern void userswFallingEdge();
+
+
+#endif
\ No newline at end of file