void rtc_set_alarm(int h, int m) { /* Set us to wake at the first second of the specified time */ pcf50605_write(0x11, 0); /* Convert to BCD */ pcf50605_write(0x12, DEC2BCD(m)); pcf50605_write(0x13, DEC2BCD(h)); }
void accessory_supply_set(bool enable) { /* Set accessory power supply to 3.3V, otherwise switch it off. */ unsigned char value = enable ? 0xf8 : 0x18; /* Write to register. */ pcf50605_write(PCF5060X_D2REGC1, value); }
void pcf50605_init(void) { #if (defined (IPOD_VIDEO) || defined (IPOD_NANO)) /* I/O and GPO voltage supply. ECO not allowed regarding data sheet. Defaults: * iPod Video = 0xf8 = 3.3V ON * iPod nano = 0xf5 = 3.0V ON */ pcf50605_write(PCF5060X_IOREGC, 0xf5); /* 3.0V ON */ /* Core voltage supply. ECO not stable, assumed due to less precision of * voltage in ECO mode. DCDC2 is not relevant as this may be used for * voltage scaling. Default is 1.2V ON for PP5022/PP5024 */ pcf50605_write(PCF5060X_DCDC1, 0xec); /* 1.2V ON */ pcf50605_write(PCF5060X_DCDC2, 0x0c); /* OFF */ /* Unknown. Defaults: * iPod Video = 0xe3 = 1.8V ON * iPod nano = 0xe3 = 1.8V ON */ pcf50605_write(PCF5060X_DCUDC1, 0xe3); /* 1.8V ON */ /* Codec voltage supply. ECO not allowed as max. current of 5mA is not * sufficient. Defaults: * iPod Video = 0xf5 = 3.0V ON * iPod nano = 0xef = 2.4V ON */ pcf50605_write(PCF5060X_D1REGC1, 0xf0); /* 2.5V ON */ /* PCF5060X_D2REGC1 is set in accordance to the accessory power setting */ #if defined (IPOD_VIDEO) /* LCD voltage supply. Defaults: * iPod Video = 0xf5 = 3.0V ON */ pcf50605_write(PCF5060X_D3REGC1, 0xf1); /* 2.6V ON */ #elif defined (IPOD_NANO) /* D3REGC has effect on LCD and ATA, leave it unchanged due to possible ATA * failures. Defaults: * iPod nano = 0xf5 = 3.0V ON */ pcf50605_write(PCF5060X_D3REGC1, 0xf5); /* 3.0V ON */ #endif /* PCF5060X_LPREGC1 is leaved untouched as the setting varies over the * different iPod platforms. Defaults: * iPod Video = 0x1f = 0ff * iPod nano = 0xf6 = 3.1V ON */ #else /* keep initialization from svn for other iPods */ pcf50605_write(PCF5060X_D1REGC1, 0xf5); /* 3.0V ON */ pcf50605_write(PCF5060X_D3REGC1, 0xf5); /* 3.0V ON */ #endif }
/** * Enables or disables the alarm. * The Ipod bootloader clears all PCF interrupt registers and always enables * the "wake on RTC" bit on OOCC1, so we have to rely on other means to find * out if we just woke from an alarm. */ void rtc_enable_alarm(bool enable) { if (enable) { /* Tell the PCF to ignore everything but second, minute and hour, so * that an alarm will trigger the next time the alarm time occurs. */ pcf50605_write_multiple(0x14, alarm_disable + 3, 4); /* Unmask the alarm interrupt (might be unneeded) */ pcf50605_write(0x5, pcf50605_read(0x5) & ~0x80); /* Make sure wake on RTC is set when shutting down */ pcf50605_wakeup_flags |= 0x10; } else { /* We use this year to indicate a disabled alarm. If you happen to live * around this time and are annoyed by this, feel free to seek out my * grave and do something nasty to it. */ pcf50605_write(0x17, 0x99); /* Make sure we don't wake on RTC after shutting down */ pcf50605_wakeup_flags &= ~0x10; } }
/* The following command puts the iPod into a deep sleep. Warning from the good people of ipodlinux - never issue this command without setting CHGWAK or EXTONWAK if you ever want to be able to power on your iPod again. */ void pcf50605_standby_mode(void) { pcf50605_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK | pcf50605_wakeup_flags); }