mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 1:9db0e321a9f4 1 /*
kenjiArai 1:9db0e321a9f4 2 * Copyright (c) 2006-2019, ARM Limited, All Rights Reserved
kenjiArai 1:9db0e321a9f4 3 * SPDX-License-Identifier: Apache-2.0
kenjiArai 1:9db0e321a9f4 4 *
kenjiArai 1:9db0e321a9f4 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
kenjiArai 1:9db0e321a9f4 6 * not use this file except in compliance with the License.
kenjiArai 1:9db0e321a9f4 7 * You may obtain a copy of the License at
kenjiArai 1:9db0e321a9f4 8 *
kenjiArai 1:9db0e321a9f4 9 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 1:9db0e321a9f4 10 *
kenjiArai 1:9db0e321a9f4 11 * Unless required by applicable law or agreed to in writing, software
kenjiArai 1:9db0e321a9f4 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
kenjiArai 1:9db0e321a9f4 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 1:9db0e321a9f4 14 * See the License for the specific language governing permissions and
kenjiArai 1:9db0e321a9f4 15 * limitations under the License.
kenjiArai 1:9db0e321a9f4 16 */
kenjiArai 1:9db0e321a9f4 17 #ifndef MBED_MBED_SLEEP_TIMER_H
kenjiArai 1:9db0e321a9f4 18 #define MBED_MBED_SLEEP_TIMER_H
kenjiArai 1:9db0e321a9f4 19
kenjiArai 1:9db0e321a9f4 20 #include "platform/source/SysTimer.h"
kenjiArai 1:9db0e321a9f4 21
kenjiArai 1:9db0e321a9f4 22 #if MBED_CONF_RTOS_PRESENT
kenjiArai 1:9db0e321a9f4 23 extern "C" {
kenjiArai 1:9db0e321a9f4 24 #include "rtx_lib.h"
kenjiArai 1:9db0e321a9f4 25 }
kenjiArai 1:9db0e321a9f4 26 #endif
kenjiArai 1:9db0e321a9f4 27
kenjiArai 1:9db0e321a9f4 28 namespace mbed {
kenjiArai 1:9db0e321a9f4 29 namespace internal {
kenjiArai 1:9db0e321a9f4 30
kenjiArai 1:9db0e321a9f4 31 #if MBED_CONF_RTOS_PRESENT
kenjiArai 1:9db0e321a9f4 32 #define OS_TICK_US (1000000 / OS_TICK_FREQ)
kenjiArai 1:9db0e321a9f4 33 #else
kenjiArai 1:9db0e321a9f4 34 #define OS_TICK_US 1000
kenjiArai 1:9db0e321a9f4 35 #endif
kenjiArai 1:9db0e321a9f4 36 typedef SysTimer<OS_TICK_US> OsTimer;
kenjiArai 1:9db0e321a9f4 37
kenjiArai 1:9db0e321a9f4 38 /* A SysTimer is used to provide the timed sleep - this provides access to share it for
kenjiArai 1:9db0e321a9f4 39 * other use, such as ticks. If accessed this way, it must not be in use when a sleep function below is called.
kenjiArai 1:9db0e321a9f4 40 */
kenjiArai 1:9db0e321a9f4 41 extern OsTimer *os_timer;
kenjiArai 1:9db0e321a9f4 42 OsTimer *init_os_timer();
kenjiArai 1:9db0e321a9f4 43
kenjiArai 1:9db0e321a9f4 44 /* -1 is effectively "sleep forever" */
kenjiArai 1:9db0e321a9f4 45 uint64_t do_timed_sleep_absolute(uint64_t wake_time, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
kenjiArai 1:9db0e321a9f4 46
kenjiArai 1:9db0e321a9f4 47 #if MBED_CONF_RTOS_PRESENT
kenjiArai 1:9db0e321a9f4 48 /* Maximum sleep time is 2^32-1 ticks; timer is always set to achieve this */
kenjiArai 1:9db0e321a9f4 49 /* Assumes that ticker has been in use prior to call, so restricted to RTOS use */
kenjiArai 1:9db0e321a9f4 50 uint32_t do_timed_sleep_relative(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
kenjiArai 1:9db0e321a9f4 51 #else
kenjiArai 1:9db0e321a9f4 52
kenjiArai 1:9db0e321a9f4 53 void do_untimed_sleep(bool (*wake_predicate)(void *), void *wake_predicate_handle = NULL);
kenjiArai 1:9db0e321a9f4 54
kenjiArai 1:9db0e321a9f4 55 /* (uint32_t)-1 delay is sleep forever */
kenjiArai 1:9db0e321a9f4 56
kenjiArai 1:9db0e321a9f4 57 void do_timed_sleep_relative_or_forever(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL);
kenjiArai 1:9db0e321a9f4 58
kenjiArai 1:9db0e321a9f4 59 #endif
kenjiArai 1:9db0e321a9f4 60
kenjiArai 1:9db0e321a9f4 61 }
kenjiArai 1:9db0e321a9f4 62 }
kenjiArai 1:9db0e321a9f4 63
kenjiArai 1:9db0e321a9f4 64 #endif