Mistake on this page?
Report an issue in GitHub or email us
mbed_fault_handler.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2018 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MBED_FAULT_HANDLER_H
18 #define MBED_FAULT_HANDLER_H
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 //Fault context struct
25 //WARNING: DO NOT CHANGE THIS STRUCT WITHOUT MAKING CORRESPONDING CHANGES in except.S files.
26 //Offset of these registers are used by fault handler in except.S
27 typedef struct {
28  uint32_t R0_reg;
29  uint32_t R1_reg;
30  uint32_t R2_reg;
31  uint32_t R3_reg;
32  uint32_t R4_reg;
33  uint32_t R5_reg;
34  uint32_t R6_reg;
35  uint32_t R7_reg;
36  uint32_t R8_reg;
37  uint32_t R9_reg;
38  uint32_t R10_reg;
39  uint32_t R11_reg;
40  uint32_t R12_reg;
41  uint32_t SP_reg;
42  uint32_t LR_reg;
43  uint32_t PC_reg;
44  uint32_t xPSR;
45  uint32_t PSP;
46  uint32_t MSP;
47  uint32_t EXC_RETURN;
48  uint32_t CONTROL;
50 
51 //Fault type definitions
52 //WARNING: DO NOT CHANGE THESE VALUES WITHOUT MAKING CORRESPONDING CHANGES in except.S files.
53 #define HARD_FAULT_EXCEPTION (0x10) //Keep some gap between values for any future insertion/expansion
54 #define MEMMANAGE_FAULT_EXCEPTION (0x20)
55 #define BUS_FAULT_EXCEPTION (0x30)
56 #define USAGE_FAULT_EXCEPTION (0x40)
57 
58 //This is a handler function called from Fault handler to print the error information out.
59 //This runs in fault context and uses special functions(defined in mbed_fault_handler.c) to print the information without using C-lib support.
60 void mbed_fault_handler(uint32_t fault_type, void *mbed_fault_context_in);
61 
62 /**
63  * Call this function to retrieve the fault context after a fatal exception which triggered a system reboot. The function retrieves the fault context stored in crash-report ram area which is preserved over reboot.
64  * @param fault_context Pointer to mbed_fault_context_t struct allocated by the caller. This is the mbed_fault_context_t info captured as part of the fatal exception which triggered the reboot.
65  * @return 0 or MBED_SUCCESS on success.
66  * MBED_ERROR_INVALID_ARGUMENT in case of invalid error_info pointer
67  * MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by teh system
68  *
69  */
70 mbed_error_status_t mbed_get_reboot_fault_context(mbed_fault_context_t *fault_context);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif
int mbed_error_status_t
mbed_error_status_t description
Definition: mbed_error.h:108
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.