This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DLPC-API-1.10 CyI2CRead Problem

Part Number: DLPC3479
Other Parts Discussed in Thread: DLPC-API

Tool/software:

Hi everyone,

I use the DLPC-API-1.10.

I run the program dlpc347x.

as known that dlpc347x build in c language, not C#.

To use it, you have no choice but to create cyusbserial.dll and code in C# yourself.

Of course I am in that process too.

If you look at the dlpc347x_samples.c code of dlpc-api 1.10, there is a function called CYPRESS_I2C_ReadI2C, and when this function is converted to C#, it is as follows.

private bool CYPRESS_I2C_ReadI2C(UInt32 ReadDataLength, byte[] ReadData)
{
CY_RETURN_STATUS Status;

CY_DATA_BUFFER ReadBuffer;
ReadBuffer.buffer = ReadData;
ReadBuffer.length = ReadDataLength;
ReadBuffer.transferCount = 0;
//0x071e3c18

Status = CyI2cRead(cy_handle,
ref s_DataConfig,
ref ReadBuffer,
I2C_TIMEOUT_MILLISECONDS);
if ((Status != CY_RETURN_STATUS.CY_SUCCESS) && (Status != CY_RETURN_STATUS.CY_ERROR_IO_TIMEOUT))
{
//printf("Read I2C Error %d!!! \n", Status);
CyI2cReset(cy_handle, false);
CyI2cReset(cy_handle, true);
return false;
}

return true;
}

CY_DATA_BUFFER was declared as follows:

struct CY_DATA_BUFFER
{
public byte[] buffer; // Pointer to the buffer from where the data is read/written
public uint length; // Length of the buffer
public uint transferCount; // Number of bytes actually read/written
}

In the step of getting the initial device ID, the sample code in C can confirm that the value 15 is entered into the buffer.

However, in the C# code, data is not loaded into the buffer.

There is no data in the buffer.

Is there a problem with the data type of the CY_DATA_BUFFER configuration format? or,

in c Code DLPC_COMMON_SendRead follows:

uint32_t DLPC_COMMON_SendRead(uint16_t ReadLength)
{
return s_ReadCommandCallback(s_WriteBufferIndex,
s_WriteBuffer,
ReadLength,
s_ReadBuffer,
&s_ProtocolData);
}

Since I couldn't implement the s_ReadCommandCallback function, I just implemented it as follows.

private uint DLPC_COMMON_SendRead(ushort ReadLength)
{
return ReadI2C(s_WriteBufferIndex, s_WriteBuffer, ReadLength, s_ReadBuffer, ref s_ProtocolData); ;
}

I thought it wouldn't be a big problem since s_ReadCommandCallback is the code that calls ReadI2C anyway. Is this causing a problem?

Thanks.

  • Hello Byeon,

    Thank you to reaching out to us through E2E!

    Please give my team some time to respond to this question, they are currently on holiday and will return shortly.

    Best,

    Aaron

  • Hello Aaron,

    I'll wait for your reply.

    Best,

    Byeon.

  • Thank you for your patience!

    Best,

    Aaron

  • Hi Aaron, Sorry I'm taking a break during the holidays.

    Please check when you have time.

    DLPC34XX_ReadControllerDeviceId function confirmed that it read 1 data successfully.

    However, in the case of DLPC34XX_ReadInputImageSize,

    in C API Example, after DLPC34XX_ReadInputImageSize function, ReadBuffer.buffer fill with 4byte data.

    This is because it sent a length of 4 bytes.


    but in C#, only gets 1 data.


    Since transferCount is 4, I confirmed that 4 data were read.


    In C#, what exactly is the correct Read and Write buffer data type to use?

    if you want to get my c# Project File, I will send to you. I just make a DLCP_API 1.10 to C# code.

    Thanks.

    Best,

    Byeon

  • Hello Byeon,


    Give me some time to analyze and get back to you.

    Regards,
    Kirthi Vignan.

  • Hello Byeon,

    Can you share the C# API project code over personal message.

    Regards,
    Kirthi Vignan.

  • Hello Kirthi,

    public unsafe string DLPC34XX_ReadDmdDeviceId()
    {
    ENUM.DLPC34XX_DmdDataSelection DmdDataSelection = ENUM.DLPC34XX_DmdDataSelection.DLPC34XX_DDS_DMD_DEVICE_ID;
    UInt32 Status = 0;
    string DMDID = "";

    DLPC_COMMON_ClearWriteBuffer();
    DLPC_COMMON_ClearReadBuffer();

    DLPC_COMMON_PackOpcode(1, 0xD5);
    DLPC_COMMON_PackBytes((byte*)&DmdDataSelection, 1);

    DLPC_COMMON_SetCommandDestination(0);
    ushort WriteLength = 1;
    ushort ReadLength = 4;

    Status = DLPC_COMMON_Read(WriteLength, GLOBAL.byte_WriteBuffer, ReadLength, GLOBAL.byte_ReadBuffer);
    if (Status == 0)
    {
    //*DeviceId = *((int*)DLPC_COMMON_UnpackBytes(4));

    //ReadData 기능중, 버퍼에 다 안채워지는 버그 존재. 해결 후 구현.

    switch(GLOBAL.byte_ReadBuffer[3])
    {
    case 64:
    case 69:
    case 8:
    DMDID = "0.2 WVGA";
    break;
    case 68:
    case 72:
    case 87:
    DMDID = "0.3 720p";
    break;
    default:
    DMDID = "0.2 WVGA";
    break;

    }
    //*DeviceId = *((int*)DLPC_COMMON_UnpackBytes(4));

    }
    else
    {
    DMDID = "Cant' read DMDID";
    }
    return DMDID;
    }

    As you know, according to the API guide book, send to device 0xd5, It means get DMD Id.

    The first byte is read normally, but sometimes the 2nd, 3rd, and 4th bytes come out and sometimes not.

    And can I ask you some questions about the DLPC function?

    Regards,

    Byeon.

  • Hello Byeon,
    Can you share the complete project. It will help me to understand the flow. Feel free to ask any questions related to DLPC.
    Regards,
    Kirthi Vignan.