Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c
- Revision:
- 40:5fa4b7c54c1d
- Parent:
- 20:4263a77256ae
- Child:
- 51:7838415c99e7
--- 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) {
