SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phungductung 0:8ede47d38d10 1 /* mbed Microcontroller Library
phungductung 0:8ede47d38d10 2 * Copyright (c) 2006-2013 ARM Limited
phungductung 0:8ede47d38d10 3 *
phungductung 0:8ede47d38d10 4 * Licensed under the Apache License, Version 2.0 (the "License");
phungductung 0:8ede47d38d10 5 * you may not use this file except in compliance with the License.
phungductung 0:8ede47d38d10 6 * You may obtain a copy of the License at
phungductung 0:8ede47d38d10 7 *
phungductung 0:8ede47d38d10 8 * http://www.apache.org/licenses/LICENSE-2.0
phungductung 0:8ede47d38d10 9 *
phungductung 0:8ede47d38d10 10 * Unless required by applicable law or agreed to in writing, software
phungductung 0:8ede47d38d10 11 * distributed under the License is distributed on an "AS IS" BASIS,
phungductung 0:8ede47d38d10 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
phungductung 0:8ede47d38d10 13 * See the License for the specific language governing permissions and
phungductung 0:8ede47d38d10 14 * limitations under the License.
phungductung 0:8ede47d38d10 15 */
phungductung 0:8ede47d38d10 16 #ifndef MBED_RAW_SERIAL_H
phungductung 0:8ede47d38d10 17 #define MBED_RAW_SERIAL_H
phungductung 0:8ede47d38d10 18
phungductung 0:8ede47d38d10 19 #include "platform.h"
phungductung 0:8ede47d38d10 20
phungductung 0:8ede47d38d10 21 #if DEVICE_SERIAL
phungductung 0:8ede47d38d10 22
phungductung 0:8ede47d38d10 23 #include "SerialBase.h"
phungductung 0:8ede47d38d10 24 #include "serial_api.h"
phungductung 0:8ede47d38d10 25
phungductung 0:8ede47d38d10 26 namespace mbed {
phungductung 0:8ede47d38d10 27
phungductung 0:8ede47d38d10 28 /** A serial port (UART) for communication with other serial devices
phungductung 0:8ede47d38d10 29 * This is a variation of the Serial class that doesn't use streams,
phungductung 0:8ede47d38d10 30 * thus making it safe to use in interrupt handlers with the RTOS.
phungductung 0:8ede47d38d10 31 *
phungductung 0:8ede47d38d10 32 * Can be used for Full Duplex communication, or Simplex by specifying
phungductung 0:8ede47d38d10 33 * one pin as NC (Not Connected)
phungductung 0:8ede47d38d10 34 *
phungductung 0:8ede47d38d10 35 * Example:
phungductung 0:8ede47d38d10 36 * @code
phungductung 0:8ede47d38d10 37 * // Send a char to the PC
phungductung 0:8ede47d38d10 38 *
phungductung 0:8ede47d38d10 39 * #include "mbed.h"
phungductung 0:8ede47d38d10 40 *
phungductung 0:8ede47d38d10 41 * RawSerial pc(USBTX, USBRX);
phungductung 0:8ede47d38d10 42 *
phungductung 0:8ede47d38d10 43 * int main() {
phungductung 0:8ede47d38d10 44 * pc.putc('A');
phungductung 0:8ede47d38d10 45 * }
phungductung 0:8ede47d38d10 46 * @endcode
phungductung 0:8ede47d38d10 47 */
phungductung 0:8ede47d38d10 48 class RawSerial: public SerialBase {
phungductung 0:8ede47d38d10 49
phungductung 0:8ede47d38d10 50 public:
phungductung 0:8ede47d38d10 51 /** Create a RawSerial port, connected to the specified transmit and receive pins
phungductung 0:8ede47d38d10 52 *
phungductung 0:8ede47d38d10 53 * @param tx Transmit pin
phungductung 0:8ede47d38d10 54 * @param rx Receive pin
phungductung 0:8ede47d38d10 55 *
phungductung 0:8ede47d38d10 56 * @note
phungductung 0:8ede47d38d10 57 * Either tx or rx may be specified as NC if unused
phungductung 0:8ede47d38d10 58 */
phungductung 0:8ede47d38d10 59 RawSerial(PinName tx, PinName rx);
phungductung 0:8ede47d38d10 60
phungductung 0:8ede47d38d10 61 /** Write a char to the serial port
phungductung 0:8ede47d38d10 62 *
phungductung 0:8ede47d38d10 63 * @param c The char to write
phungductung 0:8ede47d38d10 64 *
phungductung 0:8ede47d38d10 65 * @returns The written char or -1 if an error occured
phungductung 0:8ede47d38d10 66 */
phungductung 0:8ede47d38d10 67 int putc(int c);
phungductung 0:8ede47d38d10 68
phungductung 0:8ede47d38d10 69 /** Read a char from the serial port
phungductung 0:8ede47d38d10 70 *
phungductung 0:8ede47d38d10 71 * @returns The char read from the serial port
phungductung 0:8ede47d38d10 72 */
phungductung 0:8ede47d38d10 73 int getc();
phungductung 0:8ede47d38d10 74
phungductung 0:8ede47d38d10 75 /** Write a string to the serial port
phungductung 0:8ede47d38d10 76 *
phungductung 0:8ede47d38d10 77 * @param str The string to write
phungductung 0:8ede47d38d10 78 *
phungductung 0:8ede47d38d10 79 * @returns 0 if the write succeeds, EOF for error
phungductung 0:8ede47d38d10 80 */
phungductung 0:8ede47d38d10 81 int puts(const char *str);
phungductung 0:8ede47d38d10 82
phungductung 0:8ede47d38d10 83 int printf(const char *format, ...);
phungductung 0:8ede47d38d10 84 };
phungductung 0:8ede47d38d10 85
phungductung 0:8ede47d38d10 86 } // namespace mbed
phungductung 0:8ede47d38d10 87
phungductung 0:8ede47d38d10 88 #endif
phungductung 0:8ede47d38d10 89
phungductung 0:8ede47d38d10 90 #endif