unsigned char get_descr_ex() { unsigned char descr_len; unsigned char *p=data_buf; endp7_mode=0x80;//unsigned char endp6_mode=0x80, endp7_mode=0x80;//同步標(biāo)志位初值 toggle_send(); wr_usb_data(8,Request.Req_buf);
issue_token(( 0 << 4 ) | DEF_USB_PID_SETUP);
status=wait_interrupt(); if(status==USB_INT_SUCCESS)/* SETUP階段操作成功 */ { endp6_mode=0xc0; toggle_recv(); } else return(0); issue_token(( 0 << 4 ) | DEF_USB_PID_IN);status=wait_interrupt(); if(status==USB_INT_SUCCESS)/* DATA階段操作成功 */ { if(flag_config_2)descr_len=data_buf[2]-rd_usb_data(data_buf); else descr_len=data_buf[0]-rd_usb_data(data_buf); while(descr_len>0) { toggle_recv(); p+=0x08; issue_token(( 0 << 4 ) | DEF_USB_PID_IN);status=wait_interrupt(); if(status==USB_INT_SUCCESS) /* DATA階段操作成功 */ descr_len-=rd_usb_data(p); else return(0);
} } else return(0); endp7_mode=0xc0; toggle_send(); wr_usb_data(0,Request.Req_buf); issue_token(( 0 << 4 ) | DEF_USB_PID_OUT);status=wait_interrupt(); if(status==USB_INT_SUCCESS)/* 狀態(tài)階段操作成功 */ return(1); else return(0); }
wr_usb_data(8,Request.Req_buf);的作用是什么 控制傳輸分為SETUP,DATA,狀態(tài)階段,wr_usb_data(8,Request.Req_buf);的作用貌似是 SETUP階段發(fā)送的8字節(jié)的請(qǐng)求命令,但它為什么會(huì)在 issue_token(( 0 << 4 ) | DEF_USB_PID_SETUP); 之前,命令包應(yīng)該是緊接著SETUP包發(fā)出去的才對(duì)啊,而且 wr_usb_data(8,Request.Req_buf);中Request.Req_buf的值沒有初始化,發(fā)送的是什么命令呢