mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
changed pios watchdog from 8-bit to 16-bit ms capability, plus moved the .h file from the .c folder into the inc folder
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1466 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
e15a12329c
commit
ba5f1b37ee
@ -54,19 +54,20 @@
|
|||||||
* @param[in] delayMs The delay period in ms
|
* @param[in] delayMs The delay period in ms
|
||||||
* @returns Maximum recommended delay between updates
|
* @returns Maximum recommended delay between updates
|
||||||
*/
|
*/
|
||||||
uint8_t PIOS_WDG_Init( uint8_t delayMs )
|
uint16_t PIOS_WDG_Init(uint16_t delayMs)
|
||||||
{
|
{
|
||||||
uint16_t delay;
|
uint32_t delay = (60ul * delayMs) / 16;
|
||||||
delay = 60 / 16 * delayMs;
|
if (delay > 0xfff) delay = 0xfff;
|
||||||
if( delay > 0xfff )
|
|
||||||
delay = 0xfff;
|
|
||||||
DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); // make the watchdog stop counting in debug mode
|
DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); // make the watchdog stop counting in debug mode
|
||||||
IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
|
IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
|
||||||
IWDG_SetPrescaler( IWDG_Prescaler_16 );
|
IWDG_SetPrescaler( IWDG_Prescaler_16 );
|
||||||
IWDG_SetReload( delay );
|
IWDG_SetReload( delay );
|
||||||
IWDG_ReloadCounter();
|
IWDG_ReloadCounter();
|
||||||
IWDG_Enable();
|
IWDG_Enable();
|
||||||
return delay / (60 / 16) * .75;
|
|
||||||
|
// return delay / (60 / 16) * .75f;
|
||||||
|
return (((delay * 16) / 60) * .75f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +75,7 @@ uint8_t PIOS_WDG_Init( uint8_t delayMs )
|
|||||||
*
|
*
|
||||||
* This function must be called at the appropriate delay to prevent a reset event occuring
|
* This function must be called at the appropriate delay to prevent a reset event occuring
|
||||||
*/
|
*/
|
||||||
void PIOS_WDG_Clear()
|
void PIOS_WDG_Clear(void)
|
||||||
{
|
{
|
||||||
IWDG_ReloadCounter();
|
IWDG_ReloadCounter();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#ifndef PIOS_WDG
|
#ifndef PIOS_WDG
|
||||||
#define PIOS_WDG
|
#define PIOS_WDG
|
||||||
|
|
||||||
uint8_t PIOS_WDG_Init( uint8_t delayMs );
|
uint16_t PIOS_WDG_Init(uint16_t delayMs);
|
||||||
void PIOS_WDG_Clear();
|
void PIOS_WDG_Clear(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user