dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
nexpaq
Date:
Sat Sep 17 16:32:05 2016 +0000
Revision:
1:55a6170b404f
checking in for sharing

Who changed what in which revision?

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