48 time_t t = time(NULL);
49 struct tm tm = *localtime(&t);
50 RTCC_Struct curr_time = {tm.tm_sec,tm.tm_min,tm.tm_hour,tm.tm_wday,tm.tm_mday,tm.tm_mon+1, ((tm.tm_year+1900)-2000)};
52 printf(
"MCP79410_Initialize DEBUG now: %d-%d-%d %d:%d:%d\n", tm.tm_year, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
88 if((mask &
OSCRUN) == OSCRUN)
109 hour_t = ((hour_t &
HOUR_12) ==
HOUR_12)? (hour_t & 0x1F) : (hour_t & 0x3F);
128 unsigned char min = 0;
131 unsigned char date = 0;
133 unsigned char year = 0;
144 if(( hour &
HOUR_12) == HOUR_12)
151 if(( hour &
PM) == PM)
161 if((month &
LPYR) == LPYR)
333 unsigned char Polarity_bit = 0;
366 unsigned char AlarmRegister = 0;
468 unsigned char PowerFail;
470 if((PowerFailure_bit &
PWRFAIL) == PWRFAIL)
476 PowerFailure_bit &= ~PWRFAIL;
491 if((temp &
VBATEN) == VBATEN)
552 return powerdown_time;
562 return ((num/10 * 16) + (num % 10));
572 return ((num/16 * 10) + (num % 16));
void MCP79410_SetMFP_GPOStatus(Polarity_t status)
This function sets the MFP output logic level when the pin is configured as GPO.
unsigned char MCP79410_dec2bcd(unsigned char num)
Convert Binary Coded Decimal (BCD) to Decimal.
void MCP79410_EnableAlarm(Alarm_t alarm)
This function sets the alarm time.
void MCP79410_SetAlarmMatch(Match_t match, Alarm_t alarm)
Alarm Asserts on Match on seconds, minutes ,hours depending on match parameter.
void MCP79410_DisableVbat(void)
This function disables the backup battery functionality.
void MCP79410_DisableOscillator(void)
Disables the clock oscillator.The RTCC does not operate once the oscillator is stopped.
void MCP79410_Write(unsigned char rtcc_reg, unsigned char time_var)
The below function writes a data byte in the I2C RTCC.
unsigned char MCP79410_IsRunning(void)
Checks if the chip clock is running.
void MCP79410_SetTime(RTCC_Struct *time)
This function initializes the RTCC with a specific time contained in the time structure.
unsigned char date
Weekday.
unsigned char MCP79410_CheckPowerFailure(void)
This function checks if there was a power failure.
void MCP79410_SetAlarmMFPPolarity(Polarity_t MFP_pol, Alarm_t alarm)
This function sets the MFP polarity either high or low.
RTCC_Struct * MCP79410_GetTime(void)
The function returns a time structure with the current time from the RTCC.
unsigned char weekday
Hours, (Format used : Standard / Military)
unsigned char MCP79410_Read(unsigned char rtcc_reg)
unsigned char month
Date of the month.
void I2C_WriteByteRegister(unsigned char reg, unsigned char data)
Writes a byte value to a register address.
void MCP79410_EnableOscillator(void)
Enables the clock oscillator. This must be enabled in order for the RTCC to run.
void MCP79410_ClearInterruptFlag(Alarm_t alarm)
Clears the interrupt alarm flag.
AlarmStatus_t MCP79410_GetAlarmStatus(Alarm_t alarm)
This function gets the status of the alarm interrupt flag.
void MCP79410_Initialize(void)
Initializes the RTCC with the system time.
void MCP79410_SetHourFormat(Format_t format)
This function sets the hour format.
void MCP79410_EnableVbat(void)
This function enables backup battery mode.
void MCP79410_SetAlarmTime(RTCC_Struct *time, Alarm_t alarm)
This function sets the alarm time for one of the two alarms.
unsigned char min
Seconds.
RTCC_Struct * MCP79410_GetPowerDownTime(void)
This function returns the power-down time of the RTCC.
unsigned char I2C_ReadByteRegister(char reg)
Reads a byte from a register.
unsigned char hour
Minutes.
unsigned char MCP79410_IsVbatEnabled(void)
This function checks if battery mode is enabled.
enum AlarmStatus AlarmStatus_t
RTCC_Struct * MCP79410_GetPowerUpTime(void)
This function returns the power-up time of the RTCC.
void MCP79410_DisableAlarm(Alarm_t alarm)
This function disables one of the two alarms.
void MCP79410_SetMFP_Functionality(MFP_t mode)
This function sets the MFP pin mode.
void MCP79410_SetPMAM(PMAM_t meridian)
This function sets the meridian mode.
unsigned char MCP79410_bcd2dec(unsigned char num)
Convert Binary Coded Decimal (BCD) to Decimal.