Module SensorLibrary.c Description This is a library for initialization and functions for sensors Notes Private definitions TicksPerMS BitsPerNibble TargetPeriodA TargetPeriodB TargetPeriodC TargetPeriodD FREQ_RESET_TIME CKH GHI TickCount LastCapture ThisCapture PeriodInTicks TeamStatus /*---------------------------- Module Functions ---------------------------*/ /* prototypes for private functions for this service.They should be functions relevant to the behavior of this service */ uint32_t QueryPeriod(void) //Return period of IR pulses void ResetPeriod(void) //Reset period of IR pulses void InterruptInit(void) //Enable clock to WT5 //Enable clock to port d //Disable timers A,B //Set up 32 bit mode //Use full 32 bit count //Set up timer A,B in capture mode //Set to capture rising edges //Set up port to do capture //Map alternate function //Enable pins on c for digital I/O //Make pins an input //Enable timer to a local capture interrupt //Enable timer A,B in wide timer interrupt in NVIC //Enable interrupts globally //Kick timers off void HWInit(void) //Enable port E //Wait for ready status of port //Write to digital enable register //Set data direction output //Set data direction input and enable pull down resistor //Set port to open drain //Set ports low //Read current team and turn on respective LED uint8_t MinerDetect(void) //Read miner IR detect state //Return hi or lo void TurnOnGreen(void) //Turn on green LED void TurnOnRed(void) //Turn on red LED void TurnOnBluevoid) //Turn on blue LED void TurnOffGreen(void) //Turn on green LED void TurnOffRed(void) //Turn on red LED void TurnOffBluevoid) //Turn on blue LED bool Check4Collision(void) //Check if limit switch status has changed //If input is hi //Post collision event //return true //return false uint8_t SwitchState(void) //Return state of the team LED switch void IR1ISR(void) //Clear source of interrupt //Init timer to reset IR period //Grab captured value //Update last capture //Set period uint8_t QueryTeam(void) //Return current team void SetTeam(uint8_t Team) //Set current team