#define GPIO_INPUT_IO_WAKEUP 32 #define GPIO_INPUT_PIN_SEL (1ULL<<GPIO_INPUT_IO_WAKEUP) #define ESP_INTR_FLAG_DEFAULT 0 static void IRAM_ATTR gpio_isr_handler(void* arg) { uint32_t gpio_num = (uint32_t) arg; xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL); } static void gpio_task_example(void* arg) { uint32_t io_num; for(;;) { if(xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) { printf("GPIO[%d] intr, val: %d\n", io_num, gpio_get_level(io_num)); vTaskDelay(5000 / portTICK_PERIOD_MS); uart_write_bytes(UART_NUM_0, "F0F0A102000184", 14); printf("Set GPIO to OUTPUT Mode and send \"F0F0A102000184\" by UART0.\n"); } } }void app_main(){ gpio_config_t io_conf; io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;//interrupt of rising edge io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL;//bit mask of the pins, use GPIO4/5 here io_conf.mode = GPIO_MODE_INPUT;//set as input mode io_conf.pull_up_en = 0;//enable pull-up mode gpio_config(&io_conf); //install gpio isr service gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT); //hook isr handler for specific gpio pin gpio_isr_handler_add(GPIO_INPUT_IO_WAKEUP, gpio_isr_handler, (void*) GPIO_INPUT_IO_WAKEUP); xTaskCreate(gpio_task_example, "gpio_task_example", 2048, NULL, 10, NULL); while(1) { }}