diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/pcf50605.c | 4 | ||||
-rw-r--r-- | firmware/drivers/rtc/rtc_pcf50605.c | 10 | ||||
-rw-r--r-- | firmware/export/pcf50605.h | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/firmware/drivers/pcf50605.c b/firmware/drivers/pcf50605.c index cf4ea9fecb..94d9d0882f 100644 --- a/firmware/drivers/pcf50605.c +++ b/firmware/drivers/pcf50605.c | |||
@@ -69,6 +69,7 @@ | |||
69 | #define D2REGC1 0x25 | 69 | #define D2REGC1 0x25 |
70 | #define D3REGC1 0x26 | 70 | #define D3REGC1 0x26 |
71 | 71 | ||
72 | unsigned char pcf50605_wakeup_flags = 0; | ||
72 | 73 | ||
73 | int pcf50605_read(int address) | 74 | int pcf50605_read(int address) |
74 | { | 75 | { |
@@ -101,8 +102,7 @@ int pcf50605_write_multiple(int address, const unsigned char* buf, int count) | |||
101 | power on your iPod again. */ | 102 | power on your iPod again. */ |
102 | void pcf50605_standby_mode(void) | 103 | void pcf50605_standby_mode(void) |
103 | { | 104 | { |
104 | const char mask = pcf50605_read(OOCC1) | GOSTDBY | CHGWAK | EXTONWAK; | 105 | pcf50605_write(OOCC1, GOSTDBY | CHGWAK | EXTONWAK | pcf50605_wakeup_flags); |
105 | pcf50605_write(OOCC1, mask); | ||
106 | } | 106 | } |
107 | 107 | ||
108 | void pcf50605_init(void) | 108 | void pcf50605_init(void) |
diff --git a/firmware/drivers/rtc/rtc_pcf50605.c b/firmware/drivers/rtc/rtc_pcf50605.c index fedcdd3cdf..93fa391ae3 100644 --- a/firmware/drivers/rtc/rtc_pcf50605.c +++ b/firmware/drivers/rtc/rtc_pcf50605.c | |||
@@ -25,7 +25,9 @@ | |||
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | 26 | ||
27 | /* Values which each disable one alarm time register */ | 27 | /* Values which each disable one alarm time register */ |
28 | static char alarm_disable[] = { 0x7f, 0x7f, 0x3f, 0x07, 0x3f, 0x1f, 0xff }; | 28 | static const char alarm_disable[] = { |
29 | 0x7f, 0x7f, 0x3f, 0x07, 0x3f, 0x1f, 0xff | ||
30 | }; | ||
29 | 31 | ||
30 | void rtc_init(void) | 32 | void rtc_init(void) |
31 | { | 33 | { |
@@ -68,14 +70,16 @@ bool rtc_enable_alarm(bool enable) | |||
68 | pcf50605_write_multiple(0x14, alarm_disable + 3, 4); | 70 | pcf50605_write_multiple(0x14, alarm_disable + 3, 4); |
69 | /* Unmask the alarm interrupt (might be unneeded) */ | 71 | /* Unmask the alarm interrupt (might be unneeded) */ |
70 | pcf50605_write(0x5, pcf50605_read(0x5) & ~0x80); | 72 | pcf50605_write(0x5, pcf50605_read(0x5) & ~0x80); |
71 | /* Make sure wake on RTC is set */ | 73 | /* Make sure wake on RTC is set when shutting down */ |
72 | pcf50605_write(0x8, pcf50605_read(0x8) | 0x10); | 74 | pcf50605_wakeup_flags |= 0x10; |
73 | } else { | 75 | } else { |
74 | /* We use this year to indicate a disabled alarm. If you happen to live | 76 | /* We use this year to indicate a disabled alarm. If you happen to live |
75 | * around this time and are annoyed by this, feel free to seek out my | 77 | * around this time and are annoyed by this, feel free to seek out my |
76 | * grave and do something nasty to it. | 78 | * grave and do something nasty to it. |
77 | */ | 79 | */ |
78 | pcf50605_write(0x17, 0x99); | 80 | pcf50605_write(0x17, 0x99); |
81 | /* Make sure we don't wake on RTC after shutting down */ | ||
82 | pcf50605_wakeup_flags &= ~0x10; | ||
79 | } | 83 | } |
80 | return false; | 84 | return false; |
81 | } | 85 | } |
diff --git a/firmware/export/pcf50605.h b/firmware/export/pcf50605.h index eb899afc86..b38d6a3f14 100644 --- a/firmware/export/pcf50605.h +++ b/firmware/export/pcf50605.h | |||
@@ -20,6 +20,8 @@ | |||
20 | #ifndef PCF50605_H | 20 | #ifndef PCF50605_H |
21 | #define PCF50605_H | 21 | #define PCF50605_H |
22 | 22 | ||
23 | extern unsigned char pcf50605_wakeup_flags; | ||
24 | |||
23 | int pcf50605_read(int address); | 25 | int pcf50605_read(int address); |
24 | int pcf50605_read_multiple(int address, unsigned char* buf, int count); | 26 | int pcf50605_read_multiple(int address, unsigned char* buf, int count); |
25 | int pcf50605_write(int address, unsigned char val); | 27 | int pcf50605_write(int address, unsigned char val); |