IRSensor.c

 

void initIRSensing(void)

            Turn on timer system to allow input capture

            Set pre-scale to  /1 = 24.0MHz

            Set to capture falling edges

            Clear interrupt flag

            Enable interrupt

            Globally enable interrupts

            Make sure 1 ms timer is running

            Set lastReadTime to current [ms] time

 

void interrupt _Vec_tim1ch4 IRSensorICRoutine(void)

            Set timeoutTime to current time [ms]

            Record period of time since last edge as uPeriod

            Clear flag

 

char isAlignedWithBeacon(void)

            If uPeriod is within a calibrated range of values

                        Return True

            Else

                        Return False