Mistake on this page?
Report an issue in GitHub or email us
ResetReason.h
1 /*
2  * Copyright (c) 2018-2019 Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_RESET_REASON_H
18 #define MBED_RESET_REASON_H
19 
20 #ifdef DEVICE_RESET_REASON
21 
22 #include "reset_reason_api.h"
23 
24 namespace mbed {
25 /** \addtogroup drivers */
26 /** A platform-independent method of checking the cause of the last system reset.
27  *
28  * When the system restarts, the reason for the restart is contained in
29  * the system registers at boot time in a platform specific manner.
30  * This API provides a generic method of fetching the reason for the restart.
31  *
32  * @ingroup drivers
33  */
34 class ResetReason {
35 public:
36  /** Get the platform independent reason code for the last system reset.
37  *
38  * @return enum containing the last reset reason for the board.
39  *
40  * Example:
41  * @code
42  * const reset_reason_t reason = ResetReason::get();
43  *
44  * if (reason == RESET_REASON_WATCHDOG) {
45  * printf("Watchdog reset\n");
46  * rollback();
47  * }
48  * @endcode
49  */
50  static reset_reason_t get();
51 
52  /** Get the platform specific reason code for the last system reset.
53  *
54  * Platform specific reasons that are not covered by the ::reset_reason_t enum
55  * will cause the ResetReason::get() function to return
56  * ::RESET_REASON_PLATFORM. In order to get the actual reason the register
57  * value must be fetched directly using this function and interpreted in a
58  * platform specific manner.
59  *
60  * @return value containing the reset reason register for the given platform.
61  * If the platform contains reset reasons across multiple registers they
62  * will be concatenated here.
63  *
64  * Example:
65  * @code
66  * if (ResetReason::get() == RESET_REASON_PLATFORM) {
67  * const uint32_t platform_reason = ResetReason::get_raw();
68  * }
69  * @endcode
70  */
71  static uint32_t get_raw();
72 };
73 
74 } // namespace mbed
75 
76 #endif // DEVICE_RESET_REASON
77 #endif // MBED_RESET_REASON_H
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.