MODSERIAL with support for more devices
Fork of MODSERIAL by
Diff: PUTC.cpp
- Revision:
- 4:28de979b77cf
- Parent:
- 2:b936b4acbd92
- Child:
- 5:8365c4cf8f33
--- a/PUTC.cpp Sun Nov 21 13:58:53 2010 +0000 +++ b/PUTC.cpp Sun Nov 21 14:44:02 2010 +0000 @@ -29,29 +29,27 @@ MODSERIAL::__putc(int c, bool block) { uint32_t lsr = (uint32_t)*((char *)_base + MODSERIAL_LSR); - if ( dmaInUse[TxIrq] == NotInUse ) { - if (lsr & 0x20 && MODSERIAL_TX_BUFFER_EMPTY ) { - _THR = (uint32_t)c; - } - else { - if (buffer[TxIrq] != (char *)NULL) { - if (block) while ( MODSERIAL_TX_BUFFER_FULL ) ; // Blocks! - else if( MODSERIAL_TX_BUFFER_FULL ) { - buffer_overflow[TxIrq] = c; // Oh dear, no room in buffer. - _isr[TxOvIrq].call(); - return -1; - } - buffer[TxIrq][buffer_in[TxIrq]] = c; - buffer_count[TxIrq]++; - buffer_in[TxIrq]++; - if (buffer_in[TxIrq] >= buffer_size[TxIrq]) { - buffer_in[TxIrq] = 0; - } - _IER |= 0x2; + if (lsr & 0x20 && MODSERIAL_TX_BUFFER_EMPTY ) { + _THR = (uint32_t)c; + } + else { + if (buffer[TxIrq] != (char *)NULL) { + if (block) while ( MODSERIAL_TX_BUFFER_FULL ) ; // Blocks! + else if( MODSERIAL_TX_BUFFER_FULL ) { + buffer_overflow[TxIrq] = c; // Oh dear, no room in buffer. + _isr[TxOvIrq].call(); + return -1; } + buffer[TxIrq][buffer_in[TxIrq]] = c; + buffer_count[TxIrq]++; + buffer_in[TxIrq]++; + if (buffer_in[TxIrq] >= buffer_size[TxIrq]) { + buffer_in[TxIrq] = 0; + } + _IER |= 0x2; } } - + return 0; }