fft

Dependencies:   BSP_DISCO_F746NG SDFileSystem_Warning_Fixed

Committer:
MikamiUitOpen
Date:
Sun Oct 09 10:11:14 2016 +0000
Revision:
0:3e46577dc273
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:3e46577dc273 1 /* mbed Microcontroller Library
MikamiUitOpen 0:3e46577dc273 2 * Copyright (c) 2006-2013 ARM Limited
MikamiUitOpen 0:3e46577dc273 3 *
MikamiUitOpen 0:3e46577dc273 4 * Licensed under the Apache License, Version 2.0 (the "License");
MikamiUitOpen 0:3e46577dc273 5 * you may not use this file except in compliance with the License.
MikamiUitOpen 0:3e46577dc273 6 * You may obtain a copy of the License at
MikamiUitOpen 0:3e46577dc273 7 *
MikamiUitOpen 0:3e46577dc273 8 * http://www.apache.org/licenses/LICENSE-2.0
MikamiUitOpen 0:3e46577dc273 9 *
MikamiUitOpen 0:3e46577dc273 10 * Unless required by applicable law or agreed to in writing, software
MikamiUitOpen 0:3e46577dc273 11 * distributed under the License is distributed on an "AS IS" BASIS,
MikamiUitOpen 0:3e46577dc273 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikamiUitOpen 0:3e46577dc273 13 * See the License for the specific language governing permissions and
MikamiUitOpen 0:3e46577dc273 14 * limitations under the License.
MikamiUitOpen 0:3e46577dc273 15 */
MikamiUitOpen 0:3e46577dc273 16 #ifndef MBED_TIMER_H
MikamiUitOpen 0:3e46577dc273 17 #define MBED_TIMER_H
MikamiUitOpen 0:3e46577dc273 18
MikamiUitOpen 0:3e46577dc273 19 #include "platform.h"
MikamiUitOpen 0:3e46577dc273 20 #include "ticker_api.h"
MikamiUitOpen 0:3e46577dc273 21
MikamiUitOpen 0:3e46577dc273 22 namespace mbed {
MikamiUitOpen 0:3e46577dc273 23
MikamiUitOpen 0:3e46577dc273 24 /** A general purpose timer
MikamiUitOpen 0:3e46577dc273 25 *
MikamiUitOpen 0:3e46577dc273 26 * Example:
MikamiUitOpen 0:3e46577dc273 27 * @code
MikamiUitOpen 0:3e46577dc273 28 * // Count the time to toggle a LED
MikamiUitOpen 0:3e46577dc273 29 *
MikamiUitOpen 0:3e46577dc273 30 * #include "mbed.h"
MikamiUitOpen 0:3e46577dc273 31 *
MikamiUitOpen 0:3e46577dc273 32 * Timer timer;
MikamiUitOpen 0:3e46577dc273 33 * DigitalOut led(LED1);
MikamiUitOpen 0:3e46577dc273 34 * int begin, end;
MikamiUitOpen 0:3e46577dc273 35 *
MikamiUitOpen 0:3e46577dc273 36 * int main() {
MikamiUitOpen 0:3e46577dc273 37 * timer.start();
MikamiUitOpen 0:3e46577dc273 38 * begin = timer.read_us();
MikamiUitOpen 0:3e46577dc273 39 * led = !led;
MikamiUitOpen 0:3e46577dc273 40 * end = timer.read_us();
MikamiUitOpen 0:3e46577dc273 41 * printf("Toggle the led takes %d us", end - begin);
MikamiUitOpen 0:3e46577dc273 42 * }
MikamiUitOpen 0:3e46577dc273 43 * @endcode
MikamiUitOpen 0:3e46577dc273 44 */
MikamiUitOpen 0:3e46577dc273 45 class Timer {
MikamiUitOpen 0:3e46577dc273 46
MikamiUitOpen 0:3e46577dc273 47 public:
MikamiUitOpen 0:3e46577dc273 48 Timer();
MikamiUitOpen 0:3e46577dc273 49 Timer(const ticker_data_t *data);
MikamiUitOpen 0:3e46577dc273 50
MikamiUitOpen 0:3e46577dc273 51 /** Start the timer
MikamiUitOpen 0:3e46577dc273 52 */
MikamiUitOpen 0:3e46577dc273 53 void start();
MikamiUitOpen 0:3e46577dc273 54
MikamiUitOpen 0:3e46577dc273 55 /** Stop the timer
MikamiUitOpen 0:3e46577dc273 56 */
MikamiUitOpen 0:3e46577dc273 57 void stop();
MikamiUitOpen 0:3e46577dc273 58
MikamiUitOpen 0:3e46577dc273 59 /** Reset the timer to 0.
MikamiUitOpen 0:3e46577dc273 60 *
MikamiUitOpen 0:3e46577dc273 61 * If it was already counting, it will continue
MikamiUitOpen 0:3e46577dc273 62 */
MikamiUitOpen 0:3e46577dc273 63 void reset();
MikamiUitOpen 0:3e46577dc273 64
MikamiUitOpen 0:3e46577dc273 65 /** Get the time passed in seconds
MikamiUitOpen 0:3e46577dc273 66 */
MikamiUitOpen 0:3e46577dc273 67 float read();
MikamiUitOpen 0:3e46577dc273 68
MikamiUitOpen 0:3e46577dc273 69 /** Get the time passed in mili-seconds
MikamiUitOpen 0:3e46577dc273 70 */
MikamiUitOpen 0:3e46577dc273 71 int read_ms();
MikamiUitOpen 0:3e46577dc273 72
MikamiUitOpen 0:3e46577dc273 73 /** Get the time passed in micro-seconds
MikamiUitOpen 0:3e46577dc273 74 */
MikamiUitOpen 0:3e46577dc273 75 int read_us();
MikamiUitOpen 0:3e46577dc273 76
MikamiUitOpen 0:3e46577dc273 77 #ifdef MBED_OPERATORS
MikamiUitOpen 0:3e46577dc273 78 operator float();
MikamiUitOpen 0:3e46577dc273 79 #endif
MikamiUitOpen 0:3e46577dc273 80
MikamiUitOpen 0:3e46577dc273 81 protected:
MikamiUitOpen 0:3e46577dc273 82 int slicetime();
MikamiUitOpen 0:3e46577dc273 83 int _running; // whether the timer is running
MikamiUitOpen 0:3e46577dc273 84 unsigned int _start; // the start time of the latest slice
MikamiUitOpen 0:3e46577dc273 85 int _time; // any accumulated time from previous slices
MikamiUitOpen 0:3e46577dc273 86 const ticker_data_t *_ticker_data;
MikamiUitOpen 0:3e46577dc273 87 };
MikamiUitOpen 0:3e46577dc273 88
MikamiUitOpen 0:3e46577dc273 89 } // namespace mbed
MikamiUitOpen 0:3e46577dc273 90
MikamiUitOpen 0:3e46577dc273 91 #endif