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.
Fork of MTS-Serial by
MTSSerial.h
00001 #ifndef MTSSERIAL_H 00002 #define MTSSERIAL_H 00003 00004 #include "MTSBufferedIO.h" 00005 00006 namespace mts 00007 { 00008 00009 /** This class derives from MTSBufferedIO and provides a buffered wrapper to the 00010 * standard mbed Serial class. Since it depends only on the mbed Serial class for 00011 * accessing serial data, this class is inherently portable accross different mbed 00012 * platforms. 00013 */ 00014 class MTSSerial : public MTSBufferedIO 00015 { 00016 public: 00017 /** Creates a new MTSSerial object that can be used to talk to an mbed serial port 00018 * through internal SW buffers. 00019 * 00020 * @param TXD the transmit data pin on the desired mbed Serial interface. 00021 * @param RXD the receive data pin on the desired mbed Serial interface. 00022 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The 00023 * default is 256 bytes. 00024 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The 00025 * default is 256 bytes. 00026 */ 00027 MTSSerial(PinName TXD, PinName RXD, int txBufferSize = 256, int rxBufferSize = 256); 00028 00029 /** Destructs an MTSSerial object and frees all related resources, including 00030 * internal buffers. 00031 */ 00032 ~MTSSerial(); 00033 00034 /** This method is used to the set the baud rate of the serial port. 00035 * 00036 * @param baudrate the baudrate in bps as an int. The default is 9600 bps. 00037 */ 00038 void baud(int baudrate); 00039 00040 /** This method sets the transmission format used by the serial port. 00041 * 00042 * @param bits the number of bits in a word (5-8; default = 8) 00043 * @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, 00044 * SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None) 00045 * @param stop the number of stop bits (1 or 2; default = 1) 00046 */ 00047 void format(int bits=8, SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1); 00048 00049 protected: 00050 RawSerial serial; // Internal mbed Serial object 00051 00052 private: 00053 virtual void handleWrite(); // Method for handling data to be written 00054 virtual void handleRead(); // Method for handling data to be read 00055 }; 00056 00057 } 00058 00059 #endif /* MTSSERIAL_H */
Generated on Wed Jul 13 2022 03:12:37 by
1.7.2
