28 #ifndef __MCP79410_H__
29 #define __MCP79410_H__
45 #define MCP79410_ADDRESS 0x6f
49 #define EEPROM_WRITE 0xae // DEVICE ADDR for EEPROM (writes)
50 #define EEPROM_READ 0xaf // DEVICE ADDR for EEPROM (reads)
51 #define RTCC_WRITE 0xde // DEVICE ADDR for RTCC MCHP (writes)
52 #define RTCC_READ 0xdf // DEVICE ADDR for RTCC MCHP (reads)
54 #define SRAM_PTR 0x20 // pointer of the SRAM area (RTCC)
55 #define EEPROM_SR 0xff // STATUS REGISTER in the EEPROM
57 #define SEC 0x00 // address of SECONDS register
58 #define MIN 0x01 // address of MINUTES register
59 #define HOUR 0x02 // address of HOURS register
60 #define DAY 0x03 // address of DAY OF WK register
61 #define STAT 0x03 // address of STATUS register
62 #define DATE 0x04 // address of DATE register
63 #define MNTH 0x05 // address of MONTH register
64 #define YEAR 0x06 // address of YEAR register
65 #define CTRL 0x07 // address of CONTROL register
66 #define CAL 0x08 // address of CALIB register
67 #define ULID 0x09 // address of UNLOCK ID register
69 #define ALM0SEC 0x0a // address of ALARM0 SEC register
70 #define ALM0MIN 0x0b // address of ALARM0 MIN register
71 #define ALM0HR 0x0c // address of ALARM0 HOUR register
72 #define ALM0WDAY 0x0d // address of ALARM0 CONTR register
73 #define ALM0DATE 0x0e // address of ALARM0 DATE register
74 #define ALM0MTH 0x0f // address of ALARM0 MONTH register
76 #define ALM1SEC 0x11 // address of ALARM1 SEC register
77 #define ALM1MIN 0x12 // address of ALARM1 MIN register
78 #define ALM1HR 0x13 // address of ALARM1 HOUR register
79 #define ALM1WDAY 0x14 // address of ALARM1 CONTR register
80 #define ALM1DATE 0x15 // address of ALARM1 DATE register
81 #define ALM1MTH 0x16 // address of ALARM1 MONTH register
83 #define PWRDNMIN 0x18 // address of T_SAVER MIN(VDD->BAT)
84 #define PWRDNHOUR 0x19 // address of T_SAVER HR (VDD->BAT)
85 #define PWRDNDATE 0x1a // address of T_SAVER DAT(VDD->BAT)
86 #define PWRDNMTH 0x1b // address of T_SAVER MTH(VDD->BAT)
88 #define PWRUPMIN 0x1c // address of T_SAVER MIN(BAT->VDD)
89 #define PWRUPHOUR 0x1d // address of T_SAVER HR (BAT->VDD)
90 #define PWRUPDATE 0x1e // address of T_SAVER DAT(BAT->VDD)
91 #define PWRUPMTH 0x1f // address of T_SAVER MTH(BAT->VDD)
95 #define PM 0x20 // post-meridian bit (HOUR)
96 #define HOUR_FORMAT 0x40 // Hour format
97 #define OUT_PIN 0x80 // = b7 (CTRL)
98 #define SQWEN 0x40 // SQWE = b6 (CTRL)
99 #define ALM_NO 0x00 // no alarm activated (CTRL)
100 #define ALM_0 0x10 // ALARM0 is activated (CTRL)
101 #define ALM_1 0x20 // ALARM1 is activated (CTRL)
102 #define ALM_01 0x30 // both alarms are activated (CTRL)
103 #define MFP_01H 0x00 // MFP = SQVAW(01 HERZ) (CTRL)
104 #define MFP_04K 0x01 // MFP = SQVAW(04 KHZ) (CTRL)
105 #define MFP_08K 0x02 // MFP = SQVAW(08 KHZ) (CTRL)
106 #define MFP_32K 0x03 // MFP = SQVAW(32 KHZ) (CTRL)
107 #define MFP_64H 0x04 // MFP = SQVAW(64 HERZ) (CTRL)
108 #define ALMx_POL 0x80 // polarity of MFP on alarm (ALMxCTL)
109 #define ALMxC_SEC 0x00 // ALARM compare on SEC (ALMxCTL)
110 #define ALMxC_MIN 0x10 // ALARM compare on MIN (ALMxCTL)
111 #define ALMxC_HR 0x20 // ALARM compare on HOUR (ALMxCTL)
112 #define ALMxC_DAY 0x30 // ALARM compare on DAY (ALMxCTL)
113 #define ALMxC_DAT 0x40 // ALARM compare on DATE (ALMxCTL)
114 #define ALMxC_ALL 0x70 // ALARM compare on all param(ALMxCTL)
115 #define ALMx_IF 0x08 // MASK of the ALARM_IF (ALMxCTL)
117 #define OSCRUN 0x20 // state of the oscillator(running or not)
119 #define VBATEN 0x08 // enable battery for back-up
120 #define VBAT_DIS 0x37 // disable battery back-up
122 #define START_32KHZ 0x80 // start crystal: ST = b7 (SEC)
123 #define LP 0x20 // mask for the leap year bit(MONTH REG)
124 #define HOUR_12 0x40 // 12 hours format (HOUR)
130 #define ALM1MSK2 0x40
131 #define ALM1MSK1 0x20
132 #define ALM1MSK0 0x10
134 #define ALM0MSK2 0x40
135 #define ALM0MSK1 0x20
136 #define ALM0MSK0 0x10
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.
unsigned char MCP79410_Read(unsigned char rtcc_reg)
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.
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.
void MCP79410_Write(unsigned char rtcc_reg, unsigned char data)
The below function writes a data byte in the I2C RTCC.
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 month
Date of the month.
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.
struct _RTCC_Struct RTCC_Struct
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 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.