Other Parts Discussed in Thread: DLPC3470, DLPC3478
I wrote the following function which should cycle through the built-in splash screens displaying them one by one. Setting/Getting GPIOs seems to work fine and some of my write functionality works (output at the end of this message). Anybody have a comment on what might be wrong here?? I'm sure I'm missing something but not seeing it just yet. I am referencing the "DLPC3470 and DLPC3478 Software Programmer's Guide"
----------------------------- code ----------------------------------
/*
as a test of this function, emulate this python script which runs fine in the
DLPC347x Pico Display & Light Controller (0.2 WVGA, 0.3 720p) -
DLP Pico Display and Light Control EVM (Advanced) program provided by TI
from dlpc347x.commands import *
Summary = WriteSplashScreenSelect(0x0)
Summary = WriteSplashScreenExecute()
Summary = WriteSplashScreenSelect(0x1)
Summary = WriteSplashScreenExecute()
Summary = WriteSplashScreenSelect(0x2)
Summary = WriteSplashScreenExecute()
Summary = WriteSplashScreenSelect(0x3)
Summary = WriteSplashScreenExecute()
*/
int DLPC3470_USB_Write()
{
CY_I2C_CONFIG cyI2CConfig;
CY_DATA_BUFFER cyDataBuffer;
CY_I2C_DATA_CONFIG cyI2CDataConfig;
CY_RETURN_STATUS cyReturnStatus;
unsigned char readBuffer[4096], writeBuffer[4096];
UINT32 timeout = 5000;
UINT8 gpioValue = 0;
int retry = 1000;
if (cyHandle == NULL)
return CY_ERROR_INVALID_HANDLE;
// set gpio 5 to request I2C Bus
cyReturnStatus = CySetGpioValue(cyHandle, 0x05, 0x01);
// wait for gpio 6 to go high indicating the request was acknowledged
while (gpioValue != 1 && retry--)
cyReturnStatus = CyGetGpioValue(cyHandle, 0x06, &gpioValue);
// enable I2C bus for Cypress
cyReturnStatus = CySetGpioValue(cyHandle, 0x09, 0x01);
// report pin stats for 5, 6, 9 ....they should all be high now
cyReturnStatus = CyGetGpioValue(cyHandle, 0x05, &gpioValue);
if (cyReturnStatus != CY_SUCCESS)
printf("Error querying GPIO 5\n");
else
printf("GPIO 5 is %d\n", gpioValue);
cyReturnStatus = CyGetGpioValue(cyHandle, 0x06, &gpioValue);
if (cyReturnStatus != CY_SUCCESS)
printf("Error querying GPIO 6\n");
else
printf("GPIO 6 is %d\n", gpioValue);
cyReturnStatus = CyGetGpioValue(cyHandle, 0x09, &gpioValue);
if (cyReturnStatus != CY_SUCCESS)
printf("Error querying GPIO 9\n");
else
printf("GPIO 9 is %d\n", gpioValue);
cyI2CDataConfig.slaveAddress = 0x1B;
cyI2CDataConfig.isNakBit = true;
cyI2CDataConfig.isStopBit = true;
memset(writeBuffer, 0x00, 4096);
cyDataBuffer.buffer = writeBuffer;
cyDataBuffer.buffer[0] = 0x05; // write operating mode select
cyDataBuffer.buffer[1] = 0x02; // Display -- Splash screen mode
cyDataBuffer.length = 2;
cyReturnStatus = CyI2cWrite(cyHandle, &cyI2CDataConfig, &cyDataBuffer, timeout);
if (cyReturnStatus != CY_SUCCESS)
printf("OPERATING MODE SELECT: CyI2cWrite failure. . . return status is %d\n", cyReturnStatus);
else
printf("OPERATING MODE SELECT: Wrote %d bytes to device\n", cyDataBuffer.transferCount);
// cycle through the 4 built-in splash screens
for (int i = 0; i < 4; i++)
{
cyDataBuffer.buffer[0] = 0x0D; // write splash screen select
cyDataBuffer.buffer[1] = i;
cyDataBuffer.length = 2;
cyReturnStatus = CyI2cWrite(cyHandle, &cyI2CDataConfig, &cyDataBuffer, timeout);
if (cyReturnStatus != CY_SUCCESS)
printf("SPLASH SELECT %d: CyI2cWrite failure. . . return status is %d\n", i, cyReturnStatus);
cyDataBuffer.buffer[0] = 0x35; // write spash screen execute
cyDataBuffer.length = 1;
cyReturnStatus = CyI2cWrite(cyHandle, &cyI2CDataConfig, &cyDataBuffer, timeout);
if (cyReturnStatus != CY_SUCCESS)
printf("SPLASH EXECUTE %d: CyI2cWrite failure. . . return status is %d\n", i, cyReturnStatus);
}
cyReturnStatus = CySetGpioValue(cyHandle, 0x05, 0x00); // done with I2C bus
cyReturnStatus = CySetGpioValue(cyHandle, 0x09, 0x00); // done with I2C bus
return cyDataBuffer.transferCount;
}
------------------------ output -----------------------
GPIO 5 is 1
GPIO 6 is 1
GPIO 9 is 1
OPERATING MODE SELECT: Wrote 2 bytes to device
SPLASH SELECT 0: CyI2cWrite failure. . . return status is 6
SPLASH EXECUTE 0: CyI2cWrite failure. . . return status is 6
SPLASH SELECT 1: CyI2cWrite failure. . . return status is 6
SPLASH EXECUTE 1: CyI2cWrite failure. . . return status is 6
SPLASH SELECT 2: CyI2cWrite failure. . . return status is 6
SPLASH EXECUTE 2: CyI2cWrite failure. . . return status is 6
SPLASH SELECT 3: CyI2cWrite failure. . . return status is 6
SPLASH EXECUTE 3: CyI2cWrite failure. . . return status is 6
----------------- comments -------------------------
return status 6 = CY_ERROR_REQUEST_FAILED, /*Request sent to USB Serial device failed */