Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
intc_esp32.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021-2025 Espressif Systems (Shanghai) Co., Ltd.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_INTC_ESP32_H_
8#define ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_INTC_ESP32_H_
9
10#include <stdint.h>
11#include <stdbool.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/*
18 * Interrupt allocation flags - These flags can be used to specify
19 * which interrupt qualities the code calling esp_intr_alloc* needs.
20 *
21 */
22
23/* Keep the LEVELx values as they are here; they match up with (1<<level) */
24#define ESP_INTR_FLAG_LEVEL1 (1<<1) /* Accept a Level 1 int vector, lowest priority */
25#define ESP_INTR_FLAG_LEVEL2 (1<<2) /* Accept a Level 2 int vector */
26#define ESP_INTR_FLAG_LEVEL3 (1<<3) /* Accept a Level 3 int vector */
27#define ESP_INTR_FLAG_LEVEL4 (1<<4) /* Accept a Level 4 int vector */
28#define ESP_INTR_FLAG_LEVEL5 (1<<5) /* Accept a Level 5 int vector */
29#define ESP_INTR_FLAG_LEVEL6 (1<<6) /* Accept a Level 6 int vector */
30#define ESP_INTR_FLAG_NMI (1<<7) /* Accept a Level 7 int vector, highest priority */
31#define ESP_INTR_FLAG_SHARED (1<<8) /* Interrupt can be shared between ISRs */
32#define ESP_INTR_FLAG_EDGE (1<<9) /* Edge-triggered interrupt */
33#define ESP_INTR_FLAG_IRAM (1<<10) /* ISR can be called if cache is disabled */
34#define ESP_INTR_FLAG_INTRDISABLED (1<<11) /* Return with this interrupt disabled */
35
36/* Low and medium prio interrupts. These can be handled in C. */
37#define ESP_INTR_FLAG_LOWMED (ESP_INTR_FLAG_LEVEL1|ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3)
38
39/* High level interrupts. Need to be handled in assembly. */
40#define ESP_INTR_FLAG_HIGH (ESP_INTR_FLAG_LEVEL4|ESP_INTR_FLAG_LEVEL5|ESP_INTR_FLAG_LEVEL6| \
41 ESP_INTR_FLAG_NMI)
42
43/* Mask for all level flags */
44#define ESP_INTR_FLAG_LEVELMASK (ESP_INTR_FLAG_LEVEL1|ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3| \
45 ESP_INTR_FLAG_LEVEL4|ESP_INTR_FLAG_LEVEL5|ESP_INTR_FLAG_LEVEL6| \
46 ESP_INTR_FLAG_NMI)
47
48/*
49 * Get the interrupt flags from the supplied priority.
50 */
51#define ESP_PRIO_TO_FLAGS(priority) \
52 ((priority) > 0 ? ((1 << (priority)) & ESP_INTR_FLAG_LEVELMASK) : 0)
53
54/*
55 * Check interrupt flags from input and filter unallowed values.
56 */
57#define ESP_INT_FLAGS_CHECK(int_flags) ((int_flags) & ESP_INTR_FLAG_SHARED)
58
59/*
60 * The esp_intr_alloc* functions can allocate an int for all *_INTR_SOURCE int sources that
61 * are routed through the interrupt mux. Apart from these sources, each core also has some internal
62 * sources that do not pass through the interrupt mux. To allocate an interrupt for these sources,
63 * pass these pseudo-sources to the functions.
64 */
65#define ETS_INTERNAL_TIMER0_INTR_SOURCE -1 /* Xtensa timer 0 interrupt source */
66#define ETS_INTERNAL_TIMER1_INTR_SOURCE -2 /* Xtensa timer 1 interrupt source */
67#define ETS_INTERNAL_TIMER2_INTR_SOURCE -3 /* Xtensa timer 2 interrupt source */
68#define ETS_INTERNAL_SW0_INTR_SOURCE -4 /* Software int source 1 */
69#define ETS_INTERNAL_SW1_INTR_SOURCE -5 /* Software int source 2 */
70#define ETS_INTERNAL_PROFILING_INTR_SOURCE -6 /* Int source for profiling */
71
72/* Function prototype for interrupt handler function */
73typedef void (*intr_handler_t)(void *arg);
74
75/* Interrupt handler associated data structure */
77
78/* Handle to an interrupt handler */
80
90
91/* Pack using bitfields for better memory use */
93 int flags: 16; /* OR of VECDESC_FLAG_* defines */
94 unsigned int cpu: 1;
95 unsigned int intno: 5;
96 int source: 16; /* Int mux flags, used when not shared */
97 struct shared_vector_desc_t *shared_vec_info; /* used when VECDESC_FL_SHARED */
99};
100
106
122int esp_intr_mark_shared(int intno, int cpu, bool is_in_iram);
123
136int esp_intr_reserve(int intno, int cpu);
137
172 int flags,
173 intr_handler_t handler,
174 void *arg,
175 intr_handle_t *ret_handle);
176
177
214 int flags,
215 uint32_t intrstatusreg,
216 uint32_t intrstatusmask,
217 intr_handler_t handler,
218 void *arg,
219 intr_handle_t *ret_handle);
220
221
241
242
251
260
278
291
304int esp_intr_set_in_iram(intr_handle_t handle, bool is_in_iram);
305
310
315
316#ifdef __cplusplus
317}
318#endif
319
320#endif /* ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_INTC_ESP32_H_ */
int esp_intr_get_cpu(intr_handle_t handle)
Get CPU number an interrupt is tied to.
int esp_intr_set_in_iram(intr_handle_t handle, bool is_in_iram)
Set the "in IRAM" status of the handler.
int esp_intr_get_intno(intr_handle_t handle)
Get the allocated interrupt for a certain handle.
int esp_intr_alloc(int source, int flags, intr_handler_t handler, void *arg, intr_handle_t *ret_handle)
Allocate an interrupt with the given parameters.
void esp_intr_noniram_disable(void)
Disable interrupts that aren't specifically marked as running from IRAM.
void(* intr_handler_t)(void *arg)
Definition intc_esp32.h:73
int esp_intr_enable(intr_handle_t handle)
Enable the interrupt associated with the handle.
void esp_intr_noniram_enable(void)
Re-enable interrupts disabled by esp_intr_noniram_disable.
int esp_intr_disable(intr_handle_t handle)
Disable the interrupt associated with the handle.
int esp_intr_reserve(int intno, int cpu)
Reserve an interrupt to be used outside of this framework.
int esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusreg, uint32_t intrstatusmask, intr_handler_t handler, void *arg, intr_handle_t *ret_handle)
Allocate an interrupt with the given parameters.
int esp_intr_mark_shared(int intno, int cpu, bool is_in_iram)
Mark an interrupt as a shared interrupt.
intr_handle_data_t * intr_handle_t
Definition intc_esp32.h:79
int esp_intr_free(intr_handle_t handle)
Disable and free an interrupt.
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Interrupt handler associated data structure.
Definition intc_esp32.h:102
struct vector_desc_t * vector_desc
Definition intc_esp32.h:103
struct shared_vector_desc_t * shared_vector_desc
Definition intc_esp32.h:104
Definition intc_esp32.h:81
int disabled
Definition intc_esp32.h:82
void * arg
Definition intc_esp32.h:87
uint32_t statusmask
Definition intc_esp32.h:85
intr_handler_t isr
Definition intc_esp32.h:86
volatile uint32_t * statusreg
Definition intc_esp32.h:84
struct shared_vector_desc_t * next
Definition intc_esp32.h:88
int source
Definition intc_esp32.h:83
Definition intc_esp32.h:92
int flags
Definition intc_esp32.h:93
struct vector_desc_t * next
Definition intc_esp32.h:98
unsigned int intno
Definition intc_esp32.h:95
unsigned int cpu
Definition intc_esp32.h:94
int source
Definition intc_esp32.h:96
struct shared_vector_desc_t * shared_vec_info
Definition intc_esp32.h:97