temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

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