Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ExoController MODSERIAL SDFileSystem_HelloWorld UI-Honka mbed
Fork of Data Management by
Diff: main.cpp
- Revision:
- 7:66a5ec0c5c26
- Parent:
- 6:784990d5180a
--- a/main.cpp	Wed Jan 14 23:42:14 2015 +0000
+++ b/main.cpp	Tue Jan 27 21:03:33 2015 +0000
@@ -4,45 +4,59 @@
 #include "UI.h"
 
 Timer t_debug;
+DigitalOut myled(LED1);
 int dataIn[4], dataOut[4], buffer;
 int counter=0;
 int ii=0;
+int flag;
+
+/*void slaveComm()
+{
+    __disable_irq();
+    //while(!comm.receive());
+    if(comm.receive()) {
+        buffer=comm.read();
+
+        if(buffer==0xFE) { //end of message
+            ii=0;
+            dataIn[3]=buffer;
+            comm.reply(5);
+            counter++;
+            if(BMS.read(msg)) {
+                if(msg.id==0x18FF8320) {
+                    //pc.printf("%x\r\n",msg.data[0]);
+                }
+            }
+            phone.attachment();
+        } else if(buffer==0xFF) { //beginning of message
+            ii=1;
+            dataIn[0]=buffer;
+            comm.reply(UI);
+        } else if(ii==1) {
+            ii++;
+            dataIn[1]=buffer;
+            comm.reply(52);
+        } else if(ii==2) {
+            ii++;
+            dataIn[2]=buffer;
+            comm.reply(25);
+        }
+    }
+    __enable_irq();
+    myled=1;
+
+}*/
 
 void slaveComm()
 {
-    __disable_irq();
-    while(!comm.receive());
-    buffer=comm.read();
-
-    if(buffer==0xFE) { //end of message
-        ii=0;
-        dataIn[3]=buffer;
-        comm.reply(5);
-        counter++;
-        if(BMS.read(msg)) {
-            if(msg.id==0x18FF8320) {
-                //pc.printf("%x\r\n",msg.data[0]);
-            }
-        }
-        phone.attachment();
-    } else if(buffer==0xFF) { //beginning of message
-        ii=1;
-        dataIn[0]=buffer;
-        comm.reply(UI);
-    } else if(ii==1) {
-        ii++;
-        dataIn[1]=buffer;
-        comm.reply(52);
-    } else if(ii==2) {
-        ii++;
-        dataIn[2]=buffer;
-        comm.reply(25);
-    }
-    __enable_irq();
+    myled=1;
+    flag=1;
+    counter++;
 }
 
 int main()
 {
+    myled=0;
     dataOut[0]=7;
     dataOut[1]=30;
     mainPower=1;//Don't turn on for initial testing
@@ -51,6 +65,15 @@
     ssel.fall(&slaveComm);
     pc.printf("DataBed On!\r\n");
     while (1) { //Run these functions as fast as possible
+        if(flag && comm.receive()) {
+            __disable_irq();
+            //if(comm.receive()) {
+            buffer=comm.read();
+            myled=0;
+            //}
+            __enable_irq();
+        }
+        flag=0;
         if(counter>=10) {
             UI=0;//set the UI to 0 unless it's changed in checkUI_Xbee()
             readBuffer();
@@ -58,6 +81,7 @@
             xbeeUI.rxBufferFlush();
             counter=0;
             pc.printf("UI: %d\r\n", UI);
+            pc.printf("buffer: %d \r\n", buffer);
         }
     }
 }
\ No newline at end of file
    