Send real time clock data to Minimig.
This commit is contained in:
1
config.c
1
config.c
@@ -338,6 +338,7 @@ void MinimigReset()
|
||||
spi_osd_cmd8(OSD_CMD_RST, 0x01);
|
||||
IDE_setup();
|
||||
spi_osd_cmd8(OSD_CMD_RST, 0x00);
|
||||
user_io_rtc_reset();
|
||||
}
|
||||
|
||||
//// ApplyConfiguration() ////
|
||||
|
||||
36
user_io.c
36
user_io.c
@@ -4,6 +4,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "hardware.h"
|
||||
#include "osd.h"
|
||||
@@ -831,6 +832,12 @@ void mouse_reply(char code)
|
||||
}
|
||||
|
||||
static uint8_t use_ps2ctl = 0;
|
||||
static unsigned long rtc_timer = 0;
|
||||
|
||||
void user_io_rtc_reset()
|
||||
{
|
||||
rtc_timer = 0;
|
||||
}
|
||||
|
||||
void user_io_poll()
|
||||
{
|
||||
@@ -918,6 +925,35 @@ void user_io_poll()
|
||||
mouse_flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_MIST)
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#define UIO_GET_KBD_LED 0x1f // keyboard LEDs control
|
||||
#define UIO_SET_VIDEO 0x20 // set HDMI video mode 0: 1280x720p60(TV), 1: 1280x1024p60(PC), 2-255: reserved
|
||||
#define UIO_PS2_CTL 0x21 // get PS2 control from supported cores
|
||||
#define UIO_RTC 0x22 // transmit RTC data to core
|
||||
|
||||
// codes as used by 8bit (atari 800, zx81) via SS2
|
||||
#define UIO_GET_STATUS 0x50
|
||||
@@ -200,4 +201,6 @@ unsigned char user_io_ext_idx(char *, char*);
|
||||
|
||||
void user_io_check_reset(unsigned short modifiers, char useKeys);
|
||||
|
||||
void user_io_rtc_reset();
|
||||
|
||||
#endif // USER_IO_H
|
||||
|
||||
Reference in New Issue
Block a user