cherry-embedded / CherryUSB

CherryUSB is a tiny, beautiful and portable USB host and device stack for embedded system with USB IP
https://cherryusb.readthedocs.io/
Apache License 2.0
1.21k stars 256 forks source link

fix(common/usb_def.h):fix SELF_POWERED define err. #228

Closed liuhy-2020 closed 1 month ago

liuhy-2020 commented 1 month ago

Configuration Descriptor的bmAttributes中: 1) 第6位是SELF_POWERED。 2) 第7位固定是1。

sakumisu commented 1 month ago

这边没有问题,必须包含第七位

sakumisu commented 1 month ago

因为用户不会自己主动去设置bit7,所以必须包含

liuhy-2020 commented 1 month ago

我看了一下现在的例子CherryUSB\demo,都包含了USB_CONFIG_BUS_POWERED。这个是第7位。

现在遇到的问题是:用户的第6位是0,第7位是1。还是被判为SELF_POWERED。

sakumisu commented 1 month ago

USB 分析仪上是没问题的,解析就是 bus powered

sakumisu commented 1 month ago

image

sakumisu commented 1 month ago

如果你是用其他工具发送了 get_status,usbd_core 中 USB_CONFIG_SELF_POWERED 修改为 USB_CONFIG_POWERED_MASK即可,这边判断有误

liuhy-2020 commented 1 month ago

嗯,就是get_status时,报错:USB设备状态和USB描述符不一致。

sakumisu commented 1 month ago

已经fix

liuhy-2020 commented 1 month ago

好的