Ejemplo n.º 1
0
i_process_timer()
{
		time_increment();
		Envelope *timeout_request;
		timeout_request = K_recieve_message();
		while (timeout_request != NULL)
		{
			K_Sort_Envelope_Enqueue(timeout_request);
			timeout_request = K_recieve_message();
		}
		if (timeout_Q->free_msg_counter > 0)
		{
			Envelope* Temp=timeout_Q->head;
			while (Temp->Next!=NULL)
			{
				Temp->clockticks--;
				Temp=Temp->Next;
			}
			Temp=timeout_Q->head;
			while (Temp->clockticks==0)
			{
				Envelope* Send;				
				Send=K_Dequeue_MsgEnv(timeout_Q);
				timeout_Q->free_msg_counter--;
				Send->Msg_Type=2;
				K_send_message (Send->SenderID,Send);
				Temp=Temp->Next;
			}
		}
}
Ejemplo n.º 2
0
void smallsys::do_timestep() {
	if(!in_progress){return;}
	
	diffuse(num_total_particles, time_step, h_pos);
	
	if(time_increment() > time_end) {
		in_progress = false;
	}
}
Ejemplo n.º 3
0
/**
 * SysTick interrupt: increment global time & send data buffer through USB
 */
void sys_tick_handler(){
	++Timer;
	++msctr;
	if(Timer == 999){
		STK_RVR = RVR1;
	}else if(Timer == 1000){
		STK_RVR = RVR0;
		time_increment();
	}
}
Ejemplo n.º 4
0
// PA4 interrupt - PPS signal
void exti4_isr(){
	uint32_t t = 0, ticks;
	static uint32_t ticksavr = 0, N = 0;
	if(EXTI_PR & EXTI4){
		gpio_clear(LEDS_Y_PORT, LEDS_Y2_PIN);
		// correct
		systick_val = STK_CVR;
		STK_CVR = RVR0;
		timer_val = Timer;
		Timer = 0;
		systick_val = STK_RVR + 1 - systick_val; // Systick counts down!
		if(timer_val < 10) timer_val += 1000; // our closks go faster than real
		else if(timer_val < 990){ // something wrong
			RVR0 = RVR1 = STK_RVR_DEFAULT_VAL;
			STK_RVR = RVR0;
			need_sync = 1;
			goto theend;
		}else
			time_increment(); // ms counter less than 1000 - we need to increment time
		t = current_time.H * 3600 + current_time.M * 60 + current_time.S;
		if(t - last_corr_time == 1){ // PPS interval == 1s
			ticks =  systick_val + (timer_val-1)*(RVR0 + 1) + RVR1 + 1;
			++N;
			ticksavr += ticks;
			if(N > 20){
				ticks = ticksavr / N;
				RVR0 = ticks / 1000 - 1; // main RVR value
				STK_RVR = RVR0;
				RVR1 = RVR0 + ticks % 1000; // last millisecond RVR value (with fine correction)
				N = 0;
				ticksavr = 0;
				need_sync = 0;
			}
		}else{
			N = 0;
			ticksavr = 0;
		}
	theend:
		last_corr_time = t;
		EXTI_PR = EXTI4;
	}
}