|
| 1 | +/* |
| 2 | + * Copyright (c) 2019 ARM Limited. All rights reserved. |
| 3 | + */ |
| 4 | + |
| 5 | +#ifndef MBED_RTOS_C_H_ |
| 6 | +#define MBED_RTOS_C_H_ |
| 7 | + |
| 8 | +#include <stdint.h> |
| 9 | + |
| 10 | +#ifdef __cplusplus |
| 11 | +extern "C" { |
| 12 | +#endif |
| 13 | + |
| 14 | +/** Generic thread functions. |
| 15 | + * |
| 16 | + * These are C versions of functions provided in C++ via rtos::Thread and rtos::ThisThread |
| 17 | + */ |
| 18 | + |
| 19 | +/** Read the current RTOS kernel millisecond tick count. |
| 20 | + The tick count corresponds to the tick count the RTOS uses for timing |
| 21 | + purposes. It increments monotonically from 0 at boot, so it effectively |
| 22 | + never wraps. If the underlying RTOS only provides a 32-bit tick count, |
| 23 | + this method expands it to 64 bits. |
| 24 | + @return RTOS kernel current tick count |
| 25 | + @note Mbed OS always uses millisecond RTOS ticks, and this could only wrap |
| 26 | + after half a billion years. |
| 27 | + @note In a non-RTOS build, this computes an equivalent time in milliseconds, |
| 28 | + based on a HAL timer. The time may be referenced as 0 on first call. |
| 29 | + @note You cannot call this function from ISR context. |
| 30 | + @note The equivalent functionality is accessible in C++ via rtos::Kernel::get_ms_count. |
| 31 | + */ |
| 32 | +uint64_t get_ms_count(void); |
| 33 | + |
| 34 | +/** Sleep for a specified time period in millisec: |
| 35 | + @param millisec time delay value |
| 36 | + @note You cannot call this function from ISR context. |
| 37 | + @note The equivalent functionality is accessible in C++ via rtos::ThisThread::sleep_for. |
| 38 | +*/ |
| 39 | +void thread_sleep_for(uint32_t millisec); |
| 40 | + |
| 41 | +/** Sleep until a specified time in millisec |
| 42 | + The specified time is according to Kernel::get_ms_count(). |
| 43 | + @param millisec absolute time in millisec |
| 44 | + @note You cannot call this function from ISR context. |
| 45 | + @note if millisec is equal to or lower than the current tick count, this |
| 46 | + returns immediately. |
| 47 | + @note The equivalent functionality is accessible in C++ via ThisThread::sleep_until. |
| 48 | +*/ |
| 49 | +void thread_sleep_until(uint64_t millisec); |
| 50 | + |
| 51 | +#ifdef __cplusplus |
| 52 | +} |
| 53 | +#endif |
| 54 | + |
| 55 | +#endif /* MBED_THREAD_API_H_ */ |
0 commit comments