我利用CH375做模擬主機(jī),首先通過set_report();控制led亮滅,然后get_int_in()后,枚舉成功, 但是我想實時控制led的亮滅,但是當(dāng)我檢測到鍵盤敲擊了大小寫切換鍵之后,在調(diào)用set_report()函數(shù)之后,程序卡在這個函數(shù)的status=wait_interrupt()中,此時我已經(jīng)關(guān)閉中斷了,所以我想知道我如何實現(xiàn)鍵盤的led實時控制的問題, void get_int_in() { endp6_mode=0x80; toggle_recv();endp_int=0x01; issue_token(( endp_int << 4 ) | DEF_USB_PID_IN);//status=wait_interrupt(); }
unsigned char set_report() { set_usb_mode( 6 ); Request.Req.bmRequestType=0x21; Request.Req.bRequest=0x09; Request.Req.wValue=0x0200; Request.Req.wIndex=0x0000; Request.Req.wLength=0x0001; endp7_mode=0x80; toggle_send(); wr_usb_data(8,Request.Req_buf);/* SETUP數(shù)據(jù)總是8字節(jié) */ issue_token(( 0 << 4 ) | DEF_USB_PID_SETUP); status=wait_interrupt(); if(status==USB_INT_SUCCESS)/* SETUP階段操作成功 */ { toggle_send(); Request.Req_buf[0]=ledState; wr_usb_data(1,Request.Req_buf); issue_token(( 0 << 4 ) | DEF_USB_PID_OUT);status=wait_interrupt(); if(status==USB_INT_SUCCESS) /* DATA階段操作成功 */ { endp6_mode=0xc0; toggle_recv(); issue_token(( 0 << 4 ) | DEF_USB_PID_IN);status=wait_interrupt(); if(status==USB_INT_SUCCESS)/* 狀態(tài)階段操作成功 */ { if(rd_usb_data(data_buf)!=0) return(0); } else return(0); } else return(0); } else return(0);
return(1); }