Page 1 of 1

attachInterrupt not recognised

Posted: Thu May 18, 2023 9:14 am
by Lancsrick
I'm doing something very daft somewhere but I can't figure it out. Just starting to play with interrupts (ESP32, VSCode, ESP-IDF Framework, PlatformIO). I've commented my code down to the bare minimum and still get told at Build

Code: Select all

implicit declaration of function 'attachInterrupt'; did you mean 'xthal_get_interrupt'? [-Werror=implicit-function-declaration]
Code (trimmed to just what I haven't commented out):

Code: Select all

#include <inttypes.h>
#include <stdio.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <sys/time.h>
#include <hd44780.h>
#include <pcf8574.h>
#include <string.h>
#include "driver/gpio.h"

void IRAM_ATTR isr() {
printf("pressed");
}

void setup() {
    gpio_set_direction(GPIO_NUM_22, GPIO_MODE_INPUT);
    attachInterrupt(22, isr, RISING);
}

void lcd_test(void *pvParameters)
{
 while (1){
           
        }
}

void app_main()
{
    ESP_ERROR_CHECK(i2cdev_init());
    xTaskCreate(lcd_test, "lcd_test", configMINIMAL_STACK_SIZE * 5, NULL, 5, NULL);
}


What's the stupid error I must be making please?

Re: attachInterrupt not recognised

Posted: Thu May 18, 2023 1:43 pm
by Mermaja
As far as I know, attachInterrupt is a function used in the Arduino IDE (and PlatformIO) to attach a pseudo interrupt routine to an external (GPIO triggered) interrupt. It is not a generic function and not one supported by the Espressif IDE.

Re: attachInterrupt not recognised

Posted: Thu May 18, 2023 1:47 pm
by Lancsrick
That'll be the stupid then, thanks :).