Zephyr API Documentation  3.6.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 Espressif Systems (Shanghai) Co., Ltd.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_ESP_INTR_ALLOC_H__
8#define ZEPHYR_INCLUDE_DRIVERS_ESP_INTR_ALLOC_H__
9
10#include <stdint.h>
11#include <stdbool.h>
12
13/* number of possible interrupts per core */
14#define ESP_INTC_INTS_NUM (32)
15
16/*
17 * Interrupt allocation flags - These flags can be used to specify
18 * which interrupt qualities the code calling esp_intr_alloc* needs.
19 *
20 */
21
22/* Keep the LEVELx values as they are here; they match up with (1<<level) */
23#define ESP_INTR_FLAG_LEVEL1 (1<<1) /* Accept a Level 1 int vector, lowest priority */
24#define ESP_INTR_FLAG_LEVEL2 (1<<2) /* Accept a Level 2 int vector */
25#define ESP_INTR_FLAG_LEVEL3 (1<<3) /* Accept a Level 3 int vector */
26#define ESP_INTR_FLAG_LEVEL4 (1<<4) /* Accept a Level 4 int vector */
27#define ESP_INTR_FLAG_LEVEL5 (1<<5) /* Accept a Level 5 int vector */
28#define ESP_INTR_FLAG_LEVEL6 (1<<6) /* Accept a Level 6 int vector */
29#define ESP_INTR_FLAG_NMI (1<<7) /* Accept a Level 7 int vector, highest priority */
30#define ESP_INTR_FLAG_SHARED (1<<8) /* Interrupt can be shared between ISRs */
31#define ESP_INTR_FLAG_EDGE (1<<9) /* Edge-triggered interrupt */
32#define ESP_INTR_FLAG_IRAM (1<<10) /* ISR can be called if cache is disabled */
33#define ESP_INTR_FLAG_INTRDISABLED (1<<11) /* Return with this interrupt disabled */
34
35/* Low and medium prio interrupts. These can be handled in C. */
36#define ESP_INTR_FLAG_LOWMED (ESP_INTR_FLAG_LEVEL1|ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3)
37
38/* High level interrupts. Need to be handled in assembly. */
39#define ESP_INTR_FLAG_HIGH (ESP_INTR_FLAG_LEVEL4|ESP_INTR_FLAG_LEVEL5|ESP_INTR_FLAG_LEVEL6| \
40 ESP_INTR_FLAG_NMI)
41
42/* Mask for all level flags */
43#define ESP_INTR_FLAG_LEVELMASK (ESP_INTR_FLAG_LEVEL1|ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3| \
44 ESP_INTR_FLAG_LEVEL4|ESP_INTR_FLAG_LEVEL5|ESP_INTR_FLAG_LEVEL6| \
45 ESP_INTR_FLAG_NMI)
46
47/*
48 * The esp_intr_alloc* functions can allocate an int for all *_INTR_SOURCE int sources that
49 * are routed through the interrupt mux. Apart from these sources, each core also has some internal
50 * sources that do not pass through the interrupt mux. To allocate an interrupt for these sources,
51 * pass these pseudo-sources to the functions.
52 */
53#define ETS_INTERNAL_TIMER0_INTR_SOURCE -1 /* Xtensa timer 0 interrupt source */
54#define ETS_INTERNAL_TIMER1_INTR_SOURCE -2 /* Xtensa timer 1 interrupt source */
55#define ETS_INTERNAL_TIMER2_INTR_SOURCE -3 /* Xtensa timer 2 interrupt source */
56#define ETS_INTERNAL_SW0_INTR_SOURCE -4 /* Software int source 1 */
57#define ETS_INTERNAL_SW1_INTR_SOURCE -5 /* Software int source 2 */
58#define ETS_INTERNAL_PROFILING_INTR_SOURCE -6 /* Int source for profiling */
59
60/* Function prototype for interrupt handler function */
61typedef void (*intr_handler_t)(void *arg);
62
64 int disabled : 1;
65 int source : 8;
69 void *arg;
71};
72
73/* Pack using bitfields for better memory use */
75 int flags : 16; /* OR of VECDESC_FLAG_* defines */
76 unsigned int cpu : 1;
77 unsigned int intno : 5;
78 int source : 8; /* Int mux flags, used when not shared */
79 struct shared_vector_desc_t *shared_vec_info; /* used when VECDESC_FL_SHARED */
81};
82
87};
88
93
109int esp_intr_mark_shared(int intno, int cpu, bool is_in_iram);
110
123int esp_intr_reserve(int intno, int cpu);
124
159 int flags,
160 intr_handler_t handler,
161 void *arg,
162 struct intr_handle_data_t **ret_handle);
163
164
201 int flags,
202 uint32_t intrstatusreg,
203 uint32_t intrstatusmask,
204 intr_handler_t handler,
205 void *arg,
206 struct intr_handle_data_t **ret_handle);
207
208
228
229
238
247
265
278
291int esp_intr_set_in_iram(struct intr_handle_data_t *handle, bool is_in_iram);
292
297
298
303
304#endif
int esp_intr_enable(struct intr_handle_data_t *handle)
Enable the interrupt associated with the handle.
int esp_intr_disable(struct intr_handle_data_t *handle)
Disable the interrupt associated with the handle.
int esp_intr_alloc(int source, int flags, intr_handler_t handler, void *arg, struct intr_handle_data_t **ret_handle)
Allocate an interrupt with the given parameters.
int esp_intr_get_intno(struct intr_handle_data_t *handle)
Get the allocated interrupt for a certain handle.
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:61
int esp_intr_get_cpu(struct intr_handle_data_t *handle)
Get CPU number an interrupt is tied to.
int esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusreg, uint32_t intrstatusmask, intr_handler_t handler, void *arg, struct intr_handle_data_t **ret_handle)
Allocate an interrupt with the given parameters.
int esp_intr_free(struct intr_handle_data_t *handle)
Disable and free an interrupt.
void esp_intr_noniram_enable(void)
Re-enable interrupts disabled by esp_intr_noniram_disable.
int esp_intr_reserve(int intno, int cpu)
Reserve an interrupt to be used outside of this framework.
int esp_intr_mark_shared(int intno, int cpu, bool is_in_iram)
Mark an interrupt as a shared interrupt.
void esp_intr_initialize(void)
Initializes interrupt table to its defaults.
int esp_intr_set_in_iram(struct intr_handle_data_t *handle, bool is_in_iram)
Set the "in IRAM" status of the handler.
flags
Definition: parser.h:96
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Interrupt handler associated data structure.
Definition: intc_esp32.h:84
struct vector_desc_t * vector_desc
Definition: intc_esp32.h:85
struct shared_vector_desc_t * shared_vector_desc
Definition: intc_esp32.h:86
Definition: intc_esp32.h:63
int disabled
Definition: intc_esp32.h:64
void * arg
Definition: intc_esp32.h:69
uint32_t statusmask
Definition: intc_esp32.h:67
intr_handler_t isr
Definition: intc_esp32.h:68
volatile uint32_t * statusreg
Definition: intc_esp32.h:66
struct shared_vector_desc_t * next
Definition: intc_esp32.h:70
int source
Definition: intc_esp32.h:65
Definition: intc_esp32.h:74
int flags
Definition: intc_esp32.h:75
struct vector_desc_t * next
Definition: intc_esp32.h:80
unsigned int intno
Definition: intc_esp32.h:77
unsigned int cpu
Definition: intc_esp32.h:76
int source
Definition: intc_esp32.h:78
struct shared_vector_desc_t * shared_vec_info
Definition: intc_esp32.h:79