Add EnableWatchdog for auto-reset in ISP
This commit is contained in:
parent
0a7920c13f
commit
5b29d9b6f0
|
@ -6,7 +6,6 @@
|
||||||
#define set_MSP(x) \
|
#define set_MSP(x) \
|
||||||
__asm( "msr MSP, %0\n" : : "r" (x) )
|
__asm( "msr MSP, %0\n" : : "r" (x) )
|
||||||
|
|
||||||
|
|
||||||
/* Jump back into bootcode, enable mass storage firmware flashing */
|
/* Jump back into bootcode, enable mass storage firmware flashing */
|
||||||
|
|
||||||
void ReinvokeISP(void) {
|
void ReinvokeISP(void) {
|
||||||
|
@ -50,3 +49,25 @@ void ReinvokeISP(void) {
|
||||||
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnableWatchdog(uint32_t ms){
|
||||||
|
/* Enable WDT clock */
|
||||||
|
SCB_SYSAHBCLKCTRL |= 0x8000;
|
||||||
|
|
||||||
|
SCB_PDRUNCFG &= ~(1);
|
||||||
|
/* select internal RC */
|
||||||
|
SCB_WDTCLKSEL = SCB_WDTCLKSEL_SOURCE_INTERNALOSC;
|
||||||
|
/* enable */
|
||||||
|
SCB_WDTCLKUEN = 0;
|
||||||
|
SCB_WDTCLKUEN = 1;
|
||||||
|
|
||||||
|
#define INTERNAL_RC_HZ 12000000
|
||||||
|
WDT_WDTC= ((INTERNAL_RC_HZ/4)/1000) *ms;
|
||||||
|
|
||||||
|
SCB_WDTCLKDIV = 1;
|
||||||
|
WDT_WDMOD = WDT_WDMOD_WDRESET_ENABLED | WDT_WDMOD_WDEN_ENABLED;
|
||||||
|
|
||||||
|
// frob watchdog once.
|
||||||
|
WDT_WDFEED = WDT_WDFEED_FEED1;
|
||||||
|
WDT_WDFEED = WDT_WDFEED_FEED2;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue