Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

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?

UserRevisionLine numberNew 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_TICKER_H
thedo 167:1657b442184c 17 #define MBED_TICKER_H
thedo 167:1657b442184c 18
thedo 167:1657b442184c 19 #include "drivers/TimerEvent.h"
thedo 167:1657b442184c 20 #include "platform/Callback.h"
thedo 167:1657b442184c 21 #include "platform/mbed_toolchain.h"
thedo 167:1657b442184c 22
thedo 167:1657b442184c 23 namespace mbed {
thedo 167:1657b442184c 24 /** \addtogroup drivers */
thedo 167:1657b442184c 25
thedo 167:1657b442184c 26 /** A Ticker is used to call a function at a recurring interval
thedo 167:1657b442184c 27 *
thedo 167:1657b442184c 28 * You can use as many seperate Ticker objects as you require.
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 the blinking led after 5 seconds
thedo 167:1657b442184c 35 *
thedo 167:1657b442184c 36 * #include "mbed.h"
thedo 167:1657b442184c 37 *
thedo 167:1657b442184c 38 * Ticker timer;
thedo 167:1657b442184c 39 * DigitalOut led1(LED1);
thedo 167:1657b442184c 40 * DigitalOut led2(LED2);
thedo 167:1657b442184c 41 *
thedo 167:1657b442184c 42 * int flip = 0;
thedo 167:1657b442184c 43 *
thedo 167:1657b442184c 44 * void attime() {
thedo 167:1657b442184c 45 * flip = !flip;
thedo 167:1657b442184c 46 * }
thedo 167:1657b442184c 47 *
thedo 167:1657b442184c 48 * int main() {
thedo 167:1657b442184c 49 * timer.attach(&attime, 5);
thedo 167:1657b442184c 50 * while(1) {
thedo 167:1657b442184c 51 * if(flip == 0) {
thedo 167:1657b442184c 52 * led1 = !led1;
thedo 167:1657b442184c 53 * } else {
thedo 167:1657b442184c 54 * led2 = !led2;
thedo 167:1657b442184c 55 * }
thedo 167:1657b442184c 56 * wait(0.2);
thedo 167:1657b442184c 57 * }
thedo 167:1657b442184c 58 * }
thedo 167:1657b442184c 59 * @endcode
thedo 167:1657b442184c 60 * @ingroup drivers
thedo 167:1657b442184c 61 */
thedo 167:1657b442184c 62 class Ticker : public TimerEvent {
thedo 167:1657b442184c 63
thedo 167:1657b442184c 64 public:
thedo 167:1657b442184c 65 Ticker() : TimerEvent() {
thedo 167:1657b442184c 66 }
thedo 167:1657b442184c 67
thedo 167:1657b442184c 68 Ticker(const ticker_data_t *data) : TimerEvent(data) {
thedo 167:1657b442184c 69 data->interface->init();
thedo 167:1657b442184c 70 }
thedo 167:1657b442184c 71
thedo 167:1657b442184c 72 /** Attach a function to be called by the Ticker, specifiying the interval in seconds
thedo 167:1657b442184c 73 *
thedo 167:1657b442184c 74 * @param func pointer to the function to be called
thedo 167:1657b442184c 75 * @param t the time between calls in seconds
thedo 167:1657b442184c 76 */
thedo 167:1657b442184c 77 void attach(Callback<void()> func, float t) {
thedo 167:1657b442184c 78 attach_us(func, t * 1000000.0f);
thedo 167:1657b442184c 79 }
thedo 167:1657b442184c 80
thedo 167:1657b442184c 81 /** Attach a member function to be called by the Ticker, specifiying the interval in seconds
thedo 167:1657b442184c 82 *
thedo 167:1657b442184c 83 * @param obj pointer to the object to call the member function on
thedo 167:1657b442184c 84 * @param method pointer to the member function to be called
thedo 167:1657b442184c 85 * @param t the time between calls in seconds
thedo 167:1657b442184c 86 * @deprecated
thedo 167:1657b442184c 87 * The attach function does not support cv-qualifiers. Replaced by
thedo 167:1657b442184c 88 * attach(callback(obj, method), t).
thedo 167:1657b442184c 89 */
thedo 167:1657b442184c 90 template<typename T, typename M>
thedo 167:1657b442184c 91 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 167:1657b442184c 92 "The attach function does not support cv-qualifiers. Replaced by "
thedo 167:1657b442184c 93 "attach(callback(obj, method), t).")
thedo 167:1657b442184c 94 void attach(T *obj, M method, float t) {
thedo 167:1657b442184c 95 attach(callback(obj, method), t);
thedo 167:1657b442184c 96 }
thedo 167:1657b442184c 97
thedo 167:1657b442184c 98 /** Attach a function to be called by the Ticker, specifiying the interval in micro-seconds
thedo 167:1657b442184c 99 *
thedo 167:1657b442184c 100 * @param func pointer to the function to be called
thedo 167:1657b442184c 101 * @param t the time between calls in micro-seconds
thedo 167:1657b442184c 102 */
thedo 167:1657b442184c 103 void attach_us(Callback<void()> func, us_timestamp_t t) {
thedo 167:1657b442184c 104 _function = func;
thedo 167:1657b442184c 105 setup(t);
thedo 167:1657b442184c 106 }
thedo 167:1657b442184c 107
thedo 167:1657b442184c 108 /** Attach a member function to be called by the Ticker, specifiying the interval in micro-seconds
thedo 167:1657b442184c 109 *
thedo 167:1657b442184c 110 * @param obj pointer to the object to call the member function on
thedo 167:1657b442184c 111 * @param method pointer to the member function to be called
thedo 167:1657b442184c 112 * @param t the time between calls in micro-seconds
thedo 167:1657b442184c 113 * @deprecated
thedo 167:1657b442184c 114 * The attach_us function does not support cv-qualifiers. Replaced by
thedo 167:1657b442184c 115 * attach_us(callback(obj, method), t).
thedo 167:1657b442184c 116 */
thedo 167:1657b442184c 117 template<typename T, typename M>
thedo 167:1657b442184c 118 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 167:1657b442184c 119 "The attach_us function does not support cv-qualifiers. Replaced by "
thedo 167:1657b442184c 120 "attach_us(callback(obj, method), t).")
thedo 167:1657b442184c 121 void attach_us(T *obj, M method, us_timestamp_t t) {
thedo 167:1657b442184c 122 attach_us(Callback<void()>(obj, method), t);
thedo 167:1657b442184c 123 }
thedo 167:1657b442184c 124
thedo 167:1657b442184c 125 virtual ~Ticker() {
thedo 167:1657b442184c 126 detach();
thedo 167:1657b442184c 127 }
thedo 167:1657b442184c 128
thedo 167:1657b442184c 129 /** Detach the function
thedo 167:1657b442184c 130 */
thedo 167:1657b442184c 131 void detach();
thedo 167:1657b442184c 132
thedo 167:1657b442184c 133 protected:
thedo 167:1657b442184c 134 void setup(us_timestamp_t t);
thedo 167:1657b442184c 135 virtual void handler();
thedo 167:1657b442184c 136
thedo 167:1657b442184c 137 protected:
thedo 167:1657b442184c 138 us_timestamp_t _delay; /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
thedo 167:1657b442184c 139 Callback<void()> _function; /**< Callback. */
thedo 167:1657b442184c 140 };
thedo 167:1657b442184c 141
thedo 167:1657b442184c 142 } // namespace mbed
thedo 167:1657b442184c 143
thedo 167:1657b442184c 144 #endif
thedo 167:1657b442184c 145