1: __attribute__((__interrupt__)) 2: static void int_handler_port1_line0 (void) 3: { 4: if( gpio_get_pin_interrupt_flag( QT1081_TOUCH_SENSOR_0 ) ) 5: { // PB2 generated the interrupt. 6: gpio_tgl_gpio_pin(LED1_GPIO); 7: // Clear the interrupt flag of the pin PB2 is mapped to. 8: gpio_clear_pin_interrupt_flag(QT1081_TOUCH_SENSOR_0); 9: } 10: } 11: 12: 13: // Main function 14: int main(void) 15: { 16: U32 i; 17: 18: // Set CPU and PBA clock 19: pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP); 20: 21: gpio_configure_pin(LED1_GPIO, GPIO_DIR_OUTPUT|GPIO_INIT_HIGH); 22: gpio_enable_pin_interrupt(QT1081_TOUCH_SENSOR_0, GPIO_PIN_CHANGE); 23: Disable_global_interrupt (); 24: INTC_init_interrupts (); 25: 26: // register push button handler for PB2 and PB3 27: INTC_register_interrupt( &int_handler_port1_line0, 28: AVR32_GPIO_IRQ_0 + (QT1081_TOUCH_SENSOR_0/8), 0); 29: 30: Enable_global_interrupt (); 31: while(true); 32: }
Tutorial 4 - External Hardware Interrupts - AT32UC3A
Subscribe to:
Post Comments (Atom)
Tutorial 5 -Timer/Counter, is corrupt :S
ReplyDelete