mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Mar 18 11:00:08 2014 +0000
Parent:
121:245bc88f2e07
Child:
123:8a356fb1000a
Commit message:
Synchronized with git revision b95ba7a52a7ae9e1239b3adafff2293a2c7aebfd

Full URL: https://github.com/mbedmicro/mbed/commit/b95ba7a52a7ae9e1239b3adafff2293a2c7aebfd/

Changed in this revision

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/serial_api.c	Mon Mar 17 15:00:06 2014 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c	Tue Mar 18 11:00:08 2014 +0000
@@ -76,7 +76,7 @@
 struct serial_global_data_s {
     uint32_t serial_irq_id;
     gpio_t sw_rts, sw_cts;
-    uint8_t rx_irq_set_flow, rx_irq_set_api;
+    uint8_t count, rx_irq_set_flow, rx_irq_set_api;
 };
 
 static struct serial_global_data_s uart_data[UART_NUM];
@@ -100,7 +100,7 @@
         case UART_2: LPC_SC->PCONP |= 1 << 24; break;
         case UART_3: LPC_SC->PCONP |= 1 << 25; break;
     }
-    
+
     // enable fifos and default rx trigger level
     obj->uart->FCR = 1 << 0  // FIFO Enable - 0 = Disables, 1 = Enabled
                    | 0 << 1  // Rx Fifo Reset
@@ -357,6 +357,7 @@
 void serial_putc(serial_t *obj, int c) {
     while (!serial_writable(obj));
     obj->uart->THR = c;
+    uart_data[obj->index].count++;
 }
 
 int serial_readable(serial_t *obj) {
@@ -364,10 +365,16 @@
 }
 
 int serial_writable(serial_t *obj) {
+    int isWritable = 1;
     if (NC != uart_data[obj->index].sw_cts.pin)
-        return (gpio_read(&uart_data[obj->index].sw_cts) == 0) && (obj->uart->LSR & 0x40);  //If flow control: writable if CTS low + UART done
-    else
-        return obj->uart->LSR & 0x20;                                                       //No flow control: writable if space in holding register
+        isWritable = (gpio_read(&uart_data[obj->index].sw_cts) == 0) && (obj->uart->LSR & 0x40);  //If flow control: writable if CTS low + UART done
+    else {
+        if (obj->uart->LSR & 0x20)
+            uart_data[obj->index].count = 0;
+        else if (uart_data[obj->index].count >= 16)
+            isWritable = 0;
+    }
+    return isWritable;
 }
 
 void serial_clear(serial_t *obj) {