mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
added casting to prevent int overflows when calculating the watchdog delay
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1467 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ba5f1b37ee
commit
7813414f29
@ -56,8 +56,8 @@
|
||||
*/
|
||||
uint16_t PIOS_WDG_Init(uint16_t delayMs)
|
||||
{
|
||||
uint32_t delay = (60ul * delayMs) / 16;
|
||||
if (delay > 0xfff) delay = 0xfff;
|
||||
uint16_t delay = ((uint32_t)delayMs * 60) / 16;
|
||||
if (delay > 0x0fff) delay = 0x0fff;
|
||||
|
||||
DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); // make the watchdog stop counting in debug mode
|
||||
IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
|
||||
@ -66,8 +66,7 @@ uint16_t PIOS_WDG_Init(uint16_t delayMs)
|
||||
IWDG_ReloadCounter();
|
||||
IWDG_Enable();
|
||||
|
||||
// return delay / (60 / 16) * .75f;
|
||||
return (((delay * 16) / 60) * .75f);
|
||||
return ((((uint32_t)delay * 16) / 60) * .75f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user