A code sample showing the use of the asynchronous Serial APIs.

Dependencies:   mbed

Beware: this example is only compatible with boards supporting the asynchronous APIs!

Information

All examples in this repo are considered EXPERIMENTAL QUALITY, meaning this code has been created as one-off proof-of-concept and is suitable as a demonstration for experimental purposes only. This code will not be regularly maintained by Silicon Labs and there is no guarantee that these projects will work across all environments, SDK versions and hardware.

Revision:
4:bbf422ee69e4
Parent:
3:f911d11682f3
Child:
5:997e92a78a3b
--- a/main.cpp	Wed May 13 12:09:20 2015 +0000
+++ b/main.cpp	Wed Jun 24 07:28:48 2015 +0000
@@ -60,10 +60,10 @@
 
 void serialCb(int events) {
     /* Something triggered the callback, either buffer is full or 'S' is received */
-    unsigned char i = 0;
+    unsigned char i;
     if(events & SERIAL_EVENT_RX_CHARACTER_MATCH) {
         //Received 'S', check for buffer length
-        for(unsigned char i; i < BUFF_LENGTH; i++) {
+        for(i = 0; i < BUFF_LENGTH; i++) {
             //Found the length!
             if(rx_buf[i] == 'S') break;
         }