Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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