Code: Select all
#include <stdio.h>
#include <sys/time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/timer.h"
#include "freertos/timers.h"
TimerHandle_t timer=NULL;
void HW_IsrHandler(void* arg)
{
gpio_num_t pin = (gpio_num_t) arg;
if(gpio_get_level(pin)==0) {
xTimerResetFromISR(timer, 1000 / portTICK_RATE_MS);
}
}
void timerCallback(TimerHandle_t id) {
}
void app_main()
{
uint8_t pin=14;
timer=xTimerCreate("timer Callback", 1000 / portTICK_RATE_MS, pdFALSE, (void *)0, timerCallback);
gpio_install_isr_service(0 );
gpio_config_t io_conf;
io_conf.pull_down_en = 0;
io_conf.pull_up_en = 1;
io_conf.intr_type = GPIO_INTR_ANYEDGE;
io_conf.pin_bit_mask = (1<<pin);
io_conf.mode = GPIO_MODE_INPUT;
gpio_config(&io_conf);
gpio_isr_handler_add(pin, HW_IsrHandler, (void*) &pin);
}
Thanks for your input!