mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Timeout.h Source File

Timeout.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_TIMEOUT_H
00018 #define MBED_TIMEOUT_H
00019 
00020 #include "drivers/Ticker.h"
00021 #include "platform/NonCopyable.h"
00022 #include "platform/mbed_power_mgmt.h"
00023 
00024 namespace mbed {
00025 /** \addtogroup drivers */
00026 
00027 /** A Timeout is used to call a function at a point in the future
00028  *
00029  * You can use as many separate Timeout objects as you require.
00030  *
00031  * @note Synchronization level: Interrupt safe
00032  *
00033  * Example:
00034  * @code
00035  * // Blink until timeout.
00036  *
00037  * #include "mbed.h"
00038  *
00039  * Timeout timeout;
00040  * DigitalOut led(LED1);
00041  *
00042  * int on = 1;
00043  *
00044  * void attimeout() {
00045  *     on = 0;
00046  * }
00047  *
00048  * int main() {
00049  *     timeout.attach(&attimeout, 5);
00050  *     while(on) {
00051  *         led = !led;
00052  *         wait(0.2);
00053  *     }
00054  * }
00055  * @endcode
00056  * @ingroup drivers
00057  */
00058 class Timeout : public Ticker, private NonCopyable<Timeout> {
00059 
00060 #if !defined(DOXYGEN_ONLY)
00061 protected:
00062     virtual void handler();
00063 #endif
00064 };
00065 
00066 } // namespace mbed
00067 
00068 #endif