IDLE:
begin
//添加RESET状态
data_wr<='h0;//写数据初始化
ioRDY1_SLWRn<='b1;
ioRDY0_SLRDn<='b1; //USBFIFO 读
oPA2_SLOEn<='b1;
oPA4_FIFO0<='b1;
oPA5_FIFO1<='b1;
//这里选择的是EP8,参考上面的图片,其实无所谓,待会还重新设置。
oe<='b0;
FFlagA<='b0;
sram_d<='h0;
data_wr<='h0;
sram_a_i<='h1fff;
sram_a_o<='h1fff;
sram_rden<='b0;
sram_wren<='b0;
wr_flag<='b0;
datacnt<='h1fff;
STATE<=READ_EVENT;
End
进入下一个状态
READ_EVENT: //read from USB EP2
begin
wr_flag<='b1;
oPA4_FIFO0<='b0;
oPA5_FIFO1<='b0;
STATE<=POINT_TO_OUT_FIFO;
End
POINT_TO_OUT_FIFO: begin
if(ioCTL2_FLAGC) //not empty 也就是有数据可以读取
begin
oPA2_SLOEn<='b0;
ioRDY0_SLRDn<='b1;
STATE<=DATA_READY;
end
else
begin
oPA2_SLOEn<='b1;
ioRDY0_SLRDn<='b1;
STATE<=POINT_TO_OUT_FIFO;
end
end
然后进入数据准备好的状态
DATA_READY: //write SRAM 这里指的是读取USBFIFO,然后把读到的数据写到SRAM里面
begin
if(ioCTL2_FLAGC) //not empty
begin
PA2_SLOEn<='b0;//最好也把这句加上吧
ioRDY0_SLRDn<='b0;
sram_a_i<=sram_a_i+1;
sram_d<=ioUSB_D;
//这里是写数据到SRAM,所以SRAM地址使用了SRAM_A_I,在写之前加一,SRAM_WREN信号为1,使能写功能。
sram_wren<='b1;
sram_rden<='b0;
STATE<=READ;
end
else
begin
ioRDY0_SLRDn<='b1;
oPA2_SLOEn<='b1;
STATE<=POINT_TO_OUT_FIFO;
end
end
文章评论(0条评论)
登录后参与讨论