From: Michel Pollet Date: Tue, 9 Jun 2015 13:56:37 +0000 (+0100) Subject: twi: Always release STOP bit X-Git-Tag: v1.3~39 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=6d4c0283ee49a724d3294b142b671fdf6978c564;p=sx%2Fsimavr.git twi: Always release STOP bit Seems some libraries assume this bit will autoclear, even if the stop condition was not really called for. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/avr_twi.c b/simavr/sim/avr_twi.c index 663357e..fffd86b 100644 --- a/simavr/sim/avr_twi.c +++ b/simavr/sim/avr_twi.c @@ -173,7 +173,7 @@ avr_twi_write( /*int cleared = */avr_clear_interrupt_if(avr, &p->twi, twint); // AVR_TRACE(avr, "cleared %d\n", cleared); - if (!twsto && avr_regbit_get(avr, p->twsto)) { + if (/*!twsto && */ avr_regbit_get(avr, p->twsto)) { // generate a stop condition #if AVR_TWI_DEBUG AVR_TRACE(avr, "<<<<< I2C stop\n"); @@ -182,9 +182,10 @@ avr_twi_write( if (p->state & TWI_COND_START) { avr_raise_irq(p->io.irq + TWI_IRQ_OUTPUT, avr_twi_irq_msg(TWI_COND_STOP, p->peer_addr, 1)); - avr_regbit_clear(avr, p->twsto); } } + /* clear stop condition regardless of status */ + avr_regbit_clear(avr, p->twsto); p->state = 0; } if (!twsta && avr_regbit_get(avr, p->twsta)) {