最近再弄daplink 描述符配置从现成的例程上移植的 也正常枚举过 是没有问题的
但是修改完endpoint的配置 修改中断中重置端口 和置端口stall那块代码后 烧录就无法正常枚举了
然后奇怪的事情就来了 按p0.36和复位引脚 大概率又能正常枚举
最近再弄daplink 描述符配置从现成的例程上移植的 也正常枚举过 是没有问题的
但是修改完endpoint的配置 修改中断中重置端口 和置端口stall那块代码后 烧录就无法正常枚举了
然后奇怪的事情就来了 按p0.36和复位引脚 大概率又能正常枚举
您好,如果可以的话可以将您修改的代码贴出来看看,同时枚举过程可以用抓包工具抓取,看看枚举流程发送了什么错误。
Device Phase Data Description Cmd.Phase.Ofs(rep)
------ ----- ------------------------------------------------------------------------------------------------------ -------------------------------- ------------------
43.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 1.1.0
43.0 IN 09 02 20 00 01 01 00 80 32 .. .....2 1.2.0
43.0 CTL 80 06 00 02 00 00 20 00 GET DESCRIPTOR 2.1.0
43.0 IN 09 02 20 00 01 01 00 80 32 09 04 00 00 02 ff 80 55 00 07 05 82 02 40 00 00 07 05 02 02 40 00 00 .. .....2.......U.....@......@.. 2.2.0
43.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 3.1.0
44.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 4.1.0
44.0 IN 12 01 10 02 ef 02 01 40 28 0d 04 02 00 01 01 02 03 01 .......@(......... 4.2.0
44.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 5.1.0
44.0 IN 09 02 62 00 03 01 00 80 fa ..b...... 5.2.0
44.0 CTL 80 06 00 02 00 00 62 00 GET DESCRIPTOR 6.1.0
44.0 IN 09 02 62 00 03 01 00 80 fa 09 04 00 00 02 ff 00 00 04 07 05 01 02 40 00 00 07 05 81 02 40 00 00 ..b...................@......@.. 6.2.0
08 0b 01 02 02 02 01 05 09 04 01 00 01 02 02 01 00 05 24 00 10 01 05 24 01 00 01 04 24 02 02 05 ..................$....$....$... 6.2.32
24 06 00 01 07 05 84 03 0c 00 01 09 04 02 00 02 0a 00 00 00 07 05 82 02 40 00 01 07 05 02 02 40 $.......................@......@ 6.2.64
00 01 .. 6.2.96
44.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 7.1.0
44.0 CTL 80 06 04 03 09 04 04 00 GET DESCRIPTOR 8.1.0
44.0 IN 1a 03 43 00 ..C. 8.2.0
44.0 CTL 80 06 04 03 09 04 1a 00 GET DESCRIPTOR 9.1.0
44.0 IN 1a 03 43 00 4d 00 53 00 49 00 53 00 2d 00 44 00 41 00 50 00 20 00 76 00 32 00 ..C.M.S.I.S.-.D.A.P. .v.2. 9.2.0
44.0 CTL 80 06 05 03 09 04 04 00 GET DESCRIPTOR 10.1.0
44.0 IN 1e 03 44 00 ..D. 10.2.0
44.0 CTL 80 06 05 03 09 04 1e 00 GET DESCRIPTOR 11.1.0
44.0 IN 1e 03 44 00 41 00 50 00 4c 00 69 00 6e 00 6b 00 2d 00 43 00 44 00 43 00 45 00 78 00 74 00 ..D.A.P.L.i.n.k.-.C.D.C.E.x.t. 11.2.0
45.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 12.1.0
45.0 IN 12 01 10 02 ef 02 01 40 28 0d 04 02 00 01 01 04 03 01 .......@(......... 12.2.0
45.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 13.1.0
45.0 IN 09 02 20 00 01 01 00 80 fa .. ...... 13.2.0
45.0 CTL 80 06 00 02 00 00 20 00 GET DESCRIPTOR 14.1.0
45.0 IN 09 02 20 00 01 01 00 80 fa 09 04 00 00 02 ff 00 00 04 07 05 01 02 40 00 00 07 05 81 02 40 00 00 .. ...................@......@.. 14.2.0
45.0 CTL 80 00 00 00 00 00 02 00 GET STATUS 15.1.0
45.0 IN 00 00 .. 15.2.0
45.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 16.1.0
44.0 CTL 80 00 00 00 00 00 02 00 GET STATUS 17.1.0
44.0 NTSTS c00000bb not supported 17.2.0
44.0 CTL 01 0b 00 00 02 00 00 00 SET INTERFACE 18.1.0
44.0 CTL a1 21 00 00 01 00 07 00 CLASS 19.1.0
44.0 IN 00 e1 00 00 00 00 08 ....... 19.2.0
44.0 CTL 21 22 00 00 01 00 00 00 CLASS 20.1.0
44.0 CTL 21 20 00 00 01 00 07 00 CLASS 21.1.0
44.0 OUT 00 e1 00 00 00 00 08 ....... 21.2.0
44.0 CTL a1 21 00 00 01 00 07 00 CLASS 22.1.0
44.0 IN 00 e1 00 00 00 00 08 ....... 22.2.0
44.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 23.1.0
44.0 IN 12 01 10 02 ef 02 01 40 28 0d 04 02 00 01 01 02 03 01 .......@(......... 23.2.0
44.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 24.1.0
44.0 IN 09 02 62 00 03 01 00 80 fa ..b...... 24.2.0
44.0 CTL 80 06 00 02 00 00 62 00 GET DESCRIPTOR 25.1.0
44.0 IN 09 02 62 00 03 01 00 80 fa 09 04 00 00 02 ff 00 00 04 07 05 01 02 40 00 00 07 05 81 02 40 00 00 ..b...................@......@.. 25.2.0
08 0b 01 02 02 02 01 05 09 04 01 00 01 02 02 01 00 05 24 00 10 01 05 24 01 00 01 04 24 02 02 05 ..................$....$....$... 25.2.32
24 06 00 01 07 05 84 03 0c 00 01 09 04 02 00 02 0a 00 00 00 07 05 82 02 40 00 01 07 05 02 02 40 $.......................@......@ 25.2.64
00 01 .. 25.2.96
44.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 26.1.0
44.0 CTL 80 06 04 03 09 04 04 00 GET DESCRIPTOR 27.1.0
44.0 IN 1a 03 43 00 ..C. 27.2.0
44.0 CTL 80 06 04 03 09 04 1a 00 GET DESCRIPTOR 28.1.0
44.0 IN 1a 03 43 00 4d 00 53 00 49 00 53 00 2d 00 44 00 41 00 50 00 20 00 76 00 32 00 ..C.M.S.I.S.-.D.A.P. .v.2. 28.2.0
44.0 CTL 80 06 05 03 09 04 04 00 GET DESCRIPTOR 29.1.0
44.0 IN 1e 03 44 00 ..D. 29.2.0
44.0 CTL 80 06 05 03 09 04 1e 00 GET DESCRIPTOR 30.1.0
44.0 IN 1e 03 44 00 41 00 50 00 4c 00 69 00 6e 00 6b 00 2d 00 43 00 44 00 43 00 45 00 78 00 74 00 ..D.A.P.L.i.n.k.-.C.D.C.E.x.t. 30.2.0
45.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 31.1.0
45.0 IN 12 01 10 02 ef 02 01 40 28 0d 04 02 00 01 01 04 03 01 .......@(......... 31.2.0
45.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 32.1.0
45.0 IN 09 02 20 00 01 01 00 80 fa .. ...... 32.2.0
45.0 CTL 80 06 00 02 00 00 20 00 GET DESCRIPTOR 33.1.0
45.0 IN 09 02 20 00 01 01 00 80 fa 09 04 00 00 02 ff 00 00 04 07 05 01 02 40 00 00 07 05 81 02 40 00 00 .. ...................@......@.. 33.2.0
45.0 CTL 80 00 00 00 00 00 02 00 GET STATUS 34.1.0
45.0 IN 00 00 .. 34.2.0
45.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 35.1.0
44.0 CTL 80 00 00 00 00 00 02 00 GET STATUS 36.1.0
44.0 NTSTS c00000bb not supported 36.2.0
44.0 CTL 01 0b 00 00 02 00 00 00 SET INTERFACE 37.1.0
44.0 CTL a1 21 00 00 01 00 07 00 CLASS 38.1.0
44.0 IN 00 e1 00 00 00 00 08 ....... 38.2.0
44.0 CTL 21 22 00 00 01 00 00 00 CLASS 39.1.0
44.0 CTL 21 20 00 00 01 00 07 00 CLASS 40.1.0
44.0 OUT 00 e1 00 00 00 00 08 ....... 40.2.0
44.0 CTL a1 21 00 00 01 00 07 00 CLASS 41.1.0
44.0 IN 00 e1 00 00 00 00 08 ....... 41.2.0
44.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 42.1.0
44.0 IN 12 01 10 02 ef 02 01 40 28 0d 04 02 00 01 01 02 03 01 .......@(......... 42.2.0
44.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 43.1.0
44.0 IN 09 02 62 00 03 01 00 80 fa ..b...... 43.2.0
44.0 CTL 80 06 00 02 00 00 62 00 GET DESCRIPTOR 44.1.0
44.0 IN 09 02 62 00 03 01 00 80 fa 09 04 00 00 02 ff 00 00 04 07 05 01 02 40 00 00 07 05 81 02 40 00 00 ..b...................@......@.. 44.2.0
08 0b 01 02 02 02 01 05 09 04 01 00 01 02 02 01 00 05 24 00 10 01 05 24 01 00 01 04 24 02 02 05 ..................$....$....$... 44.2.32
24 06 00 01 07 05 84 03 0c 00 01 09 04 02 00 02 0a 00 00 00 07 05 82 02 40 00 01 07 05 02 02 40 $.......................@......@ 44.2.64
00 01 .. 44.2.96
44.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 45.1.0
44.0 CTL 80 06 04 03 09 04 04 00 GET DESCRIPTOR 46.1.0
44.0 IN 1a 03 43 00 ..C. 46.2.0
44.0 CTL 80 06 04 03 09 04 1a 00 GET DESCRIPTOR 47.1.0
44.0 IN 1a 03 43 00 4d 00 53 00 49 00 53 00 2d 00 44 00 41 00 50 00 20 00 76 00 32 00 ..C.M.S.I.S.-.D.A.P. .v.2. 47.2.0
44.0 CTL 80 06 05 03 09 04 04 00 GET DESCRIPTOR 48.1.0
44.0 IN 1e 03 44 00 ..D. 48.2.0
44.0 CTL 80 06 05 03 09 04 1e 00 GET DESCRIPTOR 49.1.0
44.0 IN 1e 03 44 00 41 00 50 00 4c 00 69 00 6e 00 6b 00 2d 00 43 00 44 00 43 00 45 00 78 00 74 00 ..D.A.P.L.i.n.k.-.C.D.C.E.x.t. 49.2.0
用bushound抓取的相关log 显示是获取一个描述符后面就会重置
/*******************************************************************************
* Function Name : DeviceInterrupt()
* Description : CH552USB中断处理函数
*******************************************************************************/
void DeviceInterrupt(void) interrupt INT_NO_USB using 1 //USB中断服务程序,使用寄存器组1
{
UINT8 len;
if (UIF_TRANSFER) // USB传输完成标志
{
switch (USB_INT_ST & (MASK_UIS_TOKEN | MASK_UIS_ENDP))
{
case UIS_TOKEN_OUT_EP1: // endpoint 1# 端点批量下传 DAP-CMD
if (U_TOG_OK) // 不同步的数据包将丢弃
{
UEP1_CTRL = UEP1_CTRL & ~ MASK_UEP_R_RES | UEP_R_RES_NAK; //收到一包数据就NAK,主函数处理完,由主函数修改响应方式
}
break;
case UIS_TOKEN_IN_EP1: // endpoint 1# 端点批量上传 DAP_ASK
UEP1_T_LEN = 0; //预使用发送长度一定要清空
UEP1_CTRL &= ~MASK_UEP_T_RES | UEP_T_RES_NAK; //默认应答NAK
break;
case UIS_TOKEN_OUT_EP2: // endpoint 2# 端点批量下传 CDC
if (U_TOG_OK) // 不同步的数据包将丢弃
{
UEP2_CTRL = UEP2_CTRL & ~ MASK_UEP_R_RES | UEP_R_RES_NAK; //收到一包数据就NAK,主函数处理完,由主函数修改响应方式
}
break;
case UIS_TOKEN_IN_EP2: // endpoint 2# 端点批量上传 CDC
UEP2_T_LEN = 0; //预使用发送长度一定要清空
UEP2_CTRL &= ~MASK_UEP_T_RES | UEP_T_RES_NAK; //默认应答NAK
break;
case UIS_TOKEN_IN_EP4: // endpoint4 IN
UEP4_T_LEN = 0; //预使用发送长度一定要清空
UEP4_CTRL &= ~MASK_UEP_T_RES | UEP_T_RES_NAK; //默认应答NAK
break;
case UIS_TOKEN_IN_EP0: // endpoint0 IN
switch (SetupReq)
{
case USB_GET_DESCRIPTOR:
case 0x20:
len = SetupLen >= THIS_ENDP0_SIZE ? THIS_ENDP0_SIZE : SetupLen; //本次传输长度
memcpy(Ep0Buffer, pDescr, len); //加载上传数据
SetupLen -= len;
pDescr += len;
UEP0_T_LEN = len;
UEP0_CTRL ^= bUEP_T_TOG; //同步标志位翻转
break;
case USB_SET_ADDRESS:
USB_DEV_AD = USB_DEV_AD & bUDA_GP_BIT | SetupLen;
UEP0_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
break;
default:
UEP0_T_LEN = 0; //状态阶段完成中断或者是强制上传0长度数据包结束控制传输
UEP0_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
break;
}
break;
case UIS_TOKEN_OUT_EP0: // endpoint0 OUT
len = USB_RX_LEN;
if (SetupReq == 0x20) //设置串口属性
{
if (U_TOG_OK)
{
memcpy(LineCoding, UsbSetupBuf, USB_RX_LEN);
// Config_Uart0(LineCoding);
UEP0_T_LEN = 0;
UEP0_CTRL |= UEP_R_RES_ACK | UEP_T_RES_ACK; // 准备上传0包
}
}
else
{
UEP0_T_LEN = 0;
UEP0_CTRL |= UEP_R_RES_ACK | UEP_T_RES_NAK; //状态阶段,对IN响应NAK
}
UEP0_CTRL ^= bUEP_R_TOG; //同步标志位翻转
break;
case UIS_TOKEN_SETUP_EP0: // SETUP事务
len = USB_RX_LEN;
if (len == (sizeof(USB_SETUP_REQ)))
{
SetupLen = UsbSetupBuf->wLengthL;
if (UsbSetupBuf->wLengthH)
SetupLen = 0xFF; // 限制总长度
len = 0; // 默认为成功并且上传0长度
SetupReq = UsbSetupBuf->bRequest;
switch (UsbSetupBuf->bRequestType & USB_REQ_TYP_MASK)
{
case USB_REQ_TYP_STANDARD:
switch (SetupReq) //请求码
{
case USB_GET_DESCRIPTOR:
switch (UsbSetupBuf->wValueH)
{
case USB_DESCR_TYP_DEVICE: //设备描述符
pDescr = DevDesc; //把设备描述符送到要发送的缓冲区
len = sizeof(DevDesc);
break;
case USB_DESCR_TYP_CONFIG: //配置描述符
pDescr = CfgDesc; //把设备描述符送到要发送的缓冲区
len = sizeof(CfgDesc);
break;
case USB_DESCR_TYP_STRING: // 字符串描述符
switch (UsbSetupBuf->wValueL)
{
case 0:
pDescr = (PUINT8)(&LangDescr[0]);
len = sizeof(LangDescr);
break;
case 1:
pDescr = (PUINT8)(&ManuInfo[0]);
len = sizeof(ManuInfo);
break;
case 2:
pDescr = (PUINT8)(&ProdInfo[0]);
len = sizeof(ProdInfo);
break;
case 3:
pDescr = (PUINT8)(&SerNumber[0]);
len = sizeof(SerNumber);
break;
case 4:
pDescr = (PUINT8)(&DAPInfo[0]);
len = sizeof(DAPInfo);
break;
case 5:
pDescr = (PUINT8)(&CDCInfo[0]);
len = sizeof(CDCInfo);
break;
default:
len = 0xFF; // 不支持的字符串描述符
break;
}
break;
case USB_DESCR_TYP_BOS:
pDescr = (PUINT8)(&BOSDesc[0]);
len = sizeof(BOSDesc);
break;
default:
len = 0xff; //不支持的命令或者出错
break;
}
break;
case USB_SET_ADDRESS:
SetupLen = UsbSetupBuf->wValueL; //暂存USB设备地址
break;
case USB_GET_CONFIGURATION:
Ep0Buffer[0] = UsbConfig;
if (SetupLen >= 1)
{
len = 1;
}
break;
case USB_SET_CONFIGURATION:
UsbConfig = UsbSetupBuf->wValueL;
if (UsbConfig)
{
Ready = 1; // set config命令一般代表usb枚举完成的标志
}
break;
case 0x0A:
break;
case USB_CLEAR_FEATURE: // Clear Feature
if ((UsbSetupBuf->bRequestType & USB_REQ_RECIP_MASK) == USB_REQ_RECIP_ENDP) // 端点
{
switch (UsbSetupBuf->wIndexL)
{
case 0x81:
UEP1_CTRL = UEP1_CTRL & ~(bUEP_T_TOG | MASK_UEP_T_RES) | UEP_T_RES_NAK;
break;
case 0x01:
UEP1_CTRL = UEP1_CTRL & ~(bUEP_R_TOG | MASK_UEP_R_RES) | UEP_R_RES_ACK;
break;
case 0x82:
UEP2_CTRL = UEP2_CTRL & ~(bUEP_T_TOG | MASK_UEP_T_RES) | UEP_T_RES_NAK;
break;
case 0x02:
UEP2_CTRL = UEP2_CTRL & ~(bUEP_R_TOG | MASK_UEP_R_RES) | UEP_R_RES_ACK;
break;
case 0x84:
UEP4_CTRL = UEP4_CTRL & ~(bUEP_R_TOG | MASK_UEP_T_RES) | UEP_T_RES_NAK;
break;
default:
len = 0xFF; // 不支持的端点
break;
}
}
else
{
len = 0xFF; // 不是端点不支持
}
break;
case USB_SET_FEATURE: /* Set Feature */
if ((UsbSetupBuf->bRequestType & 0x1F) == 0x00) /* 设置设备 */
{
if ((((UINT16)UsbSetupBuf->wValueH << 8) | UsbSetupBuf->wValueL) == 0x01)
{
if (CfgDesc[7] & 0x20)
{
/* 设置唤醒使能标志 */
}
else
{
len = 0xFF; /* 操作失败 */
}
}
else
{
len = 0xFF; /* 操作失败 */
}
}
else if ((UsbSetupBuf->bRequestType & 0x1F) == 0x02) /* 设置端点 */
{
if ((((UINT16)UsbSetupBuf->wValueH << 8) | UsbSetupBuf->wValueL) == 0x00)
{
switch (((UINT16)UsbSetupBuf->wIndexH << 8) | UsbSetupBuf->wIndexL)
{
case 0x81:
UEP1_CTRL = UEP1_CTRL & (~bUEP_T_TOG) | UEP_T_RES_STALL; /* 设置端点1 IN STALL */
break;
case 0x01:
UEP1_CTRL = UEP1_CTRL & (~bUEP_R_TOG) | UEP_R_RES_STALL; /* 设置端点1 OUT STALL */
break;
case 0x82:
UEP2_CTRL = UEP2_CTRL & (~bUEP_T_TOG) | UEP_T_RES_STALL; /* 设置端点2 IN STALL */
break;
case 0x02:
UEP2_CTRL = UEP2_CTRL & (~bUEP_R_TOG) | UEP_R_RES_STALL; /* 设置端点2 OUT STALL */
break;
case 0x84:
UEP4_CTRL = UEP4_CTRL & (~bUEP_T_TOG) | UEP_T_RES_STALL; /* 设置端点3 IN STALL */
break;
default:
len = 0xFF; /* 操作失败 */
break;
}
}
else
{
len = 0xFF; /* 操作失败 */
}
}
else
{
len = 0xFF; /* 操作失败 */
}
break;
case USB_GET_STATUS:
pDescr = (PUINT8)&USB_STATUS;
if (SetupLen >= 2)
{
len = 2;
}
else
{
len = SetupLen;
}
break;
default:
len = 0xff; //操作失败
break;
}
break;
case USB_REQ_TYP_CLASS: /*HID类命令*/
if ((UsbSetupBuf->bRequestType & USB_REQ_RECIP_MASK) == USB_REQ_RECIP_INTERF)
{
switch (SetupReq)
{
case 0x01://GetReport
break;
case GET_LINE_CODING: //0x21 currently configured
pDescr = LineCoding;
len = sizeof(LineCoding);
break;
case SET_CONTROL_LINE_STATE: //0x22 generates RS-232/V.24 style control signals
break;
case SET_LINE_CODING: //0x20 Configure
break;
default:
len = 0xFF; /*命令不支持*/
break;
}
}
break;
case USB_REQ_TYP_VENDOR:
if ((UsbSetupBuf->bRequestType & USB_REQ_RECIP_MASK) == USB_REQ_RECIP_DEVICE)
{
switch (SetupReq)
{
case 0x20: // GetReport
if (UsbSetupBuf->wIndexL == 0x07)
{
pDescr = WINDesc; //把设备描述符送到要发送的缓冲区
len = sizeof(WINDesc);
}
break;
default:
len = 0xFF; /*命令不支持*/
break;
}
}
break;
default:
len = 0xFF;
break;
}
if (len != 0 && len != 0xFF)
{
if (SetupLen > len)
{
SetupLen = len; //限制总长度
}
len = SetupLen >= THIS_ENDP0_SIZE ? THIS_ENDP0_SIZE : SetupLen; //本次传输长度
memcpy(Ep0Buffer, pDescr, len); //加载上传数据
SetupLen -= len;
pDescr += len;
}
}
else
{
len = 0xff; //包长度错误
}
if (len == 0xff)
{
SetupReq = 0xFF;
UEP0_CTRL = bUEP_R_TOG | bUEP_T_TOG | UEP_R_RES_STALL | UEP_T_RES_STALL; // STALL
}
else if (len <= THIS_ENDP0_SIZE) //上传数据或者状态阶段返回0长度包
{
UEP0_T_LEN = len;
UEP0_CTRL = bUEP_R_TOG | bUEP_T_TOG | UEP_R_RES_ACK | UEP_T_RES_ACK; //默认数据包是DATA1,返回应答ACK
}
else
{
UEP0_T_LEN = 0; //虽然尚未到状态阶段,但是提前预置上传0长度数据包以防主机提前进入状态阶段
UEP0_CTRL = bUEP_R_TOG | bUEP_T_TOG | UEP_R_RES_ACK | UEP_T_RES_ACK; //默认数据包是DATA1,返回应答ACK
}
break;
default:
break;
}
UIF_TRANSFER = 0; //写0清空中断
}
if (UIF_BUS_RST) //设备模式USB总线复位中断
{
UEP0_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
UEP1_CTRL = bUEP_AUTO_TOG | UEP_R_RES_ACK | UEP_T_RES_NAK;
UEP2_CTRL = bUEP_AUTO_TOG | UEP_R_RES_ACK | UEP_T_RES_NAK;
UEP4_CTRL = bUEP_AUTO_TOG | UEP_R_RES_ACK | UEP_T_RES_NAK;
USB_DEV_AD = 0x00;
UIF_SUSPEND = 0;
UIF_TRANSFER = 0;
UIF_BUS_RST = 0; //清中断标志
}
if (UIF_SUSPEND) // USB总线挂起/唤醒完成
{
UIF_SUSPEND = 0;
if (USB_MIS_ST & bUMS_SUSPEND) //挂起
{
}
}
else
{
//意外的中断,不可能发生的情况
USB_INT_FG = 0xFF; //清中断标志
}
}
您好。
贴上来的代码看起来不太方便,可以直接给出C文件,大致看到有几点需要注意一下:
1,此处的发送总长度现在应该是不需要的,可以去除
if (UsbSetupBuf->wLengthH)
SetupLen = 0xFF; // 限制总长度
2,此处从软件抓包看好像没有回正确的数据,检查代码是否对这个请求做处理
44.0 CTL 80 00 00 00 00 00 02 00 GET STATUS 36.1.0
44.0 NTSTS c00000bb not supported 36.2.0
3,软件抓包好像抓到了很多设备。确定一下问题设备是哪个,只抓这个设备的包
4,您的描述中,烧录完成不能正常枚举(此处尽量抓不能正常枚举时候的包),手动外部复位后正常,从这个描述大概方向是烧录完成的枚举包和手动复位的枚举流程不一样,烧录完成后的枚举流程或许多了一些命令,程序中没有处理导致程序异常等,但复位后流程上的包都回了。
应该是定位到原因了 我原先配置的是供电5v的情况下 使用外部24mhz晶振 且主频配置到24mhz 片子是vdd接usb5v 使用内部晶振到16mhz一切正常,使用外部晶振或者使用内部24mhz就会出现枚举失败
您好,CH552在5V供电下使用24M主频是可以使用的。需要确保的是供电稳且大于4.4V,使用外部晶振可以用示波器查看晶振是否起振,如果还是没有找到问题,可以将问题发送至邮箱:dxy@wch.cn