Skip to content

Commit cbf55e0

Browse files
author
Amanda Butler
authored
Create ResetReason.md
Create ResetReason contributing API reference in 5.8.
1 parent c013d05 commit cbf55e0

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<h2 id="resetreason-port">ResetReason</h2>
2+
3+
The ResetReason API provides a platform-independent method of checking the cause of the last system reset. Implementing the ResetReason API is not mandatory, but by implementing it, you can check for erroneous system resets at boot time.
4+
5+
### Assumptions
6+
7+
#### Defined behavior
8+
9+
- The function `hal_reset_reason_clear` clears the ResetReason registers for the next system boot.
10+
- By the time the user calls `hal_reset_reason_get` to read the value, some other part of the application may have cleared the value. Therefore, though there may have been a reset reason in the registers when the system started, the reason may not be available when the user comes to check it.
11+
12+
#### Undefined behavior
13+
14+
- There is no guarantee that the function `hal_reset_reason_get` will return the same value when you call it repeatedly. Store the value for later use instead of calling the function repeatedly.
15+
- The function `hal_reset_reason_clear` may not clear the ResetReason register in time for the next system boot.
16+
17+
#### Notes
18+
19+
- The contents of the targets ResetReason register may be cleared by some subsystem before it first gets called. This returns a `RESET_REASON_UNKNOWN` value to the user. To avoid this, the user should call the ResetReason API as early as possible at boot time.
20+
- If the target doesn't support clearing reset registers, `hal_reset_reason_get` seems to erroneously return a reset reason even after clearing.
21+
22+
### Dependency
23+
24+
Hardware ResetReason registers.
25+
26+
### Implementing ResetReason
27+
28+
You can find the API and specification for the ResetReason API in the following header file:
29+
30+
[![View code](https://www.mbed.com/embed/?type=library)](http://os.mbed.com/docs/v5.8/feature-hal-spec-watchdog-doxy/classmbed_1_1_reset_reason.html)
31+
32+
To enable ResetReason support in Mbed OS, add the `RESET_REASON` label in the `device_has` option of the target's section in the `targets.json` file.
33+
34+
### Testing
35+
36+
The Mbed OS HAL provides a set of conformance tests for ResetReason. You can use these tests to validate the correctness of your implementation. To run the ResetReason HAL tests use the following command:
37+
38+
```
39+
mbed test -t <toolchain> -m <target> -n "tests-mbed_hal-reset_reason"
40+
```
41+
42+
[![View code](https://www.mbed.com/embed/?type=library)](http://os.mbed.com/docs/v5.8/feature-hal-spec-watchdog-doxy/classreset__reason_1_1_reset_reason_test.html)

0 commit comments

Comments
 (0)