void endp0_out(void) //终端点0输出中断处理
{
Last_Status.Register=read_last_status(0);
if(Last_Status.Status.setup_packet)
{
Control_Data.wLength=0;
Control_Data.wCount=0;
if(read_endpoint_buff(0,sizeof(Control_Data.DeviceRequest),(unsigned char *)(&(Control_Data.DeviceRequest)))!=sizeof(REQUESTCMD))read_endpoint_buff函数中当数据读完后执行了一个清除缓冲区操作,这个操作在‘应答建立’命令之前执行会有效吗?
{
set_endpoint_status(0,0);//初始化端点0,等待接收一个data0 pid
set_endpoint_status(1,0);
return;
}
Control_Data.DeviceRequest.wValue=SWAP(Control_Data.DeviceRequest.wValue);
Control_Data.DeviceRequest.wIndex=SWAP(Control_Data.DeviceRequest.wIndex);
Control_Data.DeviceRequest.wLength=SWAP(Control_Data.DeviceRequest.wLength);
ack_setup(0);这两个就是应答建立
ack_setup(1);
Control_Data.wLength=Control_Data.DeviceRequest.wLength;
usb_flags.flags.not_end=0;
usb_flags.flags.usb_endp0_in=1;
usb_flags.flags.setup_packet_in=0;
usb_flags.flags.setup_packet_out=0;
if(Control_Data.DeviceRequest.bmRequestType&0x80){usb_flags.flags.setup_packet_in=1;return;}
else {usb_flags.flags.setup_packet_out=1;return;}
}
else
{
select_endpoint(0);
clear_buffer();
}
}