Hi Brad -
Thanks for doing this. This is also a good example of showing that you can use the IFI headers in a WPILib program, something that's not so apparent on first glance.
Some questions:
- I think I understand what RegisterRepeatingTimer() does, although it is not really documented. The header file says that timer interrupt handlers are "called with interrupts disabled". However, do you not also need to disable interrupts when you access the shared globals in the main( ) routine?
- The variables "changed" and "previous" in your ISR don't seem to do anything? Again, I think I understand what you are trying to do (e.g. collect all the commands in between times that the program actually checks for them), but "previous" never gets set to anything other than zero, and "changed" is calculated, but then not used. Would it not be simpler to just say:
Code:
irCommands |= current;
and then the main() routine can turn off each bit as it gets processed? I think that's what the code is essentially doing now, since "previous" is always zero.