A library for talking to Multi-Tech's Cellular SocketModem Devices.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
io/MTSSerialFlowControl.h
- Committer:
- mfiore
- Date:
- 2013-12-19
- Revision:
- 40:14342c4de476
- Parent:
- 36:bb6b293c7495
- Parent:
- 39:6e94520a3217
- Child:
- 46:b30547bf07d5
File content as of revision 40:14342c4de476:
#ifndef MTSSERIALFLOWCONTROL_H #define MTSSERIALFLOWCONTROL_H #include "mbed.h" #include "MTSBufferedIO.h" namespace mts { 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 DigitalIn 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 DigitalIn 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); void notifyStartSending(); void notifyStopSending(); private: InterruptIn* rts; // Used to monitor the RTS line DigitalOut* cts; // Used to control the CTS line Serial* serial; // Internal Mbed Serial object bool clearToSend; // flag determining if the CTS line is valid int highThreshold; // int lowThreshold; char* if_name; void startSending(); void stopSending(); virtual void handleRead(); virtual void handleWrite(); }; } #endif /* MTSSERIALFLOWCONTROL */