mbed library for NZ32-SC151

Committer:
modtronix
Date:
Fri Jul 24 21:01:44 2015 +1000
Revision:
1:71204b8406f2
Current mbed v103 (594)

Who changed what in which revision?

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