Fix watchdog init code
This commit is contained in:
		@@ -70,15 +70,24 @@ int watchdog_setup(uint8_t prescaler)
 | 
			
		||||
	/** - Unlock registers */
 | 
			
		||||
	IWDG->KR = STM32_WATCHDOG_REGISTER_ACCESS_KEY;
 | 
			
		||||
 | 
			
		||||
	/** - Wait until prescaler can be written */
 | 
			
		||||
	while (IWDG->SR & IWDG_SR_PVU);
 | 
			
		||||
 | 
			
		||||
	/** - Write prescaler value */
 | 
			
		||||
	IWDG->PR = prescaler_reg_val;
 | 
			
		||||
 | 
			
		||||
	/* - Wait until reload value can be written */
 | 
			
		||||
	while (IWDG->SR & IWDG_SR_RVU);
 | 
			
		||||
 | 
			
		||||
	/** - Set reload value fixed to 0xFFF */
 | 
			
		||||
	IWDG->RLR = 0xFFFU;
 | 
			
		||||
 | 
			
		||||
	/** - Write enable key */
 | 
			
		||||
	IWDG->KR = STM32_WATCHDOG_ENABLE_KEY;
 | 
			
		||||
 | 
			
		||||
	/** - Do a first reset of the counter. This also locks the config regs */
 | 
			
		||||
	watchdog_ack(WATCHDOG_MAGIC_KEY);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user