Thank you very much fo help Jan!
Now i can read and write data, but...
... there are strange things.
1. Host sends PID IN every 32ms,
0x07,//EP descr
0x05,// bDescriptorType (EP)
0x81,//ep address and direction addr=1 dir=IN
0x03,//bmAttributes
0x0A,// MaxPacketSize (low)//old 2
0x00,// MaxPacketSize (hi)
50,// bInterval
But i specify 50.
2. On receive a FW of MCU switch contain of IN packet's.
if ((answ&0xFF)==0x31) {
*((int*)0x400060A0)=0x1234; //will be sended to host
}
else {
*((int*)0x400060A0)=0x5678; //will be sended to host
}
0x400060A0 - address of transmitter buffer
Number of bytes for transmit:
COUNT1TX=2;
Algorithm at host side:
Writefile(0x31)
Readfile()
Writefile(0x30)
Readfile()
First I write 0x31 to device and next read from device. I must receive 0x1234. But i receive 0x5678;
According when i write 0x30 to device and next read from device. I must receive 0x5678. But i receive 0x1237; Reversed data?
But, when I insert dummy read:
Why i must use dummy Read?
Writefile(0x31)
Readfile()//dummy read
Readfile()
Writefile(0x30)
Readfile()
seems all right.
I think that's wrong way. Maybe RX USB buffer in host side is overflow and can't receive new data?