It's not you.
I think there have been quite a few late, late nights at IFI getting this stuff ready, and you know there's always a bug in software. You just may not know what it is yet.
We changed this around to where it made sense as you have done.
We decided to go through Process_Data_From_Master_uP() to check switches like the competition bit, then do the branch to auto or driver code.
Ours looks like:
Code:
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{ /* I'm slow! I only execute every 26.2ms because */
/* that's how fast the Master uP gives me data. */
Getdata(&rxdata); /* Get fresh data from the master microprocessor. */
Process_Data_From_Master_uP(); /* Process switch/joystick changes */
if (autonomous_mode) /* DO NOT CHANGE! */
{
User_Autonomous_Code(); /* Autonomous drive controls */
}
else
{
User_Driver(); /* User driver controls */
}
Generate_Pwms(pwm13,pwm14,pwm15,pwm16); /* N/A for EDU */
Putdata(&txdata); /* DO NOT CHANGE! */
}
Process_Data_From_Local_IO();