cancel
Showing results for 
Search instead for 
Did you mean: 

USB Low-Full-High Speed Peripherals

Anonymous
Not applicable

Hi.

   

I working i2c with fx2lp.

   

My i2c chip address is 0x23. and  i2c address 8bit and data 8bit.

   

I want write  address 0x18 , data 0x37. So how do i make i2c command line?

   

Could you please let me know where is not correct and how can i fix?

   

Firmware :

   

   

 

   

BOOL DR_VendorCmnd( void )

   

{

   

BYTE addr;

   

BYTE fail;

   

BYTE count;

   

  BYTE tmp;

   

 

   

WORD wValue;

   

WORD wIndex;

   

 

   

wValue = SETUPDAT[2];

   

wValue |= SETUPDAT[3]<<8;

   

 

   

wIndex = SETUPDAT[4];

   

wIndex |= SETUPDAT[5]<<8;

   

 

   

  

   

  switch (SETUPDAT[1])

   

  {

   

case VENDOR_CMD1: 

   

 

   

EZUSB_InitI2C();

   

Cmd1[0] = 0x02;

   

while(EZUSB_WriteI2C(0x23 >> 1, 0x01, Cmd1) != I2C_OK) {

   

;

   

}

   

EZUSB_WaitForEEPROMWrite(0x23 >> 1);

   

 

   

Cmd1[0] = 0x37;

   

while(EZUSB_WriteI2C(0x18 >> 1, 0x01, Cmd1) != I2C_OK) {

   

;

   

}

   

EZUSB_WaitForEEPROMWrite(0x18 >> 1);

   

 

   

EZUSB_ReadI2C(0x18 >> 1, 0x01, Cmd1);

   

EP0BUF[0] = Cmd1[0];

   

EP0BCH = 0;

   

EP0BCL = 1;

   

EP0CS |= bmHSNAK; // Acknowledge handshake phase of device request

   

break;

   

default:

   

   return(TRUE);

   

  }

   

 

   

  return(FALSE);

   

}

   

 

   

 

   

 

   

PC application side :

   

 

   

   

   

if(init_USB()){

   

ept0 = USBDevice->ControlEndPt;

   

ept0->Target = TGT_DEVICE;

   

ept0->ReqType = REQ_VENDOR;

   

ept0->Direction = DIR_FROM_DEVICE;

   

ept0->ReqCode = 0xDA;

   

ept0->Value = ii;

   

ept0->Index = 0x00;

   

unsigned char buf[2];

   

ZeroMemory(buf,2);

   

LONG buflen = 2;

   

   

ept0->Read(buf,buflen);

   

UpdateData(FALSE);

   

}

   

 

   

 

   

 

   

Please let me know where am i do fix ?

0 Likes
1 Reply
Anonymous
Not applicable

 Hi,

   

 

   

Refer the implementation of vendor commands "VR_EEPROM' in the AN project: Vendor Command Design Guide for the FX2LP (http://www.cypress.com/?rID=34485). This might help you.

   

 

   

Regards,

   

Gayathri

0 Likes