{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 #ifdef ENABLE_GTS_LEFT\par volatile long GTS_Left_Count;\par #endif\par \par #ifdef ENABLE_GTS_RIGHT\par volatile long GTS_Right_Count;\par #endif\par \par void Initialize_Team171(void)\par \{\par \tab GTS_Left_Count = 0;\par \tab GTS_Right_Count = 0;\par \tab Initialize_GTS();\par \}\par \par void Initialize_GTS(void) \par \{\par \tab // if enabled in encoder.h, configure encoder 1's interrupt input\par \tab #ifdef ENABLE_GTS_LEFT\par \par \tab // make sure interrupt 1 is configured as an input\par \tab TRISBbits.TRISB2 = 1;\par \par \tab // interrupt 1 is low priority\par \tab INTCON3bits.INT2IP = 0;\par \par \tab // trigger on rising edge\par \tab INTCON2bits.INTEDG2 = 1;\par \par \tab // make sure the interrupt flag is reset before enabling\par \tab INTCON3bits.INT2IF = 0;\par \par \tab // enable interrupt 1\par \tab INTCON3bits.INT2IE = 1;\par \tab #endif\par \par \tab // if enabled in encoder.h, configure encoder 2's interrupt input\par \tab #ifdef ENABLE_GTS_RIGHT\par \par \tab // make sure interrupt 2 is configured as an input\par \tab TRISBbits.TRISB3 = 1;\par \par \tab // interrupt 2 is low priority\par \tab INTCON2bits.INT3IP = 0;\par \par \tab // trigger on rising edge\par \tab INTCON2bits.INTEDG3 = 1;\par \par \tab // make sure the interrupt flag is reset before enabling\par \tab INTCON3bits.INT3IF = 0;\par \par \tab // enable interrupt 2\par \tab INTCON3bits.INT3IE = 1;\par \tab #endif\par \}\par \par \par #ifdef ENABLE_GTS_LEFT\par \par long Get_GTS_Left_Count(void)\par \{\par \tab long count;\par \par \tab // Disable\par \tab INTCON3bits.INT2IE = 0;\par \par \tab // Get Value\par \tab count = GTS_Left_Count;\par \par \tab // Enable\par \tab INTCON3bits.INT2IE = 1;\par \par \tab // Return the count\par \tab return(count);\par \}\par \par void Reset_GTS_Left_Count(void)\par \{\par \tab // Disable\par \tab INTCON3bits.INT2IE = 0;\par \par \tab // Reset\par \tab GTS_Left_Count = 0;\par \par \tab // Enable\par \tab INTCON3bits.INT2IE = 1;\par \}\par \par void GTS_Left_Handler(void)\par \{\par \tab GTS_Left_Count += 1;\par \}\par #endif\par \par #ifdef ENABLE_GTS_RIGHT\par \par long Get_GTS_Right_Count(void)\par \{\par \tab long count;\par \par \tab // Disable\par \tab INTCON3bits.INT3IE = 0;\par \par \tab // Get Value\par \tab count = GTS_Right_Count;\par \par \tab // Enable\par \tab INTCON3bits.INT3IE = 1;\par \par \tab // Return the count\par \tab return(count);\par \}\par \par void Reset_GTS_Right_Count(void)\par \{\par \tab // Disable\par \tab INTCON3bits.INT3IE = 0;\par \par \tab // Reset Count\par \tab GTS_Right_Count = 0;\par \par \tab // Enable\par \tab INTCON3bits.INT3IE = 1;\par \}\par \par void GTS_Right_Handler(void)\par \{\par \tab GTS_Right_Count += 1;\par \}\par #endif\par }