想获取系统时间,但是发现如下问题,如果定义了USE_ICALL就不能够使用,想知道,该如何在APP层获取系统的tick。
void osalTimeUpdate( void )
{
#ifndef USE_ICALL
/* Note that when ICall is in use the OSAL tick is not updated
Yue TANG:
ICall_getTicks
#ifdef USE_ICALL { /* Update osal timers to the latest before running any OSAL processes * regardless of wakeup callback from ICall because OSAL timers are added * relative to the current time. */ unsigned long newtimestamp = ICall_getTicks(); uint32 milliseconds;
if (osal_tickperiod == 1000) { milliseconds = newtimestamp – osal_last_timestamp; osal_last_timestamp = newtimestamp; } else { unsigned long long delta = (unsigned long long) ((newtimestamp – osal_last_timestamp) & 0xfffffffful); delta *= osal_tickperiod; delta /= 1000; milliseconds = (uint32) delta; osal_last_timestamp += (uint32) (delta * 1000 / osal_tickperiod); } osalAdjustTimer(milliseconds); /* Set a value that will never match osal_next_timeout() * return value so that the next time can be scheduled. */ next_timeout_prior = 0xfffffffful; }
jinhua lee:
回复 Yue TANG:
谢谢。不过,如果只是获取了tick,还需要自己实时转换成时间日期,这貌似就增加了功耗。
我发现,CC2640Stack的工程已有osal_clock,并且系统会保持时间,我将如何在CC2640App的工程去调用CC2640Stack里的系统时间呢?
jinhua lee:
回复 Yue TANG:
谢谢。我发现,即使获取了tick,仍需要自己转换成日期时间,这样就增加了功耗。
我有在CC2640Stack中看到,system中已经处理了tick,有OSAL_Clock。请问,我如何在CC2640App层调用CC2640Stack中的系统时间呢?
Yue TANG:
回复 jinhua lee:
OSAL_timeSeconds 记录的就是系统开始运行到现在的时间,单位是秒。
用osal_ConvertUTCTime可以把秒转成年月日时分秒