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

Committer:
jengbrecht
Date:
Fri Dec 27 15:55:35 2013 +0000
Revision:
83:9813f9b8ee68
Parent:
78:ef3ee53cf5df
Child:
86:186bbf974c7c
Changed MTSSerialFlowControl to inherit from MTSSerial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jengbrecht 0:563b70517320 1 #ifndef MTSSERIALFLOWCONTROL_H
jengbrecht 0:563b70517320 2 #define MTSSERIALFLOWCONTROL_H
jengbrecht 0:563b70517320 3
jengbrecht 0:563b70517320 4 #include "mbed.h"
jengbrecht 83:9813f9b8ee68 5 #include "MTSSerial.h"
jengbrecht 83:9813f9b8ee68 6
mfiore 2:8d3ea0dfce39 7
jengbrecht 77:d7b14688a704 8 namespace mts
jengbrecht 77:d7b14688a704 9 {
mfiore 39:6e94520a3217 10
jengbrecht 83:9813f9b8ee68 11 /** This class derives from MTSBufferedIO/MTSSerial and provides a buffered wrapper to the
jengbrecht 45:40745c2036cf 12 * standard mbed Serial class along with generic RTS/CTS HW flow control. Since it
jengbrecht 45:40745c2036cf 13 * depends only on the mbed Serial, DigitalOut and InterruptIn classes for accessing
jengbrecht 45:40745c2036cf 14 * the serial data, this class is inherently portable accross different mbed platforms
jengbrecht 45:40745c2036cf 15 * and provides HW flow control even when not natively supported by the processors
jengbrecht 83:9813f9b8ee68 16 * serial port. If HW flow control is not needed, use MTSSerial instead. It should also
jengbrecht 83:9813f9b8ee68 17 * be noted that the RTS/CTS functionality in this class is implemented as a DTE device.
jengbrecht 45:40745c2036cf 18 */
jengbrecht 83:9813f9b8ee68 19 class MTSSerialFlowControl : public MTSSerial
jengbrecht 0:563b70517320 20 {
jengbrecht 0:563b70517320 21 public:
jengbrecht 45:40745c2036cf 22 /** Creates a new MTSSerialFlowControl object that can be used to talk to an mbed serial
jengbrecht 36:bb6b293c7495 23 * port through internal SW buffers. Note that this class also adds the ability to use
jengbrecht 83:9813f9b8ee68 24 * RTS/CTS HW Flow Conrtol through and standard mbed DigitalIn and DigitalOut pins.
jengbrecht 83:9813f9b8ee68 25 * The RTS and CTS functionality assumes this is a DTE device.
jengbrecht 36:bb6b293c7495 26 *
jengbrecht 45:40745c2036cf 27 * @param TXD the transmit data pin on the desired mbed serial interface.
jengbrecht 45:40745c2036cf 28 * @param RXD the receive data pin on the desired mbed serial interface.
jengbrecht 83:9813f9b8ee68 29 * @param RTS the DigitalOut pin that RTS will be attached to. (DTE)
jengbrecht 83:9813f9b8ee68 30 * @param CTS the DigitalIn pin that CTS will be attached to. (DTE)
jengbrecht 36:bb6b293c7495 31 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The
jengbrecht 36:bb6b293c7495 32 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 33 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The
jengbrecht 36:bb6b293c7495 34 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 35 * @param name an optional name for the serial port. The default is blank.
jengbrecht 36:bb6b293c7495 36 */
mfiore 10:2bd727a4b329 37 MTSSerialFlowControl(PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize = 64, int rxBufSize = 64, char* name = "");
jengbrecht 36:bb6b293c7495 38
jengbrecht 36:bb6b293c7495 39 /** Destructs an MTSSerialFlowControl object and frees all related resources,
jengbrecht 36:bb6b293c7495 40 * including internal buffers.
jengbrecht 36:bb6b293c7495 41 */
jengbrecht 0:563b70517320 42 ~MTSSerialFlowControl();
jengbrecht 36:bb6b293c7495 43
jengbrecht 0:563b70517320 44 private:
jengbrecht 77:d7b14688a704 45 void notifyStartSending(); // Used to set cts start signal
jengbrecht 77:d7b14688a704 46 void notifyStopSending(); // Used to set cts stop signal
sgodinez 78:ef3ee53cf5df 47
sgodinez 78:ef3ee53cf5df 48 //This device acts as a DTE
sgodinez 78:ef3ee53cf5df 49 DigitalOut* rts; // Used to tell DCE to send or not send data
sgodinez 78:ef3ee53cf5df 50 DigitalIn* cts; // Used to check if DCE is ready for data
jengbrecht 45:40745c2036cf 51 int highThreshold; // High water mark for setting cts to stop
jengbrecht 45:40745c2036cf 52 int lowThreshold; // Low water mark for setting cts to start
jengbrecht 36:bb6b293c7495 53
jengbrecht 45:40745c2036cf 54 virtual void handleRead(); // Method for handling data to be read
jengbrecht 45:40745c2036cf 55 virtual void handleWrite(); // Method for handling data to be written
jengbrecht 0:563b70517320 56 };
mfiore 2:8d3ea0dfce39 57
mfiore 39:6e94520a3217 58 }
mfiore 39:6e94520a3217 59
jengbrecht 0:563b70517320 60 #endif /* MTSSERIALFLOWCONTROL */