MTS_SPI_Slave unfinished

Fork of MTS-Serial by MultiTech

Committer:
Mike Fiore
Date:
Mon May 19 11:18:10 2014 -0500
Revision:
1:d34b566d6f47
Parent:
0:6585b7c8cd41
Child:
4:d348d001283b
add MTSBufferedIO, MTSSerial, and MTSSerialFlowControl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfiore 0:6585b7c8cd41 1 #ifndef MTSSERIAL_H
mfiore 0:6585b7c8cd41 2 #define MTSSERIAL_H
mfiore 0:6585b7c8cd41 3
Mike Fiore 1:d34b566d6f47 4 #include "mbed.h"
Mike Fiore 1:d34b566d6f47 5 #include "MTSBufferedIO.h"
Mike Fiore 1:d34b566d6f47 6
Mike Fiore 1:d34b566d6f47 7 namespace mts
Mike Fiore 1:d34b566d6f47 8 {
Mike Fiore 1:d34b566d6f47 9
Mike Fiore 1:d34b566d6f47 10 /** This class derives from MTSBufferedIO and provides a buffered wrapper to the
Mike Fiore 1:d34b566d6f47 11 * standard mbed Serial class. Since it depends only on the mbed Serial class for
Mike Fiore 1:d34b566d6f47 12 * accessing serial data, this class is inherently portable accross different mbed
Mike Fiore 1:d34b566d6f47 13 * platforms.
Mike Fiore 1:d34b566d6f47 14 */
Mike Fiore 1:d34b566d6f47 15 class MTSSerial : public MTSBufferedIO
Mike Fiore 1:d34b566d6f47 16 {
Mike Fiore 1:d34b566d6f47 17 public:
Mike Fiore 1:d34b566d6f47 18 /** Creates a new MTSSerial object that can be used to talk to an mbed serial port
Mike Fiore 1:d34b566d6f47 19 * through internal SW buffers.
Mike Fiore 1:d34b566d6f47 20 *
Mike Fiore 1:d34b566d6f47 21 * @param TXD the transmit data pin on the desired mbed Serial interface.
Mike Fiore 1:d34b566d6f47 22 * @param RXD the receive data pin on the desired mbed Serial interface.
Mike Fiore 1:d34b566d6f47 23 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The
Mike Fiore 1:d34b566d6f47 24 * default is 256 bytes.
Mike Fiore 1:d34b566d6f47 25 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The
Mike Fiore 1:d34b566d6f47 26 * default is 256 bytes.
Mike Fiore 1:d34b566d6f47 27 */
Mike Fiore 1:d34b566d6f47 28 MTSSerial(PinName TXD, PinName RXD, int txBufferSize = 256, int rxBufferSize = 256);
Mike Fiore 1:d34b566d6f47 29
Mike Fiore 1:d34b566d6f47 30 /** Destructs an MTSSerial object and frees all related resources, including
Mike Fiore 1:d34b566d6f47 31 * internal buffers.
Mike Fiore 1:d34b566d6f47 32 */
Mike Fiore 1:d34b566d6f47 33 ~MTSSerial();
Mike Fiore 1:d34b566d6f47 34
Mike Fiore 1:d34b566d6f47 35 /** This method is used to the set the baud rate of the serial port.
Mike Fiore 1:d34b566d6f47 36 *
Mike Fiore 1:d34b566d6f47 37 * @param baudrate the baudrate in bps as an int. The default is 9600 bps.
Mike Fiore 1:d34b566d6f47 38 */
Mike Fiore 1:d34b566d6f47 39 void baud(int baudrate);
Mike Fiore 1:d34b566d6f47 40
Mike Fiore 1:d34b566d6f47 41 /** This method sets the transmission format used by the serial port.
Mike Fiore 1:d34b566d6f47 42 *
Mike Fiore 1:d34b566d6f47 43 * @param bits the number of bits in a word (5-8; default = 8)
Mike Fiore 1:d34b566d6f47 44 * @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even,
Mike Fiore 1:d34b566d6f47 45 * SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
Mike Fiore 1:d34b566d6f47 46 * @param stop the number of stop bits (1 or 2; default = 1)
Mike Fiore 1:d34b566d6f47 47 */
Mike Fiore 1:d34b566d6f47 48 void format(int bits=8, SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1);
Mike Fiore 1:d34b566d6f47 49
Mike Fiore 1:d34b566d6f47 50 protected:
Mike Fiore 1:d34b566d6f47 51 Serial serial; // Internal mbed Serial object
Mike Fiore 1:d34b566d6f47 52
Mike Fiore 1:d34b566d6f47 53 private:
Mike Fiore 1:d34b566d6f47 54 virtual void handleWrite(); // Method for handling data to be written
Mike Fiore 1:d34b566d6f47 55 virtual void handleRead(); // Method for handling data to be read
Mike Fiore 1:d34b566d6f47 56 };
Mike Fiore 1:d34b566d6f47 57
Mike Fiore 1:d34b566d6f47 58 }
Mike Fiore 1:d34b566d6f47 59
Mike Fiore 1:d34b566d6f47 60 #endif /* MTSSERIAL_H */