From 54ae724b5a71c8c1935037373c7a2bc6600d4649 Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Sun, 29 Apr 2018 14:09:08 -0700 Subject: [PATCH] Add more registers --- src/ads7846.c | 3 ++- src/hardwareRegisters.c | 28 ++++++++++++++++++++++++++-- src/hardwareRegistersTiming.c.h | 4 ++-- unimplementedFeatures.txt | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/ads7846.c b/src/ads7846.c index 9a8261a..04e9602 100644 --- a/src/ads7846.c +++ b/src/ads7846.c @@ -43,7 +43,8 @@ void ads7846SendBit(bool bit){ case 0x02: //battery - value = palmMisc.batteryLevel; + //value = palmMisc.batteryLevel; + value = 100; rangeMax = 100; break; diff --git a/src/hardwareRegisters.c b/src/hardwareRegisters.c index 5529ce8..1c88ceb 100644 --- a/src/hardwareRegisters.c +++ b/src/hardwareRegisters.c @@ -101,8 +101,13 @@ static void recalculateCpuSpeed(){ if(pctlr & 0x80) newCpuSpeed *= (double)(pctlr & 0x1F) / 31.0; - debugLog("New CPU frequency of:%f cycles per second.\n", newCpuSpeed * CRYSTAL_FREQUENCY); - debugLog("New CLK32 cycle count of:%f.\n", newCpuSpeed); + if(newCpuSpeed != palmCrystalCycles){ + debugLog("New CPU frequency of:%f cycles per second.\n", newCpuSpeed * CRYSTAL_FREQUENCY); + debugLog("New CLK32 cycle count of:%f.\n", newCpuSpeed); + if(newCpuSpeed == 0.0) + debugLog("CPU turned off with PCTLR.\n"); + } + palmCrystalCycles = newCpuSpeed; } @@ -346,10 +351,22 @@ unsigned int getHwRegister8(unsigned int address){ case PDDATA: return getPortDValue(); + case PEDATA: + //read outputs as is and inputs as true, floating pins are high + return (registerArrayRead8(PEDATA) & registerArrayRead8(PEDIR)) | ~registerArrayRead8(PEDIR); + case PFDATA: //read outputs as is and inputs as true, floating pins are high return (registerArrayRead8(PFDATA) & registerArrayRead8(PFDIR)) | ~registerArrayRead8(PFDIR); + case PGDATA: + //read outputs as is and inputs as true, floating pins are high + return (registerArrayRead8(PGDATA) & registerArrayRead8(PGDIR)) | ~registerArrayRead8(PGDIR); + + case PJDATA: + //read outputs as is and inputs as true, floating pins are high + return (registerArrayRead8(PJDATA) & registerArrayRead8(PJDIR)) | ~registerArrayRead8(PJDIR); + case PKDATA: return getPortKValue(); @@ -365,7 +382,9 @@ unsigned int getHwRegister8(unsigned int address){ //I/O direction case PBDIR: case PDDIR: + case PEDIR: case PFDIR: + case PJDIR: case PKDIR: //select between GPIO or special function @@ -442,6 +461,7 @@ unsigned int getHwRegister16(unsigned int address){ case RTCCTL: case RTCIENR: case ILCR: + case ICR: case SPICONT2: case SPIDATA2: //simple read, no actions needed @@ -641,6 +661,10 @@ void setHwRegister16(unsigned int address, unsigned int value){ //missing bits 6 and 7 registerArrayWrite16(address, value & 0xFF3F); break; + + case RTCCTL: + registerArrayWrite16(address, value & 0x000A); + break; case IMR: //this is a 32 bit register but Palm OS writes it as 16 bit chunks diff --git a/src/hardwareRegistersTiming.c.h b/src/hardwareRegistersTiming.c.h index f36eb8e..58839f8 100644 --- a/src/hardwareRegistersTiming.c.h +++ b/src/hardwareRegistersTiming.c.h @@ -198,9 +198,9 @@ static inline void timer12Clk32(){ static inline void rtcAddSecondClk32(){ //this function is part of clk32(); - //rtc + //RTC if(registerArrayRead16(RTCCTL) & 0x0080){ - //rtc enable bit set + //RTC enable bit set uint16_t rtcInterruptEvents; uint32_t newRtcTime; uint32_t oldRtcTime = registerArrayRead32(RTCTIME); diff --git a/unimplementedFeatures.txt b/unimplementedFeatures.txt index b04d738..1c68bdd 100644 --- a/unimplementedFeatures.txt +++ b/unimplementedFeatures.txt @@ -20,6 +20,7 @@ Port M Infrared shutdown (PMDATA 0x20) interrupt control register (ICR), POL5 and edge trigger selects ADC7846 temperature sensors ADC7846 dock sensor +some undocumented I/O might be on port e and port j Debug tools: missing icons