+
+ // Timeout check
+ uint8_t t;
+ // use only the least byte of millisecond timer
+ asm("lds %0, %1" : "=r" (t) : "p" (&timer_count));
+ //t = (uint8_t)timer_count; // compiler uses four registers instead of one
+ if (isr_state == 0x8000) {
+ timer_start = t;
+ } else {
+ // should not take more than 1ms
+ if (timer_start != t && (uint8_t)(timer_start + 1) != t) {
+ ibmpc_error = IBMPC_ERR_TIMEOUT;
+ //goto ERROR;
+ // timeout error recovery by clearing isr_state?
+ timer_start = t;
+ isr_state = 0x8000;
+ }
+ }
+