int main(void)
{
	DDRA=0x00; PORTA=0xFF;
	DDRB=0x0FF;PORTB=0x00;
	Bl_state=Start;
	TLED_state=Start3;
	BZ_State=Start1;
	In_state=Start4;
	TimerSet(1);
	TimerOn();
	
	while (1)
	{
		valA=0x00;
		Tick_BL();
		Tick_3L();
		Tick_IN();
		Tick_Bz();
		Update_Port_B();
		while(!TimerFlag){}
		TimerFlag=0;
		time_elapsed+=1;
		if(time_elapsed>1000)
		time_elapsed=1;
	}
}
Ejemplo n.º 2
0
/* A single finger tap is defined as 1 finger tap that lasts less than
 * wcmTapTime.  It results in a left button press.
 *
 * Some work must be done to make sure two fingers were not touching
 * during this gesture. This is easy if first finger is released
 * first.  To handle case of second finger released first, require
 * second finger to have been released before first finger ever touched.
 *
 * Function relies on ds[0/1].sample to be updated only when entering or
 * exiting proximity so no storage is needed when initial touch occurs.
 */
static void wcmSingleFingerTap(WacomDevicePtr priv)
{
	WacomCommonPtr common = priv->common;
	WacomChannelPtr firstChannel = common->wcmChannel;
	WacomChannelPtr secondChannel = common->wcmChannel + 1;
	WacomDeviceState ds[2] = { firstChannel->valid.states[0],
				   secondChannel->valid.states[0] };
	WacomDeviceState dsLast[2] = { firstChannel->valid.states[1],
					secondChannel->valid.states[1] };

	DBG(10, priv, "\n");

	/* This gesture is only valid on touchpads. */
	if (TabletHasFeature(priv->common, WCM_LCD))
		return;

	if (!ds[0].proximity && dsLast[0].proximity && !ds[1].proximity)
	{
		/* Single Tap must have lasted less than wcmTapTime
		 * and second finger must not have released after
		 * first finger touched.
		 */
		if (ds[0].sample - dsLast[0].sample <=
		    common->wcmGestureParameters.wcmTapTime &&
		    ds[1].sample < dsLast[0].sample)
		{
			common->wcmGestureMode = GESTURE_PREDRAG_MODE;

			/* Delay to detect possible drag operation */
			TimerSet(NULL, 0, common->wcmGestureParameters.wcmTapTime, wcmSingleFingerTapTimer, priv);
		}
	}
}
int main(void)
{
	//port B is output
	DDRB = 0xFF;
	
	//set and turn on timer
	TimerSet(500);
	TimerOn();
	
	//turn on PWM and set servo angle
	PWM_on();
	
	unsigned char testAngles[] = {0, 30, 60, 90, 120, 150, 180};
	unsigned char i = 0;
	//main loop
	while(1)
	{	
		
		
		if(i < 7){
			Servo_SetAngle(testAngles[i++]);
		}
		else{
			i = 0;
			Servo_SetAngle(testAngles[i++]);
		}
		
		
		while(!TimerFlag);
		TimerFlag = 0;
	}
}
Ejemplo n.º 4
0
Archivo: timer.c Proyecto: x893/OpenBLT
/************************************************************************************//**
** \brief     Initializes the timer.
** \return    none.
**
****************************************************************************************/
void TimerInit(void)
{
	/* configure the SysTick timer for 1 ms period */
	SysTick_Config(BOOT_CPU_SYSTEM_SPEED_KHZ);
	/* reset the millisecond counter */
	TimerSet(0);
}
Ejemplo n.º 5
0
int Ssl_Rxd( char *psRxdData, ulong uiExpLen,  ulong *puiOutLen, ushort UiTimeOutSec)
{
	int iRet;
	
	TimerSet(TIMER_TEMPORARY, (ushort)(UiTimeOutSec*10));
	iRet = 0;

	while (1)
	{
		if( TimerCheck(TIMER_TEMPORARY)==0 )	// 检查定时器
		{
			if( iRet>0 )	// 已经读取到数据
			{
				*puiOutLen = iRet;
				return 0;
			}
			return 0xff;
		}

		iRet = SslRecv( iSSLSocket, psRxdData, uiExpLen );
		if (iRet > 0)
		{
			*puiOutLen = iRet;
			return 0;
		}
	}

}
Ejemplo n.º 6
0
void
VAuditF(const char *f, va_list args)
{
    char *prefix;
    char buf[1024];
    int len;
    static char oldbuf[1024];

    prefix = AuditPrefix();
    len = vsnprintf(buf, sizeof(buf), f, args);

    if (len == oldlen && strcmp(buf, oldbuf) == 0) {
	/* Message already seen */
	nrepeat++;
    } else {
	/* new message */
	if (auditTimer != NULL)
	    TimerForce(auditTimer);
	ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
	strlcpy(oldbuf, buf, sizeof(oldbuf));
	oldlen = len;
	nrepeat = 0;
	auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
    }
    free(prefix);
}
Ejemplo n.º 7
0
Archivo: timer.c Proyecto: x893/OpenBLT
/************************************************************************************//**
** \brief     Initializes the timer.
** \return    none.
**
****************************************************************************************/
void TimerInit(void)
{
    /* configure the SysTick timer for 1 ms period */
    SysTick_Config(SystemCoreClock / 1000);
    /* reset the millisecond counter */
    TimerSet(0);
} /*** end of TimerInit ***/
Ejemplo n.º 8
0
/* A single finger tap is defined as 1 finger tap that lasts less than
 * wcmTapTime.  It results in a left button press.
 *
 * Some work must be done to make sure two fingers were not touching
 * during this gesture. This is easy if first finger is released
 * first.  To handle case of second finger released first, require
 * second finger to have been released before first finger ever touched.
 *
 * Function relies on ds[0/1].sample to be updated only when entering or
 * exiting proximity so no storage is needed when initial touch occurs.
 */
static void wcmSingleFingerTap(WacomDevicePtr priv)
{
	WacomCommonPtr common = priv->common;
	WacomDeviceState ds[2] = {}, dsLast[2] = {};

	getStateHistory(common, ds, ARRAY_SIZE(ds), 0);
	getStateHistory(common, dsLast, ARRAY_SIZE(dsLast), 1);

	DBG(10, priv, "\n");

	/* This gesture is only valid on touchpads. */
	if (TabletHasFeature(priv->common, WCM_LCD))
		return;

	if (!ds[0].proximity && dsLast[0].proximity && !ds[1].proximity)
	{
		/* Single Tap must have lasted less than wcmTapTime
		 * and second finger must not have released after
		 * first finger touched.
		 */
		if (ds[0].sample - dsLast[0].sample <=
		    common->wcmGestureParameters.wcmTapTime &&
		    ds[1].sample < dsLast[0].sample)
		{
			common->wcmGestureMode = GESTURE_PREDRAG_MODE;

			/* Delay to detect possible drag operation */
			TimerSet(priv->tap_timer, 0, common->wcmGestureParameters.wcmTapTime, wcmSingleFingerTapTimer, priv);
		}
	}
}
Ejemplo n.º 9
0
/** Try to initialize the statistic gathering and printing routines.
 * Initialization only takes place if #dmxStatActivate has already been
 * called.  We don't need the same generation protection that we used in
 * dmxSyncInit because our timer is always on a queue -- hence, server
 * generation will always free it. */
void
dmxStatInit(void)
{
    if (dmxStatInterval)
        dmxStatTimer = TimerSet(NULL, 0,
                                dmxStatInterval, dmxStatCallback, NULL);
}
Ejemplo n.º 10
0
Archivo: timer.c Proyecto: x893/OpenBLT
/************************************************************************************//**
** \brief     Initializes the timer.
** \return    none.
**
****************************************************************************************/
void TimerInit(void)
{
  /* configure the SysTick timer for 1 ms period */
  SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000);
  /* reset the millisecond counter */
  TimerSet(0);
} /*** end of TimerInit ***/
Ejemplo n.º 11
0
int main(void)
{
	//---- PORT Initializations -----
	DDRB = 0xFF; PORTB = 0x00;
	DDRA = 0x00; PORTA = 0xFF;
	DDRC = 0xFF; PORTC = 0x00; //used for LCD display
	DDRD = 0xFF; PORTD = 0x00; //used for LCD display
	
	// --- Function Initializations ---
	TimerSet(5);
	TimerOn();
	PWM_on();
	initUSART();
	setCustomCharacters();
	LCD_init();

	//---if eeprom address was not initialized----
	if(eeprom_read_byte((uint8_t*)46) == 0xFF)
		eeprom_write_byte((uint8_t*)46 , 0);
		
	//----load old high score saved in EEPROM----
	currHighScore = eeprom_read_byte((uint8_t*)46);
	
	gameStatus = 0;
	soundStatus = 0;
	lcdTick();
	
	while(1){	
		mainTick();
		playSound();
		while(!TimerFlag);
		TimerFlag = 0;
	}
}
Ejemplo n.º 12
0
void TUNER_set_frequency(FI1236Ptr f, CARD32 frequency)
{
    CARD16 divider;

    if(frequency < f->parm.min_freq) frequency = f->parm.min_freq;
    if(frequency > f->parm.max_freq) frequency = f->parm.max_freq;

    f->afc_delta=0;
    f->original_frequency=frequency;

    if(f->type==TUNER_TYPE_MT2032)
        {
    	MT2032_tune(f, (1.0*frequency)/16.0, 0.0625);
	} else 
	{
	FI1236_tune(f, frequency);
	}
    
    if(!f->afc_timer_installed)
        {
     	f->afc_timer_installed=TRUE;
/*     	RegisterBlockAndWakeupHandlers(FI1236_BlockHandler, AFCWakeup, f); */
	TimerSet(NULL, 0, 300, AFC_TimerCallback, f);
	}
	
}
Ejemplo n.º 13
0
Bool rfbSendRTTPing(rfbClientPtr cl)
{
    RTTInfo rttInfo;

    if (!cl->enableFence)
        return TRUE;

    memset(&rttInfo, 0, sizeof(RTTInfo));

    gettimeofday(&rttInfo.tv, NULL);
    rttInfo.offset = cl->sockOffset;
    rttInfo.inFlight = rttInfo.offset - cl->ackedOffset;

    /* We need to make sure that any old updates are already processed by the
       time we get the response back.  This allows us to reliably throttle
       back if the client or the network overloads. */
    if (!rfbSendFence(cl, rfbFenceFlagRequest | rfbFenceFlagBlockBefore,
                      sizeof(RTTInfo), (const char *)&rttInfo))
        return FALSE;

    cl->pingCounter++;

    cl->sentOffset = rttInfo.offset;

    /* Let some data flow before we adjust the settings */
    if (!cl->congestionTimerRunning) {
        TimerSet(cl->congestionTimer, 0, min(cl->baseRTT * 2, 100),
                 congestionCallback, cl);
        cl->congestionTimerRunning = TRUE;
    }
    return TRUE;
}
Ejemplo n.º 14
0
/*
 * Timers documentation:
 * http://www.x.org/releases/X11R7.7/doc/xorg-server/Xserver-spec.html#id2536042
 *
 * This function indirectly may call itself recursively using timer to guarantee correct
 * event delivery time. Ususally recursion ends after first recursive call.
 */
static CARD32 check_resolve_delayed(OsTimerPtr timer, CARD32 time, void *arg){
	LocalDevicePtr local = arg;
	struct MTouch *mt = local->private;
	mstime_t delta_millis;
	struct timeval delta;

	// If it was to early to trigger delayed button, next timer will be set,
	// but when called by timer such situation shouldn't take place.
	switch (mtouch_delayed(mt)){
	case 1:
		if(mt->is_timer_installed != 1){
			TimerCancel(mt->timer);
			mt->is_timer_installed = 1;
			timersub(&mt->gs.button_delayed_time, &mt->gs.time, &delta);
			delta_millis = timertoms(&delta);
			mt->timer = TimerSet(mt->timer, 0, delta_millis, check_resolve_delayed, local);
		}
		break;
	case 2:
		TimerCancel(mt->timer);
		mt->is_timer_installed = 0;
		handle_gestures(local, &mt->gs);
		break;
	case 3:
		TimerCancel(mt->timer);
		handle_gestures(local, &mt->gs);
		mt->is_timer_installed = 2;

		/* Install coasting timer */
		coasting_delayed(mt->timer, -1, arg);
		break;
	case 0: break;
	}
	return 0;
}
Ejemplo n.º 15
0
static void
SecurityStartAuthorizationTimer(SecurityAuthorizationPtr pAuth)
{
    pAuth->timer = TimerSet(pAuth->timer, 0,
                            SecurityComputeAuthorizationTimeout(pAuth,
                                                                pAuth->timeout),
                            SecurityAuthorizationExpired, pAuth);
}                               /* SecurityStartAuthorizationTimer */
Ejemplo n.º 16
0
Archivo: main.c Proyecto: x-lugoo/pos
// Modified by Kim_LinHB 2014-7-8
int CheckInitTerminal(void)
{
	uchar	szCurTime[16+1], szLastTime[16+1];
	uchar	ucKey;
	uchar	szBuff[50];
	
	if( !(glSysParam.ucTermStatus & INIT_MODE) )
	{
		return 0;
	}
	
	TimerSet(0, 0);
	memset(szCurTime,  0, sizeof(szCurTime));
	memset(szLastTime, 0, sizeof(szLastTime));
	while( glSysParam.ucTermStatus & INIT_MODE )
	{
	    Gui_UpdateKey(XUI_KEYFUNC, _T("FUNC"), NULL, NULL);
	    Gui_SetVirtualButton(1, 0);
		if( TimerCheck(0)==0 )
		{
			TimerSet(0, 10);
			GetEngTime(szCurTime);
			if (strcmp(szCurTime, szLastTime)!=0)
			{
				Gui_ClearScr();
				sprintf(szBuff, "%s\n[%.14s]", _T("PLEASE INIT"), AppInfo.AppName);
				Gui_UpdateTitle(szCurTime, gl_stTitleAttr);
				Gui_DrawText(szBuff, gl_stCenterAttr, 0, 50);
				memcpy(szLastTime, szCurTime, sizeof(szLastTime));
			}
		}

		ucKey = PubWaitKey(10);
		if(
			(ucKey==KEYF1 && ChkTermEx(_TERMINAL_D200_)) || (ucKey==KEYFN && !ChkTermEx(_TERMINAL_D200_))
			)
		{
			InitTransInfo();
			FunctionInit();
			TimerSet(0, 0);
			memset(szLastTime, 0, sizeof(szLastTime));
		}
	}

	return 0;
}
Ejemplo n.º 17
0
static void
rdpScheduleDeferredUpdate(void)
{
  if (!g_scheduled)
  {
    g_scheduled = 1;
    g_timer = TimerSet(g_timer, 0, 40, rdpDeferredUpdateCallback, 0);
  }
}
Ejemplo n.º 18
0
void
startautorepeat(long keycode)
{
    sunTimer = TimerSet(sunTimer, 		/* Timer */
			0, 			/* Flags */
			xf86Info.kbdDelay,	/* millis */
			processautorepeat,	/* callback */
			(pointer) keycode);	/* arg for timer */
}
Ejemplo n.º 19
0
int main(void)
{
	
	DDRA = 0x00; PORTA = 0xFF;	//Input Port, joystick and buttons.
	DDRB = 0xFF; PORTB = 0x00;	//Output Port, test output to led.
	DDRD = 0xFF; PORTD = 0x00;
	DDRC = 0xFF; PORTC = 0x00;	//C0 is motor.

	unsigned char i=0;
	tasks[i].state = JS_SMStart;
	tasks[i].period = periodJoystick;
	tasks[i].elapsedTime = tasks[i].period;
	tasks[i].TickFct = &TickFct_Joystick;
	i++;
	tasks[i].state = JP_SMStart;
	tasks[i].period = periodJump;
	tasks[i].elapsedTime = tasks[i].period;
	tasks[i].TickFct = &TickFct_Jump;
	i++;
	tasks[i].state = CH_SMStart;
	tasks[i].period = periodCrouch;
	tasks[i].elapsedTime = tasks[i].period;
	tasks[i].TickFct = &TickFct_Crouch;
	i++;
	tasks[i].state = RT_SMStart;
	tasks[i].period = periodReset;
	tasks[i].elapsedTime = tasks[i].period;
	tasks[i].TickFct = &TickFct_Reset;
	i++;
	tasks[i].state = TN_SMStart;
	tasks[i].period = periodTransmission;
	tasks[i].elapsedTime = tasks[i].period;
	tasks[i].TickFct = &TickFct_Transmission;
	i++;
	tasks[i].state = MR_SMStart;
	tasks[i].period = periodMotor;
	tasks[i].elapsedTime = tasks[i].period;
	tasks[i].TickFct = &TickFct_Motor;
	i++;
	tasks[i].state = SE_SMStart;
	tasks[i].period = periodScore;
	tasks[i].elapsedTime = tasks[i].period;
	tasks[i].TickFct = &TickFct_Score;

	TimerSet(tasksPeriodGCD);
	TimerOn();
	ADC_init();
	SPI_SlaveInit();

	while (1)
	{
		while(!TimerFlag);
		TimerFlag = 0;
	}

	return 0;
}
Ejemplo n.º 20
0
static void
damage_report_hook(DamagePtr damage, RegionPtr pRegion, void *closure)
{
    struct omap_screen_info *omaps = closure;

    if (!omaps->timer_active) {
        omaps->timer_active = 1;
        TimerSet(NULL, 0, 1, damage_timer, omaps);
    }
}
Ejemplo n.º 21
0
int
dbus_core_init(void)
{
    memset(&bus_info, 0, sizeof(bus_info));
    bus_info.fd = -1;
    bus_info.hooks = NULL;
    if (!connect_to_bus())
        bus_info.timer = TimerSet(NULL, 0, 1, reconnect_timer, NULL);

    return 1;
}
Ejemplo n.º 22
0
static void
DoTimer(TimerPtr timer, unsigned int now, TimerPtr *prev)
{
    unsigned int newTime;

    *prev = timer->next;
    timer->next = NULL;
    newTime = (*timer->callback) (timer, now, timer->arg);
    if (newTime)
        TimerSet(timer, 0, newTime, timer->callback, timer->arg);
}
Ejemplo n.º 23
0
int main(){
	DDRB = 0xFF; PORTB = 0x00;
	TimerSet(1000);
	TimerOn();
	tempB = 0x00;
	while(1) {
		while (!TimerFlag);
			TimerFlag = 0;
		led();
	}
}
Ejemplo n.º 24
0
			break;
	}
}

int main(){
	DDRB = 0xFF; PORTB = 0x00;
	DDRA = 0x00; PORTA = 0xFF;
	TimerSet(50);
	TimerOn();
	
	tempB = 0x00;
	led_state = init;
	while(1) {
		while (!TimerFlag);
int main(void)
{
	DDRA = 0x00; PORTA = 0xFF;
	DDRB = 0xFF; PORTB = 0x00;
	DDRD = 0xFF; PORTD = 0x0F;
	//PWM_on();
	TimerSet(500);
	TimerOn();
	StateSpeaker = SPEAKER_INIT;
	StatePitch = PITCH_INIT;
	TimerSet(100);
	TimerOn();

	//PWM_on();
    while(1)
    {
		//set_PWM(pitchScale[5]);
		SMSpeaker_tick();
		SMChoosePitch_tick();
		while(!TimerFlag);
		TimerFlag = 0;	
    }
}
Ejemplo n.º 26
0
Bool PVR2D_PerfInit(ScreenPtr pScreen)
{
	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
	FBDevPtr fbdev = FBDEVPTR(pScrn);
	int t;

	memset(&perf_counters, 0, sizeof(struct sgx_perf_counters));
	if (!xf86GetOptValInteger(fbdev->Options, OPTION_PERF_TIME, &t))
		return FALSE;

	fbdev->perf_timer =
	    TimerSet(fbdev->perf_timer, 0, t, perfCountersCallback, pScrn);

	return TRUE;
}
Ejemplo n.º 27
0
int main() {

   const unsigned int periodState_machine_1 = 1000; // 1000 ms default
   TimerSet(periodState_machine_1);
   TimerOn();
   
   SM1_State = -1; // Initial state
   B = 0; // Init outputs

   while(1) {
      TickFct_State_machine_1();
      while(!SM1_Clk);
      SM1_Clk = 0;
   } // while (1)
} // Main
Ejemplo n.º 28
0
int
XkbDDXAccessXBeep(DeviceIntPtr dev, unsigned what, unsigned which)
{
    XkbSrvInfoRec *xkbInfo = dev->key->xkbInfo;
    CARD32 next;

    xkbInfo->beepType = what;
    xkbInfo->beepCount = 0;
    next = _XkbDDXBeepExpire(NULL, 0, (pointer) dev);
    if (next > 0) {
        xkbInfo->beepTimer = TimerSet(xkbInfo->beepTimer,
                                      0, next,
                                      _XkbDDXBeepExpire, (pointer) dev);
    }
    return 1;
}
Ejemplo n.º 29
0
/*
 * RootlessQueueRedisplay
 *  Queue a redisplay after a timer delay to ensure we do not redisplay
 *  too frequently.
 */
void
RootlessQueueRedisplay(ScreenPtr pScreen)
{
    RootlessScreenRec *screenRec = SCREENREC(pScreen);

    screenRec->redisplay_queued = TRUE;

    if (screenRec->redisplay_timer_set)
        return;

    screenRec->redisplay_timer = TimerSet(screenRec->redisplay_timer,
                                          0, ROOTLESS_REDISPLAY_DELAY,
                                          RootlessRedisplayCallback,
                                          screenRec);
    screenRec->redisplay_timer_set = TRUE;
}
Ejemplo n.º 30
0
int main(void)
{

    // PORT config
	DDRC = 0xFF; PORTC = 0x00;
	DDRB = 0xFF; PORTB = 0x00; 	
	DDRA = 0xFD; PORTA = 0x02;	//1111 1101 : 0000 0010
   
    static task motionSensorPoll, lcdDisplay;
    task *tasks[] = { &lcdDisplay, &motionSensorPoll };
    
    unsigned short numTasks = sizeof(tasks)/sizeof(task*);
    
	//LCD display task
    lcdDisplay.period = 500;
    lcdDisplay.TickFn = &lcdDisplayTick;

	//Motion sensor polling task
	motionSensorPoll.period = 100;
	motionSensorPoll.TickFn = &motionSensorTick;
    	
    unsigned short gcd = tasksInit(tasks, numTasks);
    
    // Timer
    TimerSet(gcd);
    TimerOn();


	//initialize LCD
	LCD_init();    

	ADC_init();

    unsigned short i; // Iterator
    while(1)
    {
		sensor = GetBit(PINA,1);

        tasksTick(tasks, numTasks);

        while(!TimerFlag); // Wait for a GCD period  
        TimerFlag = 0;
     
    }
    
    return 0;
}