ReadPages(buf, TEST_BASE / PAGE_SIZE, TEST_PAGES);
isErr = 0;
for(i=0;i<TEST_PAGES*PAGE_SIZE;i++)
{
if(buf != 0xFF)
{
isErr = 1;
break;
}
}
buf(in)处的比对是与0xFF进行比对
几乎同样的例子,在Nano120的范例(....StdDriver\USBD_HID_Transfer\WindowsTool....)是
for(i = 0; i < TEST_PAGES * PAGE_SIZE; i++)
buf = i & 0xFF;
WritePages(buf, TEST_BASE / PAGE_SIZE, TEST_PAGES);
memset(buf, 0xCC, TEST_PAGES * PAGE_SIZE);
ReadPages(buf, TEST_BASE / PAGE_SIZE, TEST_PAGES);
isErr = 0;
for(i = 0; i < TEST_PAGES * PAGE_SIZE; i++)
{
if(buf != (i & 0xFF))
{
isErr = 1;
break;
}
} 作者: admin 时间: 2021-4-6 10:27
是根据MCU例程代码里IN 令牌后发,MCU发送出去的数据决定的
if(g_u32BytesInPageBuf == 0)
{
/* The previous page has sent out. Read new page to page buffer */
/* TODO: We should update new page data here. (0xFF is used in this sample code) */
printf("Reading page %d\n", u32StartPage + u32PageCnt);
for(i=0; i<PAGE_SIZE; i++)
g_u8PageBuff = 0xFF;
g_u32BytesInPageBuf = PAGE_SIZE;
/* Update the page counter */
u32PageCnt++;
}
/* Prepare the data for next HID IN transfer */
len = Minimum(g_u32EpAMaxPacketSize, g_u32BytesInPageBuf);
for (i=0; i<len; i++)
HSUSBD->EP[EPA].EPDAT_BYTE = g_u8PageBuff[PAGE_SIZE - g_u32BytesInPageBuf];
HSUSBD->EP[EPA].EPTXCNT = len;
HSUSBD_ENABLE_EP_INT(EPA, HSUSBD_EPINTEN_INTKIEN_Msk);
g_u32BytesInPageBuf -= len;