test test test

Dependencies:   mbed

Committer:
mohamedmoawya
Date:
Mon May 25 19:06:11 2020 +0000
Revision:
0:e4c5e6ec922e
snake game tteest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mohamedmoawya 0:e4c5e6ec922e 1 /* mbed Microcontroller Library
mohamedmoawya 0:e4c5e6ec922e 2 * Copyright (c) 2006-2013 ARM Limited
mohamedmoawya 0:e4c5e6ec922e 3 *
mohamedmoawya 0:e4c5e6ec922e 4 * Licensed under the Apache License, Version 2.0 (the "License");
mohamedmoawya 0:e4c5e6ec922e 5 * you may not use this file except in compliance with the License.
mohamedmoawya 0:e4c5e6ec922e 6 * You may obtain a copy of the License at
mohamedmoawya 0:e4c5e6ec922e 7 *
mohamedmoawya 0:e4c5e6ec922e 8 * http://www.apache.org/licenses/LICENSE-2.0
mohamedmoawya 0:e4c5e6ec922e 9 *
mohamedmoawya 0:e4c5e6ec922e 10 * Unless required by applicable law or agreed to in writing, software
mohamedmoawya 0:e4c5e6ec922e 11 * distributed under the License is distributed on an "AS IS" BASIS,
mohamedmoawya 0:e4c5e6ec922e 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mohamedmoawya 0:e4c5e6ec922e 13 * See the License for the specific language governing permissions and
mohamedmoawya 0:e4c5e6ec922e 14 * limitations under the License.
mohamedmoawya 0:e4c5e6ec922e 15 */
mohamedmoawya 0:e4c5e6ec922e 16 #ifndef MBED_TIMEOUT_H
mohamedmoawya 0:e4c5e6ec922e 17 #define MBED_TIMEOUT_H
mohamedmoawya 0:e4c5e6ec922e 18
mohamedmoawya 0:e4c5e6ec922e 19 #include "drivers/Ticker.h"
mohamedmoawya 0:e4c5e6ec922e 20 #include "platform/NonCopyable.h"
mohamedmoawya 0:e4c5e6ec922e 21 #include "platform/mbed_power_mgmt.h"
mohamedmoawya 0:e4c5e6ec922e 22
mohamedmoawya 0:e4c5e6ec922e 23 namespace mbed {
mohamedmoawya 0:e4c5e6ec922e 24 /** \addtogroup drivers */
mohamedmoawya 0:e4c5e6ec922e 25
mohamedmoawya 0:e4c5e6ec922e 26 /** A Timeout is used to call a function at a point in the future
mohamedmoawya 0:e4c5e6ec922e 27 *
mohamedmoawya 0:e4c5e6ec922e 28 * You can use as many separate Timeout objects as you require.
mohamedmoawya 0:e4c5e6ec922e 29 *
mohamedmoawya 0:e4c5e6ec922e 30 * @note Synchronization level: Interrupt safe
mohamedmoawya 0:e4c5e6ec922e 31 *
mohamedmoawya 0:e4c5e6ec922e 32 * Example:
mohamedmoawya 0:e4c5e6ec922e 33 * @code
mohamedmoawya 0:e4c5e6ec922e 34 * // Blink until timeout.
mohamedmoawya 0:e4c5e6ec922e 35 *
mohamedmoawya 0:e4c5e6ec922e 36 * #include "mbed.h"
mohamedmoawya 0:e4c5e6ec922e 37 *
mohamedmoawya 0:e4c5e6ec922e 38 * Timeout timeout;
mohamedmoawya 0:e4c5e6ec922e 39 * DigitalOut led(LED1);
mohamedmoawya 0:e4c5e6ec922e 40 *
mohamedmoawya 0:e4c5e6ec922e 41 * int on = 1;
mohamedmoawya 0:e4c5e6ec922e 42 *
mohamedmoawya 0:e4c5e6ec922e 43 * void attimeout() {
mohamedmoawya 0:e4c5e6ec922e 44 * on = 0;
mohamedmoawya 0:e4c5e6ec922e 45 * }
mohamedmoawya 0:e4c5e6ec922e 46 *
mohamedmoawya 0:e4c5e6ec922e 47 * int main() {
mohamedmoawya 0:e4c5e6ec922e 48 * timeout.attach(&attimeout, 5);
mohamedmoawya 0:e4c5e6ec922e 49 * while(on) {
mohamedmoawya 0:e4c5e6ec922e 50 * led = !led;
mohamedmoawya 0:e4c5e6ec922e 51 * wait(0.2);
mohamedmoawya 0:e4c5e6ec922e 52 * }
mohamedmoawya 0:e4c5e6ec922e 53 * }
mohamedmoawya 0:e4c5e6ec922e 54 * @endcode
mohamedmoawya 0:e4c5e6ec922e 55 * @ingroup drivers
mohamedmoawya 0:e4c5e6ec922e 56 */
mohamedmoawya 0:e4c5e6ec922e 57 class Timeout : public Ticker, private NonCopyable<Timeout> {
mohamedmoawya 0:e4c5e6ec922e 58
mohamedmoawya 0:e4c5e6ec922e 59 protected:
mohamedmoawya 0:e4c5e6ec922e 60 virtual void handler();
mohamedmoawya 0:e4c5e6ec922e 61 };
mohamedmoawya 0:e4c5e6ec922e 62
mohamedmoawya 0:e4c5e6ec922e 63 } // namespace mbed
mohamedmoawya 0:e4c5e6ec922e 64
mohamedmoawya 0:e4c5e6ec922e 65 #endif