Mistake on this page?
Report an issue in GitHub or email us
mbed_os_timer.h
1 /*
2  * Copyright (c) 2006-2019, 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_MBED_SLEEP_TIMER_H
18 #define MBED_MBED_SLEEP_TIMER_H
19 
20 #include "platform/source/SysTimer.h"
21 
22 #if MBED_CONF_RTOS_PRESENT
23 extern "C" {
24 #include "rtx_lib.h"
25 }
26 #endif
27 
28 namespace mbed {
29 namespace internal {
30 
31 #if MBED_CONF_RTOS_PRESENT
32 #define OS_TICK_US (1000000 / OS_TICK_FREQ)
33 #else
34 #define OS_TICK_US 1000
35 #endif
36 typedef SysTimer<OS_TICK_US> OsTimer;
37 
38 /* A SysTimer is used to provide the timed sleep - this provides access to share it for
39  * other use, such as ticks. If accessed this way, it must not be in use when a sleep function below is called.
40  */
41 extern OsTimer *os_timer;
42 OsTimer *init_os_timer();
43 
44 /* -1 is effectively "sleep forever" */
45 uint64_t do_timed_sleep_absolute(uint64_t wake_time, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
46 
47 #if MBED_CONF_RTOS_PRESENT
48 /* Maximum sleep time is 2^32-1 ticks; timer is always set to achieve this */
49 /* Assumes that ticker has been in use prior to call, so restricted to RTOS use */
50 uint32_t do_timed_sleep_relative(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
51 #else
52 
53 void do_untimed_sleep(bool (*wake_predicate)(void *), void *wake_predicate_handle = NULL);
54 
55 /* (uint32_t)-1 delay is sleep forever */
56 
57 void do_timed_sleep_relative_or_forever(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
58 
59 #endif
60 
61 }
62 }
63 
64 #endif
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.