Skip to content

Commit

Permalink
Merge pull request #505 from udo-munk/dev
Browse files Browse the repository at this point in the history
merge dev
  • Loading branch information
udo-munk authored Dec 27, 2024
2 parents 8ec01af + 13159b3 commit e9958ed
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
18 changes: 13 additions & 5 deletions picosim/srcsim/simcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,10 @@ void config(void)
ds3231_init(DS3231_I2C_PORT, DS3231_I2C_SDA_PIN,
DS3231_I2C_SCL_PIN, &rtc);

/* 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) {
/* Use a dummy read to see if a DS3231 RTC is present */
if (i2c_read_blocking(rtc.i2c_port, rtc.i2c_addr, &buf, 1,
false) >= 0) {
puts("DS3231 RTC present, using it for setting the clock\n");
/* Read the date and time from the DS3231 RTC */
ds3231_get_datetime(&dt, &rtc);
t.tm_year = dt.year - 1900;
Expand All @@ -149,6 +148,9 @@ void config(void)
ts.tv_sec = mktime(&t);
ts.tv_nsec = 0;
aon_timer_start(&ts);
#if PICO_RP2040
sleep_us(64);
#endif

menu = 1;

Expand Down Expand Up @@ -228,6 +230,9 @@ void config(void)
ds3231_set_datetime(&dt, &rtc);
ts.tv_sec = mktime(&t);
aon_timer_set_time(&ts);
#if PICO_RP2040
sleep_us(64);
#endif
}
putchar('\n');
break;
Expand Down Expand Up @@ -256,6 +261,9 @@ void config(void)
ds3231_set_datetime(&dt, &rtc);
ts.tv_sec = mktime(&t);
aon_timer_set_time(&ts);
#if PICO_RP2040
sleep_us(64);
#endif
}
putchar('\n');
break;
Expand Down
17 changes: 17 additions & 0 deletions z80core/simfun.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@
#include "sim.h"
#include "simdefs.h"

/*
* The following code can be used as a simport.h file for a machine
* running on an OS using the POSIX API. The implementations are
* included in simfun.c:
*
* #include <stdint.h>
*
* #include "sim.h"
*
* extern void sleep_for_us(long time);
* extern void sleep_for_ms(int time);
* extern uint64_t get_clock_us(void);
* #ifdef WANT_ICE
* extern int get_cmdline(char *buf, int len);
* #endif
*/

extern int load_file(char *fn, WORD start, int size);

#endif /* !SIMFUN_INC */

0 comments on commit e9958ed

Please sign in to comment.