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_RAW_SERIAL_H
IKobayashi 0:c88c3b616c00 17 #define MBED_RAW_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 "drivers/SerialBase.h"
IKobayashi 0:c88c3b616c00 24 #include "hal/serial_api.h"
IKobayashi 0:c88c3b616c00 25
IKobayashi 0:c88c3b616c00 26 namespace mbed {
IKobayashi 0:c88c3b616c00 27 /** \addtogroup drivers */
IKobayashi 0:c88c3b616c00 28 /** @{*/
IKobayashi 0:c88c3b616c00 29
IKobayashi 0:c88c3b616c00 30 /** A serial port (UART) for communication with other serial devices
IKobayashi 0:c88c3b616c00 31 * This is a variation of the Serial class that doesn't use streams,
IKobayashi 0:c88c3b616c00 32 * thus making it safe to use in interrupt handlers with the RTOS.
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: Not protected
IKobayashi 0:c88c3b616c00 38 *
IKobayashi 0:c88c3b616c00 39 * Example:
IKobayashi 0:c88c3b616c00 40 * @code
IKobayashi 0:c88c3b616c00 41 * // Send a char to the PC
IKobayashi 0:c88c3b616c00 42 *
IKobayashi 0:c88c3b616c00 43 * #include "mbed.h"
IKobayashi 0:c88c3b616c00 44 *
IKobayashi 0:c88c3b616c00 45 * RawSerial pc(USBTX, USBRX);
IKobayashi 0:c88c3b616c00 46 *
IKobayashi 0:c88c3b616c00 47 * int main() {
IKobayashi 0:c88c3b616c00 48 * pc.putc('A');
IKobayashi 0:c88c3b616c00 49 * }
IKobayashi 0:c88c3b616c00 50 * @endcode
IKobayashi 0:c88c3b616c00 51 */
IKobayashi 0:c88c3b616c00 52 class RawSerial: public SerialBase {
IKobayashi 0:c88c3b616c00 53
IKobayashi 0:c88c3b616c00 54 public:
IKobayashi 0:c88c3b616c00 55 /** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud.
IKobayashi 0:c88c3b616c00 56 *
IKobayashi 0:c88c3b616c00 57 * @param tx Transmit pin
IKobayashi 0:c88c3b616c00 58 * @param rx Receive pin
IKobayashi 0:c88c3b616c00 59 * @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
IKobayashi 0:c88c3b616c00 60 *
IKobayashi 0:c88c3b616c00 61 * @note
IKobayashi 0:c88c3b616c00 62 * Either tx or rx may be specified as NC if unused
IKobayashi 0:c88c3b616c00 63 */
IKobayashi 0:c88c3b616c00 64 RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
IKobayashi 0:c88c3b616c00 65
IKobayashi 0:c88c3b616c00 66 /** Write a char to the serial port
IKobayashi 0:c88c3b616c00 67 *
IKobayashi 0:c88c3b616c00 68 * @param c The char to write
IKobayashi 0:c88c3b616c00 69 *
IKobayashi 0:c88c3b616c00 70 * @returns The written char or -1 if an error occured
IKobayashi 0:c88c3b616c00 71 */
IKobayashi 0:c88c3b616c00 72 int putc(int c);
IKobayashi 0:c88c3b616c00 73
IKobayashi 0:c88c3b616c00 74 /** Read a char from the serial port
IKobayashi 0:c88c3b616c00 75 *
IKobayashi 0:c88c3b616c00 76 * @returns The char read from the serial port
IKobayashi 0:c88c3b616c00 77 */
IKobayashi 0:c88c3b616c00 78 int getc();
IKobayashi 0:c88c3b616c00 79
IKobayashi 0:c88c3b616c00 80 /** Write a string to the serial port
IKobayashi 0:c88c3b616c00 81 *
IKobayashi 0:c88c3b616c00 82 * @param str The string to write
IKobayashi 0:c88c3b616c00 83 *
IKobayashi 0:c88c3b616c00 84 * @returns 0 if the write succeeds, EOF for error
IKobayashi 0:c88c3b616c00 85 */
IKobayashi 0:c88c3b616c00 86 int puts(const char *str);
IKobayashi 0:c88c3b616c00 87
IKobayashi 0:c88c3b616c00 88 int printf(const char *format, ...);
IKobayashi 0:c88c3b616c00 89
IKobayashi 0:c88c3b616c00 90 protected:
IKobayashi 0:c88c3b616c00 91
IKobayashi 0:c88c3b616c00 92 /** Acquire exclusive access to this serial port
IKobayashi 0:c88c3b616c00 93 */
IKobayashi 0:c88c3b616c00 94 virtual void lock(void);
IKobayashi 0:c88c3b616c00 95
IKobayashi 0:c88c3b616c00 96 /** Release exclusive access to this serial port
IKobayashi 0:c88c3b616c00 97 */
IKobayashi 0:c88c3b616c00 98 virtual void unlock(void);
IKobayashi 0:c88c3b616c00 99 };
IKobayashi 0:c88c3b616c00 100
IKobayashi 0:c88c3b616c00 101 } // namespace mbed
IKobayashi 0:c88c3b616c00 102
IKobayashi 0:c88c3b616c00 103 #endif
IKobayashi 0:c88c3b616c00 104
IKobayashi 0:c88c3b616c00 105 #endif
IKobayashi 0:c88c3b616c00 106
IKobayashi 0:c88c3b616c00 107 /** @}*/