我利用CH375做模拟主机,首先通过set_report();控制led亮灭,然后get_int_in()后,枚举成功, 但是我想实时控制led的亮灭,但是当我检测到键盘敲击了大小写切换键之后,在调用set_report()函数之后,程序卡在这个函数的status=wait_interrupt()中,此时我已经关闭中断了,所以我想知道我如何实现键盘的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数据总是8字节 */ 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)/* 状态阶段操作成功 */ { if(rd_usb_data(data_buf)!=0) return(0); } else return(0); } else return(0); } else return(0);
return(1); }