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