I can send a report for each of the players individually, like so.
Code: Select all
if (TCNT0 > 47) //47 == 4ms approx
{
if (usbInterruptIsReady())
{
// this works fine, but only send a report for player 1
buildReport(&gamepads[0], reportBuffer);
usbSetInterrupt(reportBuffer, REPORT_SIZE);
}
}
But I cannot send both reports squentially, I found some example code at http://www.raphnet.net/electronique/2ne ... dex_en.php which I've used to template this, but it doesn't work for me. Reference the following code sample, after usbSetInterrupt() is called, the code enters a loop waiting for the buffer to clear so we can set another interrupt, but the code gets stuck in this loop and never returns.
Someone help please! Programmer in peril.
Code: Select all
if (TCNT0 > 47) //47 == 4ms approx
{
TCNT0 = 0;
for (gp = 0; gp < NUM_GAMEPADS; gp++)
{
buildReport(&gamepads[gp], reportBuffer);
if (usbInterruptIsReady())
{
usbSetInterrupt(reportBuffer, REPORT_SIZE);
while (!usbInterruptIsReady())
{
// code hangs in this loop
usbPoll();
wdt_reset();
// when uncommented, this toggles furiously!
//toggle_pin();
}
}
}
// never see this toggled
toggle_pin();
}
Thanks for your time
--Mike