Cypress技术论坛
直播中

李浩

7年用户 135经验值
私信 关注
[问答]

键入C连接器枚举问题

你好,
我一直在工作的CX3为基础的相机与USB类型的C型连接器。这将通过USB类型C连接到PC来键入电缆。我们在C型连接器和CX3芯片之间使用了MUX来选择正确的Tx和RX线。我已经添加了一个代码来检测电缆的方向,以便它总是枚举为3。我尝试了1.3.3SDK和1.3.1SDK。我使用的片段是
状态= CYU3pCONTCOSTATE(Cytru,CyTrue);
如果(CUU3PUBGETFAST())!=在默认的TX1、RX1对**中是否建立了3个连接
{
状态= CYU3PCONTCOSTATE(CyFrE,CyFalse);
*第一次尝试失败*
*在其他方向检查*
CYU3PGPIOSETValk(Type CuxMuxGPIO,CyFalse);/*将MUX转换成TX2,RX2对*/
状态= CYU3PUBSCONDSUB2支持(Cyress);
状态= CYU3pCONTCONSTATE(CyTrac,CyTrue);/*通过TX2,RX2对**重新建立连接/
如果(状态)!= CYU-U3PY成功
{
CYU3pDebug打印(4)\NRUSB连接2失败,错误代码=%D“,状态);
}
}
在SDK 1.3.3中:
我在这里遇到的问题(FrimAT1)是CyU3PUBGETSuffSee()API在Cyu3pCelpTestStand()之后立即调用CyuU3PySuxOyLoad不返回。因此,即使类型C插头连接在方向TX1、RX1对中,IF语句计算为false,MUX改变为TX2,RX2导致2操作。但是如果在这两行之间添加一个代码或延迟(如在FATAT2,FALATAT3中),它会按预期的方式正常工作。
在SDK 1.3.1中:
Frava1,FrUAT2,FrUAT3正确工作。
我想知道在不同的SDK中如何构建相同的代码是不同的。(PS.我为两个SDK都使用了相同的.LD文件)。有人能解释这种行为吗??
提前感谢,
当做,
Ashlin Surey。一
格式文件
437字节
格式文件
422字节
格式1.TXT.ZIP
405字节

以上来自于百度翻译


     以下为原文
  Hi,
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(CyU3PU***GetSpeed() != 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 = CyU3PU***ControlU***2Support (CyTrue);
status = CyU3PConnectState(CyTrue, CyTrue); /*Re establish connection through Tx2, Rx2 pair*/
if (status != CY_U3P_SUCCESS)
{
  CyU3PDebugPrint(4, "nrUSB Connect 2 failed, Error code = %d", status);
}
}

In SDK 1.3.3:
The problem I face here(Format1) is that the
CyU3PU***GetSpeed()
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,F
ormat2,F
ormat3
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,
Regards,
Ashlin Surey. A



  •   Format3.txt.zip 437 bytes  
  •   Format2.txt.zip 422 bytes  
  •   Format1.txt.zip 405 bytes  

回帖(2)

张超

2018-10-25 16:37:32
嗨,Ashlin,
关于您的代码:
Delay必须在下面两行之间给出,对于CYU3PUBGETSCAST()返回正确的值:
状态= CYU3pCONTCOSTATE(CyrEt,CyTrue);
如果(CUU3PUBGETFAST())!= CyuU3PySuffi速度
以下是C型连接器工作的另一种方法:
下面是MXX控制中FX3/CX3固件需要遵循的一系列步骤:
1)禁用USB2支持。
2)尝试使用第一个UB3对建立UB3连接。
3)检查CYU-U3PUSB事件和CYU-U3PUSB事件ESPB3LNKFAILT。
如果触发两个事件中的任何一个,请执行以下操作:
a)通过使用CYU3pCONTCONSTATE(CYFALSE,CyFalse)禁用USB PHY;
b)切换MUX选择GPIO。
c)启用USB 2支持
d)调用连接状态API以使用第二对建立USB 3连接。
如果遵循以上步骤,则代码更改:
a)第一次改变:
在FX3/CX3固件中,注释掉CYU3PCONTCONSTATE()API,并添加下面的代码片段来代替:
状态= CYU3PUBSCONDSUB2支持(CyFLUE);
如果(状态)!= CYU-U3PY成功
{
CYU3pDebug打印(4, \RN禁用USB2失败)。停止执行“”;
(1);
}
CYU3PTHeLead睡眠(20);
状态= CYU3pCONTCOSTATE(Cytru,CyTrue);
CYU3PTHeLead睡眠(50);
对于(int i=0;(i & lt;100 &&!);u3x事件)
CYU3PTHeLead睡眠(5);
如果(!)u3-真)
{
CUU3pDebug打印(5,\rnnMultSysSL不超速枚举)。翻转MUX再尝试“”;
CYU3pCeltT态(CyFe,CyFalse);
CYU3PGPIOSET值(SSMUXXSELGGPIO22,CyTrue);
CYU3PUBSCONDSUB2支持(Cyress);
CYU3PTHeLead睡眠(20);
状态= CYU3pCONTCOSTATE(Cytru,CyTrue);
CYU3PTHeLead睡眠(50);
如果(状态)!= CYU-U3PY成功
{
CYU3pDebug打印(4)\nrAPAPIIT:CONTCONSTATE Err= 0x%x“,状态);
CYCX3UVCAPPRROR处理程序(状态);
}
}
其他的
{
CYU3pDebug打印(5,  RN超速度枚举MuxSeSL低);
}
B)第二次改变:
将这两个案例添加到USB安装调用中,如下所示:
/*这是处理USB事件**的回调函数。
静态空隙
CYCX3UVCAPPUS BEN
Cyu3PueBeTyType:EVType,/*事件类型*/
UIT1616T EVDATA/*事件数据*/)
{
交换机(EvType)
{
CYU-U3PUSB事件
αIFIFF类型C~(32)启用
U3a事件=胞质;
u3-真= CyFrE;
CYU3pDebug打印(5,\nrSSyCOMPRICATION事件发生);
第二节
断裂;
CYU-U3PUSB事件ESPB3LNKFAIL:
αIFIFF类型C~(32)启用
U3a事件=胞质;
u3-真= CyFrE;
CYU3pDebug打印(5,\NRUB33LNKFAILL事件发生);
第二节
断裂;
通过上述两个代码更改,可以用C型连接器建立3个连接。
当做,
血竭

以上来自于百度翻译


     以下为原文
  Hi Ashlin,
 
With respect to your code:
 
Delay has to be given between the following two lines, for CyU3PU***GetSpeed() to return correct value:
 
status = CyU3PConnectState(CyTrue, CyTrue);     AND
 
if(CyU3PU***GetSpeed() != CY_U3P_SUPER_SPEED)
 
 
The following is another way of working with Type C connector:
 
 
Below is the sequence of steps that needs to be followed in FX3/CX3 firmware for mux control:
 
1) Disable the USB2 support.
2) Try to establish USB3 connection using the first USB3 pair.
3) check for CY_U3P_USB_EVENT_SS_COMP_ENTRY and CY_U3P_USB_EVENT_USB3_LNKFAIL.
     If any of the two event gets triggered, do the following:
          a)disable the USB PHY by using CyU3PConnectState(CyFalse, CyFalse);
          b)toggle the mux selection GPIO.
          c)enable the USB 2.0 support
          d)Call connectstate API to establish a USB 3.0 connection using the second pair.
 
Code changes if above steps are followed:
 
A) First change:
 
In your FX3/CX3 firmware comment out the CyU3PConnectState() API and add the below snippet in place of that:
 
 
status = CyU3PU***ControlU***2Support(CyFalse);
  if (status != CY_U3P_SUCCESS)
  {
          CyU3PDebugPrint(4,"rnDisabling USB2 failed. Stopping Execution");
          while(1);
  }
 
  CyU3PThreadSleep(20);
 
  status = CyU3PConnectState(CyTrue, CyTrue);
  CyU3PThreadSleep(50);
  for(int i =0 ; (i<100 && !U3_EVENT); i++ )
            CyU3PThreadSleep(5);
 
  if(!U3_TRUE)
  {
           CyU3PDebugPrint(5,"rnNot Super speed enumeration with MUX_SEL low. Flipping Mux to try again");
           CyU3PConnectState(CyFalse, CyFalse);
           CyU3PGpioSetValue(SS_MUX_SEL_GPIO22,CyTrue);
           CyU3PU***ControlU***2Support(CyTrue);
           CyU3PThreadSleep(20);
          status = CyU3PConnectState(CyTrue, CyTrue);
           CyU3PThreadSleep(50);
           if (status != CY_U3P_SUCCESS)
           {
                CyU3PDebugPrint (4, "nrAppInit:ConnectState Err = 0x%x", status);
                CyCx3UvcAppErrorHandler(status);
           }
 
  }
  else
  {
           CyU3PDebugPrint(5,"rnSuper speed enumeration with MUX_SEL low");
  }
 
 
B) Second change:
 
Add these two cases in the USB Setup call back as shown below :
 
 
/* This is the Callback function to handle the USB Events */
static void
CyCx3UvcAppUSBEventCB(
                  CyU3PU***EventType_t evtype, /* Event type */
                  uint16_t evdata /* Event data */)
{
 
 
         switch (evtype)
         {
         case  CY_U3P_USB_EVENT_SS_COMP_ENTRY:
#ifdef TYPE_C_ENABLED
                  U3_EVENT = CyTrue;
                  U3_TRUE = CyFalse;
                  CyU3PDebugPrint(5, "nrSS_COMP_ENTRY Event Occured");
#endif
                  break;
 
 
         case  CY_U3P_USB_EVENT_USB3_LNKFAIL:
#ifdef TYPE_C_ENABLED
                  U3_EVENT = CyTrue;
                  U3_TRUE = CyFalse;
                  CyU3PDebugPrint(5, "nrUSB3_LNKFAIL Event Occured");
#endif
                  break;
 
 
With the above two code changes, 3.0 connection can be established with a Type-C connector.
 
Regards,
Hemanth
举报

李浩

2018-10-25 16:54:11
引用: xianhaizhe 发表于 2018-10-25 14:25
嗨,Ashlin,
关于您的代码:
Delay必须在下面两行之间给出,对于CYU3PUBGETSCAST()返回正确的值:

嗨,海曼思,
你所提供的代码工作良好。要添加到这一点,必须将两个标志声明为
CyoOLLT U3a事件=CyFrE,U3a真= Cytru.
为了正常工作。
此外,我只观察到CyuU3PUSbSeviuSUB3LLNKFLAST事件的发生。从未发生过CyuU3pU***bEnvivsSSyCopyAccess事件。
谢谢和问候,
Ashlin Surey。一

以上来自于百度翻译


     以下为原文
  Hi Hemanth,
The code you have provided works fine. To add to this, both the flags has to be declared as
CyBool_t U3_EVENT = CyFalse,U3_TRUE=CyTrue;
for proper working.
Also, I observed only the occurrence of CY_U3P_USB_EVENT_USB3_LNKFAIL event. The CY_U3P_USB_EVENT_SS_COMP_ENTRY event never occurred.
 
Thanks and Regards,
Ashlin Surey. A
举报

更多回帖

发帖
×
20
完善资料,
赚取积分