forked from len0rd/rockbox
FS#8155: Proper initialization of E8564 RTC (used in H10). Also fixes FS#8154 - Shutting down fails when RTC alarm is active. Thanks to Przemyslaw Holubowski for the bug report and fix.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15619 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2bb48eb8ed
commit
e18125eec2
1 changed files with 20 additions and 0 deletions
|
@ -24,8 +24,28 @@
|
||||||
#include "i2c-pp.h"
|
#include "i2c-pp.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/* RTC registers */
|
||||||
|
#define RTC_CTRL1 0x00
|
||||||
|
#define RTC_CTRL2 0x01
|
||||||
|
|
||||||
|
/* Control 2 register flags */
|
||||||
|
#define RTC_TF 0x04
|
||||||
|
#define RTC_AF 0x08
|
||||||
|
|
||||||
void rtc_init(void)
|
void rtc_init(void)
|
||||||
{
|
{
|
||||||
|
unsigned char tmp;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
/* initialize Control 1 register */
|
||||||
|
tmp = 0;
|
||||||
|
pp_i2c_send(0x51, RTC_CTRL1,tmp);
|
||||||
|
|
||||||
|
/* read value of the Control 2 register - we'll need it to preserve alarm and timer interrupt assertion flags */
|
||||||
|
rv = i2c_readbytes(0x51,RTC_CTRL2,1,&tmp);
|
||||||
|
/* clear alarm and timer interrupts */
|
||||||
|
tmp &= (RTC_TF | RTC_AF);
|
||||||
|
pp_i2c_send(0x51, RTC_CTRL2,tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rtc_read_datetime(unsigned char* buf)
|
int rtc_read_datetime(unsigned char* buf)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue