uint8_t sdk_rtc_get_reset_reason(void) { uint8_t reason; reason = FIELD2VAL(RTC_RESET_REASON1_CODE, RTC.RESET_REASON1); if (reason == 5) { if (FIELD2VAL(RTC_RESET_REASON2_CODE, RTC.RESET_REASON2) == 1) { reason = 6; } else { if (FIELD2VAL(RTC_RESET_REASON2_CODE, RTC.RESET_REASON2) != 8) { reason = 0; } } } RTC.RESET_REASON0 &= ~RTC_RESET_REASON0_BIT21; return reason; }
void __attribute__((weak)) IRAM gpio_interrupt_handler(void *arg) { uint32_t status_reg = GPIO.STATUS; GPIO.STATUS_CLEAR = status_reg; uint8_t gpio_idx; while ((gpio_idx = __builtin_ffs(status_reg))) { gpio_idx--; status_reg &= ~BIT(gpio_idx); if (FIELD2VAL(GPIO_CONF_INTTYPE, GPIO.CONF[gpio_idx])) { gpio_interrupt_handler_t handler = gpio_interrupt_handlers[gpio_idx]; if (handler) { handler(gpio_idx); } } } }
// generic interrupt handler called for all interrupt void gpio_interrupt_handler() { uint32 status_reg = GPIO.STATUS; GPIO.STATUS_CLEAR = status_reg; uint8_t pin; while ((pin = __builtin_ffs(status_reg))) { pin--; status_reg &= ~BIT(pin); if (FIELD2VAL(GPIO_CONF_INTTYPE, GPIO.CONF[pin])) { uint32 ms = xTaskGetTickCountFromISR() * portTICK_RATE_MS; // debounce check (from button.c example code) //printf(" [interrupt %d] ", pin); fflush(stdout); if (button_last[pin] < ms - 200) { //printf(" [button %d pressed at %dms\r\n", pin, ms); button_last[pin] = ms; button_clicked[pin]++; button_count[pin]++; } else { //printf(" [BOUNCE! %d at %dms]\r\n", pin, ms); } } } }