Added a custom wait function to enable interrupts

Fork of m3pi by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
dmcohen24
Date:
Tue Apr 08 16:43:07 2014 +0000
Parent:
8:4b7d6ea9b35b
Commit message:
Added class functions for interruptible wait function;

Changed in this revision

m3pi.cpp Show annotated file Show diff for this revision Revisions of this file
m3pi.h Show annotated file Show diff for this revision Revisions of this file
diff -r 4b7d6ea9b35b -r 35c3c0fa2416 m3pi.cpp
--- a/m3pi.cpp	Thu May 12 13:26:37 2011 +0000
+++ b/m3pi.cpp	Tue Apr 08 16:43:07 2014 +0000
@@ -27,11 +27,13 @@
 m3pi::m3pi(PinName nrst, PinName tx, PinName rx) :  Stream("m3pi"), _nrst(nrst), _ser(tx, rx)  {
     _ser.baud(115200);
     reset();
+    tail_flag = 0;
 }
 
 m3pi::m3pi() :  Stream("m3pi"), _nrst(p23), _ser(p9, p10)  {
     _ser.baud(115200);
     reset();
+    tail_flag = 0;
 }
 
 
@@ -194,7 +196,13 @@
     return(_ser.getc());
 }
 
-
+void m3pi::wait_10ms (int time){
+    int i = 0;
+    while(tail_flag == 0 && i < time){
+        wait(0.01);
+        i++;
+    }
+}
 
 
 
diff -r 4b7d6ea9b35b -r 35c3c0fa2416 m3pi.h
--- a/m3pi.h	Thu May 12 13:26:37 2011 +0000
+++ b/m3pi.h	Tue Apr 08 16:43:07 2014 +0000
@@ -85,6 +85,8 @@
     // Public functions
 public:
 
+    int tail_flag;
+
     /** Create the m3pi object connected to the default pins
      *
      * @param nrst GPIO pin used for reset. Default is p23
@@ -217,6 +219,8 @@
      * @param int The character to send to the 3pi
      */
     int print(char* text, int length);
+        
+    void wait_10ms (int time);
 
 #ifdef MBED_RPC
     virtual const struct rpc_method *get_rpc_methods();