From: batt Date: Fri, 23 Jul 2010 15:15:43 +0000 (+0000) Subject: Refactor i2c start. X-Git-Tag: 2.6.0~288^2~38 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=44f611866e394df29723731a04fc4781eb7e02e6;p=bertos.git Refactor i2c start. git-svn-id: https://src.develer.com/svnoss/bertos/branches/i2c@4056 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/i2c.h b/bertos/drv/i2c.h index ec193c66..93ba3dfc 100644 --- a/bertos/drv/i2c.h +++ b/bertos/drv/i2c.h @@ -176,32 +176,30 @@ typedef struct I2c #include CPU_HEADER(i2c) -INLINE void i2c_start_r(I2c *i2c, uint16_t slave_addr, size_t size, int flags) +INLINE void i2c_start(I2c *i2c, uint16_t slave_addr, size_t size) { - ASSERT(i2c); ASSERT(i2c->vt); ASSERT(i2c->vt->start); ASSERT(i2c->xfer_size == 0); - i2c->flags = flags | I2C_START_R; i2c->errors = 0; i2c->xfer_size = size; i2c->vt->start(i2c, slave_addr); } -INLINE void i2c_start_w(I2c *i2c, uint16_t slave_addr, size_t size, int flags) +INLINE void i2c_start_r(I2c *i2c, uint16_t slave_addr, size_t size, int flags) { ASSERT(i2c); - ASSERT(i2c->vt); - ASSERT(i2c->vt->start); - ASSERT(i2c->xfer_size == 0); + i2c->flags = flags | I2C_START_R; + i2c_start(i2c, slave_addr) +} +INLINE void i2c_start_w(I2c *i2c, uint16_t slave_addr, size_t size, int flags) +{ + ASSERT(i2c); i2c->flags = flags & ~I2C_START_R; - i2c->errors = 0; - i2c->xfer_size = size; - - i2c->vt->start(i2c, slave_addr); + i2c_start(i2c, slave_addr); } INLINE uint8_t i2c_get(I2c *i2c)