MODSERIAL with support for more devices
Dependents: 1D-Pong BMT-K9_encoder BMT-K9-Regelaar programma_filter ... more
Check the cookbook page for more information: https://mbed.org/cookbook/MODSERIAL
Did you add a device? Please send a pull request so we can keep everything in one library instead of many copies. In that case also send a PM, since currently mbed does not inform of new pull requests. I will then also add you to the developers of this library so you can do other changes directly.
Diff: PUTC.cpp
- Revision:
- 5:8365c4cf8f33
- Parent:
- 4:28de979b77cf
- Child:
- 6:c8f77fe1cc10
--- a/PUTC.cpp Sun Nov 21 14:44:02 2010 +0000 +++ b/PUTC.cpp Sun Nov 21 16:08:36 2010 +0000 @@ -34,7 +34,21 @@ } else { if (buffer[TxIrq] != (char *)NULL) { - if (block) while ( MODSERIAL_TX_BUFFER_FULL ) ; // Blocks! + if (block) { + while ( MODSERIAL_TX_BUFFER_FULL ) { // Blocks! + // If putc() is called from an ISR then we are stuffed + // because in an ISR no bytes from the TX buffer will + // get transferred to teh TX FIFOs while we block here. + // So, to work around this, instead of sitting in a + // loop waiting for space in the TX buffer (which will + // never happen in IRQ context), check to see if the + // TX FIFO has space available to move bytes from the + // TX buffer to TX FIFO to make space. The easiest way + // to do this is to poll the isr_tx() function while we + // are blocking. + isr_tx(); + } + } else if( MODSERIAL_TX_BUFFER_FULL ) { buffer_overflow[TxIrq] = c; // Oh dear, no room in buffer. _isr[TxOvIrq].call();