コード例 #1
0
ファイル: schedule.c プロジェクト: Joey9801/Lynx
//DAC control interrupt
void tim2_isr(void){
	if(timer_interrupt_source(TIM3, TIM_SR_CC1IF)){
		gpio_set(GPIOA, GPIO12); //set the pin high. Must do this first for timing
		timer_clear_flag(TIM2, TIM_SR_CC1IF);
		//detect end of packet transmission
		/* if(end of packet){
			currently_transmitting = false;
			if(buffers_full){
				buffers_full=false;
				enable spi1 interrupts
				set 'full' pin low
			}
			timer_disable_counter(TIM2);
			timer_set_counter(TIM2, 0);
			gpio_clear(GPIOA, GPIO12); //set DAC-CLK low
		} */
	}
	if(timer_interrupt_source(TIM3, TIM_SR_UIF)){
		gpio_port_write(GPIOC, (next_transmit[1] | (next_transmit[0]<<8))); //set the dac-db pins
		gpio_clear(GPIOA, GPIO12); //set DAC-CLK low
		timer_clear_flag(TIM2, TIM_SR_UIF); //reset the interrupt flag
		generate_sample();
	}
	return;
}
コード例 #2
0
static int GetPulseTimeFiltered()
{
   int pulses = 0;

   if (timer_get_flag(REV_CNT_TIMER, TIM_SR_CC3IF))
   {
      ignore = 0;
      if (timer_get_flag(REV_CNT_TIMER, TIM_SR_UIF))
      {
         timer_clear_flag(REV_CNT_TIMER, TIM_SR_CC3IF);
         timer_clear_flag(REV_CNT_TIMER, TIM_SR_UIF);
         ignore = 1;
      }

      if (timer_get_flag(REV_CNT_TIMER, TIM_SR_CC3OF))
      {
         last_pulse_timespan = IIRFILTER(last_pulse_timespan, REV_CNT_CCR, filter);
         timer_clear_flag(REV_CNT_TIMER, TIM_SR_CC3OF);
         pulses = 2;
      }
      else
      {
         last_pulse_timespan = IIRFILTER(last_pulse_timespan, REV_CNT_CCR, filter);
         pulses = 1;
      }
   }

   return pulses;
}
コード例 #3
0
ファイル: board.c プロジェクト: iqyx/kiwi-basic
void tim2_isr(void) {
	if (TIM_SR(TIM2) & TIM_SR_CC2IF) {
		timer_clear_flag(TIM2, TIM_SR_CC2IF);

		gpsdo_1pps_irq_handler(&gpsdo);

		// printf("%u ticks=%u out=%d error=%d phase_error=%d pps_setpoint=%u\n", timer_get_counter(TIM2), gpsdo.pps_time_ticks, gpsdo.pps_steer, (int32_t)gpsdo.pps_error, (int32_t)gpsdo.phase_error, gpsdo.pps_setpoint);
	}
	if (TIM_SR(TIM2) & TIM_SR_CC3IF) {
		timer_clear_flag(TIM2, TIM_SR_CC3IF);

		gpsdo_housekeeping_irq_handler(&gpsdo);
		struct gpsdo_sync_stats stats;
		gpsdo_get_sync_status(&gpsdo, &stats);

		/*
		printf("gpsdo sync stats:\n");

		printf("  phase error: %d ns\n", stats.phase_error);
		printf("  period error: %d ns\n", stats.period_error);

		const char *status_str = "?";
		switch (stats.status) {
			case GPSDO_SYNC_STATUS_UNKNOWN: status_str = "UNKNOWN"; break;
			case GPSDO_SYNC_STATUS_ADJUSTING: status_str = "ADJUSTING"; break;
			case GPSDO_SYNC_OK: status_str = "OK"; break;
		}
		printf("  sync status: %s\n", status_str);
		*/

	}

}
コード例 #4
0
ファイル: ppm_arch.c プロジェクト: jornanke/paparazzi
void tim2_isr(void) {

  if((TIM2_SR & TIM_SR_CC2IF) != 0) {
    timer_clear_flag(TIM2, TIM_SR_CC2IF);

    uint32_t now = timer_get_counter(TIM2) + timer_rollover_cnt;
    DecodePpmFrame(now);
  }
  else if((TIM2_SR & TIM_SR_UIF) != 0) {
    timer_rollover_cnt+=(1<<16);
    timer_clear_flag(TIM2, TIM_SR_UIF);
  }

}
コード例 #5
0
/** Fonction that clears the flag of interuption in order to reactivate the interuption
 */
void clear_timer_flag(void)
{

#if DUAL_PWM_USE_TIM5
  timer_clear_flag(TIM5, TIM_SR_CC1IF);
#endif
}
コード例 #6
0
void tim2_isr(void)
{
	gpio_toggle(GPIOB, GPIO8);              /* LED1 on/off. */
	if (timer_get_flag(TIM2, TIM_SR_UIF))
        timer_clear_flag(TIM2, TIM_SR_UIF); /* Clear interrrupt flag. */
	timer_get_flag(TIM2, TIM_SR_UIF);	/* Reread to force the previous write */
}
コード例 #7
0
ファイル: porttimer.c プロジェクト: JamesLinus/ARM-Ports
void tim2_isr(void)
{
count++;
	if (timer_interrupt_source(TIM2, TIM_SR_UIF)) timer_clear_flag(TIM2, TIM_SR_UIF); /* Clear interrrupt flag. */
	timer_get_flag(TIM2, TIM_SR_UIF);	/* Reread to force the previous (buffered) write before leaving */
    pxMBPortCBTimerExpired();
}
コード例 #8
0
void tim1_up_tim10_isr(void) 
{
  //oscilloscope flag: start of interrupt
  gpio_set(GPIOD, GPIO11);

   
  //Clear the update interrupt flag
  timer_clear_flag(TIM1,  TIM_SR_UIF);

  calc_freq();

// /* ORIGINAL
if (center_aligned_state==FIRST_HALF)
{
  //oscilloscope flag: start of First HALF
  gpio_set(GPIOB, GPIO15);
  voltage_measure (ADC1,ADC_CHANNEL1);
}
else 
{
  //oscilloscope flag: start of second half
  gpio_set(GPIOD, GPIO9);
  DTC_SVM();
  collecting_floating_data();
  colllecting_flux_linkage();
  gpio_clear(GPIOD, GPIO11);
}

  //oscilloscope flag: start of halves
  //gpio_clear(GPIOB, GPIO15);

  //oscilloscope flag: end of interrupt
  gpio_clear(GPIOD, GPIO9);
  
}
コード例 #9
0
ファイル: stm32f4-discovery.c プロジェクト: via/tfi-computer
void tim2_isr() {
  if (timer_get_flag(TIM2, TIM_SR_CC1IF)) {
    timer_clear_flag(TIM2, TIM_SR_CC1IF);
    scheduler_execute();
  }
  if (timer_get_flag(TIM2, TIM_SR_CC2IF)) {
    timer_clear_flag(TIM2, TIM_SR_CC2IF);
    config.decoder.last_t0 = TIM2_CCR2;
    config.decoder.needs_decoding_t0 = 1;
  }
  if (timer_get_flag(TIM2, TIM_SR_CC3IF)) {
    timer_clear_flag(TIM2, TIM_SR_CC3IF);
    config.decoder.last_t1 = TIM2_CCR3;
    config.decoder.needs_decoding_t1 = 1;
  }
}
コード例 #10
0
ファイル: timer.c プロジェクト: garychan/pcbwriter
void tim1_up_tim10_isr(void)
{
    if(timer_get_flag(TIM1, TIM_SR_UIF)) {
        timer_clear_flag(TIM1, TIM_SR_UIF);
        if(n_overflow <= 8) n_overflow++;
    }
}
コード例 #11
0
ファイル: stepper_motors.c プロジェクト: eddyem/IR-controller
void tim4_isr(){
	if(timer_get_flag(TIM4, TIM_SR_UIF)){
		// Clear compare interrupt flag
		timer_clear_flag(TIM4, TIM_SR_UIF);
		timer_flag[1] = 1;
	}
}
コード例 #12
0
ファイル: glove.c プロジェクト: franmolinaca/Electroweed
void tim1_up_tim10_isr(void) 
{
  //Clear the update interrupt flag
  timer_clear_flag(TIM1,TIM_SR_UIF);
	
    float voltage_joint_0 = 0.0f;      
    float voltage_joint_1 = 0.0f;
    float voltage_joint_2 = 0.0f;

    float joint_0_angle = 0.0f;
    float joint_1_angle = 0.0f;
    //float joint_2_angle = 0.0f;

	static int counter = 0;
	counter +=1 ;
	if(counter >=1500)// Print frequency each n cycles

	{
        voltage_joint_0	= voltage_measure (ADC1,ADC_CHANNEL1);      
        voltage_joint_1	= voltage_measure (ADC1,ADC_CHANNEL2);
        voltage_joint_2 = voltage_measure (ADC1,ADC_CHANNEL3);

        joint_0_angle = CONVERSION_FACTOR_JOINT_0*voltage_joint_0;
        joint_1_angle = CONVERSION_FACTOR_JOINT_1*voltage_joint_1;
        joint_2_angle = CONVERSION_FACTOR_JOINT_2*voltage_joint_2;  
        printf("%6.2f \n",joint_2_angle); 
		counter=0;
	}	

  }
コード例 #13
0
void tim2_isr(void)
{
	if (timer_get_flag(TIM2, TIM_SR_CC1IF)) {

		/* Clear compare interrupt flag. */
		timer_clear_flag(TIM2, TIM_SR_CC1IF);

		/*
		 * Get current timer value to calculate next
		 * compare register value.
		 */
		compare_time = timer_get_counter(TIM2);

		/* Calculate and set the next compare value. */
		frequency = frequency_sequence[frequency_sel++];
		new_time = compare_time + frequency;

		timer_set_oc_value(TIM2, TIM_OC1, new_time);
		if (frequency_sel == 18)
			frequency_sel = 0;

		/* Toggle LED to indicate compare event. */
		gpio_toggle(GPIOC, GPIO12);
	}
}
コード例 #14
0
ファイル: gps.c プロジェクト: cuspaceflight/DorMouse
static int command(char *command, size_t length)
{
    size_t i;

    calculate_crc_and_ack(command, length);

    for (i = 0; i < length; i++)
        usart_send_blocking(USART2, command[i]);

    timer_set_counter(TIM5, 0);
    timer_clear_flag(TIM5, TIM_SR_UIF);
    timer_enable_counter(TIM5);

    for (i = 0; i < sizeof(expect_ack); )
    {
        while (!timer_get_flag(TIM5, TIM_SR_UIF) &&
               !usart_get_flag(USART2, USART_SR_RXNE));

        if (timer_get_flag(TIM5, TIM_SR_UIF))
            break;

        if (expect_ack[i] != usart_recv(USART2))
            break;
    }

    timer_disable_counter(TIM5);

    return (i == sizeof(expect_ack));
}
コード例 #15
0
ファイル: boxcar.c プロジェクト: karlp/karlnet
void tim7_isr(void)
{
	timer_clear_flag(TIM7, TIM_SR_UIF);
	state.rht_timeout = true;
	nvic_disable_irq(NVIC_TIM7_IRQ);
	timer_disable_irq(TIM7, TIM_DIER_UIE);
	timer_disable_counter(TIM7);
}
コード例 #16
0
ファイル: ppm_arch.c プロジェクト: jornanke/paparazzi
void tim1_cc_isr(void) {
  if((TIM2_SR & TIM_SR_CC3IF) != 0) {
    timer_clear_flag(TIM1, TIM_SR_CC3IF);

    uint32_t now = timer_get_counter(TIM1) + timer_rollover_cnt;
    DecodePpmFrame(now);
  }
}
コード例 #17
0
ファイル: schedule.c プロジェクト: Joey9801/Lynx
//input timeout interrupt
void tim4_isr(void){
	//stop the timer
	//cancle the current input read
	//fill the rest of the current input buffer with 0's
	//set the right status flags for read-in finish
	timer_clear_flag(TIM4, TIM_SR_UIF);
	return;
}
コード例 #18
0
ファイル: usbuart.c プロジェクト: FlyingCampDesign/blackmagic
void USBUSART_TIM_ISR(void)
{
	/* need to clear timer update event */
	timer_clear_flag(USBUSART_TIM, TIM_SR_UIF);

	/* process FIFO */
	usbuart_run();
}
コード例 #19
0
ファイル: ppm_arch.c プロジェクト: F34140r/paparazzi
void tim1_up_isr(void) {
#elif defined(STM32F4)
void tim1_up_tim10_isr(void) {
#endif
  if((TIM1_SR & TIM_SR_UIF) != 0) {
    timer_rollover_cnt+=(1<<16);
    timer_clear_flag(TIM1, TIM_SR_UIF);
  }
}

void tim1_cc_isr(void) {
  if((TIM1_SR & PPM_CC_IF) != 0) {
    timer_clear_flag(TIM1, PPM_CC_IF);

    uint32_t now = timer_get_counter(TIM1) + timer_rollover_cnt;
    DecodePpmFrame(now);
  }
}
コード例 #20
0
void tim2_isr() {
  timer_clear_flag(TIM2, TIM_SR_UIF);
  led_toggle(LED_GREEN);

  /* Random transmit length. */
  u32 len = (u32)rand() % 256;
  if(debug_send_msg(0x22, len, buff_out))
    speaking_death("debug_send_msg failed in tim2_isr");
}
コード例 #21
0
void tim2_isr(void)
{
	gpio_toggle(GPIOB, GPIO8);              /* LED2 on/off. */
	if (timer_get_flag(TIM2, TIM_SR_UIF))
        timer_clear_flag(TIM2, TIM_SR_UIF); /* Clear interrrupt flag. */
	timer_get_flag(TIM2, TIM_SR_UIF);	/* Reread to force the previous write */
	timer_disable_irq(TIM2, TIM_DIER_UIE);
	timer_disable_counter(TIM2);
}
コード例 #22
0
ファイル: transmit.c プロジェクト: Joey9801/Lynx
void tim2_isr(void){
	if(timer_interrupt_source(TIM2, TIM_SR_CC1IF)){
		gpio_set(GPIOA, GPIO14);
		timer_clear_flag(TIM2, TIM_SR_CC1IF);

		//now to generate the next sample
		generate_sample();
		i++;
		if(i==n)
			i=0;
	}
	if(timer_interrupt_source(TIM2, TIM_SR_UIF)){
		gpio_clear(GPIOA, GPIO14); //set DAC-CLK low
		gpio_port_write(GPIOC, (next_transmit[1] | (next_transmit[0]<<8))); //set the dac-db pins
		timer_clear_flag(TIM2, TIM_SR_UIF);
	}
	return;
}
コード例 #23
0
ファイル: latency-tester.c プロジェクト: GBert/misc
void tim1_cc_isr(void) {
    static int last_value = 0;
    int value;
    if (timer_get_flag(TIM1, TIM_SR_CC1IF) != 0) {
	// Timer channel 1 interrupt -> First edge (outcoming signal).
	timer_clear_flag(TIM1, TIM_SR_CC1IF);
	last_value = timer_get_counter(TIM1);
    }
    if (timer_get_flag(TIM1, TIM_SR_CC2IF)) {
	// Timer channel 2 interrupt -> response (incoming signal).
	timer_clear_flag(TIM1, TIM_SR_CC2IF);
	value = timer_get_counter(TIM1) - last_value;
	if (value < 0)
	    value = value + 0xffff;
	latency = value;
	if (latency > latency_max)
	    latency_max = latency;
    }
}
コード例 #24
0
ファイル: plc_wait_tmr.c プロジェクト: colossus212/yaplc
void PLC_WAIT_TMR_ISR(void)
{
    if (timer_get_flag(PLC_WAIT_TMR, TIM_SR_UIF))
    {

        /* Clear compare interrupt flag. */
        timer_clear_flag(PLC_WAIT_TMR, TIM_SR_UIF);
        plc_sys_timer++;
        plc_iom_tick();
    }
}
コード例 #25
0
ファイル: led.c プロジェクト: hyrant/fulcrum
void LED_blink(void)
{
    if (blinkInProgress)
        return;
    blinkInProgress = 1;
    
    set_led(true);
    TIM2_CNT = 0;
    timer_clear_flag(TIM2, TIM_SR_UIF);
    timer_enable_counter(TIM2);
}
コード例 #26
0
//*************************************************Interrupción****************************************
void tim1_up_tim10_isr(void) 
{  
  //Clear the update interrupt flag
  timer_clear_flag(TIM1,TIM_SR_UIF);
   

		



}
コード例 #27
0
ファイル: stm32f4-discovery.c プロジェクト: via/tfi-computer
void tim1_cc_isr() {
  timeval_t t = TIM1_CCR1;
  timer_clear_flag(TIM1, TIM_SR_CC1IF);
  for (int i = 0; i < NUM_SENSORS; ++i) {
    if ((config.sensors[i].method == SENSOR_FREQ) &&
        (config.sensors[i].pin == 1)) {
      config.sensors[i].raw_value = t;
    }
  }
  sensor_freq_new_data();
}
コード例 #28
0
ファイル: boxcar.c プロジェクト: karlp/karlnet
/**
 * We set this timer to count uSecs.
 * The interrupt is only to indicate that it timed out and to shut itself off.
 */
void setup_tim7(void)
{

	timer_clear_flag(TIM7, TIM_SR_UIF);
	TIM7_CNT = 1;
	timer_set_prescaler(TIM7, 23); // 24Mhz/1Mhz - 1
	timer_set_period(TIM7, RHT_INTER_BIT_TIMEOUT_USEC);
	timer_enable_irq(TIM7, TIM_DIER_UIE);
	nvic_enable_irq(NVIC_TIM7_IRQ);
	timer_enable_counter(TIM7);
}
コード例 #29
0
ファイル: pwm.c プロジェクト: Project014/Software_nucleo
void tim2_isr(void)
{
  /* reset interrupt flag */
  if (timer_get_flag(TIM2, TIM_DIER_UIE)) {
    timer_clear_flag(TIM2, TIM_DIER_UIE);
  }

  /* call user callback */
  uint16_t next_value;
  pwm_update_callback(&next_value);
  pwm_set(next_value);
}
コード例 #30
0
ファイル: led.c プロジェクト: hyrant/fulcrum
void tim2_isr(void)
{
    timer_clear_flag(TIM2, TIM_SR_UIF);
        
    if (++blinkInProgress > 2) {
        blinkInProgress = 0;
    } else {
        set_led(false);
        TIM2_CNT = 0;
        timer_enable_counter(TIM2);
    }
}