pasko-zh / brzo_i2c

Brzo I2C is a fast I2C Implementation written in Assembly for the esp8266
GNU General Public License v3.0
244 stars 47 forks source link

I2C bus handle for multiple instances posibility #34

Open sacculus opened 5 years ago

sacculus commented 5 years ago

Hi At first, thank very much for your job!

I'd propose little improvement for your library - it is add possibility to instantiate multiple instances of I2C bus object. It allows use more then one I2C bus with different IO lines simultaneously.

My proposition is to use pointer to structure wich descripts I2C bus instance. This structure (casted to void pointer for hide internal bus data from end user) used as handle for manipulate single instanse of I2C bus. Each instance of I2C bus should be binded to different couple GPIO lines.

Also I used semaphore as latch to lock I2C bus to avoid interleaving requests within one transaction to different devices.

Unfortunately I can't offer clean diff of changes with your code because I made a lot changes when adapted your code to use with esp8266_rtos_sdk and formated code style.

You could see changed library at my test project: https://github.com/sacculus/aircontrol.v2.x.x/include/brzo_i2c.h https://github.com/sacculus/aircontrol.v2.x.x/user/brzo_i2c.c

pasko-zh commented 5 years ago

Hi @sacculus Thanks for your enhancements! I will have look at it, when I have more time, since currently I am quite busy with "other" stuff.