@Gallymimu, yep you're right. So here goes a couple questions I've encountered during the past few days of research. They all basically relate to operation of the USB subsystem of the PIC18F4550.
So the relevant datasheet says that endpoint Rx/Tx is controlled through the use of buffers described in the corresponding Buffer Descriptor entries (in the BDT). But it doesn't exactly specify, as far as I've found,
- When responding to an IN token, how to set which DATAx PID will the sent packet use
- And what exactly must you write to the buffer area (data package only? PID + DATA? PID + DATA + CRC?)
DATAx packet: SOF + PID + DATA + CRC + EOF
Actually, I guess point #1 is a subset of #2. Which is, after describing the buffer starting location and byte count to send, what do you actually write in the buffer? What makes the most sense is that you only write the actual DATA you want to send, since the rest are simple protocol structures which can be generated by the silicon. But it's not really stated
anywhere... and I don't have HW USB protocol analyzers, so I can't know what comes out of the PIC. And if you only write the DATA to be sent in the buffer, how do you specify which PID (DATA0/1) should the packet use? The only relevant bits I've found are DTS in the BDSTAT byte of the Buffer Descriptor, but it says very clearly that those bits are ignored when DTSEN = 0, and besides what sense does this make for an IN endpoint? It doesn't have to check
the bit, it has to set
Data toggle synchronization is enabled; data packets with incorrect Sync value will be ignored except for a SETUP transaction, which is accepted even if the data toggle bits do not match.
This bit is ignored unless DTSEN = 1.
So, it'd be great if someone who knows can answer this, otherwise I'll try and when I (hopefully) eventually find out I'll update this post with the answer.
Oh by the way, what I'm trying to accomplish is to recreate part of the control dashboard for an aircraft, switches that control subsystem state, operation mode, etc. Also rotary inputs for dials, trim wheels, etc. So it'll be a USB HID-class "joystick" device with a bunch of axis, a bunch of on-off button inputs and that's about it
If you're curious, you can find general info http://forums.eagle.ru/forumdisplay.php?f=101