CH554例程: 【EXAM_鍵盤鼠標(biāo)多媒體自定義HID\USB\Devie\CompositeKM.C】文件中的 Fullspeed全速或低速的選擇,是不是搞反了?請(qǐng)看下面的代碼
#define Fullspeed?????????????? 1
#ifdef? Fullspeed
#define THIS_ENDP0_SIZE???????? 64
#else
#define THIS_ENDP0_SIZE???????? 8? //低速USB,中斷傳輸、控制傳輸最大包長(zhǎng)度為8
#endif
#ifdef? Fullspeed?
??? 0x07,0x05,0x84,0x03,THIS_ENDP0_SIZE,0x00,0x01,????????????? //端點(diǎn)描述符(全速間隔時(shí)間改成1ms)
??? 0x07,0x05,0x04,0x03,THIS_ENDP0_SIZE,0x00,0x01,????????????? //端點(diǎn)描述符
#else
??? 0x07,0x05,0x84,0x03,THIS_ENDP0_SIZE,0x00,0x0A,????????????? //端點(diǎn)描述符(低速間隔時(shí)間最小10ms)
??? 0x07,0x05,0x04,0x03,THIS_ENDP0_SIZE,0x00,0x0A????????????? //端點(diǎn)描述符
#endif?
void CH554USBDevWakeup( )
{
#ifdef Fullspeed
?UDEV_CTRL |= bUD_LOW_SPEED;
?mDelaymS(2);
?UDEV_CTRL &= ~bUD_LOW_SPEED;??
#else
?UDEV_CTRL &= ~bUD_LOW_SPEED;
?mDelaymS(2);
?UDEV_CTRL |= bUD_LOW_SPEED;?
#endif
}
?IE_USB = 0;
?USB_CTRL = 0x00;?????????????????????????????????????????????????????????? // 先設(shè)定USB設(shè)備模式
?UDEV_CTRL = bUD_PD_DIS;??????????????????????????????????????????????????? // 禁止DP/DM下拉電阻
#ifndef Fullspeed
??? UDEV_CTRL |= bUD_LOW_SPEED;??????????????????????????????????????????????? //選擇低速1.5M模式
??? USB_CTRL |= bUC_LOW_SPEED;
#else
??? UDEV_CTRL &= ~bUD_LOW_SPEED;?????????????????????????????????????????????? //選擇全速12M模式,默認(rèn)方式
??? USB_CTRL &= ~bUC_LOW_SPEED;
#endif
CH554.H中的定義:
#define bUD_LOW_SPEED???? 0x04????? // enable USB physical port low speed: 0=full speed, 1=low speed