Mistake on this page?
Report an issue in GitHub or email us
LowPowerClock.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_LOWPOWERCLOCK_H
18 #define MBED_LOWPOWERCLOCK_H
19 
20 #include <chrono>
21 #if DEVICE_LPTICKER
22 #include "hal/lp_ticker_api.h"
23 
24 namespace mbed {
25 /**
26  * \defgroup drivers_LowPowerClock LowPowerClock class
27  * \ingroup drivers-public-api-ticker
28  * @{
29  */
30 
31 /**
32  * A C++11 Clock representing the HAL lp_ticker.
33  *
34  * Dummy lock/unlock methods are provided to have the same generic API
35  * as UnlockedHighPowerClock. No action is required as the lp_ticker
36  * runs continuously.
37  */
39 public:
40  /* duration is C++11 standard microseconds, so representation will be 64-bit signed integer */
41  using duration = std::chrono::microseconds;
42  using rep = duration::rep;
43  using period = duration::period;
44  using time_point = std::chrono::time_point<LowPowerClock>;
45  static const bool is_steady = true;
46 
47  /** Read the current time */
48  static time_point now()
49  {
50  return time_point{duration{ticker_read_us(get_lp_ticker_data())}};
51  }
52 
53  /** Lock the clock to ensure it stays running; dummy for API compatibility with HighResClock */
54  static void lock()
55  {
56  }
57 
58  /** Unlock the clock, allowing it to stop during power saving; dummy for API compatibility with HighResClock */
59  static void unlock()
60  {
61  }
62 };
63 
64 /** @}*/
65 
66 }
67 #endif /* DEVICE_LPTICKER */
68 #endif /* MBED_LOWPOWERCLOCK_H */
A C++11 Clock representing the HAL lp_ticker.
Definition: LowPowerClock.h:38
static void unlock()
Unlock the clock, allowing it to stop during power saving; dummy for API compatibility with HighResCl...
Definition: LowPowerClock.h:59
const ticker_data_t * get_lp_ticker_data(void)
Get low power ticker&#39;s data.
static void lock()
Lock the clock to ensure it stays running; dummy for API compatibility with HighResClock.
Definition: LowPowerClock.h:54
static time_point now()
Read the current time.
Definition: LowPowerClock.h:48
us_timestamp_t ticker_read_us(const ticker_data_t *const ticker)
Read the current (absolute) ticker&#39;s timestamp.
Definition: ATHandler.h:46
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.