Part Number: DLP2010EVM-LC
I am attempting to read data from a 2010 EVM and am getting unexpected results from my read functions. This function is very
similar to my write functions (all of which work no problem). Can anyone give a suggestion as to what I might be getting wrong?
This function should return the 'input source selection' detailed at the bottom of this message.
int DLPC3470_USB_Read() { UINT8 gpioValue = 0; UCHAR rData[64]; CY_DATA_BUFFER rdBuffer; CY_I2C_DATA_CONFIG i2cReadConfig; CY_RETURN_STATUS retStatus; int retry = 1000; UINT32 timeout = 5000; memset(rData, 0, sizeof(rData)); rdBuffer.buffer = rData; rdBuffer.buffer[0] = 0x06; // read input source select rdBuffer.length = 1; i2cReadConfig.slaveAddress = 0x1B; i2cReadConfig.isNakBit = false; i2cReadConfig.isStopBit = true; if (cyHandle == NULL) // cyHandle is static to the file and is open at this point return CY_ERROR_INVALID_HANDLE; // set GPIO5 to request I2C bus; wait for GPIO6 to go high to awknowlege request; set GPIO9 high to enable I2C bus retStatus = CySetGpioValue(cyHandle, 0x05, 0x01); while (gpioValue != 1 && retry--) retStatus = CyGetGpioValue(cyHandle, 0x06, &gpioValue); retStatus = CySetGpioValue(cyHandle, 0x09, 0x01); // after this call, I would expect rdBuffer.buffer[0] to hold the current source select....it does not printf("rdBuffer values before CyI2cRead() call\n"); printf("rdBuffer[0] is %d\nrdBuffer[1] is %d\nrdBuffer[2] is %d\n", rdBuffer.buffer[0], rdBuffer.buffer[1], rdBuffer.buffer[2]); retStatus = CyI2cRead(cyHandle, &i2cReadConfig, &rdBuffer, 5000); if (retStatus != CY_SUCCESS) printf("CyI2cRead failure\n"); else { printf("Results of CyI2cRead()\n"); printf("rdBuffer should now have a value of 0-5 or 255 per section 3.1.2 of DLPC3470 and DLP3478 Software Programmer's Guide\n"); printf("rdBuffer[0] is %d\nrdBuffer[1] is %d\nrdBuffer[2] is %d\n", rdBuffer.buffer[0], rdBuffer.buffer[1], rdBuffer.buffer[2]); } retStatus = CySetGpioValue(cyHandle, 0x05, 0x00); // done with I2C bus retStatus = CySetGpioValue(cyHandle, 0x09, 0x00); // done with I2C bus return rdBuffer.transferCount; }
--------------------- output here ------------------------
rdBuffer values before CyI2cRead() call
rdBuffer[0] is 6
rdBuffer[1] is 0
rdBuffer[2] is 0
Results of CyI2cRead()
rdBuffer should now have a value of 0-5 or 255 per section 3.1.2 of DLPC3470 and DLP3478 Software Programmer's Guide
rdBuffer[0] is 158
rdBuffer[1] is 0
rdBuffer[2] is 0
-------------------- expected results ---------------------
3.1.2 Read Input Source Select (06h)
This command reads the operating mode of the system.
3.1.2.1 Read Parameters
This command has no parameters.
3.1.2.2 Return Parameters
Byte 1 Operating Mode
00h Display - External Video Mode
01h Display - Test Pattern Generator Mode
02h Display - Splash Screen Mode
03h Light Control – External Pattern Streaming Mode
04h Light Control – Internal Pattern Streaming Mode
05h Light Control – Splash Pattern Mode
06h - FEh Reserved
FFh Standby Mode
This command works in all operating modes and has no effect on the current system configuration.