exception.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _HARDWARE_EXCEPTION_H
8#define _HARDWARE_EXCEPTION_H
9
10#include "pico.h"
12
26// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION, Enable/disable assertions in the hardware_exception module, type=bool, default=0, group=hardware_exception
27#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION
28#ifdef PARAM_ASSERTIONS_ENABLED_EXCEPTION // backwards compatibility with SDK < 2.0.0
29#define PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION PARAM_ASSERTIONS_ENABLED_EXCEPTION
30#else
31#define PARAM_ASSERTIONS_ENABLED_HARDWARE_EXCEPTION 0
32#endif
33#endif
34#ifdef __cplusplus
35extern "C" {
36#endif
37
70#ifdef __riscv
72 // Assigned to non-IRQ xcause values
73 MIN_EXCEPTION_NUM = 0,
74 INSTR_ALIGN_EXCEPTION = 0,
75 INSTR_FAULT_EXCEPTION = 1,
76 INSTR_ILLEGAL_EXCEPTION = 2,
77 EBREAK_EXCEPTION = 3,
78 LOAD_ALIGN_EXCEPTION = 4,
79 LOAD_FAULT_EXCEPTION = 5,
80 STORE_ALIGN_EXCEPTION = 6,
81 STORE_FAULT_EXCEPTION = 7,
82 ECALL_UMODE_EXCEPTION = 8,
83 ECALL_SMODE_EXCEPTION = 9,
84 ECALL_MMODE_EXCEPTION = 11,
85 MAX_EXCEPTION_NUM = 11
86};
87#else
89 // Assigned to VTOR indices
90 MIN_EXCEPTION_NUM = 2,
96 MAX_EXCEPTION_NUM = 15
97};
98#endif
99
100#define PICO_LOWEST_EXCEPTION_PRIORITY 0xff
101#define PICO_HIGHEST_EXCEPTION_PRIORITY 0x00
102
103
109typedef void (*exception_handler_t)(void);
110
125
137void exception_restore_handler(enum exception_number num, exception_handler_t original_handler);
138
147
148#ifndef __riscv
167bool exception_set_priority(uint num, uint8_t hardware_priority);
168
187uint exception_get_priority(uint num);
188#endif
189
190#ifdef __cplusplus
191}
192#endif
193
194#endif
exception_handler_t exception_set_exclusive_handler(enum exception_number num, exception_handler_t handler)
Set the exception handler for an exception on the executing core.
Definition: exception.c:50
void(* exception_handler_t)(void)
Exception handler function type.
Definition: exception.h:109
exception_number
Exception number definitions.
Definition: exception.h:88
exception_handler_t exception_get_vtable_handler(enum exception_number num)
Get the current exception handler for the specified exception from the currently installed vector tab...
Definition: exception.c:45
bool exception_set_priority(uint num, uint8_t hardware_priority)
Set specified exception's priority.
Definition: exception.c:87
uint exception_get_priority(uint num)
Get specified exception's priority.
Definition: exception.c:97
void exception_restore_handler(enum exception_number num, exception_handler_t original_handler)
Restore the original exception handler for an exception on this core.
Definition: exception.c:63
@ SYSTICK_EXCEPTION
System Tick Interrupt.
Definition: exception.h:95
@ SVCALL_EXCEPTION
SV Call Interrupt.
Definition: exception.h:93
@ NMI_EXCEPTION
Non Maskable Interrupt.
Definition: exception.h:91
@ HARDFAULT_EXCEPTION
HardFault Interrupt.
Definition: exception.h:92
@ PENDSV_EXCEPTION
Pend SV Interrupt.
Definition: exception.h:94