static void tc_irq(void) { // La lecture du registre SR efface le fanion de l'interruption. tc_read_sr(EXAMPLE_TC, TC_CHANNEL); // Toggle le premier et le second LED. gpio_tgl_gpio_pin(LED0_GPIO); gpio_tgl_gpio_pin(LED1_GPIO); }
/** * \brief Touch measurement timer interrupt. * * Initiates periodically touch measurements. * Triggers every 1ms and will set the flag time_to_measure_touch every * TOUCH_MEASUREMENT_PERIOD_MS ms. */ ISR(tc_irq, TOUCH_MEASUREMENT_TC_IRQ_GROUP, AVR32_INTC_INT0) { tc_read_sr(TOUCH_MEASUREMENT_TC, TOUCH_MEASUREMENT_TC_CHANNEL); current_time_ms++; if ((current_time_ms % measurement_period_ms) == 0) { time_to_measure_touch = true; } }
__interrupt #endif static void tc_irq_handler(void) { // Clear the interrupt flag. This is a side effect of reading the TC SR. chan_status = tc_read_sr(EXAMPLE_TC, EXAMPLE_TC_CHANNEL); // Toggle LED0. gpio_tgl_gpio_pin(LED0_GPIO); }
static void tc_irq(void) { // Increment the ms seconds counter tc_tick++; if(tc_tick % 30 == 0){ exe = true; } // Clear the interrupt flag. This is a side effect of reading the TC SR. tc_read_sr(tc, TC_CHANNEL); }
static void irq_tc(void) { tcTicks++; // overflow control if(tcTicks > tcMax) { tcTicks = 0; tcOverflow = 1; } else { tcOverflow = 0; } process_timers(); // clear interrupt flag by reading timer SR tc_read_sr(APP_TC, APP_TC_CHANNEL); }
__interrupt #endif static void tc_irq(void) { // Increment the ms seconds counter tc_tick++; // Clear the interrupt flag. This is a side effect of reading the TC SR. tc_read_sr(EXAMPLE_TC, EXAMPLE_TC_CHANNEL); // specify that an interrupt has been raised //update_timer = true; /* if ( tc_tick % 1000 == 0 ) { printf( "Rawr %d\r\n", sysclk_get_pba_hz() ); tc_tick = 0; } */ if ( tc_tick == IN_FORMAT_LSBYTE_SAMPLE_FREQ ) { //printf( "weee %u %u\r\n", tc_tick, udi_audio_is_active() ); tc_tick = 0; } if ( udi_audio_is_active() ) { int16_t a = tc_tick; //ADC_ReadSampleAndSetNextAddr( 4 ); /* samples[sampleIndex] = LE16( ADC_ReadSampleAndSetNextAddr( 2 ) ); sampleIndex++; */ for ( int j = 0; j < IN_FORMAT_NB_CHANNELS; j++ ) { //samples[sampleIndex] = LE16( ADC_ReadSampleAndSetNextAddr( (j+1) % IN_FORMAT_NB_CHANNELS ) ); if ( latestSelector[j] ) { samples[sampleIndex] = LE16( latestSamples2[j] ); } else { samples[sampleIndex] = LE16( latestSamples1[j] ); } //samples[sampleIndex] = LE16( latestSamples[j] ); sampleIndex++; if ( sampleIndex >= SAMPLES_PER_PACKET ) { udi_audio_send_samples( samples, (SAMPLE_SIZE * SAMPLES_PER_PACKET) ); sampleIndex = 0; } } } }
/** * \brief TIMER ISR * \param tc_irq is the subroutine function name * \param GRP is the group under which the interrupt lies * \param LVL is the priority level assigned for the group */ ISR(tc_irq,GRP,LVL) { // update the current time current_time_ms_touch++; // Every 25th ms if( (current_time_ms_touch % qt_measurement_period_msec) == 0u ) { // set flag: it's time to measure touch time_to_measure_touch = 1u; } // Clear the interrupt flag. This is a side effect of reading the TC SR. tc_read_sr(&AVR32_TC, TC_CHANNEL); }
__interrupt #endif static void tc_irq(void) { // Increment the ms seconds counter tc_tick++; // Clear the interrupt flag. This is a side effect of reading the TC SR. tc_read_sr(EXAMPLE_TC, EXAMPLE_TC_CHANNEL); // specify that an interrupt has been raised update_timer = true; // Toggle a GPIO pin (this pin is used as a regular GPIO pin). LED_Toggle(LED0); }
__interrupt #endif static void tc1_callback(void) { uint32_t status = tc_read_sr(TIMER, TIMER_CHANNEL_ID); status &= tc_get_interrupt_settings(TIMER, TIMER_CHANNEL_ID); if ((status & AVR32_TC_IDR2_COVFS_MASK) == AVR32_TC_IDR2_COVFS_MASK) { tmr_ovf_callback(); } if ((status & AVR32_TC_IDR2_CPCS_MASK) == AVR32_TC_IDR2_CPCS_MASK) { tmr_cca_callback(); } }
static void tc_irq(void) { // Increment the ms seconds counter tc_tick++; /* * TODO: Place a breakpoint here and watch the update of tc_tick variable * in the Watch Window. */ // Clear the interrupt flag. This is a side effect of reading the TC SR. tc_read_sr(EXAMPLE_TC, EXAMPLE_TC_CHANNEL); // specify that an interrupt has been raised update_timer = true; // Toggle the GPIO line gpio_tgl_gpio_pin(EXAMPLE_TOGGLE_PIN); }
static void tc_irq(void) { // clear the interrupt flag by reading the status register tc_read_sr(CONFIG_BSP_BUZZER_REP_TIMER, CONFIG_BSP_BUZZER_REP_CHANNEL); // run the state machine if (s_buzzer) { if (s_period_counter == 0) { next_state(); } else { reset_timeout(); } } }
static void irq_tc(void) { tcTicks++; // overflow control if(tcTicks > tcMax) { tcTicks = 0; tcOverflow = 1; } else { tcOverflow = 0; } process_timers(); if(tog) { tog = 0; gpio_clr_gpio_pin(LED_MODE_PIN); } else { tog = 1; gpio_set_gpio_pin(LED_MODE_PIN); } // clear interrupt flag by reading timer SR tc_read_sr(APP_TC, APP_TC_CHANNEL); }
static void tmr_match_common_handler( int id ) { volatile avr32_tc_t *tc = &AVR32_TC; tc_read_sr( tc, id ); // clear interrupt #if VTMR_NUM_TIMERS > 0 if( id == VTMR_CH ) { cmn_virtual_timer_cb(); platform_eth_timer_handler(); platform_cdc_timer_handler(); } else #endif cmn_int_handler( INT_TMR_MATCH, id ); if( avr32_timer_int_periodic_flag[ id ] != PLATFORM_TIMER_INT_CYCLIC ) { tc->channel[ id ].IDR.cpcs = 1; tc->channel[ id ].CMR.waveform.wavsel = TC_WAVEFORM_SEL_UP_MODE; } }
/*! \brief Configure timer ISR to fire regularly. */ void init_timer (void) { volatile avr32_tc_t *tc = EXAMPLE_TC; /* options for waveform generation. */ static const tc_waveform_opt_t WAVEFORM_OPT = { .channel = EXAMPLE_TC_CHANNEL, /* Channel selection. */ .bswtrg = TC_EVT_EFFECT_NOOP, /* Software trigger effect on TIOB. */ .beevt = TC_EVT_EFFECT_NOOP, /* External event effect on TIOB. */ .bcpc = TC_EVT_EFFECT_NOOP, /* RC compare effect on TIOB. */ .bcpb = TC_EVT_EFFECT_NOOP, /* RB compare effect on TIOB. */ .aswtrg = TC_EVT_EFFECT_NOOP, /* Software trigger effect on TIOA. */ .aeevt = TC_EVT_EFFECT_NOOP, /* External event effect on TIOA. */ .acpc = TC_EVT_EFFECT_NOOP, /* RC compare effect on TIOA: toggle. */ .acpa = TC_EVT_EFFECT_NOOP, /* RA compare effect on TIOA: toggle (other possibilities are none, set and clear). */ .wavsel = TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER, /* Waveform selection: Up mode with automatic trigger(reset) on RC compare. */ .enetrg = 0u, /* External event trigger enable. */ .eevt = 0u, /* External event selection. */ .eevtedg = TC_SEL_NO_EDGE, /* External event edge selection. */ .cpcdis = 0u, /* Counter disable when RC compare. */ .cpcstop = 0u, /* Counter clock stopped with RC compare. */ .burst = 0u, /* Burst signal selection. */ .clki = 0u, /* Clock inversion. */ .tcclks = TC_CLOCK_SOURCE_TC3 /* Internal source clock 3, connected to fPBA / 8. */ }; static const tc_interrupt_t TC_INTERRUPT = { .etrgs = 0u, .ldrbs = 0u, .ldras = 0u, .cpcs = 1u, .cpbs = 0u, .cpas = 0u, .lovrs = 0u, .covfs = 0u }; /* initialize the timer/counter. */ tc_init_waveform (tc, &WAVEFORM_OPT); /* set the compare triggers. */ tc_write_rc (tc, EXAMPLE_TC_CHANNEL, EXAMPLE_RC_VALUE); /* configure Timer interrupt. */ tc_configure_interrupts (tc, EXAMPLE_TC_CHANNEL, &TC_INTERRUPT); /* start the timer/counter. */ tc_start (tc, EXAMPLE_TC_CHANNEL); } /*! \brief Timer compare ISR. */ #if (defined __GNUC__) __attribute__ ((__interrupt__)) #elif (defined __ICCAVR32__) __interrupt #endif static void tc_irq (void) { /* update the current time */ current_time_ms_touch++; /* every 25th ms */ if ((current_time_ms_touch % measurement_period_ms) == 0u) { /* set flag: it's time to measure touch */ time_to_measure_touch = 1u; } /* clear the interrupt flag. This is a side effect of reading the TC SR. */ tc_read_sr (EXAMPLE_TC, EXAMPLE_TC_CHANNEL); }
bool standalone_mode_run(void) { char tempstring1[24]; while(detect_lcd()==false); usart_write_line(LCD_USART, "play stndprog\r\n"); while(detect_lcd()==false); usart_write_line(LCD_USART, "DMETER_VALUE 1 1\r\n"); while(detect_lcd()==false); sprintf(tempstring1,"DMETER_VALUE 2 %u\r\n",t_experiment.N_experiments); usart_write_line(LCD_USART, tempstring1); while(detect_lcd()==false); usart_write_line(LCD_USART, "DMETER_VALUE 3 1\r\n"); while(detect_lcd()==false); sprintf(tempstring1,"DMETER_VALUE 4 %u\r\n",t_experiment.N_sequences); usart_write_line(LCD_USART, tempstring1); while(detect_lcd()==false); reset_SD_sink_ptr(); //start saving data at data_base_addr DAC1->dr0=t_experiment.t_Vgain; //set gain of RF amp tc_write_rc(SLOW_TC,SLOW_TC_slow_CHANNEL,t_experiment.t_sequence[0].t_TR); tc_start(SLOW_TC, SLOW_TC_slow_CHANNEL); //start slow timer tc_start(SLOW_TC, SLOW_TC_fast_CHANNEL); //start slow timer pdca_disable(USB_USART_RX_PDCA_CHANNEL); //Not going to need USB USART for a while pdca_disable(USB_USART_TX_PDCA_CHANNEL); bool progscreen=true; //state variable for user interface for(uint16_t experimentcount=0;experimentcount<t_experiment.N_experiments;experimentcount++) { for(uint8_t sequencecount=0;sequencecount<t_experiment.N_sequences;sequencecount++) { t_currentsequence=t_experiment.t_sequence[sequencecount]; //get sequence while((tc_read_sr(SLOW_TC, SLOW_TC_slow_CHANNEL) & AVR32_TC_SR1_CPCS_MASK)==0); tc_write_rc(SLOW_TC,SLOW_TC_slow_CHANNEL,t_experiment.t_sequence[sequencecount].t_TR); char *LCDCMD=get_LCD_cmd(); if((progscreen==true) && (strcmp(LCDCMD,"BR2\r")==0)) //BR2 is first cancel button { progscreen=false; usart_write_line(LCD_USART, "play confcanc\r\n"); while(detect_lcd()==false); } else if((progscreen==false) && (strcmp(LCDCMD,"BR3\r")==0)) //BR3 is confirm cancel button { usart_write_line(LCD_USART, "play modesel\r\n"); //maybe modsel isn't necessary here, but will be done after return? return false; } else if((progscreen==false) && (strcmp(LCDCMD,"BR1\r")==0)) //BR1 if resume button { progscreen=true; usart_write_line(LCD_USART, "play stndprog\r\n"); while(detect_lcd()==false); sprintf(tempstring1,"DMETER_VALUE 1 %u\r",(experimentcount+1)); usart_write_line(LCD_USART, tempstring1); while(detect_lcd()==false); sprintf(tempstring1,"DMETER_VALUE 2 %u\r",t_experiment.N_experiments); usart_write_line(LCD_USART, tempstring1); while(detect_lcd()==false); sprintf(tempstring1,"DMETER_VALUE 3 %u\r",(sequencecount+1)); usart_write_line(LCD_USART, tempstring1); while(detect_lcd()==false); sprintf(tempstring1,"DMETER_VALUE 4 %u\r",t_experiment.N_sequences); usart_write_line(LCD_USART, tempstring1); while(detect_lcd()==false); } else if(progscreen==true) { sprintf(tempstring1,"DMETER_VALUE 1 %u\r",(experimentcount+1)); gpio_set_gpio_pin(GEN1_pin); usart_write_line(LCD_USART, tempstring1); while(wait_for_CR()==false); gpio_clr_gpio_pin(GEN1_pin); sprintf(tempstring1,"DMETER_VALUE 3 %u\r",(sequencecount+1)); gpio_set_gpio_pin(GEN1_pin); usart_write_line(LCD_USART, tempstring1); while(wait_for_CR()==false); gpio_clr_gpio_pin(GEN1_pin); } executesequence_SDstorage_multiprep_combined(); } } return true; }
/*! \brief to enable overflow interrupt */ void tmr_enable_ovf_interrupt(void) { tc_read_sr(TIMER, TIMER_CHANNEL_ID); tc_interrupt.covfs = 1; tc_configure_interrupts(TIMER, TIMER_CHANNEL_ID, &tc_interrupt); }
void clear_timer_interrupt() { // Clear the interrupt flag. This is a side effect of reading the TC SR. tc_read_sr(EXAMPLE_TC, EXAMPLE_TC_CHANNEL); }