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