1 /*
2  * Copyright (c) 2018, Linaro Limited. and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /*
8  * @file	freertos/sleep.h
9  * @brief	FreeRTOS sleep primitives for libmetal.
10  */
11 
12 #ifndef __METAL_SLEEP__H__
13 #error "Include metal/sleep.h instead of metal/freertos/sleep.h"
14 #endif
15 
16 #ifndef __METAL_FREERTOS_SLEEP__H__
17 #define __METAL_FREERTOS_SLEEP__H__
18 
19 #include <FreeRTOS.h>
20 #include <task.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
__metal_sleep_usec(unsigned int usec)26 static inline int __metal_sleep_usec(unsigned int usec)
27 {
28 	const TickType_t xDelay = pdMS_TO_TICKS(usec/1000);
29 
30 	vTaskDelay(xDelay ? xDelay : 1);
31 	return 0;
32 }
33 
34 #ifdef __cplusplus
35 }
36 #endif
37 
38 #endif /* __METAL_FREERTOS_SLEEP__H__ */
39