timer.c 464 Bytes
#include <PR/bcp.h>
#include "util.h"
#include "skerror.h"


s32 gTime;
s32 gLimit;

int skEntryTimer(void)
{
    u32 sec;
    gTime++;
    sec = SK_TIMER_TIC_TO_SEC(gTime);
    gSavedCc = (sec+30)/60;
    if (gSavedCode == BB_LIMIT_CODE_TIME2) {
	message("missed keepalive\n");
	skReboot();
    }
    if (sec >= gLimit*60) {
	message("Timer to die\n");
	skReboot();
    } 
    IO_WRITE(MI_SEC_TIMER_REG, SK_TIMER_PRESCALE|SK_TIMER_TICS);
    return SK_SUCCESS;
}