Could someone who has set up ping pong before please go over the steps that I should take in order to change a non-ping pong device into one that uses ping pong?
When the bulk/interrupt endpoint is managed in polling,
0) Add a static flag, which indicates EVEN/ODD of the endpoint, on your firmware.
1) Poll the UOWN bit of BDnSTAT, indicated by your EVEN/ODD flag.
2) If UOWN shows core side (0), set up the BD and packet buffer as usual
3) Pass the BD to SIE by setting UOWN to SIE side (1). Also flip your EVEN/ODD flag.
4) Get back to polling 1)
For "ping-pong all EPs except for EP0" mode,
your firmware initializes your EVEN/ODD flag to EVEN, when the device receives Set_Configuration request. Also, reset ping-pong of SIE using UCON.PPBRST bit.
For completeness of USB spec compliance, we have to count in ping-pong initialize at Set_Interface and Clear_Feature( ENDPOINT_HALT ) requests. But if your application doesn't use these requests, you may leave them untouched.
When the endpoint is managed in hardware interrupt, your EVEN/ODD flag is also added and processed like above polling case.
To start IN transfer using hardware interrupt, the first and the second packets are passed to SIE outside of the endpoint ISR. The order of packet filling follows your EVEN/ODD flag. While filling the endpoint, USB interrupt is temporarily disabled.
The completion of an IN transaction sets UIR.TRNIF bit, and USB interrupt is evoked. In the endpoint ISR, your firmware reads out USTAT. If USTAT points your target endpoint, either EVEN or ODD, push the next packet to the endpoint, seeing your EVEN/ODD flag. And flip your EVEN/ODD flag. ie. the same process as above 2) and 3).
The point is, your EVEN/ODD flag, which is managed in your firmware.
post edited by chinzei - 2011/05/08 23:03:52