The code from https://github.com/vpcola/Nucleo

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?

UserRevisionLine numberNew 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_RAW_SERIAL_H
sinrab 0:5464d5e415e5 17 #define MBED_RAW_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 "SerialBase.h"
sinrab 0:5464d5e415e5 24 #include "serial_api.h"
sinrab 0:5464d5e415e5 25
sinrab 0:5464d5e415e5 26 namespace mbed {
sinrab 0:5464d5e415e5 27
sinrab 0:5464d5e415e5 28 /** A serial port (UART) for communication with other serial devices
sinrab 0:5464d5e415e5 29 * This is a variation of the Serial class that doesn't use streams,
sinrab 0:5464d5e415e5 30 * thus making it safe to use in interrupt handlers with the RTOS.
sinrab 0:5464d5e415e5 31 *
sinrab 0:5464d5e415e5 32 * Can be used for Full Duplex communication, or Simplex by specifying
sinrab 0:5464d5e415e5 33 * one pin as NC (Not Connected)
sinrab 0:5464d5e415e5 34 *
sinrab 0:5464d5e415e5 35 * Example:
sinrab 0:5464d5e415e5 36 * @code
sinrab 0:5464d5e415e5 37 * // Send a char to the PC
sinrab 0:5464d5e415e5 38 *
sinrab 0:5464d5e415e5 39 * #include "mbed.h"
sinrab 0:5464d5e415e5 40 *
sinrab 0:5464d5e415e5 41 * RawSerial pc(USBTX, USBRX);
sinrab 0:5464d5e415e5 42 *
sinrab 0:5464d5e415e5 43 * int main() {
sinrab 0:5464d5e415e5 44 * pc.putc('A');
sinrab 0:5464d5e415e5 45 * }
sinrab 0:5464d5e415e5 46 * @endcode
sinrab 0:5464d5e415e5 47 */
sinrab 0:5464d5e415e5 48 class RawSerial: public SerialBase {
sinrab 0:5464d5e415e5 49
sinrab 0:5464d5e415e5 50 public:
sinrab 0:5464d5e415e5 51 /** Create a RawSerial port, connected to the specified transmit and receive pins
sinrab 0:5464d5e415e5 52 *
sinrab 0:5464d5e415e5 53 * @param tx Transmit pin
sinrab 0:5464d5e415e5 54 * @param rx Receive pin
sinrab 0:5464d5e415e5 55 *
sinrab 0:5464d5e415e5 56 * @note
sinrab 0:5464d5e415e5 57 * Either tx or rx may be specified as NC if unused
sinrab 0:5464d5e415e5 58 */
sinrab 0:5464d5e415e5 59 RawSerial(PinName tx, PinName rx);
sinrab 0:5464d5e415e5 60
sinrab 0:5464d5e415e5 61 /** Write a char to the serial port
sinrab 0:5464d5e415e5 62 *
sinrab 0:5464d5e415e5 63 * @param c The char to write
sinrab 0:5464d5e415e5 64 *
sinrab 0:5464d5e415e5 65 * @returns The written char or -1 if an error occured
sinrab 0:5464d5e415e5 66 */
sinrab 0:5464d5e415e5 67 int putc(int c);
sinrab 0:5464d5e415e5 68
sinrab 0:5464d5e415e5 69 /** Read a char from the serial port
sinrab 0:5464d5e415e5 70 *
sinrab 0:5464d5e415e5 71 * @returns The char read from the serial port
sinrab 0:5464d5e415e5 72 */
sinrab 0:5464d5e415e5 73 int getc();
sinrab 0:5464d5e415e5 74
sinrab 0:5464d5e415e5 75 /** Write a string to the serial port
sinrab 0:5464d5e415e5 76 *
sinrab 0:5464d5e415e5 77 * @param str The string to write
sinrab 0:5464d5e415e5 78 *
sinrab 0:5464d5e415e5 79 * @returns 0 if the write succeeds, EOF for error
sinrab 0:5464d5e415e5 80 */
sinrab 0:5464d5e415e5 81 int puts(const char *str);
sinrab 0:5464d5e415e5 82
sinrab 0:5464d5e415e5 83 int printf(const char *format, ...);
sinrab 0:5464d5e415e5 84 };
sinrab 0:5464d5e415e5 85
sinrab 0:5464d5e415e5 86 } // namespace mbed
sinrab 0:5464d5e415e5 87
sinrab 0:5464d5e415e5 88 #endif
sinrab 0:5464d5e415e5 89
sinrab 0:5464d5e415e5 90 #endif
sinrab 0:5464d5e415e5 91