Ejemplo n.º 1
0
/** \brief Register an external interrupt handler for the touch event.
 *
 */
void at42qt1060_register_eic_int(void (*touch_detect_callback)(void))
{
  eic_options_t eic_options[1];

  at42qt1060.touch_detect_callback = touch_detect_callback;

  gpio_enable_module_pin(AT42QT1060_DETECT_PIN, AT42QT1060_EIC_EXTINT_FUNCTION);

  Disable_global_interrupt();

  INTC_register_interrupt(&at42qt1060_detect_eic_int_handler, AT42QT1060_EIC_EXTINT_IRQ,
    AT42QT1060_EIC_EXTINT_LEVEL);

  eic_options[0].eic_mode = EIC_MODE_EDGE_TRIGGERED;
  eic_options[0].eic_level = EIC_EDGE_FALLING_EDGE;
  eic_options[0].eic_async = EIC_SYNCH_MODE;
  eic_options[0].eic_line = AT42QT1060_EIC_LINE;

  eic_init(&AVR32_EIC, &eic_options[0], 1);
  eic_enable_lines(&AVR32_EIC, (1 << eic_options[0].eic_line));
  eic_enable_interrupt_lines(&AVR32_EIC, (1 << eic_options[0].eic_line));

  Enable_global_interrupt();

  return;
}
Ejemplo n.º 2
0
void Actividad3(void){
	
pm_switch_to_osc0(&AVR32_PM,FOSC0,OSC0_STARTUP);

Disable_global_interrupt();
//! Structure holding the configuration parameters of the EIC module.
eic_options_t eic_options[2];

// Enable edge-triggered interrupt.
eic_options[0].eic_mode  = EIC_MODE_EDGE_TRIGGERED;
// Interrupt will trigger on falling edge (this is a must-do for the keypad scan
// feature if the chosen mode is edge-triggered).
eic_options[0].eic_edge  = EIC_EDGE_RISING_EDGE;
// Initialize in synchronous mode : interrupt is synchronized to the clock
eic_options[0].eic_async = EIC_SYNCH_MODE;
// Set the interrupt line number.
eic_options[0].eic_line  = QT1081_EIC_EXTINT_INT;


INTC_init_interrupts();
    /* Register the EXTINT1 interrupt handler to the interrupt controller
     */
	INTC_register_interrupt(&touch_button_isr, QT1081_EIC_EXTINT_IRQ, AVR32_INTC_INT0);
 // Init the EIC controller with the options
 eic_init(&AVR32_EIC, eic_options, 1);
 // Enable the EIC lines.
 eic_enable_lines(&AVR32_EIC, (1<<eic_options[0].eic_line));
 // Enable the interrupt for each EIC line.
 eic_enable_interrupt_lines(&AVR32_EIC, (1<<eic_options[0].eic_line));
 
 gpio_enable_module_pin( QT1081_EIC_EXTINT_PIN, QT1081_EIC_EXTINT_FUNCTION);

 Enable_global_interrupt();
 
 while (1){
	 gpio_tgl_gpio_pin(LED0_GPIO);
	 gpio_tgl_gpio_pin(LED1_GPIO);
	 gpio_tgl_gpio_pin(LED2_GPIO);
	 gpio_tgl_gpio_pin(LED3_GPIO);
	 delay_s(100);

 }
 

}
Ejemplo n.º 3
0
// main function
int main(void) {

	pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);

	// Enable edge-triggered interrupt.
	eic_options[0].eic_mode  = EIC_MODE_EDGE_TRIGGERED;
	// Interrupt will trigger on falling edge (this is a must-do for the keypad scan
	// feature if the chosen mode is edge-triggered).
	eic_options[0].eic_edge  = EIC_EDGE_RISING_EDGE;
	// Initialize in synchronous mode : interrupt is synchronized to the clock
	eic_options[0].eic_async = EIC_SYNCH_MODE;
	// Set the interrupt line number.
	eic_options[0].eic_line  = QT1081_EIC_EXTINT_INT;

	// Activate LED0 & LED1 & LED2 & LED3 pins in GPIO output mode and switch them off.
	gpio_set_gpio_pin(LED0_GPIO);
	gpio_set_gpio_pin(LED1_GPIO);
	gpio_set_gpio_pin(LED2_GPIO);
	gpio_set_gpio_pin(LED3_GPIO);

	gpio_enable_module_pin( QT1081_EIC_EXTINT_PIN, QT1081_EIC_EXTINT_FUNCTION);

#if( INT_MODE == INT_MODE_GPIO)
	Disable_global_interrupt();

#if __GNUC__
	INTC_init_interrupts();
    /* Register interrupt handler to the interrupt controller
     * up, down buttons on PB22, PB23 -> GPIO_IRQ_6
     */
	INTC_register_interrupt(&touch_button_isr, AVR32_GPIO_IRQ_6, 0);//AVR32_INTC_INT0);
	/* Other buttons on PB[24..26] -> GPIO_IRQ_7 (PB23 - PB31) */
	INTC_register_interrupt(&touch_button_isr, AVR32_GPIO_IRQ_7, 0);
#endif
	gpio_enable_pin_interrupt(QT1081_TOUCH_SENSOR_0, GPIO_RISING_EDGE);
	gpio_enable_pin_interrupt(QT1081_TOUCH_SENSOR_1, GPIO_RISING_EDGE);
	gpio_enable_pin_interrupt(QT1081_TOUCH_SENSOR_2, GPIO_RISING_EDGE);
	gpio_enable_pin_interrupt(QT1081_TOUCH_SENSOR_3, GPIO_RISING_EDGE);
	gpio_enable_pin_interrupt(QT1081_TOUCH_SENSOR_4, GPIO_RISING_EDGE);

	Enable_global_interrupt();
#endif

#if(INT_MODE == INT_MODE_EIC)
	Disable_global_interrupt();

#if __GNUC__
	INTC_init_interrupts();
    /* Register the EXTINT1 interrupt handler to the interrupt controller
     */
	INTC_register_interrupt(&touch_button_isr, QT1081_EIC_EXTINT_IRQ, AVR32_INTC_INT0);
#endif

	  // Init the EIC controller with the options
	  eic_init(&AVR32_EIC, eic_options, 1);
	  // Enable the EIC lines.
	  eic_enable_lines(&AVR32_EIC, (1<<eic_options[0].eic_line));
	  // Enable the interrupt for each EIC line.
	  eic_enable_interrupt_lines(&AVR32_EIC, (1<<eic_options[0].eic_line));

	Enable_global_interrupt();
#endif

	while(true);

	return 0;
}