/* Interrupt Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#define LED GPIO_NUM_19
#define POUSSOIR GPIO_NUM_13
SemaphoreHandle_t xSemaSync;
static void gpio_isr_handler(void* arg)
{
xSemaphoreGiveFromISR(xSemaSync,NULL);
}
void vTask_Int( void *pvParameters )
{ int16_t Nb_IT=0;
for( ;; )
{
xSemaphoreTake(xSemaSync, portMAX_DELAY);
gpio_set_level(LED, 1);
printf("Interruption n° %d\n", ++Nb_IT);
}
}
extern "C" void app_main()
{
printf("init\n");
// Init Poussoir
gpio_reset_pin(POUSSOIR);
gpio_set_direction(POUSSOIR, GPIO_MODE_INPUT);
gpio_pullup_en(POUSSOIR);
gpio_reset_pin(LED);
gpio_set_direction(LED, GPIO_MODE_OUTPUT);
//Init ISR
gpio_install_isr_service(0);
gpio_set_intr_type(POUSSOIR, GPIO_INTR_NEGEDGE);
gpio_isr_handler_add(POUSSOIR, gpio_isr_handler, NULL);
printf("config complete\n");
xSemaSync = xSemaphoreCreateBinary();
xTaskCreatePinnedToCore(vTask_Int, "vTaskInt", 10000, NULL, 2, NULL,0);
for(;;) {
gpio_set_level(LED, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}