Erste version der Software für der Prototyp

Committer:
borlanic
Date:
Thu Mar 29 07:02:09 2018 +0000
Revision:
0:380207fcb5c1
Encoder, IMU --> OK; Controller --> in bearbeitung

Who changed what in which revision?

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