|
- //------------------------------------------------------------------------------
- //
- // Function: OEMGetRealTime
- //
- // Reads the current RTC value and returns a system time.
- //
- BOOL OEMGetRealTime(SYSTEMTIME *pTime)
- {
- BOOL rc = FALSE;
- S3C2410X_RTC_REG *pRTCReg;
- UINT32 data;
- UINT16 seconds;
- OALMSG(OAL_RTC&&OAL_FUNC, (L"+OEMGetRealTime(pTime = 0x%x)\r\n", pTime));
- if (pTime == NULL) goto cleanUp;
-
- // Get uncached virtual address
- pRTCReg = OALPAtoVA(S3C2410X_BASE_REG_PA_RTC, FALSE);
- do {
- data = INPORT32(&pRTCReg->BCDSEC) & 0x7f;
- seconds = FROM_BCD(data);
- data = INPORT32(&pRTCReg->BCDYEAR);
- pTime->wYear = FROM_BCD(data) + RTC_YEAR_DATUM;
- data = INPORT32(&pRTCReg->BCDMON) & 0x1f;
- pTime->wMonth = FROM_BCD(data);
- data = INPORT32(&pRTCReg->BCDDAY) & 0x3f;
- pTime->wDay = FROM_BCD(data);
- pTime->wDayOfWeek = (WORD)INPORT32(&pRTCReg->BCDDATE) - 1;
- data = INPORT32(&pRTCReg->BCDHOUR) & 0x3f;
- pTime->wHour = FROM_BCD(data);
- data = INPORT32(&pRTCReg->BCDMIN) & 0x7f;
- pTime->wMinute = FROM_BCD(data);
- data = INPORT32(&pRTCReg->BCDSEC) & 0x7f;
- pTime->wSecond = FROM_BCD(data);
- pTime->wMilliseconds = 0;
- } while (pTime->wSecond != seconds);
- // Done
- rc = TRUE;
- cleanUp:
- OALMSG(OAL_FUNC, (L"-OEMGetRealTime(rc = %d)\r\n", rc));
- return rc;
- }
复制代码
可以看到,模拟器RTC中的毫秒都是0.所以,你应用获取到的也都是0了。
如果要ms级的,可以考虑用GetTickCount(). |
|