Be defensive with holding RTC output on last cycle.

This commit is contained in:
Andrew Makousky 2020-09-05 17:48:46 -05:00
parent e2483ddd59
commit 043f815c4c

View File

@ -197,7 +197,6 @@ void halfSecondInterrupt(void) {
} }
else else
TCNT0 += 7; TCNT0 += 7;
} }
/* /*
@ -278,11 +277,12 @@ void loop(void) {
} else { } else {
/* Normally we only perform an action on the rising edge of the /* Normally we only perform an action on the rising edge of the
serial clock. The main exception is cleanup at the last cycle serial clock. The main exception is cleanup at the last cycle
of serial output, there we wait until the falling edge before of serial output, there we wait one full cycle and then until
switching the direction of the data pin back to an input. */ the falling edge before switching the direction of the data pin
back to an input. */
if (serClockFalling && if (serClockFalling &&
serialState == SENDING_DATA && serialState == SENDING_DATA &&
serialBitNum >= 8) { serialBitNum >= 9) {
clearState(); clearState();
} else if (serClockRising) { } else if (serClockRising) {
boolean writeRequest; boolean writeRequest;
@ -381,15 +381,19 @@ void loop(void) {
break; break;
case SENDING_DATA: case SENDING_DATA:
digitalWriteOD(SERIAL_DATA_PIN, bitRead(serialData, 7 - serialBitNum)); if (serialBitNum <= 7)
digitalWriteOD(SERIAL_DATA_PIN,
bitRead(serialData, 7 - serialBitNum));
serialBitNum++; serialBitNum++;
/* if (serialBitNum <= 7) /* if (serialBitNum <= 7)
break; */ break; */
/* NOTE: The last output cycle is treated specially, hold the /* NOTE: The last output cycle is treated specially, hold the
data line as an output until the falling edge of the serial data line as an output for at least one full next cycle,
clock, then switch back to an input and reset the serial then until the falling edge of the serial clock, then
communication state. */ switch back to an input and reset the serial communication
state. It's for bug compatibility with the ROM, but with a
little bit of sanity too. */
break; break;
#if !defined(NoXPRAM) || !NoXPRAM #if !defined(NoXPRAM) || !NoXPRAM