Mistake on this page?
Report an issue in GitHub or email us
TimerEvent.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2019 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may 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,
13  * WITHOUT 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_TIMEREVENT_H
18 #define MBED_TIMEREVENT_H
19 
20 #include "hal/ticker_api.h"
21 #include "platform/mbed_toolchain.h"
22 #include "platform/NonCopyable.h"
23 #include "drivers/TickerDataClock.h"
24 
25 namespace mbed {
26 
27 /**
28  * \defgroup drivers_TimerEvent TimerEvent class
29  * \ingroup drivers-public-api-ticker
30  * @{
31  */
32 
33 /** Base abstraction for timer interrupts
34  *
35  * @note Synchronization level: Interrupt safe
36  */
37 class TimerEvent : private NonCopyable<TimerEvent> {
38 #if !defined(DOXYGEN_ONLY)
39 protected:
40  TimerEvent(const ticker_data_t *data);
41 
42  /** The handler registered with the underlying timer interrupt
43  *
44  * @param id Timer Event ID
45  */
46  static void irq(uint32_t id);
47 
48  /** Destruction removes it...
49  */
50  ~TimerEvent();
51 
52  // The handler called to service the timer event of the derived class
53  virtual void handler() = 0;
54 
55  /** Set relative timestamp of the internal event.
56  * @param timestamp event's us timestamp
57  *
58  * @warning
59  * Do not insert more than one timestamp.
60  * The same @a event object is used for every @a insert/insert_absolute call.
61  *
62  * @warning
63  * Ticker's present timestamp is used for reference. For timestamps
64  * from the past the event is scheduled after ticker's overflow.
65  * For reference @see convert_timestamp
66  *
67  * @deprecated use `insert(std::chrono::microseconds timestamp)`
68  */
69  MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono duration, not an integer microsecond count. For example use `5ms` rather than `5000`.")
70  void insert(timestamp_t timestamp);
71 
72  /** Set relative timestamp of the internal event.
73  * @param timestamp event's us timestamp
74  *
75  * @warning
76  * Do not insert more than one timestamp.
77  * The same @a event object is used for every @a insert/insert_absolute call.
78  *
79  * @warning
80  * Ticker's present timestamp is used for reference. For timestamps
81  * from the past the event is scheduled after ticker's overflow.
82  * For reference @see convert_timestamp
83  */
84  void insert(std::chrono::microseconds timestamp);
85 
86  /** Set absolute timestamp of the internal event.
87  * @param timestamp event's us timestamp
88  *
89  * @warning
90  * Do not insert more than one timestamp.
91  * The same @a event object is used for every @a insert/insert_absolute call.
92  *
93  * @deprecated use `insert_absolute(TickerDataClock::time_point timestamp)`
94  */
95  MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono time_point, not an integer microsecond count. For example use `_ticker_data.now() + 5ms` rather than `ticker_read_us(_ticker_data) + 5000`.")
96  void insert_absolute(us_timestamp_t timestamp);
97 
98  /** Set absolute timestamp of the internal event.
99  * @param timestamp event's us timestamp
100  *
101  * @warning
102  * Do not insert more than one timestamp.
103  * The same @a event object is used for every @a insert/insert_absolute call.
104  */
105  void insert_absolute(TickerDataClock::time_point timestamp);
106 
107  /** Remove timestamp.
108  */
109  void remove();
110 
111  ticker_event_t event;
112 
113  TickerDataClock _ticker_data;
114 #endif
115 };
116 
117 /** @}*/
118 
119 } // namespace mbed
120 
121 #endif
uint64_t us_timestamp_t
A us timestamp stored in a 64 bit integer.
Definition: ticker_api.h:39
Ticker&#39;s data structure.
Definition: ticker_api.h:93
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:162
Base abstraction for timer interrupts.
Definition: TimerEvent.h:37
A partial implementation of a C++11 Clock representing a HAL ticker.
Ticker&#39;s event structure.
Definition: ticker_api.h:43
uint32_t timestamp_t
Legacy format representing a timestamp in us.
Definition: ticker_api.h:33
Definition: ATHandler.h:46
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.