USBUART - IRQ
Dependents: MPU9250AHRS_UBSUART-IRQ
Fork of MODSERIAL by
Diff: GETC.cpp
- Revision:
- 8:775f860e94d3
- Parent:
- 1:b7e435fbfe8e
- Child:
- 22:c11ea36f17f9
diff -r ffa4a7cb7f8d -r 775f860e94d3 GETC.cpp --- a/GETC.cpp Mon Nov 22 09:19:50 2010 +0000 +++ b/GETC.cpp Mon Nov 22 09:58:34 2010 +0000 @@ -28,6 +28,14 @@ int MODSERIAL::__getc(bool block) { + // If no buffer is in use fall back to standard RX FIFO usage. + // Note, we must block in this case and ignore bool "block" + // so as to maintain compat with Mbed Serial. + if (buffer_size[RxIrq] == 0 || buffer[RxIrq] == (char *)NULL) { + while(! MODSERIAL_RBR_HAS_DATA ) ; + return (int)(_RBR & 0xFF); + } + if (block) { while ( MODSERIAL_RX_BUFFER_EMPTY ) ; } // Blocks. else if ( MODSERIAL_RX_BUFFER_EMPTY ) return -1;