Inherit from Serial and use software buffers for TX and RX. This allows the UART peripherals to operate in a IRQ driven mode. Overrides most (but not all) stdio functions as Serial did
Dependencies: Buffer
Diff: BufferedSerial.cpp
- Revision:
- 13:e2a9eb801c48
- Parent:
- 11:779304f9c5d2
--- a/BufferedSerial.cpp Mon Mar 07 21:10:27 2016 +0000 +++ b/BufferedSerial.cpp Tue Sep 29 23:56:04 2020 +0000 @@ -26,6 +26,8 @@ BufferedSerial::BufferedSerial(PinName tx, PinName rx, uint32_t buf_size, uint32_t tx_multiple, const char* name) : RawSerial(tx, rx) , _rxbuf(buf_size), _txbuf((uint32_t)(tx_multiple*buf_size)) { + RawSerial::baud( 115200 ); + RawSerial::attach(this, &BufferedSerial::rxIrq, Serial::RxIrq); this->_buf_size = buf_size; this->_tx_multiple = tx_multiple;