Commit ddef0654 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Enable SNTP on CC3200

PUBLISHED_FROM=cea0fc4db21f5b68fd3e779334989fef84a1637a
parent ac857d18
......@@ -12388,21 +12388,24 @@ time_t HOSTtime() {
#endif /* __TI_COMPILER_VERSION__ */
#ifndef __TI_COMPILER_VERSION__
int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp) {
int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tz) {
#else
int gettimeofday(struct timeval *tp, void *tzp) {
int gettimeofday(struct timeval *tp, void *tz) {
#endif
unsigned long long r1 = 0, r2;
/* Achieve two consecutive reads of the same value. */
do {
r2 = r1;
r1 = PRCMSlowClkCtrFastGet();
} while (r1 != r2);
/* This is a 32768 Hz counter. */
tp->tv_sec = (r1 >> 15);
/* 1/32768-th of a second is 30.517578125 microseconds, approx. 31,
* but we round down so it doesn't overflow at 32767 */
tp->tv_usec = (r1 & 0x7FFF) * 30;
unsigned long sec;
unsigned short msec;
MAP_PRCMRTCGet(&sec, &msec);
tp->tv_sec = sec;
tp->tv_usec = ((unsigned long) msec) * 1000;
return 0;
}
#ifndef __TI_COMPILER_VERSION__
int settimeofday(const struct timeval *tv, const struct timezone *tz) {
#else
int settimeofday(const struct timeval *tv, const void *tz) {
#endif
MAP_PRCMRTCSet(tv->tv_sec, tv->tv_usec / 1000);
return 0;
}
......
......@@ -676,6 +676,7 @@ extern "C" {
struct SlTimeval_t;
#define timeval SlTimeval_t
int gettimeofday(struct timeval *t, void *tz);
int settimeofday(const struct timeval *tv, const void *tz);
int asprintf(char **strp, const char *fmt, ...);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment