mirror of https://github.com/ARMmbed/mbed-os.git
HAL: ResetReason: Add the get_capabilities function
Add the hal_reset_reason_get_capabilities() to ResetReason HAL API. Add a default, weak implementation, that every target can override.pull/12139/head
parent
b1b0673622
commit
57420fc2f5
|
@ -19,6 +19,7 @@
|
|||
#include "i2c_api.h"
|
||||
#include "spi_api.h"
|
||||
#include "gpio_api.h"
|
||||
#include "reset_reason_api.h"
|
||||
#include "mbed_toolchain.h"
|
||||
|
||||
// To be re-implemented in the target layer if required
|
||||
|
@ -90,4 +91,15 @@ MBED_WEAK void spi_get_capabilities(PinName ssel, bool slave, spi_capabilities_t
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if DEVICE_RESET_REASON
|
||||
// To be re-implemented in the target layer if required
|
||||
MBED_WEAK void hal_reset_reason_get_capabilities(reset_reason_capabilities_t *cap)
|
||||
{
|
||||
cap->reasons = (1 << RESET_REASON_PIN_RESET) | (1 << RESET_REASON_SOFTWARE);
|
||||
#if DEVICE_WATCHDOG
|
||||
cap->reasons |= 1 << RESET_REASON_WATCHDOG;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,8 @@ extern "C" {
|
|||
* 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.
|
||||
* * The function ::hal_reset_reason_get_capabilities fills the given
|
||||
* `reset_reason_capabilities_t` instance.
|
||||
*
|
||||
* # Undefined behavior
|
||||
* * There is no guarantee that the function ::hal_reset_reason_get will
|
||||
|
@ -88,6 +90,12 @@ typedef enum {
|
|||
RESET_REASON_UNKNOWN /**< Unknown or unreadable reset reason **/
|
||||
} reset_reason_t;
|
||||
|
||||
/** Reset reason capabilities of the platform
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t reasons; /**< Supported reset reasons. Each bit represents a corresponding reset_reason_t value.**/
|
||||
} reset_reason_capabilities_t;
|
||||
|
||||
/** Fetch the reset reason for the last system reset.
|
||||
*
|
||||
* This function must return the contents of the system reset reason registers
|
||||
|
@ -137,6 +145,10 @@ uint32_t hal_reset_reason_get_raw(void);
|
|||
*/
|
||||
void hal_reset_reason_clear(void);
|
||||
|
||||
/** Fill the given reset_reason_capabilities_t instance according to platform capabilities.
|
||||
*/
|
||||
void hal_reset_reason_get_capabilities(reset_reason_capabilities_t *cap);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue