Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

C-code question

2006-03-25 by heedaf

In the following sample code does anyone know what tS8 (tS8 retCode 
= 0;) do/mean?  It is contained in a .h file.


tS8
i2cWrite(tU8  addr,
         tU8  extraCmd,
         tU16 extra,
         tU8* pData,
         tU16 len)
{
  tS8 retCode = 0;
  tU8 i       = 0;

  do
  {
    //generate Start condition
    retCode = i2cStart();
    if(retCode != I2C_CODE_OK)
      break;
    
    //Transmit slave address
    retCode = i2cPutCharAndWait(addr);
    if(retCode != I2C_CODE_OK)
      break;

    //Transmit MSB of extra word (if wanted)
   	if (extraCmd == I2C_EXTRA_WORD)
  	{
      retCode = i2cPutCharAndWait((tU8)(extra >> 8));
      if(retCode != I2C_CODE_OK)
        break;
    }

    //Transmit LSB of extra work (if wanted)
   	if ((extraCmd == I2C_EXTRA_BYTE) || (extraCmd == 
I2C_EXTRA_WORD))
   	{
      retCode = i2cPutCharAndWait((tU8)(extra & 0xff));
      if(retCode != I2C_CODE_OK)
        break;
	  }

    //wait until address transmitted and transmit data
    for(i = 0; i < len; i++)
    {
      retCode = i2cPutCharAndWait(*pData);
      if(retCode != I2C_CODE_OK)
        break;
      pData++;
    }
  } while(0);

  return retCode;
}

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.