Skip to content

Commit 46f0ce2

Browse files
committed
fix state saving on error
1 parent de14cae commit 46f0ce2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,24 +331,24 @@ static void handle_i2c(i2c_state_struct *i2c) {
331331
}
332332
}
333333

334-
i2c->state = state;
335-
i2c->phase = phase;
336-
i2c->work_byte = work_byte;
337-
i2c->work_bit = work_bit;
338-
339334
if (0) {
340335
handle_nak:
341336
SHARED->i2c.flags = 0x4e55;
342-
i2c->state = I2C_STATE_IDLE;
337+
state = I2C_STATE_IDLE;
343338
}
344339

345340
if (0) {
346341
handle_timeout:
347342
if (--i2c->timeout == 0) {
348343
SHARED->i2c.flags = 0x5455;
349-
i2c->state = I2C_STATE_IDLE;
344+
state = I2C_STATE_IDLE;
350345
}
351346
}
347+
348+
i2c->state = state;
349+
i2c->phase = phase;
350+
i2c->work_byte = work_byte;
351+
i2c->work_bit = work_bit;
352352
}
353353

354354
void main() {

0 commit comments

Comments
 (0)