From: batt Date: Fri, 23 Jul 2010 19:40:05 +0000 (+0000) Subject: Automatically decrement transfer size. X-Git-Tag: 2.6.0~288^2~33 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=75daa48c6fff4f866acc1a0076bd0d97a33f2875;p=bertos.git Automatically decrement transfer size. git-svn-id: https://src.develer.com/svnoss/bertos/branches/i2c@4061 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/i2c.h b/bertos/drv/i2c.h index eea0073a..f527f359 100644 --- a/bertos/drv/i2c.h +++ b/bertos/drv/i2c.h @@ -214,12 +214,16 @@ INLINE uint8_t i2c_get(I2c *i2c) ASSERT(i2c->vt); ASSERT(i2c->vt->get); - ASSERT(i2c->xfer_size >= 1); + ASSERT(i2c->xfer_size); ASSERT(I2C_TEST_START(i2c->flags) == I2C_START_R); if (!i2c->errors) - return i2c->vt->get(i2c); + { + uint8_t data = i2c->vt->get(i2c); + i2c->xfer_size--; + return data; + } else return 0xFF; } @@ -230,12 +234,15 @@ INLINE void i2c_put(I2c *i2c, uint8_t data) ASSERT(i2c->vt); ASSERT(i2c->vt->put); - ASSERT(i2c->xfer_size >= 1); + ASSERT(i2c->xfer_size); ASSERT(I2C_TEST_START(i2c->flags) == I2C_START_W); if (!i2c->errors) + { i2c->vt->put(i2c, data); + i2c->xfer_size--; + } } INLINE void i2c_send(I2c *i2c, const void *_buf, size_t count)