initial

Dependencies:   mbed

Committer:
yihui
Date:
Mon Jan 11 02:32:24 2016 +0000
Revision:
0:638edba3adf6
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 0:638edba3adf6 1 /* mbed Microcontroller Library
yihui 0:638edba3adf6 2 * Copyright (c) 2006-2013 ARM Limited
yihui 0:638edba3adf6 3 *
yihui 0:638edba3adf6 4 * Licensed under the Apache License, Version 2.0 (the "License");
yihui 0:638edba3adf6 5 * you may not use this file except in compliance with the License.
yihui 0:638edba3adf6 6 * You may obtain a copy of the License at
yihui 0:638edba3adf6 7 *
yihui 0:638edba3adf6 8 * http://www.apache.org/licenses/LICENSE-2.0
yihui 0:638edba3adf6 9 *
yihui 0:638edba3adf6 10 * Unless required by applicable law or agreed to in writing, software
yihui 0:638edba3adf6 11 * distributed under the License is distributed on an "AS IS" BASIS,
yihui 0:638edba3adf6 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
yihui 0:638edba3adf6 13 * See the License for the specific language governing permissions and
yihui 0:638edba3adf6 14 * limitations under the License.
yihui 0:638edba3adf6 15 */
yihui 0:638edba3adf6 16 #ifndef MBED_SERIAL_H
yihui 0:638edba3adf6 17 #define MBED_SERIAL_H
yihui 0:638edba3adf6 18
yihui 0:638edba3adf6 19 #include "platform.h"
yihui 0:638edba3adf6 20
yihui 0:638edba3adf6 21 #if DEVICE_SERIAL
yihui 0:638edba3adf6 22
yihui 0:638edba3adf6 23 #include "Stream.h"
yihui 0:638edba3adf6 24 #include "SerialBase.h"
yihui 0:638edba3adf6 25 #include "serial_api.h"
yihui 0:638edba3adf6 26
yihui 0:638edba3adf6 27 namespace mbed {
yihui 0:638edba3adf6 28
yihui 0:638edba3adf6 29 /** A serial port (UART) for communication with other serial devices
yihui 0:638edba3adf6 30 *
yihui 0:638edba3adf6 31 * Can be used for Full Duplex communication, or Simplex by specifying
yihui 0:638edba3adf6 32 * one pin as NC (Not Connected)
yihui 0:638edba3adf6 33 *
yihui 0:638edba3adf6 34 * Example:
yihui 0:638edba3adf6 35 * @code
yihui 0:638edba3adf6 36 * // Print "Hello World" to the PC
yihui 0:638edba3adf6 37 *
yihui 0:638edba3adf6 38 * #include "mbed.h"
yihui 0:638edba3adf6 39 *
yihui 0:638edba3adf6 40 * Serial pc(USBTX, USBRX);
yihui 0:638edba3adf6 41 *
yihui 0:638edba3adf6 42 * int main() {
yihui 0:638edba3adf6 43 * pc.printf("Hello World\n");
yihui 0:638edba3adf6 44 * }
yihui 0:638edba3adf6 45 * @endcode
yihui 0:638edba3adf6 46 */
yihui 0:638edba3adf6 47 class Serial : public SerialBase, public Stream {
yihui 0:638edba3adf6 48
yihui 0:638edba3adf6 49 public:
yihui 0:638edba3adf6 50 #if DEVICE_SERIAL_ASYNCH
yihui 0:638edba3adf6 51 using SerialBase::read;
yihui 0:638edba3adf6 52 using SerialBase::write;
yihui 0:638edba3adf6 53 #endif
yihui 0:638edba3adf6 54
yihui 0:638edba3adf6 55 /** Create a Serial port, connected to the specified transmit and receive pins
yihui 0:638edba3adf6 56 *
yihui 0:638edba3adf6 57 * @param tx Transmit pin
yihui 0:638edba3adf6 58 * @param rx Receive pin
yihui 0:638edba3adf6 59 *
yihui 0:638edba3adf6 60 * @note
yihui 0:638edba3adf6 61 * Either tx or rx may be specified as NC if unused
yihui 0:638edba3adf6 62 */
yihui 0:638edba3adf6 63 Serial(PinName tx, PinName rx, const char *name=NULL);
yihui 0:638edba3adf6 64
yihui 0:638edba3adf6 65 protected:
yihui 0:638edba3adf6 66 virtual int _getc();
yihui 0:638edba3adf6 67 virtual int _putc(int c);
yihui 0:638edba3adf6 68 };
yihui 0:638edba3adf6 69
yihui 0:638edba3adf6 70 } // namespace mbed
yihui 0:638edba3adf6 71
yihui 0:638edba3adf6 72 #endif
yihui 0:638edba3adf6 73
yihui 0:638edba3adf6 74 #endif