Mbed OS Reference
Loading...
Searching...
No Matches
ResetReason HAL API

Low-level interface to the ResetReason of a target. More...

Modules

 ResetReason HAL tests
 Greentea tests for the ResetReason HAL.
 

Data Structures

struct  reset_reason_capabilities_t
 Reset reason capabilities of the platform. More...
 

Enumerations

enum  reset_reason_t {
  RESET_REASON_POWER_ON , RESET_REASON_PIN_RESET , RESET_REASON_BROWN_OUT , RESET_REASON_SOFTWARE ,
  RESET_REASON_WATCHDOG , RESET_REASON_LOCKUP , RESET_REASON_WAKE_LOW_POWER , RESET_REASON_ACCESS_ERROR ,
  RESET_REASON_BOOT_ERROR , RESET_REASON_MULTIPLE , RESET_REASON_PLATFORM , RESET_REASON_UNKNOWN
}
 Definitions of different reset reasons. More...
 

Functions

reset_reason_t hal_reset_reason_get (void)
 Fetch the reset reason for the last system reset. More...
 
uint32_t hal_reset_reason_get_raw (void)
 Fetch the raw platform specific reset reason register value. More...
 
void hal_reset_reason_clear (void)
 Clear the reset reason from registers. More...
 
void hal_reset_reason_get_capabilities (reset_reason_capabilities_t *cap)
 Fill the given reset_reason_capabilities_t instance according to platform capabilities. More...
 

Detailed Description

Low-level interface to the ResetReason of a target.

This module provides a platform-independent method of checking the cause of the last system reset.

Defined behavior

Undefined behavior

Notes

Enumeration Type Documentation

◆ reset_reason_t

Definitions of different reset reasons.

Enumerator
RESET_REASON_POWER_ON 

Set when power is initially applied to the board.

The power-on-reset circuit causes a POWER_ON reset when this occurs

RESET_REASON_PIN_RESET 

Set when a reset is triggered by the hardware pin on the board.

RESET_REASON_BROWN_OUT 

Triggered when the voltage drops below the low voltage detect (LVD) threshold; the system is held in a reset until the voltage rises above the threshold.

RESET_REASON_SOFTWARE 

Set during software reset, typically triggered by writing the SYSRESETREQ bit in the Application Interrupt and Reset Control register.

RESET_REASON_WATCHDOG 

Set when a running watchdog timer fails to be refreshed.

RESET_REASON_LOCKUP 

Set when the core is locked because of an unrecoverable exception.

RESET_REASON_WAKE_LOW_POWER 

Set when waking from deep sleep mode.

RESET_REASON_ACCESS_ERROR 

Umbrella value that encompasses any access related reset.

RESET_REASON_BOOT_ERROR 

Umbrella value that encompasses any boot related reset.

RESET_REASON_MULTIPLE 

Set if multiple reset reasons are set within the board.

Occurs when the reset reason registers aren't cleared between resets

RESET_REASON_PLATFORM 

Platform specific reset reason not captured in this enum.

RESET_REASON_UNKNOWN 

Unknown or unreadable reset reason.

Definition at line 78 of file reset_reason_api.h.

Function Documentation

◆ hal_reset_reason_get()

reset_reason_t hal_reset_reason_get ( void  )

Fetch the reset reason for the last system reset.

This function must return the contents of the system reset reason registers cast to an appropriate platform independent reset reason. If multiple reset reasons are set, this function should return RESET_REASON_MULTIPLE. If the reset reason does not match any existing platform independent value, this function should return RESET_REASON_PLATFORM. If no reset reason can be determined, this function should return RESET_REASON_UNKNOWN.

This function is not idempotent; there is no guarantee the system reset reason will not be cleared between calls to this function altering the return value between calls.

Note: Some platforms contain reset reason registers that persist through system resets. If the registers haven't been cleared before calling this function, multiple reasons may be set within the registers. If multiple reset reasons are detected, this function returns RESET_REASON_MULTIPLE.

Returns
enum containing the last reset reason for the board.

◆ hal_reset_reason_get_raw()

uint32_t hal_reset_reason_get_raw ( void  )

Fetch the raw platform specific reset reason register value.

This function must return the raw contents of the system reset reason registers cast to a uint32_t value. If the platform contains reset reasons that span multiple registers/addresses, the value should be concatenated into the return type.

This function is not idempotent; there is no guarantee the system reset reason will not be cleared between calls to this function altering the return value between calls.

Returns
value containing the reset reason register for the given platform. If the platform contains reset reasons across multiple registers, they will be concatenated here.

◆ hal_reset_reason_clear()

void hal_reset_reason_clear ( void  )

Clear the reset reason from registers.

Reset the value of the reset status registers. The reset reason persists between system resets on certain platforms, so the registers should be cleared before the system resets. Failing to do so may make it difficult to determine the cause of any subsequent system resets.

◆ hal_reset_reason_get_capabilities()

void hal_reset_reason_get_capabilities ( reset_reason_capabilities_t cap)

Fill the given reset_reason_capabilities_t instance according to platform capabilities.