1 /* 2 * Copyright (c) 2020-2021, WangHuachen 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2020-11-30 WangHuachen the first version 9 */ 10 #ifndef XLI_SLEEP_H 11 #define XLI_SLEEP_H 12 13 #include <rtthread.h> 14 #include <rthw.h> 15 16 #include "xil_types.h" 17 #include "xil_io.h" 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 usleep(unsigned long useconds)23static inline void usleep(unsigned long useconds) 24 { 25 rt_uint32_t milliseconds = useconds/1000; 26 useconds = useconds%1000; 27 if (milliseconds) rt_thread_mdelay(milliseconds); 28 if (useconds) rt_hw_us_delay(useconds); 29 } 30 sleep(unsigned int seconds)31static inline void sleep(unsigned int seconds) 32 { 33 rt_thread_delay(seconds*RT_TICK_PER_SECOND); 34 } 35 36 #ifdef __cplusplus 37 } 38 #endif 39 40 #endif 41