Select one of the symbols to view example projects that use it.
 
Outline
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "freertos/FreeRTOSConfig.h"
#include "freertos/FreeRTOS.h"
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "hal/gpio_ll.h"
#include "soc/interrupts.h"
#include "example_gpio.h"
app_main()
Files
loading...
SourceVuESP-IDF Framework and Examplesnmi_isr samplemain/nmi_isr_main.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 *//* ... */ #include <stdio.h> #include <string.h> #include <inttypes.h> #include "freertos/FreeRTOSConfig.h" #include "freertos/FreeRTOS.h" #include "sdkconfig.h" #include "driver/gpio.h" #include "hal/gpio_ll.h" #include "soc/interrupts.h" #include "example_gpio.h"10 includes extern volatile int nmi_triggered; extern void xt_nmi(void*); void app_main(void) { intr_handle_t handle; esp_err_t err; printf("example: Start\n"); gpio_reset_pin(EXAMPLE_GPIO_IN); /* Make sure we have a pull-down on the input GPIO to prevent noise (when disconnected) */ gpio_pulldown_en(EXAMPLE_GPIO_IN); gpio_set_direction(EXAMPLE_GPIO_IN, GPIO_MODE_INPUT_OUTPUT); /* Register the interrupt handler as an NMI. When registering high level interrupts, * the interrupt allocator expects the handler passed as an argument to be NULL. *//* ... */ err = esp_intr_alloc(ETS_GPIO_INTR_SOURCE, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_NMI, NULL, NULL, &handle); if (err != ESP_OK) { printf("Failure: could not install NMI ISR, %d(0x%x)\n", err, err); return; }{...} gpio_set_intr_type(EXAMPLE_GPIO_IN, GPIO_INTR_HIGH_LEVEL); gpio_intr_enable(EXAMPLE_GPIO_IN); vTaskDelay(200 / portTICK_PERIOD_MS); /* Disable interrupts on the CPU side and make sure the NMI is still triggered */ const uint32_t mask = esp_cpu_intr_get_enabled_mask(); esp_cpu_intr_disable(0xFFFFFFFF); nmi_triggered = 0; /* Setting EXAMPLE_GPIO_IN to 1 will trigger the NMI interrupt. */ gpio_set_level(EXAMPLE_GPIO_IN, 1); /* Wait for the interrupt to occur */ while (nmi_triggered == 0) { /* We cannot use vTaskDelay since the interrupts are disabled */ }{...} esp_cpu_intr_enable(mask); gpio_intr_disable(EXAMPLE_GPIO_IN); esp_intr_free(handle); printf("example: Success\n"); }{ ... }
Details