Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-STM32F103C8_org by
Serial.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_SERIAL_H 00017 #define MBED_SERIAL_H 00018 00019 #include "platform/platform.h" 00020 00021 #if DEVICE_SERIAL 00022 00023 #include "Stream.h" 00024 #include "SerialBase.h" 00025 #include "PlatformMutex.h" 00026 #include "serial_api.h" 00027 00028 00029 namespace mbed { 00030 /** \addtogroup drivers */ 00031 /** @{*/ 00032 00033 /** A serial port (UART) for communication with other serial devices 00034 * 00035 * Can be used for Full Duplex communication, or Simplex by specifying 00036 * one pin as NC (Not Connected) 00037 * 00038 * @Note Synchronization level: Thread safe 00039 * 00040 * Example: 00041 * @code 00042 * // Print "Hello World" to the PC 00043 * 00044 * #include "mbed.h" 00045 * 00046 * Serial pc(USBTX, USBRX); 00047 * 00048 * int main() { 00049 * pc.printf("Hello World\n"); 00050 * } 00051 * @endcode 00052 */ 00053 class Serial : public SerialBase, public Stream { 00054 00055 public: 00056 #if DEVICE_SERIAL_ASYNCH 00057 using SerialBase::read; 00058 using SerialBase::write; 00059 #endif 00060 00061 /** Create a Serial port, connected to the specified transmit and receive pins 00062 * 00063 * @param tx Transmit pin 00064 * @param rx Receive pin 00065 * @param name The name of the stream associated with this serial port (optional) 00066 * @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) 00067 * 00068 * @note 00069 * Either tx or rx may be specified as NC if unused 00070 */ 00071 Serial(PinName tx, PinName rx, const char *name=NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); 00072 00073 00074 /** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud 00075 * 00076 * @param tx Transmit pin 00077 * @param rx Receive pin 00078 * @param baud The baud rate of the serial port 00079 * 00080 * @note 00081 * Either tx or rx may be specified as NC if unused 00082 */ 00083 Serial(PinName tx, PinName rx, int baud); 00084 00085 protected: 00086 virtual int _getc(); 00087 virtual int _putc(int c); 00088 virtual void lock(); 00089 virtual void unlock(); 00090 00091 PlatformMutex _mutex; 00092 }; 00093 00094 } // namespace mbed 00095 00096 #endif 00097 00098 #endif 00099 00100 /** @}*/
Generated on Tue Jul 12 2022 16:30:32 by
1.7.2
