I have been working on a CX3 based camera with USB type-C connector. This will be connected to the PC through a USB Type-C to Type A cable. We have used a MUX in between the Type-C connector and the CX3 chip to select the correct Tx and Rx lines. I have added a code to detect the orientation of the cable so that it always enumerates as 3.0. I tried this in 1.3.3 sdk as well as 1.3.1 sdk. The snippet I have used for this is,
status = CyU3PConnectState(CyTrue, CyTrue);
if(CyU3PUsbGetSpeed() != CY_U3P_SUPER_SPEED) /*Checks whether 3.0 connection is established in the default Tx1,Rx1 pair*/
status = CyU3PConnectState(CyFalse, CyFalse);
/*First attempt failed*/
/* Check in other orientation */
CyU3PGpioSetValue(TYPEC_MUX_GPIO, CyFalse); /*Swiches the mux to the Tx2,Rx2 pair*/
status = CyU3PUsbControlUsb2Support (CyTrue);
status = CyU3PConnectState(CyTrue, CyTrue); /*Re establish connection through Tx2, Rx2 pair*/
if (status != CY_U3P_SUCCESS)
CyU3PDebugPrint(4, "\n\rUSB Connect 2 failed, Error code = %d", status);
In SDK 1.3.3:
The problem I face here(Format1) is that the CyU3PUsbGetSpeed() API doesn't return CY_U3P_SUPER_SPEED when called immediately after CyU3PConnectState() . Because of this even if the Type-C plug is connected in the orientation Tx1,Rx1 pair , the if statement evaluates to false and the MUX changes to Tx2,Rx2 resulting in 2.0 operation. But if a code or delay is added in between these two lines (as in Format2, Format3), this works correctly as expected.
In SDK 1.3.1:
Format1,Format2,Format3 works correctly.
I wonder how building the same code in different sdk works differently. (PS. I have used the same .ld file for both the SDKs). Can anyone explain this behaviour??
Thanks in advance,
Ashlin Surey. A