write_clk(CLOCK_CONTROL, 0x04); // stop 1Hz reset, enable alarm
write_clk(ALARM_WEEKDAY, 0x40); // weekly alarm on weekday 6
write_clk(ALARM_CONTROL, 0xA0); // enable weekly alarm and interrupt
The first argument is the address to write to. The ones used above are
defined as:
#define CLOCK_CONTROL 0x00
#define ALARM_CONTROL 0x08
#define ALARM_WEEKDAY 0x0E
And the function to set the alarm values is:
#define CLK_WRITE 0xA0
void
write_clk(byte address, byte data)
{
i2c_start();
i2c_write(CLK_WRITE);
i2c_write(address);
i2c_write(data);
i2c_stop();
}