temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

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