cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Observer
Observer
2,362 Views
Registered: ‎01-12-2009

EDK IIC

In TestApp _ Peripheral =>souce
If I hope IIC to write one data device outside
Is that written like this mistakenly? Why seem not to write? '

Suppose I set up as follows
device address =0x4C;
register address =0x03;
data =0x64;


Could you tell me where is the mistake?  thank ............
 
//-----------------------------------------------------------------------------------------------------------------------------
 
int main (void) {
Xuint8 xdata[2];
 xdata[0]=0x03;
 xdata[1]=0x64;
vsk_iic_write(XPAR_IIC_0_BASEADDR, 0X4C, xdata[0],&xdata[1],1);

}
//---------------------------------------------------------------------------------------------------------------
 
Xuint8  vsk_iic_write(Xuint32 CoreAddress, Xuint8 ChipAddress, Xuint8 RegAddress,
                  Xuint8 *BufferPtr, Xuint8 ByteCount)
{
  Xuint8 SentByteCount;
  Xuint8 WriteBuffer[10];
  Xuint8 Index;
 
       

  /*
   * A temporary write buffer must be used which contains both the address
   * and the data to be written, put the address in first
   */
  WriteBuffer[0] = RegAddress;


  /*
   * Put the data in the write buffer following the address.
   */

  for (Index = 0; Index < ByteCount; Index++)
  {
    WriteBuffer[Index + 1] = BufferPtr[Index];
  }
  /*
   * Write data at the specified address.
   */

  SentByteCount = XIic_Send(CoreAddress, ChipAddress, WriteBuffer,ByteCount + 1, XIIC_STOP);
 
if (SentByteCount < 1) { SentByteCount = 1; }                            
  // Return the number of bytes written.
  return SentByteCount - 1;

}
 
//-----------------------------------------------------------------------------------------------------------------------------------

0 Kudos
0 Replies