Created
January 29, 2018 17:27
-
-
Save aandr/8c8fb17608914bcba08a45da934d1907 to your computer and use it in GitHub Desktop.
NVIC reset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__disable_irq(); | |
/* Disable the stack monitor */ | |
R_SPMON->MSPMPUPT = 0xA500; /* Enable access to Main Stack Pointer Monitor Access Control Register */ | |
R_SPMON->PSPMPUPT = 0xA500; /* Enable access to Process Stack Pointer Monitor Access Control Register */ | |
R_SPMON->MSPMPUCTL_b.ENABLE = 0; /* disable the Main stack monitor */ | |
R_SPMON->PSPMPUCTL_b.ENABLE = 0; /* disable the Process stack monitor */ | |
SysTick->CTRL = 0; /* Disable the systick timer */ | |
NVIC_DisableIRQ ( SysTick_IRQn ); /* Disable the systick timer IRQ */ | |
NVIC_ClearPendingIRQ( SysTick_IRQn ); /* Clear any pending systick timer IRQ */ | |
R_USBFS->SYSCFG = 0; /* Disable USB FS */ | |
R_USBFS->DVSTCTR0 = 0; | |
R_USBFS->INTENB0 = 0; | |
R_USBFS->INTENB1 = 0; | |
R_USBFS->INTSTS0 = 0; | |
R_USBFS->INTSTS1 = 0; | |
R_USBFS->BRDYENB = 0; | |
R_USBFS->NRDYENB = 0; | |
R_USBFS->BEMPENB =0; | |
R_USBFS->USBADDR = 0; | |
R_USBFS->DPUSR0R = 0; | |
R_USBFS->DPUSR1R = 0; | |
R_ELC_Disable(); | |
/* | |
* Clear all interrupts! | |
* | |
*/ | |
for (uint32_t i = 0; i<96; i++) | |
{ | |
R_ICU->IELSRn[i] = 0; | |
} | |
for (uint32_t i = 0; i<8; i++) | |
{ | |
NVIC->ICER[i] = 0xFFFFFFFF; | |
NVIC->ICPR[i] = 0xFFFFFFFF; | |
} | |
for (uint32_t i = 0; i<16; i++) | |
{ | |
R_ICU->IRQCRn[i] = 0; | |
} | |
/* Ensure that when we jump we're using the Main Stack Pointer */ | |
__set_CONTROL(0); | |
p_jump_to_app = (main_fnptr*)(address+4); | |
SCB->VTOR = (address & 0x1FFFFF80); | |
__DSB(); | |
/** Set stack here. */ | |
__set_MSP(*((uint32_t*)(address))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment