Skip to content

Commit 9bc5320

Browse files
authored
Merge pull request #697 from lyusupov/master
add an interface to read Reset reason
2 parents 7770246 + 2cfc196 commit 9bc5320

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cores/nRF5/wiring.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ nrf_nvic_state_t nrf_nvic_state;
3030
// Must match temp register in bootloader
3131
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
3232
uint32_t bootloaderVersion = 0;
33+
static uint32_t _reset_reason = 0;
3334

3435
void init( void )
3536
{
37+
_reset_reason = NRF_POWER->RESETREAS;
38+
3639
// clear reset reason: can save it for application usage if needed.
3740
NRF_POWER->RESETREAS |= NRF_POWER->RESETREAS;
3841

@@ -66,6 +69,11 @@ void init( void )
6669
#endif
6770
}
6871

72+
uint32_t readResetReason(void)
73+
{
74+
return _reset_reason;
75+
}
76+
6977
void enterUf2Dfu(void)
7078
{
7179
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;

cores/nRF5/wiring.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ extern uint32_t bootloaderVersion;
2929

3030
extern void init(void);
3131

32+
uint32_t readResetReason(void);
33+
3234
void enterSerialDfu(void);
3335
void enterOTADfu(void);
3436
void enterUf2Dfu(void);

0 commit comments

Comments
 (0)