陈德胜 2013-07-09 01:36
浏览 1355

wince下RTC驱动该如何写?芯片是M41T81

我的板子核心CPU是PXA270,然后我有一个外接的RTC芯片M41T81,用它来实现实时时钟,可是现在关机后,每次重启时间都会归零。
我的IIC总线有两个IC器件在用,一个是摄像头,一个就是这个M41T81。我把我的RTC驱动部分代码贴出来,请大家指教。
BOOL
OEMGetRealTime(LPSYSTEMTIME lpst)
{
unsigned int cur_time;
// Get the RTC value
GetRTCTime (&cur_time);
FormatSystemTime (cur_time, lpst);

//QU_GetRTCTime (lpst);

#if 0
DEBUGMSG(0,(TEXT("OEMGetRealTime: Year: %u, Month: %u, Day: %u, Hour: %u, Minute: %u, second: %u rcnr=%Xh\n"),
lpst->wYear, lpst->wMonth,lpst->wDay, lpst->wHour, lpst->wMinute,lpst->wSecond, cur_time));
#endif

return TRUE;

}

//
//
// Sets the RTC.
// Called by kernel in response to SetSystemTime()
//
//
BOOL OEMSetRealTime(LPSYSTEMTIME lpst)
{
unsigned int cur_time;
ConvertSystemTime (lpst, &cur_time);
SetRTCTime (cur_time);
//QU_SetRTCTime (lpst);

#if 0
DEBUGMSG(0,(TEXT("OEMSetRealTime: Year: %u, Month: %u, Day: %u, Hour: %u, Minute: %u, second: %u rcnr=%Xh\n"),
lpst->wYear, lpst->wMonth,lpst->wDay, lpst->wHour, lpst->wMinute, lpst->wSecond, cur_time));
#endif

return TRUE;

}

//
//
// Set the RTC alarm.
// Ensure synchronization to RTC registers.
//
// Default behavior will allow setting an alarm
// (thereby cancelling any pending one)
//
//
BOOL OEMSetAlarmTime(LPSYSTEMTIME lpst)
{
unsigned int min, day, month, year;
unsigned int *mtbl;
unsigned int alarm_time;

XLLP_RTC_HANDLE_T   XllpRTCHandle;

XllpRTCHandle.pRTCRegs = (XLLP_RTC_T *)RTC_BASE_U_VIRTUAL;
XllpRTCHandle.pINTCRegs = (XLLP_INTC_T *)INTC_BASE_U_VIRTUAL;

day = 0;
for (year=ORIGINYEAR; year<lpst->wYear; year++) {
    day += 365 + isleap(year);
}

mtbl = isleap(year) ? monthtable_leap : monthtable;
for (month=0; month<((unsigned)lpst->wMonth-1); month++) {
    day += mtbl[month];
}

day += lpst->wDay - 1;

min = (day * 24 + lpst->wHour) * 60 + lpst->wMinute;

alarm_time = min * 60 + lpst->wSecond;

// 
// Configure and arm the alarm 
//
XllpRtcConfigureAlarm (&XllpRTCHandle, alarm_time);


return TRUE;

}

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题