#define BCD(X) (((X) % 10) | (((X) / 10) << 4)) #define DCB(X) ((((X) & 0xF0) >> 4) * 10 + ((X) & 0x0F)) enum RTCADDR { RTCSECONDS, RTCALARMSECONDS, RTCMINUTES, RTCALARMMINUTES, RTCHOURS, RTCALARMHOURS, RTCDOW, RTCDOM, RTCMONTH, RTCYEAR, RTCREGA, RTCREGB, RTCREGC, RTCREGD }; /* The century register at location 32h is a BCD register designed to automatically load the BCD value 20 as the year register changes from 99 to 00. The MSB of this register is not affected when the load of 20 occurs, and remains at the value written by the user. */ #define RTCCENTURY 0x32 /* When the 12-hour format is selected, the higher-order bit of the hours byte represents PM when it is logic 1. */ #define RTCAMPM 0b10000000 /* Register A bitflags */ enum RTCRABITS { /* Rate Selector (RS0) These four rate-selection bits select one of the 13 taps on the 15-stage divider or disable the divider output. The tap selected can be used to generate an output square wave (SQW pin) and/or a periodic interrupt. The user can do one of the following: - Enable the interrupt with the PIE bit; - Enable the SQW output pin with the SQWE bit; - Enable both at the same time and the same rate; or - Enable neither. Table 3 lists the periodic interrupt rates and the square wave frequencies that can be chosen with the RS bits. These four read/write bits are not affected by !RESET. */ RTCRS0 = 0b1, RTCRS1 = 0b10, /*!