rt-thread/bsp/zynqmp-r5-axu4ev/drivers/Zynq_HAL_Driver/sleep.h

32 lines
532 B
C
Raw Normal View History

#ifndef XLI_SLEEP_H
#define XLI_SLEEP_H
#include <rtthread.h>
#include <rthw.h>
#include "xil_types.h"
#include "xil_io.h"
#ifdef __cplusplus
extern "C" {
#endif
static inline void usleep(unsigned long useconds)
{
2021-05-14 14:22:23 +08:00
rt_uint32_t milliseconds = useconds/1000;
useconds = useconds%1000;
if (milliseconds) rt_thread_mdelay(milliseconds);
if (useconds) rt_hw_us_delay(useconds);
}
static inline void sleep(unsigned int seconds)
{
2021-05-14 14:22:23 +08:00
rt_thread_delay(seconds*RT_TICK_PER_SECOND);
}
#ifdef __cplusplus
}
#endif
#endif