i2c_t3 Wire.endTransmission() return values 2 and 4?

Status
Not open for further replies.

DaQue

Well-known member
I think if Wire.endTransmission() returns 2 that's just a nak but what does it mean if it returns 4?
 
disconnect the device or try to endTransmission an address not used, it should be a timeout/disconnected flag, either way one of my remote i2c devices (3 addresses on the same bus) shuts off when not needed, i use the return flag to block the functions till it comes back online, then update its registers when it does, and the functions continue working with the chips
 
I only have to send a few bytes and I wait a fairly long time between them. If i understand you right if it returns 4 (and/or 2 possibly) you retry again later. I think I got it then I'm back to ground zero.

I send a wake up, config0, config1, play or record, then a stop after two seconds.

maybe I should do something like
I2Cstatus = wakeUpSV() // global I2Cstatus declared and defined somewhere
while (I2Cstatus !=0) {
I2Cstatus = wakeUpSV();
}

My program sends a few commands and sometimes they return 0 for several runs then starts to return 2 or 4 and I'm not quite sure what's going on. It could be hardware.
Code:
int playSV(uint8_t huint8_t, uint8_t luint8_t)
{
  // must complet powerUpSV,  wakeUpSV, config0SV, and config1SV before calling this function
  int I2Cstatus;
  Wire.beginTransmission(0x40);  // transmit to device #40 the stored voice chip
  Wire.write((uint8_t) 0xA9);        // sends one uint8_t
  Wire.write(huint8_t);        // sends one uint8_t
  Wire.write(luint8_t);        // sends one uint8_t
  I2Cstatus = Wire.endTransmission();   // stop transmitting
  return I2Cstatus;

}
int recordSV(uint8_t  huint8_t, uint8_t  luint8_t)
{
  // must complet powerUpSV,  wakeUpSV, and I2C config0SV and config1SV before calling this function
  int I2Cstatus;
  Wire.beginTransmission(0x40);  // transmit to device #40 the stored voice chip
  Wire.write((uint8_t) 0x91);        // sends one uint8_t
  Wire.write(huint8_t);        // sends one uint8_t
  Wire.write(luint8_t);        // sends one uint8_t
  I2Cstatus = Wire.endTransmission();   // stop transmitting
  return I2Cstatus;

}
int wakeUpSV(void)
{
  // must complet powerUpSV,   before calling this function
  int I2Cstatus;
  Wire.beginTransmission(0x40);  // transmit to device #0x40 the stored voice chip
  Wire.write((uint8_t) 0x80);        // sends one uint8_t
  I2Cstatus = Wire.endTransmission();   // stop transmitting
  return I2Cstatus;
}



int config0SV(void)
{
  // must complet power up,  wakeUpSV, and I2C config0SV and config1SV before calling this function
  int I2Cstatus;
  Wire.beginTransmission(0x40);  // transmit to device #40 the stored voice chip
  Wire.write((uint8_t) 0x82);        // sends one uint8_t
  Wire.write((uint8_t) 0x24);        // sends one uint8_t
  Wire.write((uint8_t) 0x37);        // sends one uint8_t
  I2Cstatus = Wire.endTransmission();   // stop transmitting
  return I2Cstatus;

}
int config1SV(void)
{
  // must complet power up,  wakeUpSV, and I2C config0SV and config1SV before calling this function
  int I2Cstatus;
  Wire.beginTransmission(0x40);  // transmit to device #40 the stored voice chip
  Wire.write((uint8_t) 0x83);        // sends one uint8_t
  Wire.write((uint8_t) 0x03);        // sends one uint8_t
  Wire.write((uint8_t) 0xF1);        // sends one uint8_t
  I2Cstatus = Wire.endTransmission();   // stop transmitting
  return I2Cstatus;

}
int StopSV(void)
{

  // must complet power up,  wakeUpSV, and I2C config0SV and config1SV before calling this function
  int I2Cstatus;
  Wire.beginTransmission(0x40);  // transmit to device #40 the stored voice chip
  Wire.write((uint8_t) 0x00);        // sends one uint8_t
  Wire.write((uint8_t) 0x00);        // sends one uint8_t
  I2Cstatus = Wire.endTransmission();   // stop transmitting
  return I2Cstatus;

}
}
 
I tried the while loop to check/retry the wakeupSV() and that seems for the moment to have made it pretty repeatable now. It usually only retries once. I think I will add that to all the functions. Thank you.
 
Status
Not open for further replies.
Back
Top