Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_os_timer.h Source File

mbed_os_timer.h

00001 /*
00002  * Copyright (c) 2006-2019, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00006  * not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_MBED_SLEEP_TIMER_H
00018 #define MBED_MBED_SLEEP_TIMER_H
00019 
00020 #include "platform/source/SysTimer.h"
00021 
00022 #if MBED_CONF_RTOS_PRESENT
00023 extern "C" {
00024 #include "rtx_lib.h"
00025 }
00026 #endif
00027 
00028 namespace mbed {
00029 namespace internal {
00030 
00031 #if MBED_CONF_RTOS_PRESENT
00032 #define OS_TICK_US (1000000 / OS_TICK_FREQ)
00033 #else
00034 #define OS_TICK_US 1000
00035 #endif
00036 typedef SysTimer<OS_TICK_US> OsTimer;
00037 
00038 /* A SysTimer is used to provide the timed sleep - this provides access to share it for
00039  * other use, such as ticks. If accessed this way, it must not be in use when a sleep function below is called.
00040  */
00041 extern OsTimer *os_timer;
00042 OsTimer *init_os_timer();
00043 
00044 /* -1 is effectively "sleep forever" */
00045 uint64_t do_timed_sleep_absolute(uint64_t wake_time, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
00046 
00047 #if MBED_CONF_RTOS_PRESENT
00048 /* Maximum sleep time is 2^32-1 ticks; timer is always set to achieve this */
00049 /* Assumes that ticker has been in use prior to call, so restricted to RTOS use */
00050 uint32_t do_timed_sleep_relative(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
00051 #else
00052 
00053 void do_untimed_sleep(bool (*wake_predicate)(void *), void *wake_predicate_handle = NULL);
00054 
00055 /* (uint32_t)-1 delay is sleep forever */
00056 
00057 void do_timed_sleep_relative_or_forever(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
00058 
00059 #endif
00060 
00061 }
00062 }
00063 
00064 #endif