ibmpc: Read data line earlier in ISR as possible
This commit is contained in:
parent
fc4b6cd341
commit
3e2900dcc8
1 changed files with 6 additions and 9 deletions
|
|
@ -172,10 +172,7 @@ ISR(IBMPC_INT_VECT)
|
||||||
static uint8_t data = 0;
|
static uint8_t data = 0;
|
||||||
static uint8_t parity = 1;
|
static uint8_t parity = 1;
|
||||||
|
|
||||||
// return unless falling edge
|
uint8_t dbit = IBMPC_DATA_PIN&(1<<IBMPC_DATA_BIT);
|
||||||
if (clock_in()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset state when taking more than 1ms
|
// Reset state when taking more than 1ms
|
||||||
if (last_time && timer_elapsed(last_time) > 10) {
|
if (last_time && timer_elapsed(last_time) > 10) {
|
||||||
|
|
@ -190,9 +187,9 @@ ISR(IBMPC_INT_VECT)
|
||||||
case START:
|
case START:
|
||||||
if (ibmpc_protocol == IBMPC_PROTOCOL_XT) {
|
if (ibmpc_protocol == IBMPC_PROTOCOL_XT) {
|
||||||
// ignore start(0) bit
|
// ignore start(0) bit
|
||||||
if (!data_in()) return;
|
if (!dbit) return;
|
||||||
} else {
|
} else {
|
||||||
if (data_in())
|
if (dbit)
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
}
|
}
|
||||||
case BIT0:
|
case BIT0:
|
||||||
|
|
@ -204,7 +201,7 @@ ISR(IBMPC_INT_VECT)
|
||||||
case BIT6:
|
case BIT6:
|
||||||
case BIT7:
|
case BIT7:
|
||||||
data >>= 1;
|
data >>= 1;
|
||||||
if (data_in()) {
|
if (dbit) {
|
||||||
data |= 0x80;
|
data |= 0x80;
|
||||||
parity++;
|
parity++;
|
||||||
}
|
}
|
||||||
|
|
@ -218,7 +215,7 @@ ISR(IBMPC_INT_VECT)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PARITY:
|
case PARITY:
|
||||||
if (data_in()) {
|
if (dbit) {
|
||||||
if (!(parity & 0x01))
|
if (!(parity & 0x01))
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -227,7 +224,7 @@ ISR(IBMPC_INT_VECT)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STOP:
|
case STOP:
|
||||||
if (!data_in())
|
if (!dbit)
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
if (!ringbuf_put(&rb, data)) {
|
if (!ringbuf_put(&rb, data)) {
|
||||||
ibmpc_error = IBMPC_ERR_FULL;
|
ibmpc_error = IBMPC_ERR_FULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue