Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge dev #488

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions picosim/srcsim/picosim.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ int main(void)
/* print banner */
printf("\fZ80pack release %s, %s\n", RELEASE, COPYR);
printf("%s release %s\n", USR_COM, USR_REL);
#if PICO_RP2350
#if PICO_RISCV
puts("running on Hazard RISC-V cores");
#else
puts("running on ARM Cortex-M33 cores");
#endif
#endif
printf("%s\n\n", USR_CPR);

init_cpu(); /* initialize CPU */
Expand Down
30 changes: 10 additions & 20 deletions picosim/srcsim/simcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ void config(void)
static const char *dotw[7] = { "Sun", "Mon", "Tue", "Wed",
"Thu", "Fri", "Sat" };
struct timespec ts;
struct ds3231_rtc rtc;
ds3231_datetime_t dt;
uint8_t buf;
UNUSED(DS3231_MONTHS);
UNUSED(DS3231_WDAYS);

Expand All @@ -117,30 +120,17 @@ void config(void)
}

/* Create a real-time clock structure and initiate this */
struct ds3231_rtc rtc;
ds3231_init(DS3231_I2C_PORT, DS3231_I2C_SDA_PIN,
DS3231_I2C_SCL_PIN, &rtc);

/* A `ds3231_datetime_t` structure holds date and time values. It is */
/* used first to set the initial (user-defined) date/time. After */
/* these initial values are set, then this same structure will be */
/* updated by the ds3231 functions as needed with the most current */
/* time and date values. */
ds3231_datetime_t dt = {
.year = 2000, /* Year (2000-2099) */
.month = 1, /* Month (1-12, 1=January, 12=December) */
.day = 1, /* Day (1-31) */
.hour = 0, /* Hour, in 24-h format (0-23) */
.minutes = 0, /* Minutes (0-59) */
.seconds = 0, /* Seconds (0-59) */
.dotw = 1, /* Day of the week (1-7, 1=Monday, 7=Sunday) */
};

/* Read the date and time from the DS3231 RTC */
ds3231_get_datetime(&dt, &rtc);

/* if we read something take it over */
if (dt.year != 2000) {
/* Try to read the DS3231 RTC status register */
buf = DS3231_STATUS_REG;
i2c_write_blocking(rtc.i2c_port, rtc.i2c_addr, &buf, 1, true);
if (i2c_read_blocking(rtc.i2c_port, rtc.i2c_addr,
&buf, 1, false) == 1) {
/* Read the date and time from the DS3231 RTC */
ds3231_get_datetime(&dt, &rtc);
t.tm_year = dt.year - 1900;
t.tm_mon = dt.month - 1;
t.tm_mday = dt.day;
Expand Down
Loading