comparison 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
comparison
equal deleted inserted replaced
29:077cdff4662a 30:435c6330896c
12 #include <sys/types.h> 12 #include <sys/types.h>
13 #include <sys/stat.h> 13 #include <sys/stat.h>
14 #include <sys/time.h> 14 #include <sys/time.h>
15 15
16 #include "comm.h" 16 #include "comm.h"
17 #include "rtc.h"
17 #include "stm32f10x.h" /* for _get_PSP() from core_cm3.h*/ 18 #include "stm32f10x.h" /* for _get_PSP() from core_cm3.h*/
18 19
19 #undef errno 20 #undef errno
20 extern int errno; 21 extern int errno;
21 22
118 } 119 }
119 120
120 int 121 int
121 _gettimeofday_r(struct _reent *reent __attribute__((unused)), struct timeval *tp, void *tzp __attribute__((unused))) { 122 _gettimeofday_r(struct _reent *reent __attribute__((unused)), struct timeval *tp, void *tzp __attribute__((unused))) {
122 tp->tv_sec = RTC_GetCounter(); 123 tp->tv_sec = RTC_GetCounter();
123 tp->tv_usec = 0; 124 tp->tv_usec = RTC_PS2USEC(RTC_GetDivider());
124 125
125 return 0; 126 return 0;
126 } 127 }
127 128
128 int 129 int
129 settimeofday(const struct timeval *tp, const struct timezone *tzp __attribute__((unused))) { 130 settimeofday(const struct timeval *tp, const struct timezone *tzp __attribute__((unused))) {