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.

Files at this revision

API Documentation at this revision

Comitter:
stevew817
Date:
Wed May 13 12:09:20 2015 +0000
Parent:
2:77e141c1ffa9
Child:
4:bbf422ee69e4
Commit message:
bugfixes

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed May 13 11:59:39 2015 +0000
+++ b/main.cpp	Wed May 13 12:09:20 2015 +0000
@@ -50,12 +50,12 @@
 LowPowerTicker      blinker;
 bool                blinking = false;
 event_callback_t    serialEventCb;
-DigitalOut          LED;
-char                rx_buf[BUFF_LENGTH + 1];
+DigitalOut          LED(LED_PIN);
+uint8_t             rx_buf[BUFF_LENGTH + 1];
 
 /*------------------ Callbacks -------------------*/
 void blink(void) {
-    LED = ~LED;
+    LED = !LED;
 }
 
 void serialCb(int events) {
@@ -88,10 +88,10 @@
     }
     
     // Echo string, no callback
-    test_connection.write(rx_buf, i+1, (event_callback_t*)0, 0);
+    test_connection.write(rx_buf, i+1, 0, 0);
     
     // Reset serial reception
-    test_connection.read(rx_buf, BUFF_LENGTH, &serialEventCb, SERIAL_EVENT_RX_ALL, 'S');
+    test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'S');
 }
 
 /*-------------------- Main ----------------------*/
@@ -102,7 +102,7 @@
     /* Setup serial connection */
     test_connection.baud(BRATE);
     test_connection.printf("Low Power API test\n\nSend 'S' to toggle blinking\n");
-    test_connection.read(rx_buf, BUFF_LENGTH, &serialEventCb, SERIAL_EVENT_RX_ALL, 'S');
+    test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'S');
     
     /* Let the callbacks take care of everything */
     while(1) sleep();