コード例 #1
0
ファイル: sysdelay.c プロジェクト: DanielCollins/BeagleDrone
void Sysdelay(unsigned int milliSec)
{
#ifdef DELAY_USE_INTERRUPTS
    unsigned int countVal = TIMER_OVERFLOW - (milliSec * TIMER_1MS_COUNT);

    DMTimerCounterSet(SOC_DMTIMER_7_REGS, countVal);

    flagIsr = FALSE;

    /* Enable the DMTimer interrupts */
    DMTimerIntEnable(SOC_DMTIMER_7_REGS, DMTIMER_INT_OVF_EN_FLAG);

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

    while(FALSE == flagIsr) ;

    /* Disable the DMTimer interrupts */
    DMTimerIntDisable(SOC_DMTIMER_7_REGS, DMTIMER_INT_OVF_EN_FLAG);

#else
    while(milliSec != 0)
    {
        DMTimerCounterSet(SOC_DMTIMER_7_REGS, 0);
        DMTimerEnable(SOC_DMTIMER_7_REGS);
        while(DMTimerCounterGet(SOC_DMTIMER_7_REGS) < TIMER_1MS_COUNT);
        DMTimerDisable(SOC_DMTIMER_7_REGS);
        milliSec--;
    }
 
#endif
}
コード例 #2
0
ファイル: sysdelay.c プロジェクト: DanielCollins/BeagleDrone
void SysDelayTimerSetup(void)
{   

#ifdef DELAY_USE_INTERRUPTS
    /* This function will enable clocks for the DMTimer7 instance */
    DMTimer7ModuleClkConfig();

    /* Registering DMTimerIsr */
    IntRegister(SYS_INT_TINT7, DMTimerIsr);

    /* Set the priority */
    IntPrioritySet(SYS_INT_TINT7, 0, AINTC_HOSTINT_ROUTE_IRQ);

    /* Enable the system interrupt */
    IntSystemEnable(SYS_INT_TINT7);

    DMTimerCounterSet(SOC_DMTIMER_7_REGS, 0);

    /* Configure the DMTimer for Auto-reload and compare mode */
    DMTimerModeConfigure(SOC_DMTIMER_7_REGS, DMTIMER_ONESHOT_NOCMP_ENABLE);
#else
    DMTimer7ModuleClkConfig();

    DMTimerModeConfigure(SOC_DMTIMER_7_REGS, DMTIMER_ONESHOT_NOCMP_ENABLE);
#endif

}
コード例 #3
0
ファイル: grlibDemoTouch.c プロジェクト: OS-Project/Divers
/*
** Timer 3 ISR
*/
static void Timer3Isr(void)
{
    /* Clear the status of the interrupt flags */
    DMTimerIntStatusClear(SOC_DMTIMER_3_REGS, DMTIMER_INT_MAT_EN_FLAG);

    DMTimerDisable(SOC_DMTIMER_3_REGS);
    DMTimerCounterSet(SOC_DMTIMER_3_REGS, 0);
   
    touchRelease = 1;
}
コード例 #4
0
ファイル: sysdelay.c プロジェクト: DanielCollins/BeagleDrone
/**
 * /brief This function starts the timer.
 *
 * /milliSec Maximum value = TIMER_OVERFLOW/TIMER_1MS_COUNT.
 *
 * /NOTE  SysDelay functionality cannot be used till SysStopTimer is called.
 */
void SysStartTimer(unsigned int milliSec)
{
#ifdef DELAY_USE_INTERRUPTS
    unsigned int countVal = TIMER_OVERFLOW - (milliSec * TIMER_1MS_COUNT);

    DMTimerCounterSet(SOC_DMTIMER_7_REGS, countVal);

    flagIsr = FALSE;

    /* Enable the DMTimer interrupts */
    DMTimerIntEnable(SOC_DMTIMER_7_REGS, DMTIMER_INT_OVF_EN_FLAG);

    /* Start the DMTimer */
    DMTimerEnable(SOC_DMTIMER_7_REGS);
#else
    DMTimerCounterSet(SOC_DMTIMER_7_REGS, 0);
    DMTimerEnable(SOC_DMTIMER_7_REGS);
    flagIsr = milliSec;
#endif
}
コード例 #5
0
ファイル: dmtimerCounter.c プロジェクト: OS-Project/Divers
/*
** Setup the timer for one-shot and compare mode.
*/
static void DMTimerSetUp(void)
{
    /* Load the counter with the initial count value */
    DMTimerCounterSet(SOC_DMTIMER_2_REGS, TIMER_INITIAL_COUNT);

    /* Load the load register with the reload count value */
    DMTimerReloadSet(SOC_DMTIMER_2_REGS, TIMER_RLD_COUNT);

    /* Configure the DMTimer for Auto-reload and compare mode */
    DMTimerModeConfigure(SOC_DMTIMER_2_REGS, DMTIMER_AUTORLD_NOCMP_ENABLE);
}
コード例 #6
0
ファイル: demoTimer.c プロジェクト: OS-Project/Divers
/*
** Configures the Timer4 for 32 bit
*/
void Timer4Config(void)
{
    /* Load the counter with the initial count value */
    DMTimerCounterSet(SOC_DMTIMER_4_REGS, TIMER4_INITIAL_COUNT);

    /* Load the load register with the reload count value */
    DMTimerReloadSet(SOC_DMTIMER_4_REGS, TIMER_200MS_DELAY);

    /* Configure the DMTimer for one shot mode */
    DMTimerModeConfigure(SOC_DMTIMER_4_REGS, DMTIMER_AUTORLD_NOCMP_ENABLE);
	
	Timer4Stop();
}
コード例 #7
0
ファイル: demoTimer.c プロジェクト: OS-Project/Divers
/*
** Configures the Timer2 for 32 bit
*/
void Timer2Config(void)
{
    /* Load the counter with the initial count value */
    DMTimerCounterSet(SOC_DMTIMER_2_REGS, TIMER_INITIAL_COUNT);

    /* Load the load register with the reload count value */
    //DMTimerReloadSet(SOC_DMTIMER_2_REGS, TIMER_RLD_COUNT);

    /* Configure the DMTimer for one shot mode */
    DMTimerModeConfigure(SOC_DMTIMER_2_REGS, DMTIMER_ONESHOT_NOCMP_ENABLE);
	
	Timer2Stop();
}
コード例 #8
0
ファイル: demoTimer.c プロジェクト: OS-Project/Divers
/*
** Timer 2 Interrupt Service Routine
*/
static void Timer2Isr(void)
{
	static unsigned int index = 0;
	
    /* Clear the status of the interrupt flags */
    DMTimerIntStatusClear(SOC_DMTIMER_2_REGS, DMTIMER_INT_OVF_EN_FLAG);
    
    tmr2Flag = TRUE;
	
	DMTimerCounterSet(SOC_DMTIMER_2_REGS, timerCount[index++%10]);
	
	DMTimerEnable(SOC_DMTIMER_2_REGS);	
	
}
コード例 #9
0
unsigned int SysTimer(unsigned int flag)
{
    unsigned int timeInTicks=0;

    if(flag)
    {
            DMTimerCounterSet(SOC_DMTIMER_7_REGS, 0);
            DMTimerEnable(SOC_DMTIMER_7_REGS);
    }
    else
    {
            DMTimerDisable(SOC_DMTIMER_7_REGS);
            timeInTicks = DMTimerCounterGet(SOC_DMTIMER_7_REGS);
    }

    return timeInTicks;
}
コード例 #10
0
ファイル: tscCalibrate.c プロジェクト: OS-Project/Divers
static void TouchCalibrate(void)
{
    unsigned char i;
 
    POINT stDisplayPoint[3] = {{0, 0},{LCD_WIDTH, 0}, {0, LCD_HEIGHT}};
    POINT stTouchScreenPoint[3];

    UARTPuts("Touch at Right bottom", -1);

    while(!IsTSPress);

    IsTSPress = 1; 

    for(i = 0; i < 3; i++)
    {
         while(DMTimerCounterGet(SOC_DMTIMER_2_REGS) < 0xffffff);

         DMTimerDisable(SOC_DMTIMER_2_REGS);

         DMTimerCounterSet(SOC_DMTIMER_2_REGS, 0);

	 stTouchScreenPoint[i].x = x_val[0];
	 stTouchScreenPoint[i].y = y_val[0];

         if(i == 0)
         {
              UARTPuts("\r\n", -1);
              UARTPuts("Touch at Left bottom", -1);

         }
         else if(i == 1)
         {
              UARTPuts("\r\n", -1);
              UARTPuts("Touch at Right Top", -1);
         }
         else
         {
              UARTPuts("\r\n", -1);
         }
    }

    setCalibrationMatrix( stDisplayPoint, stTouchScreenPoint, &stMatrix);
}
コード例 #11
0
ファイル: demoTimer.c プロジェクト: OS-Project/Divers
/*
** Configures the Timer6 for 32 bit
*/
void Timer6Config(void)
{
    /* Register DMTimer6 interrupts */
    Timer6IntRegister();

    /* Enable DMTimer6 module clocks */
    DMTimer6ModuleClkConfig();

    /* Set counter value to overflow in 15 seconds */
    DMTimerCounterSet(SOC_DMTIMER_6_REGS, TIMER6_INITIAL_COUNT);

    /* Configure the DMTimer for one shot mode */
    DMTimerModeConfigure(SOC_DMTIMER_6_REGS, DMTIMER_ONESHOT_NOCMP_ENABLE);

    /* Stop the timer */
    Timer6Stop();

    /* Enable DMTimer6 interrupts */
    Timer6IntEnable();
}
コード例 #12
0
ファイル: irqPreemption.c プロジェクト: OS-Project/Divers
/*
** Configure and start the Timer
*/
static void TimerSetupAndEnable(void)
{
    /* This function will enable clocks for the DMTimer2 instance */
    DMTimer2ModuleClkConfig();

    /* Load the counter with the initial count value */
    DMTimerCounterSet(TIMER_INST_BASE, TIMER_INITIAL_COUNT);

    /* Load the load register with the reload count value */
    DMTimerReloadSet(TIMER_INST_BASE, TIMER_RLD_COUNT);

    /* Configure the DMTimer for Auto-reload and compare mode */
    DMTimerModeConfigure(TIMER_INST_BASE, DMTIMER_AUTORLD_NOCMP_ENABLE);

    /* Enable the DMTimer interrupts */
    DMTimerIntEnable(TIMER_INST_BASE, DMTIMER_INT_OVF_EN_FLAG);

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

    IntSystemEnable(TIMER_INT_NUM);
}
コード例 #13
0
ファイル: demoPwrMgmnt.c プロジェクト: OS-Project/Divers
/*
** This function configures given source for standby wakeup.
*/
void enableStandbyWakeSrc(unsigned int wakeSource)
{
    /* Disable interrupt of SW pin to avoid wake through SW for other src sel */
    GPIOPinIntDisable(GPIO_INST_BASE_SW, GPIO_INT_LINE_1, GPIO_SW_PIN_NUM);
    GPIOPinIntDisable(GPIO_INST_BASE_SW, GPIO_INT_LINE_2, GPIO_SW_PIN_NUM);

    /* IO Pad Configuration */
    pmStdbySrcIOPin.padConfig.slewRate = 0;
    pmStdbySrcIOPin.padConfig.mode = 7;
    pmStdbySrcIOPin.padConfig.type = CONTROL_CONF_RXACTIVE;
    pmStdbySrcIOPin.padConfig.pullEnable = CONTROL_CONF_PULLUDDISABLE;
    pmStdbySrcIOPin.padConfig.pullSel = 0;

    /* GPIO Pin Configuration */
    pmStdbySrcIOPin.gpioConfig.dir = GPIO_DIR_INPUT;
    pmStdbySrcIOPin.gpioConfig.debouEnable = GPIO_DEBOUNCE_FUNC_DISABLE;
    pmStdbySrcIOPin.gpioConfig.intrEnable = 1;
    pmStdbySrcIOPin.gpioConfig.intrType = GPIO_INT_TYPE_BOTH_EDGE;

    switch(wakeSource)
    {
        case WAKE_SOURCE_TSC:

            /* Skip Touchscreen for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_ADC_TSC);

            /* Enable hardware pen event interrupt */
            TSCADCEventInterruptEnable(TSC_ADC_INSTANCE,
                                       TSCADC_ASYNC_HW_PEN_EVENT_INT);
            break;

        case WAKE_SOURCE_UART:

            /* Skip GPIO for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_GPIO1);


            /* Enable GPIO Interrupt on UART RXD Pin */
            pmStdbySrcIOPin.ioPadOff = GPIO_UART_RDX_PAD_OFFSET;
            pmStdbySrcIOPin.pinNum = GPIO_UART_RDX_PIN_NUM;
            pmStdbySrcIOPin.gpioBaseAddr = GPIO_INST_BASE_UART_RXD;
            pmStdbySrcIOPin.gpioConfig.intrLine = GPIO_UART_RXD_INTR_LINE;
            pmStdbySrcIOPin.intrNum = GPIO_UART_RXD_SYS_INT_NUM;
            pmStdbySrcIOPin.gpioIsr = gpioStdbyUartIsr;

            DemoGpioPinStandbySrcConfig(&pmStdbySrcIOPin);
            break;

        case WAKE_SOURCE_TMR:

            /* Skip Timer for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_TIMER6);

            ConsoleUtilsPrintf("\r\n Peripheral domain Timer is configured as"
                               "wake source.\r\n\r\n ... system will release "
                               "from standby in 20 seconds ...\r\n\r\n");

            /* Configure Timer 6 */
            Timer6Config();

            /* Set the counter value */
            DMTimerCounterSet(DMTIMER6_BASE_ADDR, TIMER_OVRFLW_20_SECOND_24MHZ);

            /* Start the timer */
            Timer6Start();
            break;

        case WAKE_SOURCE_GPIO:

            /* Skip GPIO for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_GPIO0);

            /* Enable GPIO Interrupt on UART RXD Pin */
            pmStdbySrcIOPin.ioPadOff = GPIO_SW_PAD_OFFSET;
            pmStdbySrcIOPin.pinNum = GPIO_SW_PIN_NUM;
            pmStdbySrcIOPin.gpioBaseAddr = GPIO_INST_BASE_SW;
            pmStdbySrcIOPin.gpioConfig.intrLine = GPIO_SW_INTR_LINE;
            pmStdbySrcIOPin.intrNum = GPIO_SW_SYS_INT_NUM;
            pmStdbySrcIOPin.gpioIsr = gpioStdbyGPIOIsr;

            DemoGpioPinStandbySrcConfig(&pmStdbySrcIOPin);
            break;

        case WAKE_SOURCE_RTC:

            /* Include GPIO for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_RTC);

            ConsoleUtilsPrintf("\t..Alarm is configured to wakeup system after "
                               "20 Sec..");
            configWakeRTC();
            enableRTCAlarmIntr();
            break;

        default:
            break;
    }
}
コード例 #14
0
ファイル: tscCalibrate.c プロジェクト: OS-Project/Divers
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();
}
コード例 #15
0
ファイル: grlibDemoTouch.c プロジェクト: OS-Project/Divers
/*
** 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();
}