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 }
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; }
/** * This function checks whether 'count' milli secs are elapsed or not. * SysStartTimer has to be called prior to checking status. * NOTE: SysDelay functionality cannot be used till SysStopTimer is called. */ unsigned int SysIsTimerElapsed(void) { #ifdef DELAY_USE_INTERRUPTS return flagIsr; #else if(DMTimerCounterGet(SOC_DMTIMER_7_REGS) < (flagIsr * TIMER_1MS_COUNT)) { return 0; } else { return 1; } #endif }
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); }