From: crazyt Date: Mon, 17 Aug 2015 16:59:01 +0000 (+0200) Subject: fix for wrong return value of i2c_write. X-Git-Tag: v1.3~19^2 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=47cb0b9b645c98578eb9ec3554cf5d63bdc8b2ab;p=sx%2Fsimavr.git fix for wrong return value of i2c_write. --- diff --git a/simavr/sim/avr_twi.c b/simavr/sim/avr_twi.c index 629f9a4..8249ee7 100644 --- a/simavr/sim/avr_twi.c +++ b/simavr/sim/avr_twi.c @@ -308,9 +308,15 @@ avr_twi_write( p->state & TWI_COND_ACK ? TWI_MRX_ADR_ACK : TWI_MRX_ADR_NACK); } else { - _avr_twi_delay_state(p, 9, - p->state & TWI_COND_ACK ? - TWI_MTX_ADR_ACK : TWI_MTX_ADR_NACK); + if(p->state & TWI_COND_WRITE){ + _avr_twi_delay_state(p, 0, + p->state & TWI_COND_ACK ? + TWI_MTX_DATA_ACK : TWI_MTX_DATA_NACK); + }else{ + _avr_twi_delay_state(p, 9, + p->state & TWI_COND_ACK ? + TWI_MTX_ADR_ACK : TWI_MTX_ADR_NACK); + } } } p->state &= ~TWI_COND_WRITE;