void Update(void)
{
SYSTEMTIME cpltime, tmptime;
// to allow the user to get good feedback about the current timezone
// daylight savings time etc, we actually update the system on the fly
// for these items the changes will be reflected in the time of each date
// control
DateTime_GetSystemtime(M_DI(IDC_TIME_TIME),(LPARAM)&cpltime);
// load the 'date'
MonthCal_GetCurSel(M_DI(IDC_TIME_DATE), (LPARAM)&tmptime);
// copy the dates into cpltime
cpltime.wYear = tmptime.wYear;
cpltime.wDayOfWeek = tmptime.wDayOfWeek;
cpltime.wDay = tmptime.wDay;
cpltime.wMonth = tmptime.wMonth;
{
// Need to change system time but didn't do it in UpdateTimeZone
SetLocalTime(&cpltime);
}
GetLocalTime(&cpltime);
DateTime_SetSystemtime(M_DI(IDC_TIME_TIME), GDT_VALID, &cpltime);
MonthCal_SetToday(M_DI(IDC_TIME_DATE), &cpltime);
MonthCal_SetCurSel(M_DI(IDC_TIME_DATE), &cpltime);
}
OEMSetRealTime中的部分代码如下:
OUTPORT32(&pRTCReg->BCDSEC, TO_BCD(pTime->wSecond));
OUTPORT32(&pRTCReg->BCDMIN, TO_BCD(pTime->wMinute));
OUTPORT32(&pRTCReg->BCDHOUR, TO_BCD(pTime->wHour));
OUTPORT32(&pRTCReg->BCDDATE, pTime->wDayOfWeek + 1);
OUTPORT32(&pRTCReg->BCDDAY, TO_BCD(pTime->wDay));
OUTPORT32(&pRTCReg->BCDMON, TO_BCD(pTime->wMonth));
OUTPORT32(&pRTCReg->BCDYEAR, TO_BCD(pTime->wYear - RTC_YEAR_DATUM));
BCDDAY Bit Description Initial State
Reserved [7:3] – –
DAYDATA [2:0] BCD value for a day of the week. –
1 ~ 7
Reserved [7:6] – –
DATEDATA [5:4] BCD value for date.
0 ~ 3 –
[3:0] 0 ~ 9 –