From 60da28cddd9984a7741ec06e613b6d158e94e806 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 3 Jan 2012 00:05:44 +0100 Subject: [PATCH] Following the idea of https://github.com/mmuman/r0ket/commit/9beb9bbaae3a8e15b430cebb14c14dfbf2d12b57 make the simulator timing more accurate. --- simulat0r/firmware/basic/delayms.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/simulat0r/firmware/basic/delayms.c b/simulat0r/firmware/basic/delayms.c index a628242..c0d69d3 100644 --- a/simulat0r/firmware/basic/delayms.c +++ b/simulat0r/firmware/basic/delayms.c @@ -1,2 +1,16 @@ -/* AUTOGENERATED SOURCE FILE */ -#include "../../../firmware/basic/delayms.c" +#include +#include "lpc134x.h" + +/* Simulator improved version */ + +#define _POSIX_C_SOURCE 199309 +#include + +void delayms(uint32_t ms) +{ + struct timespec t; + t.tv_sec = ms / 1000; + t.tv_nsec = (ms % 1000) * 1000000; + + nanosleep (&t, NULL); +}