dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

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