CH375發(fā)送token一直返回0長度數(shù)據(jù)包

最近在使用CH376,單片機為cortex-m3的arm單片機,想試圖讀取超出64Bytes的config desc,參考了官方的

SETUP_Transfer函數(shù),但一直是失敗的,

麻煩各位dalao能不能看看有什么問題

unsigned?short?MeUsb::SETUP_Transfer(?unsigned?char?*DataBuf,?int?*plen)
{
??printf("%s:%d\r\n",?__func__,?__LINE__);
??unsigned?char??l,?s;
??unsigned?short?req_len,?real_len?=?0;
??unsigned?char?*p?=?DataBuf;
??endp7_mode?=?0x80;?//DATA0發(fā)送器
??endp6_mode?=?0xc0;?//DATA1接收器
??req_len?=?(unsigned?short?int)Request.Req.wLength;

??/*?SETUP階段?*/
??wr_usb_data(8,?Request.Req_buf);
??toggle_send();
??s?=?issue_token((0?<<?4)?|?DEF_USB_PID_SETUP?);
??if?(s?!=?USB_INT_SUCCESS)
??{
????return?(0);
??}
??/*?DATA階段?*/
??if?(Request.Req_buf[0]?&?0x80)?//IN數(shù)據(jù)
??{
????printf("%s:%d\r\n",?__func__,?__LINE__);
????while?(req_len)
????{
??????printf("%s:%d\r\n",?__func__,?__LINE__);
??????toggle_recv();
??????s?=?issue_token((0?<<?4)?|?DEF_USB_PID_IN);
??????if?(?s?==?USB_INT_SUCCESS?)
??????{
????????printf("%s:%d\r\n",?__func__,?__LINE__);
????????l?=?rd_usb_data(?p?);
????????real_len?+=?l;
????????if?(?l?<?max_package?)?//短包
????????{
??????????break;
????????}
????????p?+=?l;
????????req_len?-=?l;
??????}
??????else?return?(0);
????}
??}
??else??????????????//OUT數(shù)據(jù)
??{
????printf("%s:%d\r\n",?__func__,?__LINE__);
????while?(req_len)
????{
??????printf("%s:%d\r\n",?__func__,?__LINE__);
??????l?=?(req_len?>?max_package)???max_package?:?req_len;
??????wr_usb_data(l,?p);
??????toggle_send();
??????s?=?issue_token((0?<<?4)?|?DEF_USB_PID_OUT);
??????if?(?s?==?USB_INT_SUCCESS?)
??????{
????????real_len?+=?l;
????????p?+=?l;
????????req_len?-=?l;
??????}
??????else?return?(0);
????}
??}

??/*?狀態(tài)階段?*/
??endp7_mode?=?endp6_mode?=?0xc0;?//DATA1
??if?(Request.Req_buf[0]?&?0x80)
??{
????wr_usb_data(0,?Request.Req_buf);
????toggle_send();
????s?=?issue_token((0?<<?4)?|?DEF_USB_PID_OUT);
??}
??else
??{
????toggle_recv();
????s?=?issue_token((0?<<?4)?|?DEF_USB_PID_IN);
??}
??if?(s?!=?USB_INT_SUCCESS)
??{
????return?(0);
??}

??*plen?=?real_len;
??return?(s);???//成功
}

串口通訊的數(shù)據(jù)是這樣的,不管是get config 還是get status到后面讀取數(shù)據(jù)都是0.,采用自帶的指令可以正常獲取到desc,但是最高只能到64bytes,有些鼠標鍵盤的desc已經(jīng)超過了64bytes了

>>57,AB

>>45

>>5

>>57,AB

>>22

<<14

>>57,AB

>>13

>>5

>>57,AB

>>22

<<14

usb wr:8

>>57,AB

>>2B

>>8

>>80

>>8

>>0

>>0

>>0

>>0

>>1

>>0

toggle send:80

>>57,AB

>>1D

>>80

>>57,AB

>>4F

>>D

issue token:D

>>57,AB

>>22

<<14

>>57,AB

>>1C

>>C0

toggle recv:C0

>>57,AB

>>4F

>>9

issue token:9

>>57,AB

>>22

<<14

>>57,AB

>>27

<<0


您好,您實際操作的是CH376嗎,如果是那應該調用的頭文件應該用CH376INC.H,您錯誤用成了CH375INC.H


只有登錄才能回復,可以選擇微信賬號登錄

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