iram static void pc_int_handler(uint32_t pc, void *arg) { gpio_t *gpio; gpio_config_entry_t *cfg; unsigned int current; for(current = 0; current < gpio_size; current++) { gpio = &gpios[current]; if(pc & (1 << gpio->index)) { cfg = get_config(gpio); gpio->counter.count++; gpio->counter.debounce = cfg->counter.debounce; } } gpio_intr_ack(pc); }
/** * Handle a GPIO interrupt. * We have arrived in this callback function because the state of a GPIO pin has changed * and it is time to record that change. */ static void CALLED_FROM_INTERRUPT intrHandlerCB( uint32 interruptMask, //!< A mask indicating which GPIOs have changed. void *arg //!< Optional argument. ) { // Given the interrupt mask, we as if bit "x" is on. If it is, then that is defined as meaning // that the state of GPIO "x" has changed so we want to raised an event that indicates that this // has happened... // Once we have handled the interrupt flags, we need to acknowledge the interrupts so // that the ESP8266 will once again cause future interrupts to be processed. //os_printf_plus(">> intrHandlerCB\n"); gpio_intr_ack(interruptMask); // We have a mask of interrupts that have happened. Go through each bit in the mask // and, if it is on, then an interrupt has occurred on the corresponding pin. int pin; for (pin=0; pin<JSH_PIN_COUNT; pin++) { if ((interruptMask & (1<<pin)) != 0) { // Pin has changed so push the event that says pin has changed. jshPushIOWatchEvent(pinToEV_EXTI(pin)); gpio_pin_intr_state_set(GPIO_ID_PIN(pin), GPIO_PIN_INTR_ANYEDGE); } } //os_printf_plus("<< intrHandlerCB\n"); }