updates

Dependencies:   BLE_API mbed-dev-bin nRF51822

Fork of microbit-dal-eddystone by Martin Woolley

Files at this revision

API Documentation at this revision

Comitter:
LancasterUniversity
Date:
Wed Jul 13 12:18:25 2016 +0100
Parent:
45:23b71960fe6c
Child:
47:69f452b1a5c9
Commit message:
Synchronized with git rev 3b587e14
Author: James Devine
microbit-dal: serial SYNC_SLEEP / SYNC_SPINWAIT modes transmit all characters [issue #141]

In SYNC_SLEEP and SYNC_SPINWAIT modes the maximum length that could be
sent was always dictated by the buffer size.

This was incorrect as these two modes should wait until all characters
have been transmitted from the given buffer before returning control to
the user.

ASYNC mode will still return immediately after copying the number of
bytes available in the TX buffer.

Changed in this revision

source/drivers/MicroBitSerial.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/source/drivers/MicroBitSerial.cpp	Wed Jul 13 12:18:24 2016 +0100
+++ b/source/drivers/MicroBitSerial.cpp	Wed Jul 13 12:18:25 2016 +0100
@@ -489,9 +489,17 @@
             return result;
     }
 
-    int bytesWritten = setTxInterrupt(buffer, bufferLen, mode);
+    bool complete = false;
+    int bytesWritten = 0;
 
-    send(mode);
+    while(!complete)
+    {
+        bytesWritten += setTxInterrupt(buffer + bytesWritten, bufferLen - bytesWritten, mode);
+        send(mode);
+
+        if(mode == ASYNC || bytesWritten >= bufferLen)
+            complete = true;
+    }
 
     unlockTx();