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/MTSSerialFlowControl.h
- Committer:
- sgodinez
- Date:
- 2013-12-26
- Revision:
- 78:ef3ee53cf5df
- Parent:
- 77:d7b14688a704
- Child:
- 83:9813f9b8ee68
File content as of revision 78:ef3ee53cf5df:
#ifndef MTSSERIALFLOWCONTROL_H
#define MTSSERIALFLOWCONTROL_H
#include "mbed.h"
#include "MTSBufferedIO.h"
namespace mts
{
/** This class derives from MTSBufferedIO and provides a buffered wrapper to the
* standard mbed Serial class along with generic RTS/CTS HW flow control. Since it
* depends only on the mbed Serial, DigitalOut and InterruptIn classes for accessing
* the serial data, this class is inherently portable accross different mbed platforms
* and provides HW flow control even when not natively supported by the processors
* serial port. If HW flow control is not needed, use MTSSerial instead.
*/
class MTSSerialFlowControl : public MTSBufferedIO
{
public:
/** Creates a new MTSSerialFlowControl object that can be used to talk to an mbed serial
* port through internal SW buffers. Note that this class also adds the ability to use
* RTS/CTS HW Flow Conrtol through and standard mbed InterruptIn and DigitalOut pins.
*
* @param TXD the transmit data pin on the desired mbed serial interface.
* @param RXD the receive data pin on the desired mbed serial interface.
* @param RTS the InterruptIn pin that RTS will be attached to.
* @param CTS the DigitalOut pin that CTS will be attached to.
* @param txBufferSize the size in bytes of the internal SW transmit buffer. The
* default is 64 bytes.
* @param rxBufferSize the size in bytes of the internal SW receive buffer. The
* default is 64 bytes.
* @param name an optional name for the serial port. The default is blank.
*/
MTSSerialFlowControl(PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize = 64, int rxBufSize = 64, char* name = "");
/** Destructs an MTSSerialFlowControl object and frees all related resources,
* including internal buffers.
*/
~MTSSerialFlowControl();
/** This method is used to the set the baud rate of the serial port.
*
* @param baudrate the baudrate in bps as an int. The internal interface
* default is 9600 bps.
*/
void baud(int baudrate);
/** This method sets the transmission format used by the serial port.
*
* @param bits the number of bits in a word (5-8; default = 8)
* @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even,
* SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
* @param stop the number of stop bits (1 or 2; default = 1)
*/
void format(int bits=8, SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1);
private:
void notifyStartSending(); // Used to set cts start signal
void notifyStopSending(); // Used to set cts stop signal
//This device acts as a DTE
DigitalOut* rts; // Used to tell DCE to send or not send data
DigitalIn* cts; // Used to check if DCE is ready for data
Serial* serial; // Internal Mbed Serial object
int highThreshold; // High water mark for setting cts to stop
int lowThreshold; // Low water mark for setting cts to start
char* if_name; // Internal variable for interface name
virtual void handleRead(); // Method for handling data to be read
virtual void handleWrite(); // Method for handling data to be written
};
}
#endif /* MTSSERIALFLOWCONTROL */
uIP Socket Modem Shield (Outdated - see below)