Opencv 3.1 project on GR-PEACH board
Fork of gr-peach-opencv-project by
drivers/PortOut.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_PORTOUT_H |
thedo | 167:1657b442184c | 17 | #define MBED_PORTOUT_H |
thedo | 167:1657b442184c | 18 | |
thedo | 167:1657b442184c | 19 | #include "platform/platform.h" |
thedo | 167:1657b442184c | 20 | |
thedo | 167:1657b442184c | 21 | #if defined (DEVICE_PORTOUT) || defined(DOXYGEN_ONLY) |
thedo | 167:1657b442184c | 22 | |
thedo | 167:1657b442184c | 23 | #include "hal/port_api.h" |
thedo | 167:1657b442184c | 24 | #include "platform/mbed_critical.h" |
thedo | 167:1657b442184c | 25 | |
thedo | 167:1657b442184c | 26 | namespace mbed { |
thedo | 167:1657b442184c | 27 | /** \addtogroup drivers */ |
thedo | 167:1657b442184c | 28 | /** A multiple pin digital out |
thedo | 167:1657b442184c | 29 | * |
thedo | 167:1657b442184c | 30 | * @note Synchronization level: Interrupt safe |
thedo | 167:1657b442184c | 31 | * |
thedo | 167:1657b442184c | 32 | * Example: |
thedo | 167:1657b442184c | 33 | * @code |
thedo | 167:1657b442184c | 34 | * // Toggle all four LEDs |
thedo | 167:1657b442184c | 35 | * |
thedo | 167:1657b442184c | 36 | * #include "mbed.h" |
thedo | 167:1657b442184c | 37 | * |
thedo | 167:1657b442184c | 38 | * // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23 |
thedo | 167:1657b442184c | 39 | * #define LED_MASK 0x00B40000 |
thedo | 167:1657b442184c | 40 | * |
thedo | 167:1657b442184c | 41 | * PortOut ledport(Port1, LED_MASK); |
thedo | 167:1657b442184c | 42 | * |
thedo | 167:1657b442184c | 43 | * int main() { |
thedo | 167:1657b442184c | 44 | * while(1) { |
thedo | 167:1657b442184c | 45 | * ledport = LED_MASK; |
thedo | 167:1657b442184c | 46 | * wait(1); |
thedo | 167:1657b442184c | 47 | * ledport = 0; |
thedo | 167:1657b442184c | 48 | * wait(1); |
thedo | 167:1657b442184c | 49 | * } |
thedo | 167:1657b442184c | 50 | * } |
thedo | 167:1657b442184c | 51 | * @endcode |
thedo | 167:1657b442184c | 52 | * @ingroup drivers |
thedo | 167:1657b442184c | 53 | */ |
thedo | 167:1657b442184c | 54 | class PortOut { |
thedo | 167:1657b442184c | 55 | public: |
thedo | 167:1657b442184c | 56 | |
thedo | 167:1657b442184c | 57 | /** Create an PortOut, connected to the specified port |
thedo | 167:1657b442184c | 58 | * |
thedo | 167:1657b442184c | 59 | * @param port Port to connect to (Port0-Port5) |
thedo | 167:1657b442184c | 60 | * @param mask A bitmask to identify which bits in the port should be included (0 - ignore) |
thedo | 167:1657b442184c | 61 | */ |
thedo | 167:1657b442184c | 62 | PortOut(PortName port, int mask = 0xFFFFFFFF) { |
thedo | 167:1657b442184c | 63 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 64 | port_init(&_port, port, mask, PIN_OUTPUT); |
thedo | 167:1657b442184c | 65 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 66 | } |
thedo | 167:1657b442184c | 67 | |
thedo | 167:1657b442184c | 68 | /** Write the value to the output port |
thedo | 167:1657b442184c | 69 | * |
thedo | 167:1657b442184c | 70 | * @param value An integer specifying a bit to write for every corresponding PortOut pin |
thedo | 167:1657b442184c | 71 | */ |
thedo | 167:1657b442184c | 72 | void write(int value) { |
thedo | 167:1657b442184c | 73 | port_write(&_port, value); |
thedo | 167:1657b442184c | 74 | } |
thedo | 167:1657b442184c | 75 | |
thedo | 167:1657b442184c | 76 | /** Read the value currently output on the port |
thedo | 167:1657b442184c | 77 | * |
thedo | 167:1657b442184c | 78 | * @returns |
thedo | 167:1657b442184c | 79 | * An integer with each bit corresponding to associated PortOut pin setting |
thedo | 167:1657b442184c | 80 | */ |
thedo | 167:1657b442184c | 81 | int read() { |
thedo | 167:1657b442184c | 82 | return port_read(&_port); |
thedo | 167:1657b442184c | 83 | } |
thedo | 167:1657b442184c | 84 | |
thedo | 167:1657b442184c | 85 | /** A shorthand for write() |
thedo | 167:1657b442184c | 86 | */ |
thedo | 167:1657b442184c | 87 | PortOut& operator= (int value) { |
thedo | 167:1657b442184c | 88 | write(value); |
thedo | 167:1657b442184c | 89 | return *this; |
thedo | 167:1657b442184c | 90 | } |
thedo | 167:1657b442184c | 91 | |
thedo | 167:1657b442184c | 92 | PortOut& operator= (PortOut& rhs) { |
thedo | 167:1657b442184c | 93 | write(rhs.read()); |
thedo | 167:1657b442184c | 94 | return *this; |
thedo | 167:1657b442184c | 95 | } |
thedo | 167:1657b442184c | 96 | |
thedo | 167:1657b442184c | 97 | /** A shorthand for read() |
thedo | 167:1657b442184c | 98 | */ |
thedo | 167:1657b442184c | 99 | operator int() { |
thedo | 167:1657b442184c | 100 | return read(); |
thedo | 167:1657b442184c | 101 | } |
thedo | 167:1657b442184c | 102 | |
thedo | 167:1657b442184c | 103 | private: |
thedo | 167:1657b442184c | 104 | port_t _port; |
thedo | 167:1657b442184c | 105 | }; |
thedo | 167:1657b442184c | 106 | |
thedo | 167:1657b442184c | 107 | } // namespace mbed |
thedo | 167:1657b442184c | 108 | |
thedo | 167:1657b442184c | 109 | #endif |
thedo | 167:1657b442184c | 110 | |
thedo | 167:1657b442184c | 111 | #endif |
thedo | 167:1657b442184c | 112 |