mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

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