posix_sleep.c 317 B

123456789101112131415
  1. #include <stdlib.h>
  2. #include <rtthread.h>
  3. #include <unistd.h>
  4. unsigned int sleep(unsigned int seconds)
  5. {
  6. rt_tick_t delta_tick;
  7. delta_tick = rt_tick_get();
  8. rt_thread_delay(seconds * RT_TICK_PER_SECOND);
  9. delta_tick = rt_tick_get() - delta_tick;
  10. return seconds - delta_tick/RT_TICK_PER_SECOND;
  11. }