From 6e54ea6bcb4c5871147b280e97cf9abae00aded3 Mon Sep 17 00:00:00 2001 From: Udo Munk Date: Thu, 19 Dec 2024 11:08:05 +0100 Subject: [PATCH 1/2] on RP2350 show on which cores we are running --- picosim/srcsim/picosim.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/picosim/srcsim/picosim.c b/picosim/srcsim/picosim.c index 74474e4c..d1622e41 100644 --- a/picosim/srcsim/picosim.c +++ b/picosim/srcsim/picosim.c @@ -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 */ From 5a060fe9eaba8d9681a43384d4e76f91d03deb24 Mon Sep 17 00:00:00 2001 From: Udo Munk Date: Thu, 19 Dec 2024 11:15:05 +0100 Subject: [PATCH 2/2] more reliable detection of the DS3231 RTC --- picosim/srcsim/simcfg.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/picosim/srcsim/simcfg.c b/picosim/srcsim/simcfg.c index af5066cd..4bbf7c9c 100644 --- a/picosim/srcsim/simcfg.c +++ b/picosim/srcsim/simcfg.c @@ -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); @@ -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;