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.
serialBuffer.cpp
- Committer:
- UHSLMarcus
- Date:
- 2016-10-03
- Revision:
- 0:dd6d74f39384
- Child:
- 1:985b6f1c7347
File content as of revision 0:dd6d74f39384:
#include "serialBuffer.h" SerialBuffer::SerialBuffer(PinName tx, PinName rx) : RawSerial(tx, rx) { RawSerial::attach(this, &SerialBuffer::rx_interrupt, Serial::RxIrq); return; } SerialBuffer::~SerialBuffer() { RawSerial::attach(NULL, RawSerial::RxIrq); return; } int SerialBuffer::readable() { return rx_buffer.readable(); } char SerialBuffer::getc() { char * output; RawSerial::attach(NULL, RawSerial::RxIrq); CircularBuffer<char>::nextItem nextChar = rx_buffer.getNext(); if (nextChar.success) output = (char*)nextChar.item; RawSerial::attach(this, &SerialBuffer::rx_interrupt, Serial::RxIrq); return *output; } void rx_interrupt(void) { if(serial_readable(&_serial) && rx_buffer.writeable()) { rx_buffer.add(serial_getc(&_serial)); } return; }