Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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