Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: serialBuffer.cpp
- Revision:
- 1:985b6f1c7347
- Parent:
- 0:dd6d74f39384
- Child:
- 6:ca024bcee813
--- a/serialBuffer.cpp Mon Oct 03 12:34:17 2016 +0000 +++ b/serialBuffer.cpp Tue Oct 04 09:18:23 2016 +0000 @@ -1,19 +1,20 @@ #include "serialBuffer.h" -SerialBuffer::SerialBuffer(PinName tx, PinName rx) : RawSerial(tx, rx) { - RawSerial::attach(this, &SerialBuffer::rx_interrupt, Serial::RxIrq); +utils::SerialBuffer::SerialBuffer(PinName tx, PinName rx) : RawSerial(tx, rx), rx_buffer(255) { + RawSerial::attach(this, &utils::SerialBuffer::rx_interrupt, Serial::RxIrq); return; } -SerialBuffer::~SerialBuffer() { +utils::SerialBuffer::~SerialBuffer() { RawSerial::attach(NULL, RawSerial::RxIrq); return; } -int SerialBuffer::readable() { +int utils::SerialBuffer::readable() { return rx_buffer.readable(); } -char SerialBuffer::getc() { + +char utils::SerialBuffer::getc() { char * output; RawSerial::attach(NULL, RawSerial::RxIrq); @@ -21,12 +22,12 @@ if (nextChar.success) output = (char*)nextChar.item; - RawSerial::attach(this, &SerialBuffer::rx_interrupt, Serial::RxIrq); + RawSerial::attach(this, &utils::SerialBuffer::rx_interrupt, Serial::RxIrq); return *output; } -void rx_interrupt(void) { +void utils::SerialBuffer::rx_interrupt(void) { if(serial_readable(&_serial) && rx_buffer.writeable()) { rx_buffer.add(serial_getc(&_serial)); }