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.

Revision:
113:65a335a675de
Parent:
109:bc5f94f2a67f
Child:
122:6790158fd562
--- a/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c	Fri Mar 07 16:00:07 2014 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c	Mon Mar 10 11:30:07 2014 +0000
@@ -76,7 +76,7 @@
 struct serial_global_data_s {
     uint32_t serial_irq_id;
     gpio_t sw_rts, sw_cts;
-    uint8_t count, rx_irq_set_flow, rx_irq_set_api;
+    uint8_t rx_irq_set_flow, rx_irq_set_api;
 };
 
 static struct serial_global_data_s uart_data[UART_NUM];
@@ -357,7 +357,6 @@
 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) {
@@ -365,16 +364,10 @@
 }
 
 int serial_writable(serial_t *obj) {
-    int isWritable = 1;
     if (NC != uart_data[obj->index].sw_cts.pin)
-        isWritable = (gpio_read(&uart_data[obj->index].sw_cts) == 0) && (obj->uart->LSR & 0x40);
-    else {
-        if (obj->uart->LSR & 0x20)
-            uart_data[obj->index].count = 0;
-        else if (uart_data[obj->index].count >= 16)
-            isWritable = 0;
-    }
-    return isWritable;
+        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
 }
 
 void serial_clear(serial_t *obj) {
@@ -419,7 +412,7 @@
             pinmap_pinout(txflow, PinMap_UART_CTS);
         } else {
             // Can't enable in hardware, use software emulation
-            gpio_init(&uart_data[index].sw_cts, txflow, PIN_INPUT);
+            gpio_init_in(&uart_data[index].sw_cts, txflow);
         }
     }
     if (((FlowControlRTS == type) || (FlowControlRTSCTS == type)) && (NC != rxflow)) {
@@ -434,8 +427,7 @@
             uart1->MCR |= UART_MCR_RTSEN_MASK;
             pinmap_pinout(rxflow, PinMap_UART_RTS);
         } else { // can't enable in hardware, use software emulation
-            gpio_init(&uart_data[index].sw_rts, rxflow, PIN_OUTPUT);
-            gpio_write(&uart_data[index].sw_rts, 0);
+            gpio_init_out_ex(&uart_data[index].sw_rts, rxflow, 0);
             // Enable RX interrupt
             serial_flow_irq_set(obj, 1);
         }