delay.c 897 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-05-07 Meco Man first Version
  9. */
  10. #include <rtthread.h>
  11. #include <rthw.h>
  12. #define DBG_TAG "POSIX.delay"
  13. #define DBG_LVL DBG_INFO
  14. #include <rtdbg.h>
  15. RT_WEAK void rt_hw_us_delay(rt_uint32_t us)
  16. {
  17. (void) us;
  18. LOG_W("Please consider implementing rt_hw_us_delay() in another file.");
  19. }
  20. void msleep(unsigned int msecs)
  21. {
  22. rt_thread_mdelay(msecs);
  23. }
  24. RTM_EXPORT(msleep);
  25. void ssleep(unsigned int seconds)
  26. {
  27. msleep(seconds * 1000);
  28. }
  29. RTM_EXPORT(ssleep);
  30. void mdelay(unsigned long msecs)
  31. {
  32. rt_hw_us_delay(msecs * 1000);
  33. }
  34. RTM_EXPORT(mdelay);
  35. void udelay(unsigned long usecs)
  36. {
  37. rt_hw_us_delay(usecs);
  38. }
  39. RTM_EXPORT(udelay);
  40. void ndelay(unsigned long nsecs)
  41. {
  42. rt_hw_us_delay(1);
  43. }
  44. RTM_EXPORT(ndelay);