xt_usb: Read data earlier as possible in ISR
This commit is contained in:
parent
2b9d4ace5b
commit
ea004061a5
1 changed files with 3 additions and 2 deletions
|
|
@ -93,17 +93,18 @@ ISR(XT_INT_VECT)
|
||||||
} state = START;
|
} state = START;
|
||||||
static uint8_t data = 0;
|
static uint8_t data = 0;
|
||||||
|
|
||||||
|
uint8_t dbit = data_in();
|
||||||
// This is needed if using PCINT which can be called on both falling and rising edge
|
// This is needed if using PCINT which can be called on both falling and rising edge
|
||||||
if (clock_in()) return;
|
if (clock_in()) return;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case START:
|
case START:
|
||||||
// ignore start(0) bit
|
// ignore start(0) bit
|
||||||
if (!data_in()) return;
|
if (!dbit) return;
|
||||||
break;
|
break;
|
||||||
case BIT0 ... BIT7:
|
case BIT0 ... BIT7:
|
||||||
data >>= 1;
|
data >>= 1;
|
||||||
if (data_in())
|
if (dbit)
|
||||||
data |= 0x80;
|
data |= 0x80;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue