|
@@ -60,6 +60,7 @@ struct acts_timer_data {
|
|
|
|
|
|
|
|
uint16_t timer_crc[2] __attribute((used)) = {0};
|
|
uint16_t timer_crc[2] __attribute((used)) = {0};
|
|
|
uint8_t read_time_data[7] = {0};
|
|
uint8_t read_time_data[7] = {0};
|
|
|
|
|
+bool bInitTimeData; // 0: no need to init; 1: need to init
|
|
|
static struct acts_timer_data timer_acts_ddata;
|
|
static struct acts_timer_data timer_acts_ddata;
|
|
|
|
|
|
|
|
static int _sd8563_close_write_protection(const struct device *i2c_dev);
|
|
static int _sd8563_close_write_protection(const struct device *i2c_dev);
|
|
@@ -343,7 +344,6 @@ static void _sd8563_set_time(const struct device *i2c_dev,
|
|
|
#if 1
|
|
#if 1
|
|
|
uint8_t write_cmd[8] = {0};
|
|
uint8_t write_cmd[8] = {0};
|
|
|
uint8_t read_cmd[7] = {0};
|
|
uint8_t read_cmd[7] = {0};
|
|
|
- bool power_on_set_time_data = false;
|
|
|
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
|
|
printk("_sd8563_set_time start\n");
|
|
printk("_sd8563_set_time start\n");
|
|
@@ -365,7 +365,7 @@ static void _sd8563_set_time(const struct device *i2c_dev,
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- power_on_set_time_data = true;
|
|
|
|
|
|
|
+ bInitTimeData = true; //need to init time
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
_sd8563_read_time(i2c_dev, false); //read time
|
|
_sd8563_read_time(i2c_dev, false); //read time
|
|
@@ -397,7 +397,7 @@ static void _sd8563_set_time(const struct device *i2c_dev,
|
|
|
read_time_data[6] = set_year;//(set_year / 10) * 16 + set_year % 10; //DEC TO BCD CODE
|
|
read_time_data[6] = set_year;//(set_year / 10) * 16 + set_year % 10; //DEC TO BCD CODE
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (power_on_set_time_data == true)
|
|
|
|
|
|
|
+ if (bInitTimeData == true) //need to init time
|
|
|
{
|
|
{
|
|
|
//BCD code
|
|
//BCD code
|
|
|
write_cmd[1] = 0; //sec
|
|
write_cmd[1] = 0; //sec
|
|
@@ -504,6 +504,8 @@ static void _sd8563_init_work(struct k_work *work)
|
|
|
|
|
|
|
|
external_rtc->inited = true;
|
|
external_rtc->inited = true;
|
|
|
|
|
|
|
|
|
|
+ bInitTimeData = false;
|
|
|
|
|
+
|
|
|
if (_sd8563_close_write_protection(external_rtc->i2c_dev) == 1)
|
|
if (_sd8563_close_write_protection(external_rtc->i2c_dev) == 1)
|
|
|
{
|
|
{
|
|
|
//k_msleep(2);
|
|
//k_msleep(2);
|