Mbed OS Reference
Loading...
Searching...
No Matches
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
24namespace mbed {
25/** \addtogroup drivers-public-api */
26/** @{*/
27
28/**
29 * \defgroup drivers_ResetReason ResetReason class
30 * @{
31 */
32/** A platform-independent method of checking the cause of the last system reset.
33 *
34 * When the system restarts, the reason for the restart is contained in
35 * the system registers at boot time in a platform specific manner.
36 * This API provides a generic method of fetching the reason for the restart.
37 *
38 */
40public:
41 /** Get the platform independent reason code for the last system reset.
42 *
43 * @return enum containing the last reset reason for the board.
44 *
45 * Example:
46 * @code
47 * const reset_reason_t reason = ResetReason::get();
48 *
49 * if (reason == RESET_REASON_WATCHDOG) {
50 * printf("Watchdog reset\n");
51 * rollback();
52 * }
53 * @endcode
54 */
56
57 /** Get the platform specific reason code for the last system reset.
58 *
59 * Platform specific reasons that are not covered by the ::reset_reason_t enum
60 * will cause the ResetReason::get() function to return
61 * ::RESET_REASON_PLATFORM. In order to get the actual reason the register
62 * value must be fetched directly using this function and interpreted in a
63 * platform specific manner.
64 *
65 * @return value containing the reset reason register for the given platform.
66 * If the platform contains reset reasons across multiple registers they
67 * will be concatenated here.
68 *
69 * Example:
70 * @code
71 * if (ResetReason::get() == RESET_REASON_PLATFORM) {
72 * const uint32_t platform_reason = ResetReason::get_raw();
73 * }
74 * @endcode
75 */
76 static uint32_t get_raw();
77};
78
79/** @}*/
80/** @}*/
81
82} // namespace mbed
83
84#endif // DEVICE_RESET_REASON
85#endif // MBED_RESET_REASON_H
A platform-independent method of checking the cause of the last system reset.
Definition: ResetReason.h:39
static reset_reason_t get()
Get the platform independent reason code for the last system reset.
static uint32_t get_raw()
Get the platform specific reason code for the last system reset.
reset_reason_t
Definitions of different reset reasons.