mbed library sources

Dependents:   Nucleo_blink_led

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Fri Oct 25 13:45:04 2013 +0100
Parent:
39:6f0d2ff04ac3
Child:
41:e8b66477f5bf
Commit message:
Synchronized with git revision 9d881770c95de5efecb420cd223375ebc93153b9

Changed in this revision

targets/hal/TARGET_NXP/TARGET_LPC176X/objects.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_NXP/TARGET_LPC176X/objects.h	Fri Oct 25 13:30:04 2013 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC176X/objects.h	Fri Oct 25 13:45:04 2013 +0100
@@ -47,6 +47,7 @@
 struct serial_s {
     LPC_UART_TypeDef *uart;
     int index;
+    uint8_t count;
 };
 
 struct analogin_s {
--- a/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c	Fri Oct 25 13:30:04 2013 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c	Fri Oct 25 13:45:04 2013 +0100
@@ -106,6 +106,7 @@
         case UART_2: obj->index = 2; break;
         case UART_3: obj->index = 3; break;
     }
+    obj->count = 0;
     
     is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);
     
@@ -283,6 +284,7 @@
 void serial_putc(serial_t *obj, int c) {
     while (!serial_writable(obj));
     obj->uart->THR = c;
+    obj->count++;
 }
 
 int serial_readable(serial_t *obj) {
@@ -290,7 +292,13 @@
 }
 
 int serial_writable(serial_t *obj) {
-    return obj->uart->LSR & 0x20;
+    int isWritable = 1;
+    if (obj->uart->LSR & 0x20)
+        obj->count = 0;
+    else if (obj->count >= 16)
+        isWritable = 0;
+        
+    return isWritable;
 }
 
 void serial_clear(serial_t *obj) {