Send RTC data to all 8bit cores upon start.

This commit is contained in:
sorgelig
2017-09-27 21:21:18 +08:00
parent 95030afb5d
commit 5d7f541846

View File

@@ -218,6 +218,33 @@ static void parse_config()
}
}
//MSM6242B layout
void send_rtc()
{
printf("Update RTC\n");
time_t t = time(NULL);
struct tm tm = *localtime(&t);
uint8_t rtc[8];
rtc[0] = (tm.tm_sec % 10) | ((tm.tm_sec / 10) << 4);
rtc[1] = (tm.tm_min % 10) | ((tm.tm_min / 10) << 4);
rtc[2] = (tm.tm_hour % 10) | ((tm.tm_hour / 10) << 4);
rtc[3] = (tm.tm_mday % 10) | ((tm.tm_mday / 10) << 4);
rtc[4] = ((tm.tm_mon + 1) % 10) | (((tm.tm_mon + 1) / 10) << 4);
rtc[5] = (tm.tm_year % 10) | (((tm.tm_year / 10) % 10) << 4);
rtc[6] = tm.tm_wday;
rtc[7] = 0x40;
spi_uio_cmd_cont(UIO_RTC);
spi_w((rtc[1] << 8) | rtc[0]);
spi_w((rtc[3] << 8) | rtc[2]);
spi_w((rtc[5] << 8) | rtc[4]);
spi_w((rtc[7] << 8) | rtc[6]);
DisableIO();
}
void user_io_detect_core_type()
{
char *name;
@@ -342,6 +369,8 @@ void user_io_detect_core_type()
}
}
send_rtc();
// release reset
user_io_8bit_set_status(0, UIO_STATUS_RESET);
break;
@@ -926,33 +955,12 @@ void user_io_poll()
}
}
if (!rtc_timer || CheckTimer(rtc_timer))
{
printf("Update RTC\n");
// Update once per minute should be enough
rtc_timer = GetTimer(60000);
time_t t = time(NULL);
struct tm tm = *localtime(&t);
uint8_t rtc[8];
rtc[0] = (tm.tm_sec % 10) | ((tm.tm_sec / 10)<<4);
rtc[1] = (tm.tm_min % 10) | ((tm.tm_min / 10)<<4);
rtc[2] = (tm.tm_hour % 10) | ((tm.tm_hour / 10)<<4);
rtc[3] = (tm.tm_mday % 10) | ((tm.tm_mday / 10)<<4);
rtc[4] = ((tm.tm_mon+1) % 10) | (((tm.tm_mon+1) / 10) << 4);
rtc[5] = (tm.tm_year % 10) | (((tm.tm_year / 10) % 10) << 4);
rtc[6] = tm.tm_wday;
rtc[7] = 0x40;
spi_uio_cmd_cont(UIO_RTC);
spi_w((rtc[1] << 8) | rtc[0]);
spi_w((rtc[3] << 8) | rtc[2]);
spi_w((rtc[5] << 8) | rtc[4]);
spi_w((rtc[7] << 8) | rtc[6]);
DisableIO();
send_rtc();
}
}