Zephyr API 3.6.99
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 * Get the interrupt flags from the supplied priority.
49 */
50#define ESP_PRIO_TO_FLAGS(priority) \
51 ((priority) > 0 ? ((1 << (priority)) & ESP_INTR_FLAG_LEVELMASK) : 0)
52
53/*
54 * Check interrupt flags from input and filter unallowed values.
55 */
56#define ESP_INT_FLAGS_CHECK(int_flags) ((int_flags) & ESP_INTR_FLAG_SHARED)
57
58/*
59 * The esp_intr_alloc* functions can allocate an int for all *_INTR_SOURCE int sources that
60 * are routed through the interrupt mux. Apart from these sources, each core also has some internal
61 * sources that do not pass through the interrupt mux. To allocate an interrupt for these sources,
62 * pass these pseudo-sources to the functions.
63 */
64#define ETS_INTERNAL_TIMER0_INTR_SOURCE -1 /* Xtensa timer 0 interrupt source */
65#define ETS_INTERNAL_TIMER1_INTR_SOURCE -2 /* Xtensa timer 1 interrupt source */
66#define ETS_INTERNAL_TIMER2_INTR_SOURCE -3 /* Xtensa timer 2 interrupt source */
67#define ETS_INTERNAL_SW0_INTR_SOURCE -4 /* Software int source 1 */
68#define ETS_INTERNAL_SW1_INTR_SOURCE -5 /* Software int source 2 */
69#define ETS_INTERNAL_PROFILING_INTR_SOURCE -6 /* Int source for profiling */
70
71/* Function prototype for interrupt handler function */
72typedef void (*intr_handler_t)(void *arg);
73
83
84/* Pack using bitfields for better memory use */
86 int flags : 16; /* OR of VECDESC_FLAG_* defines */
87 unsigned int cpu : 1;
88 unsigned int intno : 5;
89 int source : 8; /* Int mux flags, used when not shared */
90 struct shared_vector_desc_t *shared_vec_info; /* used when VECDESC_FL_SHARED */
92};
93
99
104
120int esp_intr_mark_shared(int intno, int cpu, bool is_in_iram);
121
134int esp_intr_reserve(int intno, int cpu);
135
170 int flags,
171 intr_handler_t handler,
172 void *arg,
173 struct intr_handle_data_t **ret_handle);
174
175
212 int flags,
213 uint32_t intrstatusreg,
214 uint32_t intrstatusmask,
215 intr_handler_t handler,
216 void *arg,
217 struct intr_handle_data_t **ret_handle);
218
219
239
240
249
258
276
289
302int esp_intr_set_in_iram(struct intr_handle_data_t *handle, bool is_in_iram);
303
308
313
314#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:72
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:95
struct vector_desc_t * vector_desc
Definition intc_esp32.h:96
struct shared_vector_desc_t * shared_vector_desc
Definition intc_esp32.h:97
Definition intc_esp32.h:74
int disabled
Definition intc_esp32.h:75
void * arg
Definition intc_esp32.h:80
uint32_t statusmask
Definition intc_esp32.h:78
intr_handler_t isr
Definition intc_esp32.h:79
volatile uint32_t * statusreg
Definition intc_esp32.h:77
struct shared_vector_desc_t * next
Definition intc_esp32.h:81
int source
Definition intc_esp32.h:76
Definition intc_esp32.h:85
int flags
Definition intc_esp32.h:86
struct vector_desc_t * next
Definition intc_esp32.h:91
unsigned int intno
Definition intc_esp32.h:88
unsigned int cpu
Definition intc_esp32.h:87
int source
Definition intc_esp32.h:89
struct shared_vector_desc_t * shared_vec_info
Definition intc_esp32.h:90