puuu / USIWire

USI based TWI/I2C library for Arduino
GNU Lesser General Public License v3.0
58 stars 18 forks source link

Library Clarification #4

Closed bukatea closed 6 years ago

bukatea commented 6 years ago

Hi,

This is not so much of an issue than it is a question for clarification. If I understand the purpose of this library correct, this library utilizes Universal Serial Interface (USI) to provide I2C Master and Slave functionality for the ATtiny family (those having USI capabilities), correct? In other words, when programming an ATtiny (say, ATtiny24a, for instance) using Arduino as an ISP, USIWire will allow the ATtiny (disconnected from the Arduino and running standalone) to act as a master and communicate with a slave, correct?

Also, is `#ifdef ESP8266 // default value of 230 us is too short Wire.setClockStretchLimit(1500);

endif` necessary for communication with ANY slave?

Thanks so much! Jonathan Lee bukatea@gmail.com

liebman commented 6 years ago

When using an ESP8266 as a master with ATtiny slave, I found that if your running the ATtiny at 8mhz or above its not needed. Even 4mhz I found it "mostly" works. At 1mhz its absolutely required as the slave will do long clock stretches and the ESP8266 will timeout, sometimes leaving the i2c buss in a bad state.

bukatea commented 6 years ago

Sorry if I wasn't clear. I mean using the ATtiny as a master to control a slave, such as a battery fuel gauge, not ESP8266 as a master of the ATtiny slave. is that statement necessary?

liebman commented 6 years ago

That statement is only needed for an ESP8266 master. (That's why it's #ifdef'd)

bukatea commented 6 years ago

Thanks for clarifying. To be sure, this library allows the user to use the Wire library from Arduino when you're programming an ATtiny (say, 44a) using Arduino's ISP Programmer capabilities, right? In other words, can you upload a piece of code with a command such as Wire.beginTransmission(ADDRESS_HERE); to the ATtiny using the Arduino ISP sketch?

Thanks so much! Jonathan Lee bukatea@gmail.com

liebman commented 6 years ago

Yes, while I've only used this as a slave, master is fully implemented.

bukatea commented 6 years ago

Thanks so much! You've been a great help.