ISR(display_rtc_irq, DISPLAY_RTC_IRQ_GROUP, DISPLAY_RTC_IRQ_PRIORITY) { ui_display_draw_dot(); /* clear the interrupt flag */ rtc_clear_interrupt(&AVR32_RTC); }
__interrupt #endif void rtc_irq(void) { // Increment the minutes counter sec++; // clear the interrupt flag rtc_clear_interrupt(&AVR32_RTC); // specify that an interrupt has been raised print_sec = 1; }
/*! \brief Initializes QT60168 resources: GPIO and SPI */ static void ui_buttons_enable(void) { static const gpio_map_t QT60168_SPI_GPIO_MAP = { {QT60168_SPI_SCK_PIN, QT60168_SPI_SCK_FUNCTION}, {QT60168_SPI_MISO_PIN, QT60168_SPI_MISO_FUNCTION}, {QT60168_SPI_MOSI_PIN, QT60168_SPI_MOSI_FUNCTION}, {QT60168_SPI_NPCS0_PIN, QT60168_SPI_NPCS0_FUNCTION} }; /* SPI options. */ spi_options_t spiOptions = { .reg = QT60168_SPI_NCPS, .baudrate = QT60168_SPI_MASTER_SPEED, .bits = QT60168_SPI_BITS, .spck_delay = 0, .trans_delay = 0, .stay_act = 0, .spi_mode = 3, .modfdis = 1 }; /* Assign I/Os to SPI. */ gpio_enable_module(QT60168_SPI_GPIO_MAP, sizeof(QT60168_SPI_GPIO_MAP) / sizeof(QT60168_SPI_GPIO_MAP[0])); /* Initialize as master */ spi_initMaster(QT60168_SPI, &spiOptions); /* Set selection mode: variable_ps, pcs_decode, delay */ spi_selectionMode(QT60168_SPI, 0, 0, 0); /* Enable SPI */ spi_enable(QT60168_SPI); /* Initialize QT60168 with SPI clock Osc0. */ spi_setupChipReg(QT60168_SPI, &spiOptions, sysclk_get_cpu_hz()); qt60168_init(sysclk_get_cpu_hz()); } ISR(button_rtc_irq, BUTTON_RTC_IRQ_GROUP, BUTTON_RTC_IRQ_PRIORITY) { ui_buttons_read(); /* clear the interrupt flag */ rtc_clear_interrupt(&AVR32_RTC); }
__interrupt #endif void rtc_irq(void) { static volatile int delay_count=0; static unsigned short all_key= 0; static int update_delay = 0; delay_count++; update_delay++; if(update_delay>10) { if(special_qt60168_report_all_key(&all_key)==true) { update_delay=0; //gpio_tgl_gpio_pin(LED2_GPIO); Old_status = New_status; New_status = all_key; // The one that has just been read if(Old_status != New_status) { update_joystick_status( New_status); } if(New_status!=0) { // LED2 on if key is currently pressed gpio_clr_gpio_pin(LED2_GPIO); } else { gpio_set_gpio_pin(LED2_GPIO); } } } if(Read_data==1) { Read_data=2; delay_count=0; } if((delay_count>1)&&(Read_data==2)) { // We can read the DATA // Select QT60168 spi_selectChip(QT60168_SPI,QT60168_SPI_NCPS); // Read Reply spi_read(QT60168_SPI, &Data); // Unselect QT60168 spi_unselectChip(QT60168_SPI,QT60168_SPI_NCPS); Read_data=0; } // clear the interrupt flag rtc_clear_interrupt(&AVR32_RTC); }
ISR(rtc_irq, AVR32_RTC_IRQ_GROUP, AVR32_INTC_INT0) { static volatile int delay_count = 0; static unsigned short all_key = 0; static int update_delay = 0; delay_count++; update_delay++; if (update_delay > 10) { if (special_qt60168_report_all_key(&all_key) == true) { update_delay = 0; controller_keys_update(all_key); } } if (Read_data == 1) { Read_data = 2; delay_count = 0; } if ((delay_count > 1) && (Read_data == 2)) { // We can read the DATA // Select QT60168 spi_selectChip(QT60168_SPI,QT60168_SPI_NCPS); // Read Reply spi_read(QT60168_SPI, &Data); // Unselect QT60168 spi_unselectChip(QT60168_SPI,QT60168_SPI_NCPS); Read_data = 0; } // clear the interrupt flag rtc_clear_interrupt(&AVR32_RTC); }