mbed-drivers
Timer.h
1 /*
2  * Copyright (c) 2006-2016, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_TIMER_H
18 #define MBED_TIMER_H
19 
20 #include "platform.h"
21 #include "ticker_api.h"
22 
23 namespace mbed {
24 
46 class Timer {
47 
48 public:
49  Timer();
50  Timer(const ticker_data_t *const data);
51 
54  void start();
55 
58  void stop();
59 
64  void reset();
65 
68  float read();
69 
72  int read_ms();
73 
76  int read_us();
77 
78 #ifdef MBED_OPERATORS
79  operator float();
80 #endif
81 
82 protected:
83  int slicetime();
84  int _running; // whether the timer is running
85  unsigned int _start; // the start time of the latest slice
86  int _time; // any accumulated time from previous slices
87  const ticker_data_t *const _ticker_data;
88 };
89 
90 } // namespace mbed
91 
92 #endif
float read()
Definition: Timer.cpp:47
int read_ms()
Definition: Timer.cpp:51
void start()
Definition: Timer.cpp:31
int read_us()
Definition: Timer.cpp:43
void reset()
Definition: Timer.cpp:63
Definition: Timer.h:46
Definition: BusIn.cpp:19
void stop()
Definition: Timer.cpp:38