Code: Select all
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "sdkconfig.h"
#define BLINK_GPIO_GREEN 25
#define BUTTON GPIO_NUM_36
#define ESP_INTR_FLAG_DEFAULT 0
void blink_task(void *pvParameter)
{
while (1)
{
ESP_LOGI("test", "Restarting now.");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
static void IRAM_ATTR gpio_isr_handler()
{
gpio_set_level(BLINK_GPIO_GREEN, 1);
}
void app_main()
{
gpio_pad_select_gpio(BLINK_GPIO_GREEN);
gpio_set_direction(BLINK_GPIO_GREEN, GPIO_MODE_OUTPUT);
gpio_config_t btn_config;
btn_config.intr_type = GPIO_INTR_HIGH_LEVEL;
btn_config.mode = GPIO_MODE_INPUT; //Set as Input
btn_config.pin_bit_mask = (1ULL << GPIO_NUM_36); //Bitmask
btn_config.pull_up_en = GPIO_PULLUP_DISABLE; //Disable pullup
btn_config.pull_down_en = GPIO_PULLDOWN_DISABLE; //Disable pulldown
gpio_config(&btn_config);
//install gpio isr service
gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(BUTTON, gpio_isr_handler, NULL);
xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
Code: Select all
ESP_LOGI("test", "Restarting now.");
I do not understand.
Thanks I am using ESP-IDF 3.3 on with VSCode on windows and a ESP WROOM 32 devkit