Moved delay mechanism into separate function

This commit is contained in:
Martin Lund 2016-05-18 08:17:07 +02:00
parent 14fc053e8b
commit 13a8bc7790
3 changed files with 13 additions and 8 deletions

View file

@ -23,6 +23,7 @@
#include <stdlib.h>
#include <time.h>
#include "tio/error.h"
#include "tio/print.h"
char * current_time(void)
{
@ -42,3 +43,13 @@ char * current_time(void)
return time_string;
}
void delay(long ms)
{
struct timespec ts;
ts.tv_sec = ms / 1000;
ts.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&ts, NULL);
}