17#ifndef MBED_WAIT_API_H
18#define MBED_WAIT_API_H
20#include "platform/mbed_toolchain.h"
21#include "platform/mbed_atomic.h"
108#if DEVICE_USTICKER && defined US_TICKER_PERIOD_NUM
109void _wait_us_ticks(uint32_t ticks);
110void _wait_us_generic(
unsigned int us);
113#if MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT
114#define _us_ticker_is_initialized true
116extern bool _us_ticker_initialized;
117#define _us_ticker_is_initialized core_util_atomic_load_bool(&_us_ticker_initialized)
120#if US_TICKER_PERIOD_DEN == 1 && (US_TICKER_MASK * US_TICKER_PERIOD_NUM) >= 0xFFFFFFFF
122#define _us_is_small_enough(us) true
128#define _us_is_small_enough(us) ((us) < 8192)
132inline void _wait_us_inline(
unsigned int us)
138 if (_us_is_small_enough(us) && _us_ticker_is_initialized) {
139 const uint32_t ticks = ((us * US_TICKER_PERIOD_DEN) + US_TICKER_PERIOD_NUM - 1) / US_TICKER_PERIOD_NUM;
140 _wait_us_ticks(ticks);
142 _wait_us_generic(us);
146#define wait_us(us) _wait_us_inline(us)