Yahoo Groups archive

Lpc2000

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

Thread

C-code question

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;
}

Re: [lpc2000] C-code question

2006-03-25 by Robert Bacs

I guess it means an 8 bits  signed type.

Boby


--- heedaf <ruffellfamily@...> wrote:

> 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;
> }
> 
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

Re: [lpc2000] C-code question

2006-03-25 by Dave Hylands

Hi heedaf,

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

>   tS8 retCode = 0;

This declares a variable called retCode using a type called tS8 and
initializes it to zero. The tS8 type is probably declared somewhere
like this:

typedef signed cahr tS8;

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

Re: [lpc2000] C-code question

2006-03-25 by Robert Adsett

At 10:38 PM 3/25/2006 +0000, heedaf wrote:
>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;

retCode id declared as type tS8 and initialized to 0.  tS8 will defined 
elsewhere At a guess (and only a guess), it's meant to be a mnemonic for 
"type signed 8 bits".  It would probably have been a lot better just to use 
int.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

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.