Mistake on this page?
Report an issue in GitHub or email us
LowPowerTimeout.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2015 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_LOWPOWERTIMEOUT_H
18 #define MBED_LOWPOWERTIMEOUT_H
19 
20 #include "platform/platform.h"
21 
22 #if DEVICE_LPTICKER || defined(DOXYGEN_ONLY)
23 
24 #include "drivers/LowPowerClock.h"
25 #include "drivers/Timeout.h"
26 
27 namespace mbed {
28 /**
29  * \defgroup drivers_LowPowerTimeout LowPowerTimeout class
30  * \ingroup drivers-public-api-ticker
31  * @{
32  */
33 
34 /** Low Power Timout
35  *
36  * @note Synchronization level: Interrupt safe
37  */
38 class LowPowerTimeout : public TimeoutBase {
39 public:
41 
42  /** Clock to use with attach_absolute, guaranteeing running only while attached or manually locked */
44 
45  /** Clock to use with attach_absolute, running always */
47 
48  /** @copydoc TimeoutBase::scheduled_time() */
49  LowPowerClock::time_point scheduled_time() const
50  {
51  /* Massage from virtual TickerDataClock::time_point used internally to true LowPowerClock::time_point */
52  return LowPowerClock::time_point{TimeoutBase::scheduled_time().time_since_epoch()};
53  }
54 
55  /** Attach a function to be called by the Timeout, specifying the absolute time
56  *
57  * @param func pointer to the function to be called
58  * @param abs_time the absolute time for the call, referenced to LowPowerClock
59  *
60  * @note setting @a abs_time to a time in the past means the event will be scheduled immediately
61  * resulting in an instant call to the function.
62  */
63  template <class F>
64  void attach_absolute(F &&func, LowPowerClock::time_point abs_time)
65  {
66  /* Massage from true LowPowerClock::time_point to virtual TickerDataClock::time_point used internally */
67  TimeoutBase::attach_absolute(std::forward<F>(func), TickerDataClock::time_point{abs_time.time_since_epoch()});
68  }
69 };
70 
71 /** @}*/
72 
73 } // namespace mbed
74 
75 #endif
76 
77 #endif
A C++11 Clock representing the HAL lp_ticker.
Definition: LowPowerClock.h:38
void attach_absolute(F &&func, LowPowerClock::time_point abs_time)
Attach a function to be called by the Timeout, specifying the absolute time.
A Timeout is used to call a function at a point in the future.
Definition: Timeout.h:60
Low Power Timout.
LowPowerClock::time_point scheduled_time() const
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.