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.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
io/MTSBufferedIO.cpp
- Committer:
- jengbrecht
- Date:
- 2013-12-09
- Revision:
- 0:563b70517320
- Child:
- 2:8d3ea0dfce39
File content as of revision 0:563b70517320:
#ifndef MTSBUFFEREDIO_CPP
#define MTSBUFFEREDIO_CPP
#include "MTSBufferedIO.h"
MTSBufferedIO::MTSBufferedIO(int txBufferSize, int rxBufferSize)
{
txBuffer = new MTSCircularBuffer(txBufferSize);
rxBuffer = new MTSCircularBuffer(rxBufferSize);
}
MTSBufferedIO::~MTSBufferedIO()
{
delete txBuffer;
delete rxBuffer;
}
int MTSBufferedIO::write(char* data, int length)
{
int tmp = txBuffer->write(data, length);
handleWrite();
return tmp;
}
int MTSBufferedIO::write(char data)
{
int tmp = txBuffer->write(data);
handleWrite();
return tmp;
}
int MTSBufferedIO::read(char* data, int length)
{
return rxBuffer->read(data, length);
}
int MTSBufferedIO::read()
{
return rxBuffer->read();
}
template<typename T>
void MTSBufferedIO::attach(T *tptr, void(T::*mptr)(void), int threshold, Vars::RelationalOperator op, Serial::IrqType type)
{
if (type == Serial::TxIrq) {
txBuffer->attach(tptr, mptr, threshold, op);
} else if (type == Serial::RxIrq) {
rxBuffer->attach(tptr, mptr, threshold, op);
}
}
void MTSBufferedIO::attach(void(*fptr)(void), int threshold, Vars::RelationalOperator op, Serial::IrqType type)
{
if (type == Serial::TxIrq) {
txBuffer->attach(fptr, threshold, op);
} else if (type == Serial::RxIrq) {
rxBuffer->attach(fptr, threshold, op);
}
}
bool MTSBufferedIO::txEmpty()
{
return txBuffer->isEmpty();
}
bool MTSBufferedIO::rxEmpty()
{
return rxBuffer->isEmpty();
}
bool MTSBufferedIO::txFull()
{
return txBuffer->isFull();
}
bool MTSBufferedIO::rxFull()
{
return rxBuffer->isFull();
}
void MTSBufferedIO::txClear()
{
txBuffer->clear();
}
void MTSBufferedIO::rxClear()
{
rxBuffer->clear();
}
int MTSBufferedIO::txAvailable()
{
return txBuffer->available();
}
int MTSBufferedIO::rxAvailable()
{
return rxBuffer->available();
}
int MTSBufferedIO::txCapacity()
{
return txBuffer->capacity();
}
int MTSBufferedIO::rxCapacity()
{
return rxBuffer->capacity();
}
#endif /* MTSBUFFEREDSERIAL_CPP */
uIP Socket Modem Shield (Outdated - see below)