游戏王对战板,目前code还是空的

Committer:
WFKnight
Date:
Thu Jun 21 13:51:43 2018 +0000
Revision:
0:9b3d4731edbb
UART, RTOS, LED

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WFKnight 0:9b3d4731edbb 1 /* mbed Microcontroller Library
WFKnight 0:9b3d4731edbb 2 * Copyright (c) 2006-2013 ARM Limited
WFKnight 0:9b3d4731edbb 3 *
WFKnight 0:9b3d4731edbb 4 * Licensed under the Apache License, Version 2.0 (the "License");
WFKnight 0:9b3d4731edbb 5 * you may not use this file except in compliance with the License.
WFKnight 0:9b3d4731edbb 6 * You may obtain a copy of the License at
WFKnight 0:9b3d4731edbb 7 *
WFKnight 0:9b3d4731edbb 8 * http://www.apache.org/licenses/LICENSE-2.0
WFKnight 0:9b3d4731edbb 9 *
WFKnight 0:9b3d4731edbb 10 * Unless required by applicable law or agreed to in writing, software
WFKnight 0:9b3d4731edbb 11 * distributed under the License is distributed on an "AS IS" BASIS,
WFKnight 0:9b3d4731edbb 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
WFKnight 0:9b3d4731edbb 13 * See the License for the specific language governing permissions and
WFKnight 0:9b3d4731edbb 14 * limitations under the License.
WFKnight 0:9b3d4731edbb 15 */
WFKnight 0:9b3d4731edbb 16 #ifndef MBED_RAW_SERIAL_H
WFKnight 0:9b3d4731edbb 17 #define MBED_RAW_SERIAL_H
WFKnight 0:9b3d4731edbb 18
WFKnight 0:9b3d4731edbb 19 #include "platform/platform.h"
WFKnight 0:9b3d4731edbb 20
WFKnight 0:9b3d4731edbb 21 #if defined (DEVICE_SERIAL) || defined(DOXYGEN_ONLY)
WFKnight 0:9b3d4731edbb 22
WFKnight 0:9b3d4731edbb 23 #include "drivers/SerialBase.h"
WFKnight 0:9b3d4731edbb 24 #include "hal/serial_api.h"
WFKnight 0:9b3d4731edbb 25 #include "platform/NonCopyable.h"
WFKnight 0:9b3d4731edbb 26
WFKnight 0:9b3d4731edbb 27 namespace mbed {
WFKnight 0:9b3d4731edbb 28 /** \addtogroup drivers */
WFKnight 0:9b3d4731edbb 29
WFKnight 0:9b3d4731edbb 30 /** A serial port (UART) for communication with other serial devices
WFKnight 0:9b3d4731edbb 31 * This is a variation of the Serial class that doesn't use streams,
WFKnight 0:9b3d4731edbb 32 * thus making it safe to use in interrupt handlers with the RTOS.
WFKnight 0:9b3d4731edbb 33 *
WFKnight 0:9b3d4731edbb 34 * Can be used for Full Duplex communication, or Simplex by specifying
WFKnight 0:9b3d4731edbb 35 * one pin as NC (Not Connected)
WFKnight 0:9b3d4731edbb 36 *
WFKnight 0:9b3d4731edbb 37 * @note Synchronization level: Not protected
WFKnight 0:9b3d4731edbb 38 *
WFKnight 0:9b3d4731edbb 39 * Example:
WFKnight 0:9b3d4731edbb 40 * @code
WFKnight 0:9b3d4731edbb 41 * // Send a char to the PC
WFKnight 0:9b3d4731edbb 42 *
WFKnight 0:9b3d4731edbb 43 * #include "mbed.h"
WFKnight 0:9b3d4731edbb 44 *
WFKnight 0:9b3d4731edbb 45 * RawSerial pc(USBTX, USBRX);
WFKnight 0:9b3d4731edbb 46 *
WFKnight 0:9b3d4731edbb 47 * int main() {
WFKnight 0:9b3d4731edbb 48 * pc.putc('A');
WFKnight 0:9b3d4731edbb 49 * }
WFKnight 0:9b3d4731edbb 50 * @endcode
WFKnight 0:9b3d4731edbb 51 * @ingroup drivers
WFKnight 0:9b3d4731edbb 52 */
WFKnight 0:9b3d4731edbb 53 class RawSerial: public SerialBase, private NonCopyable<RawSerial> {
WFKnight 0:9b3d4731edbb 54
WFKnight 0:9b3d4731edbb 55 public:
WFKnight 0:9b3d4731edbb 56 /** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud.
WFKnight 0:9b3d4731edbb 57 *
WFKnight 0:9b3d4731edbb 58 * @param tx Transmit pin
WFKnight 0:9b3d4731edbb 59 * @param rx Receive pin
WFKnight 0:9b3d4731edbb 60 * @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
WFKnight 0:9b3d4731edbb 61 *
WFKnight 0:9b3d4731edbb 62 * @note
WFKnight 0:9b3d4731edbb 63 * Either tx or rx may be specified as NC if unused
WFKnight 0:9b3d4731edbb 64 */
WFKnight 0:9b3d4731edbb 65 RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
WFKnight 0:9b3d4731edbb 66
WFKnight 0:9b3d4731edbb 67 /** Write a char to the serial port
WFKnight 0:9b3d4731edbb 68 *
WFKnight 0:9b3d4731edbb 69 * @param c The char to write
WFKnight 0:9b3d4731edbb 70 *
WFKnight 0:9b3d4731edbb 71 * @returns The written char or -1 if an error occurred
WFKnight 0:9b3d4731edbb 72 */
WFKnight 0:9b3d4731edbb 73 int putc(int c);
WFKnight 0:9b3d4731edbb 74
WFKnight 0:9b3d4731edbb 75 /** Read a char from the serial port
WFKnight 0:9b3d4731edbb 76 *
WFKnight 0:9b3d4731edbb 77 * @returns The char read from the serial port
WFKnight 0:9b3d4731edbb 78 */
WFKnight 0:9b3d4731edbb 79 int getc();
WFKnight 0:9b3d4731edbb 80
WFKnight 0:9b3d4731edbb 81 /** Write a string to the serial port
WFKnight 0:9b3d4731edbb 82 *
WFKnight 0:9b3d4731edbb 83 * @param str The string to write
WFKnight 0:9b3d4731edbb 84 *
WFKnight 0:9b3d4731edbb 85 * @returns 0 if the write succeeds, EOF for error
WFKnight 0:9b3d4731edbb 86 */
WFKnight 0:9b3d4731edbb 87 int puts(const char *str);
WFKnight 0:9b3d4731edbb 88
WFKnight 0:9b3d4731edbb 89 int printf(const char *format, ...);
WFKnight 0:9b3d4731edbb 90
WFKnight 0:9b3d4731edbb 91 protected:
WFKnight 0:9b3d4731edbb 92
WFKnight 0:9b3d4731edbb 93 /* Acquire exclusive access to this serial port
WFKnight 0:9b3d4731edbb 94 */
WFKnight 0:9b3d4731edbb 95 virtual void lock(void);
WFKnight 0:9b3d4731edbb 96
WFKnight 0:9b3d4731edbb 97 /* Release exclusive access to this serial port
WFKnight 0:9b3d4731edbb 98 */
WFKnight 0:9b3d4731edbb 99 virtual void unlock(void);
WFKnight 0:9b3d4731edbb 100 };
WFKnight 0:9b3d4731edbb 101
WFKnight 0:9b3d4731edbb 102 } // namespace mbed
WFKnight 0:9b3d4731edbb 103
WFKnight 0:9b3d4731edbb 104 #endif
WFKnight 0:9b3d4731edbb 105
WFKnight 0:9b3d4731edbb 106 #endif