X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fi2c.h;h=f0a3ec0dabb9bc445c577cfd97a288c653c465a9;hb=eea6e7e95a7c2ac1343ea0485782efa02a737ec2;hp=c7fa9587f8aa960767a375c059c53b23af41f54d;hpb=f062d0cd413c738978ac8781da89a12301615754;p=bertos.git diff --git a/bertos/drv/i2c.h b/bertos/drv/i2c.h index c7fa9587..f0a3ec0d 100644 --- a/bertos/drv/i2c.h +++ b/bertos/drv/i2c.h @@ -134,6 +134,25 @@ bool i2c_recv(void *_buf, size_t count); * I2c new api */ +/** + * \name I2C bitbang devices enum + */ +enum +{ + I2C_BITBANG0 = 1000, + I2C_BITBANG1, + I2C_BITBANG2, + I2C_BITBANG3, + I2C_BITBANG4, + I2C_BITBANG5, + I2C_BITBANG6, + I2C_BITBANG7, + I2C_BITBANG8, + I2C_BITBANG9, + + I2C_BITBANG_CNT /**< Number of serial ports */ +}; + /* * I2C error flags */ @@ -190,6 +209,7 @@ typedef struct I2c * Low level i2c init implementation prototype. */ void i2c_hw_init(I2c *i2c, int dev, uint32_t clock); +void i2c_hw_bitbangInit(I2c *i2c, int dev); void i2c_genericWrite(I2c *i2c, const void *_buf, size_t count); void i2c_genericRead(I2c *i2c, void *_buf, size_t count); @@ -303,7 +323,10 @@ INLINE int i2c_error(I2c *i2c) INLINE void i2c_init_3(I2c *i2c, int dev, uint32_t clock) { - i2c_hw_init(i2c, dev, clock); + if (dev > I2C_BITBANG0) + i2c_hw_bitbangInit(i2c, dev); + else + i2c_hw_init(i2c, dev, clock); } #endif