Dependencies:   FRDM_MMA8451Q KL46Z-USBHost MAG3110 SocketModem TSI mbed FATFileSystem

Fork of AxedaGo-Freescal_FRDM-KL46Z revert by Axeda Corp

Committer:
AxedaCorp
Date:
Wed Jul 02 15:59:38 2014 +0000
Revision:
1:5ad12c581db4
Parent:
0:65004368569c
url ip switch
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AxedaCorp 0:65004368569c 1 /* Universal Socket Modem Interface Library
AxedaCorp 0:65004368569c 2 * Copyright (c) 2013 Multi-Tech Systems
AxedaCorp 0:65004368569c 3 *
AxedaCorp 0:65004368569c 4 * Licensed under the Apache License, Version 2.0 (the "License");
AxedaCorp 0:65004368569c 5 * you may not use this file except in compliance with the License.
AxedaCorp 0:65004368569c 6 * You may obtain a copy of the License at
AxedaCorp 0:65004368569c 7 *
AxedaCorp 0:65004368569c 8 * http://www.apache.org/licenses/LICENSE-2.0
AxedaCorp 0:65004368569c 9 *
AxedaCorp 0:65004368569c 10 * Unless required by applicable law or agreed to in writing, software
AxedaCorp 0:65004368569c 11 * distributed under the License is distributed on an "AS IS" BASIS,
AxedaCorp 0:65004368569c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AxedaCorp 0:65004368569c 13 * See the License for the specific language governing permissions and
AxedaCorp 0:65004368569c 14 * limitations under the License.
AxedaCorp 0:65004368569c 15 */
AxedaCorp 0:65004368569c 16
AxedaCorp 0:65004368569c 17 #ifndef MTSSERIALFLOWCONTROL_H
AxedaCorp 0:65004368569c 18 #define MTSSERIALFLOWCONTROL_H
AxedaCorp 0:65004368569c 19
AxedaCorp 0:65004368569c 20 #include "mbed.h"
AxedaCorp 0:65004368569c 21 #include "MTSSerial.h"
AxedaCorp 0:65004368569c 22
AxedaCorp 0:65004368569c 23
AxedaCorp 0:65004368569c 24 namespace mts
AxedaCorp 0:65004368569c 25 {
AxedaCorp 0:65004368569c 26
AxedaCorp 0:65004368569c 27 /** This class derives from MTSBufferedIO/MTSSerial and provides a buffered wrapper to the
AxedaCorp 0:65004368569c 28 * standard mbed Serial class along with generic RTS/CTS HW flow control. Since it
AxedaCorp 0:65004368569c 29 * depends only on the mbed Serial, DigitalOut and InterruptIn classes for accessing
AxedaCorp 0:65004368569c 30 * the serial data, this class is inherently portable accross different mbed platforms
AxedaCorp 0:65004368569c 31 * and provides HW flow control even when not natively supported by the processors
AxedaCorp 0:65004368569c 32 * serial port. If HW flow control is not needed, use MTSSerial instead. It should also
AxedaCorp 0:65004368569c 33 * be noted that the RTS/CTS functionality in this class is implemented as a DTE device.
AxedaCorp 0:65004368569c 34 */
AxedaCorp 0:65004368569c 35 class MTSSerialFlowControl : public MTSSerial
AxedaCorp 0:65004368569c 36 {
AxedaCorp 0:65004368569c 37 public:
AxedaCorp 0:65004368569c 38 /** Creates a new MTSSerialFlowControl object that can be used to talk to an mbed serial
AxedaCorp 0:65004368569c 39 * port through internal SW buffers. Note that this class also adds the ability to use
AxedaCorp 0:65004368569c 40 * RTS/CTS HW Flow Conrtol through and standard mbed DigitalIn and DigitalOut pins.
AxedaCorp 0:65004368569c 41 * The RTS and CTS functionality assumes this is a DTE device.
AxedaCorp 0:65004368569c 42 *
AxedaCorp 0:65004368569c 43 * @param TXD the transmit data pin on the desired mbed serial interface.
AxedaCorp 0:65004368569c 44 * @param RXD the receive data pin on the desired mbed serial interface.
AxedaCorp 0:65004368569c 45 * @param RTS the DigitalOut pin that RTS will be attached to. (DTE)
AxedaCorp 0:65004368569c 46 * @param CTS the DigitalIn pin that CTS will be attached to. (DTE)
AxedaCorp 0:65004368569c 47 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The
AxedaCorp 0:65004368569c 48 * default is 64 bytes.
AxedaCorp 0:65004368569c 49 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The
AxedaCorp 0:65004368569c 50 * default is 64 bytes.
AxedaCorp 0:65004368569c 51 * @param name an optional name for the serial port. The default is blank.
AxedaCorp 0:65004368569c 52 */
AxedaCorp 0:65004368569c 53 MTSSerialFlowControl(PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize = 64, int rxBufSize = 64);
AxedaCorp 0:65004368569c 54
AxedaCorp 0:65004368569c 55 /** Destructs an MTSSerialFlowControl object and frees all related resources,
AxedaCorp 0:65004368569c 56 * including internal buffers.
AxedaCorp 0:65004368569c 57 */
AxedaCorp 0:65004368569c 58 ~MTSSerialFlowControl();
AxedaCorp 0:65004368569c 59
AxedaCorp 0:65004368569c 60 /** This method clears all the data from the internal Rx or read buffer.
AxedaCorp 0:65004368569c 61 */
AxedaCorp 0:65004368569c 62 virtual void rxClear();
AxedaCorp 0:65004368569c 63
AxedaCorp 0:65004368569c 64 private:
AxedaCorp 0:65004368569c 65 void notifyStartSending(); // Used to set cts start signal
AxedaCorp 0:65004368569c 66 void notifyStopSending(); // Used to set cts stop signal
AxedaCorp 0:65004368569c 67
AxedaCorp 0:65004368569c 68 //This device acts as a DTE
AxedaCorp 0:65004368569c 69 bool rxReadyFlag; //Tracks state change for rts signaling
AxedaCorp 0:65004368569c 70 DigitalOut rts; // Used to tell DCE to send or not send data
AxedaCorp 0:65004368569c 71 DigitalIn cts; // Used to check if DCE is ready for data
AxedaCorp 0:65004368569c 72 int highThreshold; // High water mark for setting cts to stop
AxedaCorp 0:65004368569c 73 int lowThreshold; // Low water mark for setting cts to start
AxedaCorp 0:65004368569c 74
AxedaCorp 0:65004368569c 75 virtual void handleRead(); // Method for handling data to be read
AxedaCorp 0:65004368569c 76 virtual void handleWrite(); // Method for handling data to be written
AxedaCorp 0:65004368569c 77 };
AxedaCorp 0:65004368569c 78
AxedaCorp 0:65004368569c 79 }
AxedaCorp 0:65004368569c 80
AxedaCorp 0:65004368569c 81 #endif /* MTSSERIALFLOWCONTROL */