RPP

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: ESP8266 GPIO Interrupt #23050
    RPP
    Participant

    I found an example at https://github.com/espressif/esp8266-rtos-sample-code/blob/master/02Peripheral/GPIOtest/user/user_main.c

    I did the following:

    1 – Declare the prototype “void gpio_config(GPIO_ConfigTypeDef *pGPIOConfig);” in the file “gpio.h”. This function is already defined at gpio.c;
    2 – Define the macros “#define ETS_GPIO_INTR_ENABLE() _xt_isr_unmask(1 << ETS_GPIO_INUM) //ENABLE INTERRUP//TS” and “#define ETS_GPIO_INTR_DISABLE() _xt_isr_mask(1 << ETS_GPIO_INUM) //DISABLE INTERRUPTS”
    in the file “ets_sys.h”
    3 – Configure the interrupt for the desired pin (in this case, GPIO4):
    GPIO_ConfigTypeDef io_in_conf;
    io_in_conf.GPIO_IntrType = GPIO_PIN_INTR_NEGEDGE;
    io_in_conf.GPIO_Mode = GPIO_Mode_Input;
    io_in_conf.GPIO_Pin = GPIO_Pin_4;
    io_in_conf.GPIO_Pullup = GPIO_PullUp_DIS;
    gpio_config(&io_in_conf);
    gpio_intr_handler_register((void *)ISR_shutoff, NULL);
    ETS_GPIO_INTR_ENABLE();
    4 – Create the interrupt handle:
    static void ISR_shutoff(void *pvParameters)
    {
    Uint16 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);

    if (gpio_status & (BIT(4)))
    {
    (…)
    }
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status);
    }

    Best regards,

    RPP

    in reply to: ESP8266 GPIO Interrupt #23049
    RPP
    Participant

    Both examples uses “Arduino core for ESP8266 WiFi chip” and I would like an example using ESP8266_RTOS_SDK v2.x.x (I don’t known exactly wich RTOS SDK version “esp8266-gcc5.2.0-r15.exe” installs).

    I took a look at https://github.com/espressif/ESP8266_RTOS_SDK/tree/release/v2.x.x/examples, but there isn’t a GPIO interrupt example.

    There is an exemple for SDK v3.0 at https://github.com/espressif/ESP8266_RTOS_SDK/blob/release/v3.0/examples/peripherals/gpio/main/user_main.c, but I would have to change the SDK.

    Do you know where I can found an example for SDK v2.x.x?

Viewing 2 posts - 1 through 2 (of 2 total)