芯片是51内核的,执行上面部分是正常的,但是将usbEp0Buffer的数据通过memcpy拷贝到结构体gUsbReqInfo中(即下面部分),usbEp0Buffer的数据会被改掉
#if 1
{
uint8_t bmRequestType;
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
int16_t wLength;
bmRequestType = usbEp0Buffer[0];
bRequest = usbEp0Buffer[1];
wValue = (uint16_t)usbEp0Buffer[3] << 8 | usbEp0Buffer[2];
wIndex = (uint16_t)usbEp0Buffer[5] << 8 | usbEp0Buffer[4];
wLength = (uint16_t)usbEp0Buffer[7] << 8 | usbEp0Buffer[6];
gUsbReqInfo.bmRequestType = bmRequestType;
gUsbReqInfo.bRequest = bRequest;
gUsbReqInfo.wValue = wValue;
gUsbReqInfo.wIndex = wIndex;
gUsbReqInfo.wLength = wLength;
}
#else
memcpy((uint8_t *)(&gUsbReqInfo), usbEp0Buffer, sizeof(gUsbReqInfo));
#endif
而且也试过将usbEp0Buffer直接赋值给gUsbReqInfo,也会有同样的问题。能想到的是应该是堆栈之类的影响?好久没玩过51内核的东西了,不知道怎么解决。
|