cc2538: sys-ctrl: Provide last reset cause

Add functions providing the last reset cause, one as an integer (ID),
and one as a string.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
This commit is contained in:
Benoît Thébaudeau 2016-06-11 22:56:58 +02:00
parent 8e6c6cc45b
commit b3ea790449
2 changed files with 36 additions and 0 deletions

View file

@ -50,6 +50,26 @@
#define SYS_CTRL_OSCS SYS_CTRL_CLOCK_CTRL_OSC32K
#endif
/*---------------------------------------------------------------------------*/
int
sys_ctrl_get_reset_cause(void)
{
return (REG(SYS_CTRL_CLOCK_STA) & SYS_CTRL_CLOCK_STA_RST) >>
SYS_CTRL_CLOCK_STA_RST_S;
}
/*---------------------------------------------------------------------------*/
const char *
sys_ctrl_get_reset_cause_str(void)
{
static const char *reset_cause[] = {
"POR",
"External reset",
"WDT",
"CLD or software reset"
};
return reset_cause[sys_ctrl_get_reset_cause()];
}
/*---------------------------------------------------------------------------*/
void
sys_ctrl_init()
{