Merge pull request #697 from lyusupov/master

add an interface to read Reset reason
This commit is contained in:
Ha Thach 2021-10-14 12:16:08 +07:00 committed by GitHub
commit 9bc5320ab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -30,9 +30,12 @@ nrf_nvic_state_t nrf_nvic_state;
// Must match temp register in bootloader
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
uint32_t bootloaderVersion = 0;
static uint32_t _reset_reason = 0;
void init( void )
{
_reset_reason = NRF_POWER->RESETREAS;
// clear reset reason: can save it for application usage if needed.
NRF_POWER->RESETREAS |= NRF_POWER->RESETREAS;
@ -66,6 +69,11 @@ void init( void )
#endif
}
uint32_t readResetReason(void)
{
return _reset_reason;
}
void enterUf2Dfu(void)
{
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;

View file

@ -29,6 +29,8 @@ extern uint32_t bootloaderVersion;
extern void init(void);
uint32_t readResetReason(void);
void enterSerialDfu(void);
void enterOTADfu(void);
void enterUf2Dfu(void);