mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
Diff: targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c
- Revision:
- 113:65a335a675de
- Parent:
- 109:bc5f94f2a67f
- Child:
- 122:6790158fd562
diff -r a7168c414ef2 -r 65a335a675de targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c --- 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); }