#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "esp_timer.h"
#define USED_GPIO GPIO_NUM_21
QueueHandle_t handlerQueue;
static void isr_handler(void *args) {
int numero= (int)args;
xQueueSend(handlerQueue, &numero, 0);
}
void tarea1(void *args){
int dato = 0;
while (1) {
if (xQueueReceive(handlerQueue, &dato, 100)) {
printf("Hola, %d\n", dato);
}
vTaskDelay(5000/portTICK_PERIOD_MS);
}
}
void app_main() {
gpio_reset_pin(USED_GPIO);
gpio_set_direction(USED_GPIO, GPIO_MODE_INPUT);
gpio_set_intr_type(USED_GPIO, GPIO_INTR_ANYEDGE);
handlerQueue = xQueueCreate(50, sizeof(int));
xTaskCreate(tarea1, "tarea1", 2046, NULL, 1, &handlerQueue);
gpio_install_isr_service(0);
gpio_isr_handler_add(USED_GPIO, isr_handler, (void *) USED_GPIO);
}