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

Support speeds < 100KHz #35

Open gkaindl opened 5 years ago

gkaindl commented 5 years ago

Thanks for a very nice library!

I've noticed that it's sometimes necessary to use speeds < 100KHz to talk to a device, which the library currently doesn't support.

As an example, at 100KHz, it's almost impossible (very error-prone) to talk to an ATMega running at 8MHz or even an ATTiny, such as the reasonably popular BlinkM LEDs.

I can work around this by setting iteration_scl_halfcycle accordingly to achieve speeds like 50KHz or even slower, but the library currently doesn't support this out of the box.

Doing a pull request for this would be trivial, but I'm unsure about how to approach it without breaking the current API, e.g. right now, any speeds <100KHz would get treated as 100KHz. Maybe adding a new function like start_transaction_slow is the safest way without breaking backwards compatibility, which just supports speeds (roughly) between 10-100KHz?

pasko-zh commented 5 years ago

Well, I have written the library to be fast... but yes slower speeds should be supported, too. 😄 I will think of a "good" way to allow that.

hqs1 commented 5 years ago

It's a really good library Recently, I also have the requirement of 10-100khz IIC frequency, because the frequency of components is not too high.But arduino wire.h cannot be less than 100khz, so I can only write the soft IIC driver.