CH554例程: 【EXAM_键盘鼠标多媒体自定义HID\USB\Devie\CompositeKM.C】文件中的 Fullspeed全速或低速的选择,是不是搞反了?请看下面的代码
#define Fullspeed 1
#ifdef Fullspeed
#define THIS_ENDP0_SIZE 64
#else
#define THIS_ENDP0_SIZE 8 //低速USB,中断传输、控制传输最大包长度为8
#endif
#ifdef Fullspeed
0x07,0x05,0x84,0x03,THIS_ENDP0_SIZE,0x00,0x01, //端点描述符(全速间隔时间改成1ms)
0x07,0x05,0x04,0x03,THIS_ENDP0_SIZE,0x00,0x01, //端点描述符
#else
0x07,0x05,0x84,0x03,THIS_ENDP0_SIZE,0x00,0x0A, //端点描述符(低速间隔时间最小10ms)
0x07,0x05,0x04,0x03,THIS_ENDP0_SIZE,0x00,0x0A //端点描述符
#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; // 先设定USB设备模式
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模式,默认方式
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