Tympan / Tympan_Library

Arduino/Teensy Library for Tympan Open Source Hearing Aid
MIT License
124 stars 33 forks source link

No delay needed after Wire.write(). #13

Closed Koepel closed 3 years ago

Koepel commented 6 years ago

In the file "Tympan_Library/src/control_tlv320aic3206.cpp", there is sometimes a delay() after a Wire.write(). I think that delay() can be removed.

It is similar to this:

int i = 3;
delay(10);  // wait until i becomes 3
int j = 5;
delay(10);  // wait until j becomes 5

In the Arduino Wire library and in most Arduino Wire compatible libraries, a buffer is used. The Wire.beginTransmission() resets the buffer, the Wire.write() fills the buffer and the Wire.endTransmission() does the complete I2C transaction with START, I2C address, write data from the buffer and STOP.

I took a quick glance at the TLV320AIC3206 datasheet, but I can't read that a delay would be needed somewhere.

chipaudette commented 3 years ago

Over the last several years, I think that we have now pulled out most of the delay() calls. There are a few delay() calls left in there, but they are mostly after register settings that change how the hardware functions, so they are there to let the hardware settle.

I think that this is complete.