mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:f782d9c66c49 1 /* mbed Microcontroller Library
dkato 0:f782d9c66c49 2 * Copyright (c) 2006-2013 ARM Limited
dkato 0:f782d9c66c49 3 *
dkato 0:f782d9c66c49 4 * Licensed under the Apache License, Version 2.0 (the "License");
dkato 0:f782d9c66c49 5 * you may not use this file except in compliance with the License.
dkato 0:f782d9c66c49 6 * You may obtain a copy of the License at
dkato 0:f782d9c66c49 7 *
dkato 0:f782d9c66c49 8 * http://www.apache.org/licenses/LICENSE-2.0
dkato 0:f782d9c66c49 9 *
dkato 0:f782d9c66c49 10 * Unless required by applicable law or agreed to in writing, software
dkato 0:f782d9c66c49 11 * distributed under the License is distributed on an "AS IS" BASIS,
dkato 0:f782d9c66c49 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dkato 0:f782d9c66c49 13 * See the License for the specific language governing permissions and
dkato 0:f782d9c66c49 14 * limitations under the License.
dkato 0:f782d9c66c49 15 */
dkato 0:f782d9c66c49 16 #ifndef MBED_SERIAL_H
dkato 0:f782d9c66c49 17 #define MBED_SERIAL_H
dkato 0:f782d9c66c49 18
dkato 0:f782d9c66c49 19 #include "platform/platform.h"
dkato 0:f782d9c66c49 20
dkato 0:f782d9c66c49 21 #if DEVICE_SERIAL
dkato 0:f782d9c66c49 22
dkato 0:f782d9c66c49 23 #include "Stream.h"
dkato 0:f782d9c66c49 24 #include "SerialBase.h"
dkato 0:f782d9c66c49 25 #include "PlatformMutex.h"
dkato 0:f782d9c66c49 26 #include "serial_api.h"
dkato 0:f782d9c66c49 27
dkato 0:f782d9c66c49 28 namespace mbed {
dkato 0:f782d9c66c49 29 /** \addtogroup drivers */
dkato 0:f782d9c66c49 30 /** @{*/
dkato 0:f782d9c66c49 31
dkato 0:f782d9c66c49 32 /** A serial port (UART) for communication with other serial devices
dkato 0:f782d9c66c49 33 *
dkato 0:f782d9c66c49 34 * Can be used for Full Duplex communication, or Simplex by specifying
dkato 0:f782d9c66c49 35 * one pin as NC (Not Connected)
dkato 0:f782d9c66c49 36 *
dkato 0:f782d9c66c49 37 * @Note Synchronization level: Thread safe
dkato 0:f782d9c66c49 38 *
dkato 0:f782d9c66c49 39 * Example:
dkato 0:f782d9c66c49 40 * @code
dkato 0:f782d9c66c49 41 * // Print "Hello World" to the PC
dkato 0:f782d9c66c49 42 *
dkato 0:f782d9c66c49 43 * #include "mbed.h"
dkato 0:f782d9c66c49 44 *
dkato 0:f782d9c66c49 45 * Serial pc(USBTX, USBRX);
dkato 0:f782d9c66c49 46 *
dkato 0:f782d9c66c49 47 * int main() {
dkato 0:f782d9c66c49 48 * pc.printf("Hello World\n");
dkato 0:f782d9c66c49 49 * }
dkato 0:f782d9c66c49 50 * @endcode
dkato 0:f782d9c66c49 51 */
dkato 0:f782d9c66c49 52 class Serial : public SerialBase, public Stream {
dkato 0:f782d9c66c49 53
dkato 0:f782d9c66c49 54 public:
dkato 0:f782d9c66c49 55 #if DEVICE_SERIAL_ASYNCH
dkato 0:f782d9c66c49 56 using SerialBase::read;
dkato 0:f782d9c66c49 57 using SerialBase::write;
dkato 0:f782d9c66c49 58 #endif
dkato 0:f782d9c66c49 59
dkato 0:f782d9c66c49 60 /** Create a Serial port, connected to the specified transmit and receive pins
dkato 0:f782d9c66c49 61 *
dkato 0:f782d9c66c49 62 * @param tx Transmit pin
dkato 0:f782d9c66c49 63 * @param rx Receive pin
dkato 0:f782d9c66c49 64 * @param name The name of the stream associated with this serial port (optional)
dkato 0:f782d9c66c49 65 * @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
dkato 0:f782d9c66c49 66 *
dkato 0:f782d9c66c49 67 * @note
dkato 0:f782d9c66c49 68 * Either tx or rx may be specified as NC if unused
dkato 0:f782d9c66c49 69 */
dkato 0:f782d9c66c49 70 Serial(PinName tx, PinName rx, const char *name=NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
dkato 0:f782d9c66c49 71
dkato 0:f782d9c66c49 72
dkato 0:f782d9c66c49 73 /** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud
dkato 0:f782d9c66c49 74 *
dkato 0:f782d9c66c49 75 * @param tx Transmit pin
dkato 0:f782d9c66c49 76 * @param rx Receive pin
dkato 0:f782d9c66c49 77 * @param baud The baud rate of the serial port
dkato 0:f782d9c66c49 78 *
dkato 0:f782d9c66c49 79 * @note
dkato 0:f782d9c66c49 80 * Either tx or rx may be specified as NC if unused
dkato 0:f782d9c66c49 81 */
dkato 0:f782d9c66c49 82 Serial(PinName tx, PinName rx, int baud);
dkato 0:f782d9c66c49 83
dkato 0:f782d9c66c49 84 protected:
dkato 0:f782d9c66c49 85 virtual int _getc();
dkato 0:f782d9c66c49 86 virtual int _putc(int c);
dkato 0:f782d9c66c49 87 virtual void lock();
dkato 0:f782d9c66c49 88 virtual void unlock();
dkato 0:f782d9c66c49 89
dkato 0:f782d9c66c49 90 PlatformMutex _mutex;
dkato 0:f782d9c66c49 91 };
dkato 0:f782d9c66c49 92
dkato 0:f782d9c66c49 93 } // namespace mbed
dkato 0:f782d9c66c49 94
dkato 0:f782d9c66c49 95 #endif
dkato 0:f782d9c66c49 96
dkato 0:f782d9c66c49 97 #endif
dkato 0:f782d9c66c49 98
dkato 0:f782d9c66c49 99 /** @}*/