A temporary workaround for stdio hangs when using both inside and outside an interrupt

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
simon
Date:
Sat Feb 20 07:55:48 2010 +0000
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 51318bb188e2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 20 07:55:48 2010 +0000
@@ -0,0 +1,29 @@
+// using 2 serial instances to workaround hand bug while using printf both inside and outside interrupt
+
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+Serial pc2(USBTX, USBRX); // tx, rx
+
+// debugging LEDs
+DigitalOut interrupt(LED1);
+DigitalOut tx(LED4);
+
+void handle() {
+    char rx_byte = pc2.getc();
+    interrupt = !interrupt;
+}
+
+int main() {
+    pc2.attach(handle);
+
+    while (1) {
+        // send a long string of bytes
+        tx = 1;
+        for (int i=0;i<20;i++) {
+            printf("If I receive while transmitting this I will crash...\r\n");
+        }
+        tx = 0;
+        wait(1.0);
+    }
+}
diff -r 000000000000 -r 51318bb188e2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 20 07:55:48 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0