diff syscalls.c @ 30:435c6330896c

Set tv_usec in gettimeofday() by using the prescaler counter.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 27 Nov 2012 13:19:11 +1030
parents 2bce4dbf52b8
children d3b7d4964807
line wrap: on
line diff
--- a/syscalls.c	Tue Nov 27 13:17:42 2012 +1030
+++ b/syscalls.c	Tue Nov 27 13:19:11 2012 +1030
@@ -14,6 +14,7 @@
 #include <sys/time.h>
 
 #include "comm.h"
+#include "rtc.h"
 #include "stm32f10x.h" /* for _get_PSP() from core_cm3.h*/
 
 #undef errno
@@ -120,8 +121,8 @@
 int
 _gettimeofday_r(struct _reent *reent __attribute__((unused)), struct timeval *tp, void *tzp __attribute__((unused))) {
     tp->tv_sec = RTC_GetCounter();
-    tp->tv_usec = 0;
-
+    tp->tv_usec = RTC_PS2USEC(RTC_GetDivider());
+    
     return 0;
 }