/**************************************************************************** Module Angels_IRDetectModule.c Revision 1.0.1 Description This is a file for implementing flat state machines under the Gen2 Events and Services Framework. Notes History When Who What/Why -------------- --- -------- 01/15/12 11:12 jec revisions for Gen2 framework 11/07/11 11:26 jec made the queue static 10/30/11 17:59 jec fixed references to CurrentEvent in RunMotorSM() 10/23/11 18:20 jec began conversion from SMTMotor.c (02/20/07 rev) ****************************************************************************/ /**************************************************************************** Function initBeaconDetectors Takes nothing Returns nothing ****************************************************************************/ Enable interrupt timers Set Timer Rate for Prescale to 15 to give 1.5MHz Initialize the pin for the left phototransistor Initialize the pin for the right phototransistor Set timer 0, channel 5 to interrupt on a leading edge only Set timer 0, channel 6 to interupt on a falling edge only Enable input captures on timer 0, channel 5 Enable input captures on timer 0, channel 6 Enable interrupts End of initBeaconDetectors /**************************************************************************** Function interrupt _Vec_tim0ch5 RespondLeftIR Takes nothing Returns nothing ****************************************************************************/ Calculate the current period picked in the left phototransistor Convert that value into uS Save the current period value Reset the timer0, channel 5 flag End of interrupt _Vec_tim0ch5 RespondLeftIR /**************************************************************************** Function interrupt _Vec_tim0ch6 RespondRightIR Takes nothing Returns nothing ****************************************************************************/ Calculate the current period picked in the right phototransistor Convert that value into uS Save the current period value Reset the timer0, channel 6 flag End of interrupt _Vec_tim0ch6 RespondRightIR /**************************************************************************** Function RightFreq Takes nothing Returns float ****************************************************************************/ Return calculated frequency from the right period End of RightFreq /**************************************************************************** Function LeftFreq Takes nothing Returns float ****************************************************************************/ Return calculated frequency from the left period End of LeftFreq /**************************************************************************** Function RightPeriod_uS Takes nothing Returns unsigned int ****************************************************************************/ Return the variable holding the right period in uS End of RightPeriod_uS /**************************************************************************** Function LeftPeriod_uS Takes nothing Returns unsigned int ****************************************************************************/ Return the variable holding the left period in uS End of LeftPeriod_uS