From 219522a911512c0f1cbe9244e609d4fb464f08b2 Mon Sep 17 00:00:00 2001 From: George Wright Date: Sun, 8 Dec 2024 12:50:47 -0800 Subject: [PATCH] fix falling edge detect with asic14 and gpio handled state. fix ostimer ticks --- WindCore/sa1100.cpp | 4 +++- WindCore/sa1100.h | 1 + WindCore/sa1100/asic14.cpp | 1 + WindCore/sa1100/asic14.h | 11 ++++++++++- WindCore/sa1100/gpio_controller.cpp | 4 ---- WindCore/sa1100/gpio_controller.h | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/WindCore/sa1100.cpp b/WindCore/sa1100.cpp index e2e8cd2..36f02ec 100644 --- a/WindCore/sa1100.cpp +++ b/WindCore/sa1100.cpp @@ -957,6 +957,7 @@ void Emulator::configure() { nextTickAt = TICK_INTERVAL; nextRTCTick = 0; + nextTimerTick = 0; memoryConfig.reset(); setProcessorID(0x4401A111); powerManager->reset(); @@ -1011,8 +1012,9 @@ bool Emulator::executeUntil(int64_t cycles) { pendingInterrupts |= (1<tick(); } - if (passedCycles % TICKS_3_6864_MHZ == 0) { + if (passedCycles >= nextTimerTick) { osTimer->tick(); + nextTimerTick += TICKS_3_6864_MHZ; } if (passedCycles >= nextRTCTick) { printf("RTC tick\n"); diff --git a/WindCore/sa1100.h b/WindCore/sa1100.h index 6212d85..9969df8 100644 --- a/WindCore/sa1100.h +++ b/WindCore/sa1100.h @@ -52,6 +52,7 @@ private: uint16_t lastSSIRequest = 0; int ssiReadCounter = 0; uint32_t nextRTCTick = 0; + uint32_t nextTimerTick = 0; uint32_t kScan = 0; uint8_t keyboardColumns[8] = {0,0,0,0,0,0,0}; diff --git a/WindCore/sa1100/asic14.cpp b/WindCore/sa1100/asic14.cpp index cf23854..5976020 100644 --- a/WindCore/sa1100/asic14.cpp +++ b/WindCore/sa1100/asic14.cpp @@ -57,6 +57,7 @@ namespace SA1100 { m_SPI_DATA = 0; m_SPI_FN = 0; m_STATUS6 = (1 << 1) | (1 << 10) | (1 << 11); + pinState = false; } void ASIC14::run() {} diff --git a/WindCore/sa1100/asic14.h b/WindCore/sa1100/asic14.h index a43f6ef..76ed243 100644 --- a/WindCore/sa1100/asic14.h +++ b/WindCore/sa1100/asic14.h @@ -41,6 +41,7 @@ class ASIC14 { private: uint8_t prom[0x80] = {}; + bool pinState; int mCurrPlace = 0; GPIOController* mGPIOController; enum @@ -113,9 +114,17 @@ class ASIC14 { //m_IRQ_STATUS = IRQ_CFCARD_CHANGE | IRQ_PCMCIA_CHANGE; m_IRQ_STATUS = m_IRQ_MASK; if (m_IRQ_STATUS != 0) { - mGPIOController->pull_pin(10, false); + if (pinState == false) { + // Go high for one cycle, then low next cycle. + mGPIOController->pull_pin(10, true); + pinState = true; + } else { + mGPIOController->pull_pin(10, false); + pinState = false; + } } else { mGPIOController->pull_pin(10, true); + pinState = true; } } }; diff --git a/WindCore/sa1100/gpio_controller.cpp b/WindCore/sa1100/gpio_controller.cpp index ec26152..f760415 100644 --- a/WindCore/sa1100/gpio_controller.cpp +++ b/WindCore/sa1100/gpio_controller.cpp @@ -126,10 +126,6 @@ namespace SA1100 { // GEDR status bits are cleared by writing a one to them. // Writing a zero to a GEDR status bit has no effect. m_GEDR &= ~(value & 0xFFFFFFF); - // Probably not the best way to handle this, as reading GPLR will result in incorrect - // data - m_GPLR &= ~(value & 0xFFFFFFF); - m_GPLR_backup &= ~(value & 0xFFFFFFF); //printf("GEDR write %08x [%08x]\n", value, m_GEDR); break; diff --git a/WindCore/sa1100/gpio_controller.h b/WindCore/sa1100/gpio_controller.h index 0c3b75b..e614ed0 100644 --- a/WindCore/sa1100/gpio_controller.h +++ b/WindCore/sa1100/gpio_controller.h @@ -101,7 +101,7 @@ class GPIOController { inline void run() { uint32_t const temp = m_GPLR ^ m_GPLR_backup; - + if (temp != 0) { m_GEDR |= (m_GRER & (m_GPLR & temp)); m_GEDR |= (m_GFER & (m_GPLR_backup & temp)); -- 2.45.2