My idea involved not disabling interrupts at all. It would look something like this:
Replace
with
And then add this line to all of your interrupt service routines:
That way, if the GC read gets interrupted, it just retries the read after the interrupt returns. This would allow interrupts to behave normally, as well as avoid garbage data being returned due to interrupted timing. Basically, rather than disabling interrupts, you simply delay the read until the interrupt has been serviced. Interrupts aren't sent from the Wiimote very often, so that shouldn't be a big deal.
Replace
Code:
noInterrupts();
GCPad_send(cmd, 3);
GCPad_recv(raw_joy_data, 64);
with
Code:
do {
GlobalFlagWasInterrupted = false;
GCPad_send(cmd, 3);
GCPad_recv(raw_joy_data, 64);
} while (GlobalFlagWasInterrupted == true);
And then add this line to all of your interrupt service routines:
Code:
EveryInterruptTriggeredFunction() {
GlobalFlagWasInterrupted = true;
//rest of function
}
That way, if the GC read gets interrupted, it just retries the read after the interrupt returns. This would allow interrupts to behave normally, as well as avoid garbage data being returned due to interrupted timing. Basically, rather than disabling interrupts, you simply delay the read until the interrupt has been serviced. Interrupts aren't sent from the Wiimote very often, so that shouldn't be a big deal.