Beispiel #1
0
/*
Valeur mini ? 1ms
Valeur neutre ? 1,50 ms
Valeur maxi ? 2,0ms
*/
void EXTI9_5_RFHandler(){
	if(Port_IO_Read(GPIOB, PIN_RF)){
		Timer_Run(TIM_RF_CNT);
	} else {
		timcnt = TIM_RF_CNT->CNT;
		Timer_Stop(TIM_RF_CNT);
		TIM_RF_CNT->CNT = 0;
		timcnt = (timcnt*TIM_RF_US)/autoreload;
		if (first>10){
			correction = timcnt;
			first=0;
		} else if (first!=0) {
			first+=1;
		} else {
			commande = timcnt - correction;
			if (commande > commande_max){
				commande_max=commande;
			} else if ((-commande) > commande_max){
				commande_max=(-commande);
			}
			if (commande > seuilCommande) {
				Port_IO_Set(GPIOA, 2);
				rapport = (float) commande/commande_max;
			} else if (commande < -seuilCommande) {
				Port_IO_Reset(GPIOA, 2);
				rapport = (float) (-commande)/commande_max;
			} else {
				rapport = 0;
			}
			update_PWM(TIM2, 1.0f-rapport, 2);
		}
	}
	EXTI->PR |= 0x1 << 6;
}
Beispiel #2
0
void InterruptHandler20(int *esp)
{
    UI_Timer *tree, *old;
    bool taskswitch;

    IO_Out8(PIC0_OCW2, 0x60);	/* IRQ-00受付完了をPICに通知 。0x60+番号。*/
    timerctrl.count++;
    taskswitch = false;

    if(timerctrl.count == timerctrl.next->timeout) {	//時間になった
        tree = timerctrl.next;
        timerctrl.next = timerctrl.next->next;
        for(;;) {	//同一タイムアウトを探す。
            if(tree->fifo != 0) {	//FIFOの送信先が有効かチェック
                FIFO32_Put(tree->fifo, tree->data);
            } else if(tree == timerctrl.ts) {
                taskswitch = true;
            }
            old = tree;
            tree = old->tree;
            old->tree = 0;	//同一タイムアウトなし
            old->state = configured;	//設定済み
            if(old->mode == interval) {	//繰り返すなら
                Timer_Run(old);
            }
            if(tree == 0) {	//もう同一タイムアウトはない
                break;
            }
        }
    }
    if(taskswitch) {
        MultiTask_TaskSwitch();
    }
    return;
}
Beispiel #3
0
void initGirouette(void){
	TIM_SERVO=TIM4;
	voie=3;
	
	// initialisation des broches pour la lecture en mode floating input
	Port_IO_Init_InputPull(GPIOA, 5); // Index
	Port_IO_Init_Input(GPIOA, 6); // A
	Port_IO_Init_Input(GPIOA, 7); // B
	
	// configuration du timer pour la position (angle) de la girouette
	// on multiplie par quatre car il y a 4 cas différents où le timer s'incrémente
	Timer_Compare_Count(360*4, TIM3);
	
	// configuration de la mise à jour du servo-moteur de la voile
	// met à jour la position de la voile à chaque période
	
	// enable SysTick
	SysTick->CTRL |= SysTick_CTRL_ENABLE;
	// enable interruption
	SysTick->CTRL |= SysTick_CTRL_TICKINT;
	
	Systick_Prio_IT(6, UpdateGrandeVoile);
	// toutes les 10ms
	Systick_Period(10000);
	
	// init the PWM
	Port_IO_Init_Alt_Output( GPIOB, 8);
	Timer_1234_PWM_Init(TIM_SERVO, tempsPWM, 0.87f, 1, voie);
	Timer_Run(TIM_SERVO);
}
Beispiel #4
0
void RF_Init(){
	// Timer pour compter
	TIM_RF_CNT=TIM1;
	
	first=1;
	correction=1500;
	commande_max=1;
	//Configure le pin du RF en entrée
	Timer_1234_Init(TIM_RF_CNT, TIM_RF_US);
	autoreload = TIM_RF_CNT->ARR;
	Port_IO_Init_InputPull(GPIOB, PIN_RF);
	
	//Configuration moteur 
	Port_IO_Init_Alt_Output(GPIOA, 1);
	Port_IO_Init_Output(GPIOA, 2);
	Port_IO_Set(GPIOA, 2);
	
	//Timer pour commander le moteur en PWM
	Timer_1234_PWM_Init(TIM2, tempsPWM, 0.0f, 1, 2);
	Timer_Run(TIM2);
}
Beispiel #5
0
uint Timer_TimeOut(void)
{
	UI_Timer *search, *old;

	search = timerctrl->timer_root;
	timerctrl->timer_root = timerctrl->timer_root->root_next;

	for(;;){
		if(search->fifo != Null){
			FIFO32_Put(search->fifo, search->fifo_putdata);
		}
		old = search;
		search = old->tree_next;
		old->tree_next = 0;
		old->flags.bit.running = False;
		if(old->flags.bit.interval){
			Timer_Run(old);
		}
		if(search == Null){
			break;
		}
	}
	return 0;
}
void DpyAndSwitch(void)
{
  static byte digito=0;				// digito a visualizar (0-3)
  static byte display=_DPY_INF;		// display a refrescar (sup/inf) 	
  byte leds; //conjunto de leds a mostrar
/* cada digito lo refresco cada 1 msg */
/* muestro display inferior */

  if(display==_DPY_INF)
  {
    
/* escaneo la ultima tecla */
  if (digito<4){
    
    if(digito==0)
      Switches(DigInfOn[digito]);
    
    #ifdef HD90
    	if(!HD90_flag && (KeyEdge=='u' || KeyEdge=='d'))
		  KeyEdge=0;
    #endif
    
    Display1_PutVal(0);		//PTA
    if(digito<2)					// PTM
    {  
      bits2ULN_PutVal(0);		//PTJ
      bits5ULN_PutVal(DigInfOn[digito]); //PTM
    }
    
    else 
    {
      bits5ULN_PutVal(0);
      bits2ULN_PutVal(DigInfOn[digito]);		// PTJ
      
    };
    if (Nletras[display]>4){
    if (Scroll) {
  	    Scroll=FALSE;
  	    b++;
        if (b==Nletras[display])
          b=0;  
		    Timer_Run(TIME_SCROLL,&Scroll,UNICO_SET);
    }
    c=b+digito;
    if (c>=Nletras[display]){
    c=c-Nletras[display];
    }
    }else c=digito;
    Display1_PutVal(DigDpy[display][c]);  //PTA
  } else {										//Muestro los leds (los puertos que seleccionan el digito ya se encuentran en el DL2)
  Display1_PutVal(0);	 //PTA
      if (led[outc1L]==TRUE)
      leds=1;
      else
      leds=0;
      #if NUM_SALIDAS > 1
	    if (led[outa1L]==TRUE)
      leds|=2;
	    #if NUM_SALIDAS > 2
	    if (led[outa2L]==TRUE)
      leds|=4;
	    #if NUM_SALIDAS > 3
	    if (led[outa3L]==TRUE)
      leds|=8;
	    #endif
	    #endif
	    #endif
	   bits5ULN_PutVal(leds); 	 //PTM
    }
 
  if(++digito==5)
  {
    digito=0;


//dan
    display=_DPY_SUP;
//  if(HD90_flag == 1)
//		display = _DPY_SUP;
//  else display =  _DPY_INF;
//dan  

  }
  }  
  
/* muestro display superior */

  else
  {
  
/* el escaneo del teclado se hace luego del envio de la señal de ON
   del digito para que el pin PULL se encuentre estable */
    
	if(digito>0)
	  Switches(DigSupOn[digito]);
		#ifdef HD90
		if(!HD90_flag && (KeyEdge=='u' || KeyEdge=='d'))
		  KeyEdge=0;
    if (KeyEdge=='r' || KeyEdge=='f'){
      HD90_flag = 0;
      Timer_Run(CHANGE_HD90_TEXT,&HD90_flag,UNICO_SET);     
    }
    #endif
	Display1_PutVal(0);		 //PTA
	bits2ULN_PutVal(0);
	bits5ULN_PutVal(DigSupOn[digito]);  //PTM
	//Display1_PutVal(DigDpy[0][digito]);	  //PTA
  if (Nletras[display]>4){
    if (Scroll) {
  	    Scroll=FALSE;
  	    d++;
        if (d==Nletras[display])
          d=0;  
		    Timer_Run(TIME_SCROLL,&Scroll,UNICO_SET);        
    }
    c=d+digito;
    if (c>=Nletras[display]){
    c=c-Nletras[display];
    }
    }else c=digito;
    #ifdef HD90
    Display1_PutVal(DigDpy[!HD90_flag][c]);  //PTA
    #else
    Display1_PutVal(DigDpy[display][c]);  //PTA
    #endif
  if(++digito==4)
  {
    digito=0;

    display=_DPY_INF;


  }
  }  
		  
  

}
void ResetScroll(void){
  b=d=0;								//resetear variables de SCROLL
	Scroll=FALSE;
	Timer_Run(TIME_SCROLL*2,&Scroll,UNICO_SET);					 //resetear variables de SCROLL
}