cherry-embedded / CherryUSB

CherryUSB is a tiny and portable USB Stack (device & host) for embedded system with USB IP
https://cherryusb.readthedocs.io/
Apache License 2.0
1.14k stars 245 forks source link

WBVAL & DBVAL #169

Closed wyl2008056 closed 5 months ago

wyl2008056 commented 5 months ago

usb_util.h文件中,如下两个宏定义有bug,需要对x添加括号,182~183行

define WBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF)

define DBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF), ((x >> 16) & 0xFF), ((x >> 24) & 0xFF)

修改如下:

define WBVAL(x) ((x) & 0xFF), (((x) >> 8) & 0xFF)

define DBVAL(x) ((x) & 0xFF), (((x) >> 8) & 0xFF), (((x) >> 16) & 0xFF), (((x) >> 24) & 0xFF)

sakumisu commented 5 months ago

不需要修改,没有问题。

sakumisu commented 5 months ago

这都用了2年了多了,写法不存在问题

sakumisu commented 5 months ago

你可以github上随便找这些code,有加的有不加的,没有影响的

sakumisu commented 5 months ago

如果你的x不是一个值而是表达式,这边是有问题的,但是我这边禁止使用表达式