Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RawSerial.h Source File

RawSerial.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_RAW_SERIAL_H
00018 #define MBED_RAW_SERIAL_H
00019 
00020 #include "platform/platform.h"
00021 
00022 #if DEVICE_SERIAL || defined(DOXYGEN_ONLY)
00023 
00024 #include "platform/mbed_toolchain.h"
00025 #include "drivers/SerialBase.h"
00026 #include "platform/NonCopyable.h"
00027 #include <cstdarg>
00028 
00029 namespace mbed {
00030 /** \defgroup drivers-public-api-uart UART
00031  * \ingroup drivers-public-api
00032  */
00033 
00034 /**
00035  * \defgroup drivers_RawSerial RawSerial class
00036  * \ingroup drivers-public-api-uart
00037  * @{
00038  */
00039 
00040 /** @deprecated
00041  * A serial port (UART) for communication with other serial devices
00042  * This is a variation of the Serial class that doesn't use streams,
00043  * thus making it safe to use in interrupt handlers with the RTOS.
00044  *
00045  * Can be used for Full Duplex communication, or Simplex by specifying
00046  * one pin as NC (Not Connected)
00047  *
00048  * @note Synchronization level: Not protected
00049  *
00050  * Example:
00051  * @code
00052  * // Send a char to the PC
00053  *
00054  * #include "mbed.h"
00055  *
00056  * RawSerial pc(USBTX, USBRX);
00057  *
00058  * int main() {
00059  *     pc.putc('A');
00060  * }
00061  * @endcode
00062  */
00063 class
00064     MBED_DEPRECATED_SINCE (
00065         "mbed-os-6.0.0",
00066         "Use UnbufferedSerial instead."
00067     ) RawSerial: public SerialBase, private NonCopyable<RawSerial> {
00068 
00069 public:
00070     /** @deprecated
00071      * Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud.
00072      *
00073      *  @param tx Transmit pin
00074      *  @param rx Receive pin
00075      *  @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
00076      *
00077      *  @note
00078      *    Either tx or rx may be specified as NC if unused
00079      */
00080     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00081     RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
00082 
00083     /** @deprecated
00084      * Write a char to the serial port
00085      *
00086      * @param c The char to write
00087      *
00088      * @returns The written char or -1 if an error occurred
00089      */
00090     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00091     int putc(int c);
00092 
00093     /** @deprecated
00094      * Read a char from the serial port
00095      *
00096      * @returns The char read from the serial port
00097      */
00098     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00099     int getc();
00100 
00101     /** @deprecated
00102      * Write a string to the serial port
00103      *
00104      * @param str The string to write
00105      *
00106      * @returns 0 if the write succeeds, EOF for error
00107      */
00108     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00109     int puts(const char *str);
00110 
00111     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00112     int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);
00113 
00114     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00115     int vprintf(const char *format, std::va_list arg);
00116 
00117 #if !(DOXYGEN_ONLY)
00118 protected:
00119 
00120     /* Acquire exclusive access to this serial port
00121      */
00122     virtual void lock(void);
00123 
00124     /* Release exclusive access to this serial port
00125      */
00126     virtual void unlock(void);
00127 #endif
00128 };
00129 
00130 /** @}*/
00131 
00132 } // namespace mbed
00133 
00134 #endif
00135 
00136 #endif