14 Replies Latest reply on Feb 27, 2019 5:12 PM by YangyangC_06

    CyWrite Always Return CY_ERROR_I2C_DEVICE_BUSY

    shvo_3974456

      Hi All,

       

      I am using USB CY7C65215  for my usb projector connection , here is my visual c++ sample code as well as attached cyusbserial.dll so please have a look it

       

      BYTE *writeBuffer = new BYTE[1];

      ZeroMemory(writeBuffer, (sizeof(BYTE) * 1));

      writeBuffer[0] = (BYTE)83;

      CY_RETURN_STATUS num1 = Write((BYTE)27, writeBuffer, len1);

       

       

       

      *************** Write Function Code

      CY_RETURN_STATUS Write(UCHAR byteSlaveAddres7bit, UCHAR *buf, UINT32 len)

      {

      CY_I2C_DATA_CONFIG* dataConfig = NULL;

      CY_DATA_BUFFER* writeBuffer = NULL;

      UCHAR *pszWriteBuffer = NULL;

      try

      {

      dataConfig = new CY_I2C_DATA_CONFIG();

      CHECK_NULL(dataConfig)

       

       

      writeBuffer = new CY_DATA_BUFFER();

      CHECK_NULL(writeBuffer)

       

       

      pszWriteBuffer = new UCHAR[len];

      CHECK_NULL(pszWriteBuffer)

      memset(pszWriteBuffer, 0, len);

      memcpy(pszWriteBuffer, buf, len);

       

       

       

       

      dataConfig->slaveAddress = byteSlaveAddres7bit;

      dataConfig->isStopBit = (BOOL)TRUE;

      writeBuffer->length = (UINT32)len;

      writeBuffer->buffer = pszWriteBuffer;

       

      CY_RETURN_STATUS cyReturnStatus = LTWrite(mHandle, dataConfig, writeBuffer, 5000U);

       

       

      SAFE_DELETE(pszWriteBuffer)

      SAFE_DELETE(dataConfig)

      SAFE_DELETE(writeBuffer)

      return cyReturnStatus;

      }

      catch(std::exception &e)

      {

      SAFE_DELETE(pszWriteBuffer)

      SAFE_DELETE(dataConfig)

      SAFE_DELETE(writeBuffer)

       

       

      throw LTException(e.what());

      }

      };

      ** CY_RETURN_STATUS cyReturnStatus = LTWrite(mHandle, dataConfig, writeBuffer, 5000U);

       

      Above line always return CY_ERROR_I2C_DEVICE_BUSY and please find attached cyusbserial.dll which I am using for read/write operation.

       

      When I have checked the same thing from Cypress SDK -> Cypress\USB-Serial SDK\examples\usbserialexample\i2cmaster then also I am getting the same error.

       

      Thanks In Advance.

      Shailesh Vora.