Update to host detection logic

This commit is contained in:
Philip Smart
2023-05-10 09:49:24 +01:00
parent 0341bb35b6
commit 95b4ce47fb
2 changed files with 14 additions and 11 deletions

View File

@@ -577,7 +577,7 @@ uint32_t getHostType(bool eFuseInvalid, t_EFUSE sharpkeyEfuses)
// Count the number of pulses on the TxD line (X68000) or Mouse Ctrl line. If there are pulses then the host is a mouse port. // Count the number of pulses on the TxD line (X68000) or Mouse Ctrl line. If there are pulses then the host is a mouse port.
uint32_t cntCtrl= 0; uint32_t cntCtrl= 0;
gpioIN = gpioINLast = REG_READ(GPIO_IN_REG); gpioIN = gpioINLast = REG_READ(GPIO_IN_REG);
for(uint32_t idx=0; idx < 400000; idx++) for(uint32_t idx=0; idx < 2000000; idx++)
{ {
gpioIN = REG_READ(GPIO_IN_REG); gpioIN = REG_READ(GPIO_IN_REG);
if((gpioIN & KDB0_MASK) && (gpioIN & KDB0_MASK) != (gpioINLast & KDB0_MASK)) cntCtrl++; if((gpioIN & KDB0_MASK) && (gpioIN & KDB0_MASK) != (gpioINLast & KDB0_MASK)) cntCtrl++;
@@ -591,20 +591,23 @@ uint32_t getHostType(bool eFuseInvalid, t_EFUSE sharpkeyEfuses)
// Check for X68000 - KD4 = low, MPX = low, RTSN = high // Check for X68000 - KD4 = low, MPX = low, RTSN = high
gpioIN = REG_READ(GPIO_IN_REG); gpioIN = REG_READ(GPIO_IN_REG);
//ESP_LOGW(MAINTAG, "INREG(%x) MPXI(%x) RTSNI(%x) KD4(%x) and cntCtrl(%d).", gpioIN, (gpioIN & (1 << CONFIG_HOST_MPXI)), (REG_READ(GPIO_IN1_REG) & RTSNI_MASK), (gpioIN & (1 << CONFIG_HOST_KDI4)), cntCtrl);
if(cntCtrl <= 1 && (gpioIN & (1 << CONFIG_HOST_MPXI)) == 0 && (REG_READ(GPIO_IN1_REG) & RTSNI_MASK) != 0 && if(cntCtrl <= 1 && (gpioIN & (1 << CONFIG_HOST_MPXI)) == 0 && (REG_READ(GPIO_IN1_REG) & RTSNI_MASK) != 0 &&
eFuseInvalid == false && (sharpkeyEfuses.disableRestrictions == true || sharpkeyEfuses.enableX68000 == true)) eFuseInvalid == false && (sharpkeyEfuses.disableRestrictions == true || sharpkeyEfuses.enableX68000 == true))
{ {
ifMode = 68000; ifMode = 68000;
} }
else // Check for Mouse - KD4 = high, MPX = low, RTSN = high
else if(cntCtrl > 0 && (gpioIN & (1 << CONFIG_HOST_KDI4)) != 0 && (gpioIN & (1 << CONFIG_HOST_MPXI)) == 0 && (REG_READ(GPIO_IN1_REG) & RTSNI_MASK) != 0 &&
eFuseInvalid == false && (sharpkeyEfuses.disableRestrictions == true || sharpkeyEfuses.enableMouse == true))
{ {
// Check for Mouse - KD4 = high, MPX = low, RTSN = high ifMode = 2;
gpioIN = REG_READ(GPIO_IN_REG); }
if(cntCtrl > 1 && (gpioIN & (1 << CONFIG_HOST_KDI4)) != 0 && (gpioIN & (1 << CONFIG_HOST_MPXI)) == 0 && (REG_READ(GPIO_IN1_REG) & RTSNI_MASK) != 0 && // Check for PC-9801 - KD4 = low, MPX = low, RTSN = high
eFuseInvalid == false && (sharpkeyEfuses.disableRestrictions == true || sharpkeyEfuses.enableMouse == true)) else if((gpioIN & (1 << CONFIG_HOST_KDI4)) == 0 && (gpioIN & (1 << CONFIG_HOST_MPXI)) == 0 && (REG_READ(GPIO_IN1_REG) & RTSNI_MASK) != 0 &&
{ eFuseInvalid == false && (sharpkeyEfuses.disableRestrictions == true || sharpkeyEfuses.enableMouse == true))
ifMode = 2; {
} ifMode = 9801;
} }
} }
} }
@@ -620,7 +623,7 @@ uint32_t getHostType(bool eFuseInvalid, t_EFUSE sharpkeyEfuses)
#ifdef CONFIG_MZ25KEY_MZ2800 #ifdef CONFIG_MZ25KEY_MZ2800
uint32_t ifMode = 2800; uint32_t ifMode = 2800;
#endif #endif
ifMode = 9801;
// Return a value which represents the detected host type. // Return a value which represents the detected host type.
return(ifMode); return(ifMode);
} }

View File

@@ -265,7 +265,7 @@ CONFIG_IF_WIFI_MAX_CONNECTIONS=5
# #
# Debug Options # Debug Options
# #
# CONFIG_DEBUG_SERIAL is not set CONFIG_DEBUG_SERIAL=y
# CONFIG_DEBUG_DISABLE_KDB is not set # CONFIG_DEBUG_DISABLE_KDB is not set
# CONFIG_DEBUG_DISABLE_KDO is not set # CONFIG_DEBUG_DISABLE_KDO is not set
# CONFIG_DEBUG_DISABLE_RTSNI is not set # CONFIG_DEBUG_DISABLE_RTSNI is not set