/***************************************************************************//** * @brief * GPIO even interrupt handler * * @details * This function is automatically called by the hardware upon incoming * interrupt generated by an even-numbered GPIO pin. ******************************************************************************/ void GPIO_EVEN_IRQHandler(void) { uint32_t flag; uint32_t system_mask = TD_GPIO_Hooks[TD_GPIO_SYSTEM_EVEN].mask; uint32_t user_mask = TD_GPIO_Hooks[TD_GPIO_USER_EVEN].mask; // Get interrupt bits flag = GPIO_IntGet() & TD_GPIO_EVEN_MASK & GPIO_IntGetEnabled(); // Acknowledge IRQ. // We acknowledge all IRQ read, for this IRQ (EVEN) and enabled // even if theses IRQ are not used (otherwise, it will infinitely reenter in this IRQ) GPIO_IntClear(flag); #ifdef WAKE_MAIN_LOOP_DEBUG tfp_printf("IO:0x%08X\r\n"); #endif // System hook set on odd IRQ if (TD_GPIO_Hooks[TD_GPIO_SYSTEM_EVEN].callback && (flag & system_mask)) { // Call the IRQ hook TD_GPIO_Hooks[TD_GPIO_SYSTEM_EVEN].callback(flag & system_mask); // Remember that this interrupt source has been processed flag &= ~system_mask; TD_WakeMainLoop(); } // User hook on even IRQ if (TD_GPIO_Hooks[TD_GPIO_USER_EVEN].callback && (flag & user_mask)) { // Call the IRQ hook TD_GPIO_Hooks[TD_GPIO_USER_EVEN].callback(flag & user_mask); TD_WakeMainLoop(); } }
void GPIO_ODD_IRQHandler(void) { uint16_t intFlags = GPIO_IntGet(); /* clear flag for FIX interrupt */ GPIO_IntClear(intFlags); GPIO_PinOutToggle(EXT_LED, RED_LED); fix_val++; }
/** * @brief Actual interrupt handler for both even and odd pin index numbers. */ static void gpio_irq(void) { for (int i = 0; i < NUMOF_IRQS; i++) { if (GPIO_IntGet() & (1 << i)) { isr_ctx[i].cb(isr_ctx[i].arg); GPIO_IntClear(1 << i); } } cortexm_isr_end(); }
void GPIO_ODD_IRQHandler(void) { uint32_t interrupts = GPIO_IntGet() & 0xaaaaaaaa; GPIO_IntClear(interrupts); if (interrupts & (1 << ACC_INT_PIN)) { // A.5 fd_event_set(FD_EVENT_ACC_INT); } if (interrupts & (1 << CHG_STAT_PIN)) { // C.9 fd_event_set(FD_EVENT_CHG_STAT); } }
/** * @brief Actual interrupt handler for both even and odd pin index numbers. */ static void gpio_irq(void) { for (int i = 0; i < NUMOF_IRQS; i++) { if (GPIO_IntGet() & (1 << i)) { isr_ctx[i].cb(isr_ctx[i].arg); GPIO_IntClear(1 << i); } } if (sched_context_switch_request) { thread_yield(); } }
/**************************************************************************//** * @brief Button Handler * Shared by GPIO Even and GPIO Odd interrupt handlers *****************************************************************************/ void button_handler() { uint32_t interrupt_source = GPIO_IntGet(); /* Both buttons were pushed - toggle the timer */ if (pb1_is_pushed && pb0_is_pushed) { toggleTimer = true; } if (toggleTimer) { /* Wait for both buttons to be released */ if (!pb1_is_pushed && !pb0_is_pushed) { if (enableTimer) { SegmentLCD_Write("STOP"); time = old_time; SegmentLCD_Number(time); /* Disable RTC */ RTC_Enable(false); } else { SegmentLCD_Write("START"); old_time = time; /* Enable RTC */ RTC_Enable(true); } enableTimer = !enableTimer; toggleTimer = false; return; } } else { /* If only Push Button 0 was pressed - decrease the time */ if (!pb0_is_pushed && interrupt_source & 1 << PB0_PIN) { if (time > 0) time--; SegmentLCD_Number(time); } /* If only Push Button 1 was pressed - increase the time */ else if (!pb1_is_pushed && interrupt_source & 1 << PB1_PIN) { if (time < 9999) time++; SegmentLCD_Number(time); } } }
void GPIO_EVEN_IRQHandler(void) { uint32_t interrupts = GPIO_IntGet() & 0x55555555; GPIO_IntClear(interrupts); if (interrupts & (1 << MAG_INT_PIN)) { // A.10 fd_event_set(FD_EVENT_MAG_INT); } if (interrupts & (1 << NRF_RDYN_PIN)) { // D.4 fd_event_set(FD_EVENT_NRF_RDYN); } if (interrupts & (1 << I2C0_INT_PIN)) { // C.8 fd_event_set(FD_EVENT_I2C0_INT); } }
/**************************************************************************//** * @brief GPIO Interrupt Handler *****************************************************************************/ void GPIO_IRQHandler_2(void) { /* Get the interrupt source, either Push Button 2 (pin B11) or pin D3 */ uint32_t interrupt_source = GPIO_IntGet(); /* Push Button 2 (pin B11) */ if (interrupt_source & (1 << PB1_PIN)) { GPIO_IntClear(1 << PB1_PIN); SegmentLCD_Write("Clear"); time = 0; enableCount = false; SegmentLCD_Number(time); } /* Pin D3 - channel 3 => 2^3 */ if (interrupt_source & (1 << 3)) { /* Operations can be made atomic, i.e. it cannot be interrupted by * interrupts with higher priorities, by disabling iterrupts. Uncomment * __disable_irq(); and __enable_irq(); to see how the update of the time * is delayed by the dummy loop below.*/ /* __disable_irq(); */ /* Toggle enableGecko */ if (enableGecko) enableGecko = false; else enableGecko = true; SegmentLCD_Symbol(LCD_SYMBOL_GECKO, enableGecko); /* This dummy loop is intended to illustrate the different levels of * priority. The timer will continue to update the LCD display, but * interrupts produced by Push Button 1 and 2 will not be served until * after this function has finished. */ for (uint32_t tmp = 0; tmp < 2000000; tmp++) ; GPIO_IntClear(1 << 3); /* Enable interrupts again */ /* __enable_irq(); */ } }
void RADIO_Interrupt() { if (GPIO_IntGet() & NRF_INT_PIN) { // handle interrupt uint8_t status = readRegister(NRF_STATUS); // tx if (status & 0x20) { bufferCount--; // if nothing left to sendk if (bufferCount == 0) { NRF_CE_lo; #ifdef BS RADIO_QueueTDMAPulse(); #endif } } // rx if (status & 0x40) { bufferCount++; } writeRegister(NRF_STATUS,0x70); GPIO_IntClear(NRF_INT_PIN); } }