-/*
- * Overloaded functions definition.
- */
-int i2c_write_5(I2c *i2c, uint16_t slave_addr, int flags, const void *buf, size_t len);
-int i2c_read_5(I2c *i2c, uint16_t slave_addr, int flags, void *buf, size_t len);
-
-int i2c_write_7(I2c *i2c, uint16_t slave_addr, int flags, const void *buf, size_t len,
- const void *buf1, size_t len1);
-int i2c_read_7(I2c *i2c, uint16_t slave_addr, int flags, void *buf, size_t len,
- void *buf1, size_t len1);
-
-int i2c_write_9(I2c *i2c, uint16_t slave_addr, int flags, const void *buf, size_t len,
- const void *buf1, size_t len1,
- const void *buf2, size_t len2);
-int i2c_read_9(I2c *i2c, uint16_t slave_addr, int flags, void *buf, size_t len,
- void *buf1, size_t len1,
- void *buf2, size_t len2);
-
-int i2c_write_11(I2c *i2c, uint16_t slave_addr, int flags, const void *buf, size_t len,
- const void *buf1, size_t len1,
- const void *buf2, size_t len2
- const void *buf3, size_t len3);
-int i2c_read_11(I2c *i2c, uint16_t slave_addr, int flags, void *buf, size_t len,
- void *buf1, size_t len1,
- void *buf2, size_t len2
- void *buf3, size_t len3);
+INLINE void i2c_start(I2c *i2c, uint16_t slave_addr, size_t size)
+{
+ ASSERT(i2c->vt);
+ ASSERT(i2c->vt->start);
+
+ if (!i2c->errors)
+ ASSERT(i2c->xfer_size == 0);
+
+ i2c->errors = 0;
+ i2c->xfer_size = size;
+
+ i2c->vt->start(i2c, slave_addr);
+}
+
+INLINE void i2c_start_r(I2c *i2c, uint16_t slave_addr, size_t size, int flags)
+{
+ ASSERT(i2c);
+ i2c->flags = flags | I2C_START_R;
+ i2c_start(i2c, slave_addr, size);
+}
+
+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_start(i2c, slave_addr, size);
+}
+
+INLINE uint8_t i2c_get(I2c *i2c)
+{
+ ASSERT(i2c);
+ ASSERT(i2c->vt);
+ ASSERT(i2c->vt->get);
+
+ ASSERT(i2c->xfer_size);
+
+ ASSERT(I2C_TEST_START(i2c->flags) == I2C_START_R);