From 320d61551b96874b0abd6721308a338994199d5b Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Tue, 15 Mar 2022 22:37:23 +0100 Subject: [PATCH] ESP32 tweaks --- ESP32/main.ino | 23 ++++++++++++++++++----- ESP32/platformio.ini | 4 ++-- tty.cpp | 6 ++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ESP32/main.ino b/ESP32/main.ino index 4171b97..40d011d 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -214,6 +214,8 @@ uint16_t loadbin(bus *const b) uint16_t exec_addr = 0; +uint32_t start_ts = 0; + void setup() { Serial.begin(115200); @@ -240,6 +242,8 @@ void setup() { exec_addr = loadbin(b); c->setRegister(7, exec_addr); + pinMode(LED_BUILTIN, OUTPUT); + Serial.println(F("Press to start")); for(;;) { @@ -253,27 +257,36 @@ void setup() { } Serial.println(F("Emulation starting!")); + + start_ts = millis(); } -unsigned int icount = 0; +uint32_t icount = 0; void loop() { icount++; - if (icount % 1000 == 0 && Serial.available()) { - char c = Serial.read(); + if ((icount & 1023) == 0) { + if (Serial.available()) { + char c = Serial.read(); - if (c > 0 && c < 127) - tty_->sendChar(c); + if (c > 0 && c < 127) + tty_->sendChar(c); + } } if (c->step()) { Serial.println(F("")); Serial.println(F(" *** EMULATION STOPPED *** ")); + Serial.print(F("Instructions per second: ")); + Serial.println(icount * 1000.0 / (millis() - start_ts)); delay(1000); Serial.println(F(" *** EMULATION RESTARTING *** ")); c->setRegister(7, exec_addr); c->resetHalt(); + + start_ts = millis(); + icount = 0; } } diff --git a/ESP32/platformio.ini b/ESP32/platformio.ini index abb19e7..a08cf94 100644 --- a/ESP32/platformio.ini +++ b/ESP32/platformio.ini @@ -30,8 +30,8 @@ framework = arduino monitor_speed = 115200 upload_speed = 1000000 lib_deps = -build_flags = -std=c++17 -build_unflags = -std=gnu++11 +build_flags = -std=c++17 -Ofast +build_unflags = -std=gnu++11 -Os [env:serial32_debug] platform = espressif32 diff --git a/tty.cpp b/tty.cpp index db6d583..c134a5c 100644 --- a/tty.cpp +++ b/tty.cpp @@ -52,6 +52,12 @@ uint16_t tty::readWord(const uint16_t addr) if (addr == PDP11TTY_TKS) { vtemp = c ? 128 : 0; + +#if defined(ESP32) + static bool led_state = true; + digitalWrite(LED_BUILTIN, led_state); + led_state = !led_state; +#endif } else if (addr == PDP11TTY_TKB) { vtemp = c | (parity(c) << 7);