logi loader fork from jpiat

Fork of mbed-src by Jonathan Piat

Committer:
mbed_official
Date:
Fri May 22 09:45:08 2015 +0100
Revision:
547:88c982c8f758
Parent:
525:c320967f86b9
Synchronized with git revision 61deb3e97c669a7c9bc99d3941d8f4c28c463f24

Full URL: https://github.com/mbedmicro/mbed/commit/61deb3e97c669a7c9bc99d3941d8f4c28c463f24/

Timer/Ticker - fix constness of the data argument/member

Who changed what in which revision?

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