/* Do acknowledge polling on EEPROM device. 
When writing to an EEPROM, the EEPROM device will be busy for some time after issuing a (page) write. During this time, the EEPROM is not accessible, and will therefore not ACK any requests. This feature can be used to determine when the write is actually completed, and is denoted acknowledgement polling. */
static int EEPROM_AckPoll(I2C_TypeDef *i2c, uint8_t addr)
/* Do acknowledge polling on EEPROM device. 
When writing to an EEPROM, the EEPROM device will be busy for some time after issuing a (page) write. During this time, the EEPROM is not accessible, and will therefore not ACK any requests. This feature can be used to determine when the write is actually completed, and is denoted acknowledgement polling. */
static int EEPROM_AckPoll(I2C_TypeDef *i2c, uint8_t addr)
{
  I2C_TransferSeq_TypeDef    seq;
  I2C_TransferReturn_TypeDef ret;
  seq.addr  = addr;
  seq.flags = I2C_FLAG_WRITE;
  seq.buf[0].data = NULL;
  seq.buf[0].len  = 0;
  while (1)
  {
    ret = I2CSPM_Transfer(i2c, &seq);
    if (ret == i2cTransferDone)
    {
      break;
    }
    else if (ret == i2cTransferNack)
    {
      continue;
    }
    else
    {
      return((int) ret);
    }
  }
  return(0);
}