mbed-os/libraries
Adam Green 969733ae8f serial_putc() to make better use of Tx FIFO
If don't know if this is an issue that anyone cares about.  I am also
not sure what the best way to solve it is either.  I just thought I
would issue a pull request with this commit to bring the issue to light
and show a possible solution that I have tested on my mbed-1768 device.

Previously the serial_putc() API didn't make any use of the Tx FIFO
since the serial_writable() API it utilizes only returns true when the
FIFO is completely empty.  This is due to the fact that the THRE bit of
the UART's LSR (Line Status Register) only goes high when the whole
FIFO is empty.

I noticed this when doing some performance testing with the network
stack.  I went from calling printf() to output 3 bytes every 10 seconds
(with packet drop stats) to instead output 4 bytes every 10 seconds.
I thought these should easily fit in the 16 byte FIFO but outputting
one extra byte caused an additional three 550 byte UDP packets to be
dropped.  This should only happen if the additional character being
sent to the UART was taking away extra CPU cycles from the network
stack.

My solution is to keep track of the number of bytes that have been
placed in the Tx FIFO since it was last detected as being completely
empty (via the THRE bit).  Only once this count hits 16 does the code
then block, waiting for the THRE bit to go high.  Each time the THRE
bit does go high, the count is reset to 0 again and it is incremented
for each byte that is loaded into the THR.
2013-10-25 15:17:06 +03:00
..
USBDevice USBDevice memory leaks fixes 2013-09-12 16:35:52 +03:00
USBHost Modifications for compatibility with GCC 2013-10-17 10:34:07 +03:00
doc Initial commit of the mbed libraries and tools 2013-02-18 15:32:11 +00:00
dsp Initial commit of the mbed libraries and tools 2013-02-18 15:32:11 +00:00
fs fs: Silence GCC signed/unsigned warnings 2013-08-19 22:53:49 -07:00
mbed serial_putc() to make better use of Tx FIFO 2013-10-25 15:17:06 +03:00
net Added CellularModem as an abstract base class for modem implementations 2013-10-17 15:40:46 +03:00
rpc Added LPC1114 and target for some test cases 2013-08-16 00:24:09 +09:00
rtos [LPC812] Added RTOS support 2013-09-11 02:30:27 +09:00
tests Added new serial class, remove interrupt chaining 2013-10-23 16:08:34 +03:00