void ADC_0_ISR(void)
{
	unsigned int status;

    status = TSCADCIntStatus(SOC_ADC_TSC_0_REGS);

    if(status & TSCADC_END_OF_SEQUENCE_INT)
    {
         /* Read data from fifo 0 */
         Voltage.ADCCounts_VDD_5V0 	= TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);
         Voltage.ADCCounts_SYS_5V0 	= TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);
         Voltage.ADCCounts_VBAT 		= TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);
         Voltage.ADCCounts_VDD_3V3 	= TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);
         ADC_SetFinishedFlag();
    }

    TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS, status);
}
Example #2
0
/* Reads the data from FIFO 0 and FIFO 1 */
static void ADCIsr()
{
    volatile unsigned int status;

    status = TSCADCIntStatus(SOC_ADC_TSC_0_REGS);

    TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS, status);

    if(status & TSCADC_END_OF_SEQUENCE_INT)
    {
        /* Read data from fifo 0 */
        sample1 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);

        /* Read data from fif 1*/
        sample2 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_1);

        flag = 0;
    }
}
Example #3
0
static void TouchScreenIsr()
{
    unsigned int wordsLeft = 0;
    unsigned int status;
    unsigned int arr_x[5] = {0,0,0,0,0};
    unsigned int arr_y[5] = {0,0,0,0,0};
    unsigned int x_data = 0;
    unsigned int y_data = 0;
    unsigned int i = 0;
    unsigned int sum = 0;

    status = TSCADCIntStatus(TSC_ADC_INSTANCE);

    if(status & TSCADC_FIFO1_THRESHOLD_INT)
    {
         wordsLeft = TSCADCFIFOWordCountRead(TSC_ADC_INSTANCE, TSCADC_FIFO_0);

         while(wordsLeft)
         {
              x_data = TSCADCFIFOADCDataRead(TSC_ADC_INSTANCE, TSCADC_FIFO_0);

              arr_x[i++] = x_data;

              wordsLeft = TSCADCFIFOWordCountRead(TSC_ADC_INSTANCE, TSCADC_FIFO_0);
         }

         sum = arr_x[1] + arr_x[2] + arr_x[3];

         sum = sum / 3;

         x_data = sum;

         wordsLeft = TSCADCFIFOWordCountRead(TSC_ADC_INSTANCE, TSCADC_FIFO_1);

         i = 0;

         while(wordsLeft)
         {
              y_data = TSCADCFIFOADCDataRead(TSC_ADC_INSTANCE, TSCADC_FIFO_1);

              arr_y[i++] = y_data;

              wordsLeft = TSCADCFIFOWordCountRead(TSC_ADC_INSTANCE, TSCADC_FIFO_1);
         }

         sum = arr_y[1] + arr_y[2] + arr_y[3];

         sum = sum / 3;

         y_data = sum;

    }

    x_val[Index] = x_data;
    y_val[Index] = y_data;

    Index = (Index + 0x01) & 0x01;

    /* Load the counter with the initial count value */
    DMTimerCounterSet(SOC_DMTIMER_2_REGS, 0);

    /* Start the DMTimer */
    DMTimerEnable(SOC_DMTIMER_2_REGS);

    TSCADCIntStatusClear(TSC_ADC_INSTANCE,  TSCADC_FIFO1_THRESHOLD_INT);

    IsTSPress = 1;

    StepEnable();
}
Example #4
0
/*
** ISR for Touch Screen
*/
static void TouchScreenIsr(void)
{
    volatile unsigned int wordsLeft = 0;
    unsigned int status;
    unsigned int i = 0;
    unsigned int prevVal_x = 0xFFFFFFFF;
    unsigned int prevVal_y = 0xFFFFFFFF;
    unsigned int currDiff_x;
    unsigned int currDiff_y;
    unsigned int prevDiff_x = 0xFFFFFFFF;
    unsigned int prevDiff_y = 0xFFFFFFFF;
    unsigned int readx1;
    unsigned int ready1;

    status = TSCADCIntStatus(SOC_ADC_TSC_0_REGS);
	
	wordsLeft = TSCADCFIFOWordCountRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_1);

    if(status & TSCADC_FIFO1_THRESHOLD_INT)
    {
         for (i = 0; i < wordsLeft; i++) 
         { 
              readx1 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);
              readx1 = readx1 & 0xfff; 

              if (readx1 > prevVal_x) 
              {
                   currDiff_x = readx1 - prevVal_x; 
              }
              else 
              { 
                   currDiff_x = prevVal_x - readx1; 
              }
              if (currDiff_x < prevDiff_x) 
              { 
                   prevDiff_x = currDiff_x; 
                   xdata = readx1; 
              } 
              prevVal_x = readx1;
 
              ready1 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_1);
              ready1 &= 0xfff; 

              if (ready1 > prevVal_y) 
              {
                  currDiff_y = ready1 - prevVal_y; 
              }
              else
              { 
                  currDiff_y = prevVal_y - ready1; 
              }
              if (currDiff_y < prevDiff_y) 
              { 
                  prevDiff_y = currDiff_y; 
                  ydata = ready1; 
              } 
              prevVal_y = ready1; 
              wordsLeft = TSCADCFIFOWordCountRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_1);			  
         } 

         x_data[dbidx] = xdata;
         y_data[dbidx] = ydata;
         dbidx = (dbidx + 1) & 0x01;
    }

    /* Restart the timer counter */
    DMTimerCounterSet(SOC_DMTIMER_3_REGS, 0);
    DMTimerEnable(SOC_DMTIMER_3_REGS);

    //TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS,  TSCADC_FIFO1_THRESHOLD_INT);
	TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS,   TSCADC_FIFO1_THRESHOLD_INT |
										   TSCADC_ASYNC_HW_PEN_EVENT_INT |
										   TSCADC_SYNC_PEN_EVENT_INT |
										   TSCADC_FIFO0_UNDER_FLOW_INT |
										   TSCADC_FIFO1_UNDER_FLOW_INT |
										   TSCADC_END_OF_SEQUENCE_INT |
										   TSCADC_FIFO0_THRESHOLD_INT |
										   TSCADC_FIFO0_OVER_RUN_INT |
										   TSCADC_FIFO1_OVER_RUN_INT |
										   TSCADC_OUT_OF_RANGE_INT |
										   TSCADC_PEN_UP_EVENT_INT);

    IsTSPress = 1;
    touchRelease = 0;
   
    StepEnable();
}