CH573 USB Device 怎么分包發(fā)送 descriptor

由于我需要傳 BOS Descriptor 的內(nèi)容,Microsoft OS 2.0 descriptor 長(zhǎng)達(dá) 178 字節(jié),但是我每次只能發(fā)送 64字節(jié)

我參考了官方示例的 USB 中斷處理函數(shù),其中

??????else
??????{
????????if?(?chtype?&?0x80?)?????//?上傳
????????{
??????????len?=?(?SetupReqLen?>?DevEP0SIZE?)??
??????????????DevEP0SIZE?:?SetupReqLen;
??????????SetupReqLen?-=?len;
????????}
????????else
??????????len?=?0;????????//?下傳
????????R8_UEP0_T_LEN?=?len;
????????R8_UEP0_CTRL?=?RB_UEP_R_TOG?|?RB_UEP_T_TOG?|?UEP_R_RES_ACK?|?UEP_T_RES_ACK;????//?默認(rèn)數(shù)據(jù)包是DATA1
??????}

這里會(huì)將 len 設(shè)置成 64 (DevEp0Size),期望的是 Host 繼續(xù)發(fā)同樣的請(qǐng)求,并且?pSetupReqPak->wLength 為 178 - 64,但這并沒有發(fā)生,我這里是不是做錯(cuò)了,需要怎么分包發(fā)送呢?

m.findthetime.net/bbs/thread-67066-1.html

你好,可以參考上面的網(wǎng)頁例程demo,里面有涉及到分包發(fā)送的處理。


在端點(diǎn)0 的in會(huì)繼續(xù)發(fā)送吧 直到發(fā)完


@xph 好像不行把,Ep0 USB FS 最大packet好像只能 64B


您好,麻煩請(qǐng)幫我看一下這么發(fā)送的結(jié)果對(duì)嘛?Windows 上似乎仍然沒法正確獲得描述符


image.png


下面這個(gè)是USB協(xié)議分析儀sniff出來的結(jié)果

image.png

//?待發(fā)送內(nèi)容
const?uint8_t?msOS20Descriptor[]?=?{
????//?Microsoft?OS?2.0?descriptor?set?header?(table?10)
????0x0A,?0x00,?????????????//?Descriptor?size?(10?bytes)
????0x00,?0x00,?????????????//?MS?OS?2.0?descriptor?set?header
????0x00,?0x00,?0x03,?0x06,?//?Windows?version?(8.1)?(0x06030000)
????0xB2,?0x00,??????//?Size,?MS?OS?2.0?descriptor?set

????//?Microsoft?OS?2.0?configuration?subset?header
????0x08,?0x00,?????????????//?wLength
????0x01,?0x00,?????????????//?wDescriptionTypes
????0x00,???????????????????//?bConfigurationValue,?????Applies?to?configuration?1?(indexed?from?0?despite?configurations?normally?indexed?from?1)
????0x00,???????????????????//?Reserved
????0xA8,?0x00,?//?Size,?MS?OS?2.0?function?subset

????//?Microsoft?OS?2.0?function?subset?header
????0x08,?0x00,?????????????//?Descriptor?size?(8?bytes)
????0x02,?0x00,?????????????//?MS?OS?2.0?function?subset?header
????0x01,???????????????????//?first?interface?no;?msOS20Descriptor[14]
????0x00,???????????????????//?Reserved
????0xA0,?0x00,?//?Size,?MS?OS?2.0?function?subset

????//?Microsoft?OS?2.0?compatible?ID?descriptor?(table?13)
????0x14,?0x00,?????????????????????//?wLength
????0x03,?0x00,???????????????????//?MS_OS_20_FEATURE_COMPATIBLE_ID
????'W',?'I',?'N',?'U',?'S',?'B',?//
????0x00,?0x00,?0x00,?0x00,?0x00,?0x00,?0x00,?0x00,?0x00,?0x00,

????//?interface?guids
????0x84,?0x00,?//?Size?of?this?descriptor
????0x04,?0x00,?//Registry?property?descriptor
????0x07,?0x00,?//REG_MULTI_SZ
????//
????0x2A,?0,?//?Length?of?the?property?name

????//?Property?name?with?null?terminator?encoded?in?UTF-16LE
????'D',?0,?'e',?0,?'v',?0,?'i',?0,?'c',?0,?'e',?0,?'I',?0,?'n',?0,?'t',?0,?'e',?0,?'r',?0,?'f',?0,
????'a',?0,?'c',?0,?'e',?0,?'G',?0,?'U',?0,?'I',?0,?'D',?0,?'s',?0,?0,?0,
????//?Length?of?the?property?value
????0x50,?0,
????//
????'{',?0,?'9',?0,?'2',?0,?'C',?0,?'E',?0,?'6',?0,?'4',?0,?'6',?0,?'2',?0,?'-',?0,?'9',?0,?'C',?0,
????'7',?0,?'7',?0,?'-',?0,?'4',?0,?'6',?0,?'F',?0,?'E',?0,?'-',?0,?'9',?0,?'3',?0,?'3',?0,?'B',?0,
????'-',?0,?'3',?0,?'1',?0,?'C',?0,?'B',?0,?'9',?0,?'C',?0,?'5',?0,?'A',?0,?'A',?0,?'3',?0,?'B',?0,
????'B',?0,?'}',?0,?0,?0,?0,?0};
????
void?USBDevice_EP0_Send_Packet(uint8_t*?data,?uint16_t?len)?{
????uint16_t?len_left?=?len;
????uint8_t*?pData?=?data;
????uint16_t?send_len;

????while?(len_left)?{
????????if?(R8_USB_INT_FG?&?RB_UIF_TRANSFER)?{
????????????//?TX?RES?發(fā)送?NAK
????????????R8_UEP0_CTRL?=?RB_UEP_R_TOG?|?RB_UEP_T_TOG?|?UEP_R_RES_NAK?|?UEP_T_RES_NAK;

????????????send_len?=?len_left?>=?DevEP0SIZE??
????????????????DevEP0SIZE?:?len_left;????//?本次傳輸長(zhǎng)度
????????????memcpy(?pEP0_DataBuf,?pData,?send_len?);?/*?加載上傳數(shù)據(jù)?*/

????????????len_left?-=?send_len;
????????????pData?+=?send_len;

????????????R8_UEP0_T_LEN?=?send_len;

????????????R8_UEP0_CTRL?=?RB_UEP_R_TOG?|?RB_UEP_T_TOG?|?UEP_R_RES_ACK?|?UEP_T_RES_ACK;????//?默認(rèn)數(shù)據(jù)包是DATA1

????????????R8_USB_INT_FG?=?RB_UIF_TRANSFER;
????????}
????}

????while?(!(R8_USB_INT_FG?&?RB_UIF_TRANSFER));
????R8_UEP0_T_LEN?=?0;
????R8_UEP0_CTRL?^=?RB_UEP_T_TOG;

????R8_USB_INT_FG?=?RB_UIF_TRANSFER;

}

在中斷處理函數(shù)里收到 windows 發(fā)來要我發(fā)這個(gè) descriptor 的包的時(shí)候直接調(diào)用

USBDevice_EP0_Send_Packet(msOS20Descriptor,?178);



只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频