Declare Schedule variable volatile

This commit is contained in:
Josh Stewart 2013-09-08 20:01:47 +10:00
parent 2e761c5d95
commit 8bfa4e29f3
2 changed files with 7 additions and 4 deletions

View File

@ -35,8 +35,8 @@ void setIgnitionSchedule2(void (*startCallback)(), unsigned long timeout, unsign
enum ScheduleStatus {OFF, PENDING, RUNNING}; //The 3 statuses that a schedule can have
struct Schedule {
unsigned long duration;
ScheduleStatus Status;
volatile unsigned long duration;
volatile ScheduleStatus Status;
void (*StartCallback)(); //Start Callback function for schedule
void (*EndCallback)(); //Start Callback function for schedule
};

View File

@ -91,10 +91,13 @@ void setIgnitionSchedule2(void (*startCallback)(), unsigned long timeout, unsign
TIMSK5 |= (1 << OCIE5B); //Turn on the A compare unit (ie turn on the interrupt)
}
//Timer3A (fuel schedule 1) Compare Vector
//This function gets called when either the start time or the duration time are reached
//This function (All 4 ISR functions that are below) gets called when either the start time or the duration time are reached
//This calls the relevant callback function (startCallback or endCallback) depending on the status of the schedule.
//If the startCallback function is called, we put the scheduler into RUNNING state
//Timer3A (fuel schedule 1) Compare Vector
ISR(TIMER3_COMPA_vect) //fuelSchedule1
{
if (fuelSchedule1.Status == PENDING) //Check to see if this schedule is turn on