Simply UART communication for STM32F0 Discovery using mbed. Received char is sent back to the computer.

Dependencies:   mbed

Revision:
0:0fb9dd105439
Child:
1:2cae2115481a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 13 09:43:37 2015 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+
+//SERIAL_TX=PA_2/PA_9 Discovery
+//SERIAL_RX=PA_3/PA_10 Discovery
+Serial pc(PA_2, PA_3);
+
+DigitalOut myled(PC_8);
+char buffer[255];
+int prijato=0;
+
+void serialRx()
+{
+    while(pc.readable()) {
+        char c=pc.getc();
+        buffer[prijato++]=c;
+    }
+}
+
+int main()
+{
+    int i = 1;
+    pc.printf("Program started !\n");
+    pc.attach(&serialRx,Serial::RxIrq);
+    while(1) {
+        while(prijato) {
+            pc.printf("Prisel znak: %c (%d).\n", buffer[prijato-1],(int)buffer[prijato-1]);
+            prijato--;
+        }
+        wait(1);
+        pc.printf("This program runs since %d seconds.\n", i++);
+        myled = !myled;
+    }
+}