diff --git a/hwTestSuite/tools.c b/hwTestSuite/tools.c index 3304a86..b459138 100644 --- a/hwTestSuite/tools.c +++ b/hwTestSuite/tools.c @@ -64,6 +64,9 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8Bi config |= 0x04; config |= 0x03;/*force ADC and reference always on*/ } + else{ + config |= 0x01;/*force ADC always on and reference off*/ + } config |= channel << 4 & 0x70; diff --git a/qtBuildSystem/Mu/Mu.pro b/qtBuildSystem/Mu/Mu.pro index 3c92049..4aef9a4 100644 --- a/qtBuildSystem/Mu/Mu.pro +++ b/qtBuildSystem/Mu/Mu.pro @@ -31,7 +31,7 @@ macx { } CONFIG(debug, debug|release){ - DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER EMU_LOG_REGISTER_ACCESS_ALL + DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER EMU_LOG_REGISTER_ACCESS_UNKNOWN # DEFINES += EMU_OPCODE_LEVEL_DEBUG EMU_LOG_APIS } diff --git a/qtBuildSystem/Mu/Mu.pro.user b/qtBuildSystem/Mu/Mu.pro.user index 648b4be..b75cea0 100644 --- a/qtBuildSystem/Mu/Mu.pro.user +++ b/qtBuildSystem/Mu/Mu.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -300,14 +300,17 @@ 13 14 - -1 + 2 - - - - + Mu - ProjectExplorer.CustomExecutableRunConfiguration + Qt4ProjectManager.Qt4RunConfiguration:/Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/Mu/Mu.pro + true + + Mu.pro + false + + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_1_clang_64bit-Debug/Mu.app/Contents/MacOS 3768 false true diff --git a/src/ads7846.c b/src/ads7846.c index 536822d..cd08b29 100644 --- a/src/ads7846.c +++ b/src/ads7846.c @@ -4,6 +4,8 @@ #include "portability.h" +static uint16_t dockResistorValues[PORT_END] = {0xFFF/*none*/, 0x1EB/*USB cradle*/, 0/*serial cradle*/, 0/*USB peripheral*/, 0/*serial peripheral*/}; + uint8_t ads7846BitsToNextControl;//bits before starting a new control byte uint8_t ads7846ControlByte; bool ads7846PenIrqEnabled; @@ -41,129 +43,134 @@ bool ads7846ExchangeBit(bool bitIn){ if(ads7846BitsToNextControl == 6){ //control byte and busy cycle finished, get output value - bool mode = ads7846ControlByte & 0x08; + bool bitMode = ads7846ControlByte & 0x08; bool differentialMode = !(ads7846ControlByte & 0x04); + uint8_t channel = (ads7846ControlByte & 0x70) >> 4; uint8_t powerSave = ads7846ControlByte & 0x03; - //check if ADC is on, if not do nothing, PENIRQ is handled in refreshInputState() in hardwareRegisters.c - if(powerSave != 0x02){ - debugLog("Accessed ADS7846 Ch:%d, %s Mode.\n", (ads7846ControlByte & 0x70) >> 4, differentialMode ? "Diff" : "Normal"); - if(differentialMode){ - //differential mode, this is whats used for touchscreen positions - switch(ads7846ControlByte & 0x70){ - case 0x00: + debugLog("Accessed ADS7846 Ch:%d, %s Mode, Power Save:%d.\n", channel, differentialMode ? "Diff" : "Normal", ads7846ControlByte & 0x03); + + //check if ADC is on, PENIRQ is handled in refreshInputState() in hardwareRegisters.c + switch(powerSave){ + case 0: + case 1: + //normal touchscreen operation + switch(channel){ + case 0: //temperature 0, wrong mode - ads7846OutputValue = 0x0FFF; + ads7846OutputValue = 0xFFF; break; - case 0x10: + case 1: //touchscreen y if(palmInput.touchscreenTouched) - ads7846OutputValue = ads7846RangeMap(0, 219, 219 - palmInput.touchscreenY, 0x00EE, 0x0F00); + ads7846OutputValue = ads7846RangeMap(0, 219, 219 - palmInput.touchscreenY, 0x0EE, 0xF00); else - ads7846OutputValue = 0x0FFF;//y is on when dorment - //debugLog("Accessed ADS7846 Touchscreen Y.\n"); + ads7846OutputValue = 0xFEF;//y is almost fully on when dorment break; - case 0x20: - //battery, unknown hasent gotten low enough to test yet - ads7846OutputValue = 0x0FFF; - //ads7846OutputValue = ads7846RangeMap(0, 100, palmMisc.batteryLevel, 0x0000, 0x07F8); - //debugLog("Accessed Batt, Diff Mode.\n"); + case 2: + //battery, wrong mode + ads7846OutputValue = 0xFFF; break; - case 0x30: - //touchscreen x relative to y - ads7846OutputValue = 0x0FFF; - //debugLog("Accessed ADS7846 Touchscreen X~Y, Diff Mode.\n"); + case 3: + //touchscreen x relative to y, unemulated + ads7846OutputValue = 0xFFF; + debugLog("ADS7846, Unemulated Channel:3\n"); break; - case 0x40: - //touchscreen y relative to x - ads7846OutputValue = 0x0FFF; - //debugLog("Accessed ADS7846 Touchscreen Y~X, Diff Mode.\n"); + case 4: + //touchscreen y relative to x, unemulated + ads7846OutputValue = 0xFFF; + debugLog("ADS7846, Unemulated Channel:4\n"); break; - case 0x50: + case 5: //touchscreen x if(palmInput.touchscreenTouched) - ads7846OutputValue = ads7846RangeMap(0, 159, 159 - palmInput.touchscreenX, 0x00FD, 0x0F47); + ads7846OutputValue = ads7846RangeMap(0, 159, 159 - palmInput.touchscreenX, 0x0FD, 0xF47); else - ads7846OutputValue = 0x0000; - //debugLog("Accessed ADS7846 Touchscreen X.\n"); + ads7846OutputValue = 0x000; break; - case 0x60: + case 6: //dock, wrong mode - ads7846OutputValue = 0x0FFF; + ads7846OutputValue = 0xFFF; break; - case 0x70: + case 7: //temperature 1, wrong mode - ads7846OutputValue = 0x0FFF; + ads7846OutputValue = 0xFFF; break; } - } - else{ - //not differential mode, used for battery and dock - switch(ads7846ControlByte & 0x70){ - case 0x00: - //temperature 0, unemulated for now - ads7846OutputValue = 0x05C3; - //debugLog("Accessed Temp 0.\n"); + break; + + case 2: + //ADC is off, return invalid data + if((channel == 3 || channel == 5) && !palmInput.touchscreenTouched) + ads7846OutputValue = 0x000; + else + ads7846OutputValue = 0xFFF; + break; + + case 3: + //non touchscreen data + switch(channel){ + case 0: + //temperature 0, room temperature + ads7846OutputValue = 0x3E2; break; - case 0x10: + case 1: //touchscreen y, wrong mode - ads7846OutputValue = 0x07C3; + ads7846OutputValue = 0xFFF; break; - case 0x20: + case 2: //battery, unknown hasent gotten low enough to test yet - ads7846OutputValue = 0x07C3; - //debugLog("Accessed Batt, Non Diff Mode.\n"); + ads7846OutputValue = 0x65C;//~90% + //ads7846OutputValue = ads7846RangeMap(0, 100, palmMisc.batteryLevel, 0x0000, 0x07F8); break; - case 0x30: - //empty slot - ads7846OutputValue = 0x05C0; + case 3: + //touchscreen x relative to y, wrong mode + ads7846OutputValue = 0x000; break; - case 0x40: - //empty slot - ads7846OutputValue = 0x07C3; + case 4: + //touchscreen y relative to x, wrong mode + ads7846OutputValue = 0xFFF; break; - case 0x50: + case 5: //touchscreen x, wrong mode - ads7846OutputValue = 0x0002; + ads7846OutputValue = 0x000; break; - case 0x60: - //dock, unemulated for now, changes depending on the type of dock attached 0x07C3 in unplugged - ads7846OutputValue = 0x07C3; - //debugLog("Accessed Dock.\n"); + case 6: + //dock + if(palmMisc.dataPort < PORT_END) + ads7846OutputValue = dockResistorValues[palmMisc.dataPort]; + else + ads7846OutputValue = dockResistorValues[PORT_NONE]; break; - case 0x70: - //temperature 1, unemulated for now - ads7846OutputValue = 0x06C3; - //debugLog("Accessed Temp 1.\n"); + case 7: + //temperature 1, room temperature + ads7846OutputValue = 0x4A1; break; } - } - - ads7846OutputValue <<= 4;//move to output position - - //if 8 bit conversion, clear extra bits - if(mode) - ads7846OutputValue &= 0xFF00; - } - else{ - //nothing in register - ads7846OutputValue = 0x0000; + break; } + //move to output position + ads7846OutputValue <<= 4; + + //if 8 bit conversion, clear extra bits + if(bitMode) + ads7846OutputValue &= 0xFF00; + ads7846PenIrqEnabled = !(powerSave & 0x01); } diff --git a/src/hardwareRegisters.c b/src/hardwareRegisters.c index 2ea3a39..f3a8cac 100644 --- a/src/hardwareRegisters.c +++ b/src/hardwareRegisters.c @@ -144,6 +144,7 @@ static void recalculateCpuSpeed(){ newCpuSpeed = 0.0; } + /* 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); @@ -154,6 +155,7 @@ static void recalculateCpuSpeed(){ debugLog("CPU turned off with DISPLL bit.\n"); } } + */ palmCrystalCycles = newCpuSpeed; } diff --git a/unimplementedHardware.txt b/unimplementedHardware.txt index 8c90998..59dbfc7 100644 --- a/unimplementedHardware.txt +++ b/unimplementedHardware.txt @@ -54,6 +54,8 @@ swivelview register ADS7846: channels can't be read in single reference mode in hwTestSuite channels are not implemented properly in the emulator +electrical noise on lines(conversions probably should have +-20 added to values) +need to trigger a false PENIRQ interrupt on reading certain channels Fixed: