ibmpc: Protocol detection between AT and XT
This commit is contained in:
parent
0481aa08e5
commit
2c9ae5ac95
2 changed files with 9 additions and 6 deletions
|
|
@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
volatile uint8_t ibmpc_protocol = IBMPC_PROTOCOL_AT;
|
volatile uint8_t ibmpc_protocol = IBMPC_PROTOCOL_NO;
|
||||||
volatile uint8_t ibmpc_error = IBMPC_ERR_NONE;
|
volatile uint8_t ibmpc_error = IBMPC_ERR_NONE;
|
||||||
|
|
||||||
/* 2-byte buffer for data received from keyhboard
|
/* 2-byte buffer for data received from keyhboard
|
||||||
|
|
@ -97,8 +97,6 @@ int16_t ibmpc_host_send(uint8_t data)
|
||||||
bool parity = true;
|
bool parity = true;
|
||||||
ibmpc_error = IBMPC_ERR_NONE;
|
ibmpc_error = IBMPC_ERR_NONE;
|
||||||
|
|
||||||
if (ibmpc_protocol == IBMPC_PROTOCOL_XT) return -1;
|
|
||||||
|
|
||||||
dprintf("w%02X ", data);
|
dprintf("w%02X ", data);
|
||||||
|
|
||||||
IBMPC_INT_OFF();
|
IBMPC_INT_OFF();
|
||||||
|
|
@ -269,6 +267,7 @@ ISR(IBMPC_INT_VECT)
|
||||||
case 0b11000000:
|
case 0b11000000:
|
||||||
// XT_Clone-done
|
// XT_Clone-done
|
||||||
isr_state = isr_state>>8;
|
isr_state = isr_state>>8;
|
||||||
|
ibmpc_protocol = IBMPC_PROTOCOL_XT_CLONE;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
break;
|
break;
|
||||||
case 0b10100000: // ^2
|
case 0b10100000: // ^2
|
||||||
|
|
@ -284,6 +283,7 @@ ISR(IBMPC_INT_VECT)
|
||||||
} else {
|
} else {
|
||||||
// no stop bit: XT_IBM-done
|
// no stop bit: XT_IBM-done
|
||||||
isr_state = isr_state>>8;
|
isr_state = isr_state>>8;
|
||||||
|
ibmpc_protocol = IBMPC_PROTOCOL_XT_IBM;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -295,6 +295,7 @@ ISR(IBMPC_INT_VECT)
|
||||||
// AT-done
|
// AT-done
|
||||||
// TODO: parity check?
|
// TODO: parity check?
|
||||||
isr_state = isr_state>>6;
|
isr_state = isr_state>>6;
|
||||||
|
ibmpc_protocol = IBMPC_PROTOCOL_AT;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
break;
|
break;
|
||||||
case 0b01100000:
|
case 0b01100000:
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define IBMPC_RESEND 0xFE
|
#define IBMPC_RESEND 0xFE
|
||||||
#define IBMPC_SET_LED 0xED
|
#define IBMPC_SET_LED 0xED
|
||||||
|
|
||||||
#define IBMPC_PROTOCOL_AT 0
|
#define IBMPC_PROTOCOL_NO 0
|
||||||
#define IBMPC_PROTOCOL_XT 1
|
#define IBMPC_PROTOCOL_AT 1
|
||||||
|
#define IBMPC_PROTOCOL_XT_IBM 2
|
||||||
|
#define IBMPC_PROTOCOL_XT_CLONE 3
|
||||||
|
|
||||||
// TODO: error numbers
|
// Error numbers
|
||||||
#define IBMPC_ERR_NONE 0
|
#define IBMPC_ERR_NONE 0
|
||||||
#define IBMPC_ERR_RECV 0x00
|
#define IBMPC_ERR_RECV 0x00
|
||||||
#define IBMPC_ERR_SEND 0x10
|
#define IBMPC_ERR_SEND 0x10
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue