dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

PIOS Comamnds to initialize and clear watchdog timer. More...

Files

file  pios_wdg.h
 SPI functions header.
 

Macros

#define PIOS_WDG_ACTUATOR   0x0001
 
#define PIOS_WDG_STABILIZATION   0x0002
 
#define PIOS_WDG_ATTITUDE   0x0004
 
#define PIOS_WDG_MANUAL   0x0008
 
#define PIOS_WDG_SENSORS   0x0010
 

Functions

uint16_t PIOS_WDG_Init ()
 Initialize the watchdog timer for a specified timeout. More...
 
bool PIOS_WDG_RegisterFlag (uint16_t flag_requested)
 Register a module against the watchdog. More...
 
bool PIOS_WDG_UpdateFlag (uint16_t flag)
 Function called by modules to indicate they are still running. More...
 
uint16_t PIOS_WDG_GetBootupFlags ()
 Returns the flags that were set at bootup. More...
 
uint16_t PIOS_WDG_GetActiveFlags ()
 Returns the currently active flags. More...
 
void PIOS_WDG_Clear (void)
 Clear the watchdog timer. More...
 
static bool PIOS_WDG_Check ()
 This function returns true if the watchdog would have expired. More...
 

Variables

unsigned int wdg_registered_flags
 
unsigned int wdg_updated_flags
 
uint32_t wdg_cleared_time
 
uint32_t wdg_last_update_time
 
bool wdg_expired
 

Detailed Description

PIOS Comamnds to initialize and clear watchdog timer.

Macro Definition Documentation

#define PIOS_WDG_ACTUATOR   0x0001

Definition at line 35 of file pios_wdg.h.

#define PIOS_WDG_ATTITUDE   0x0004

Definition at line 37 of file pios_wdg.h.

#define PIOS_WDG_MANUAL   0x0008

Definition at line 38 of file pios_wdg.h.

#define PIOS_WDG_SENSORS   0x0010

Definition at line 39 of file pios_wdg.h.

#define PIOS_WDG_STABILIZATION   0x0002

Definition at line 36 of file pios_wdg.h.

Function Documentation

static bool PIOS_WDG_Check ( )
static

This function returns true if the watchdog would have expired.

Definition at line 155 of file pios_wdg.c.

void PIOS_WDG_Clear ( void  )

Clear the watchdog timer.

This function must be called at the appropriate delay to prevent a reset event occuring

Definition at line 147 of file pios_wdg.c.

uint16_t PIOS_WDG_GetActiveFlags ( )

Returns the currently active flags.

For external monitoring

Returns
The active flags register

Definition at line 137 of file pios_wdg.c.

uint16_t PIOS_WDG_GetBootupFlags ( )

Returns the flags that were set at bootup.

This is used for diagnostics, if only one flag not set this was likely the module that wasn't running before reset

Returns
The active flags register from bootup

Definition at line 125 of file pios_wdg.c.

uint16_t PIOS_WDG_Init ( )

Initialize the watchdog timer for a specified timeout.

It is important to note that this function returns the achieved timeout for this hardware. For hardware indendence this should be checked when scheduling updates. Other hardware dependent details may need to be considered such as a window time which sets a minimum update time, and this function should return a recommended delay for clearing.

For the STM32 nominal clock rate is 32 khz, but for the maximum clock rate of 60 khz and a prescalar of 4 yields a clock rate of 15 khz. The delay that is set in the watchdog assumes the nominal clock rate, but the delay for FreeRTOS to use is 75% of the minimal delay.

Parameters
[in]delayMsThe delay period in ms
Returns
Maximum recommended delay between updates

It is important to note that this function returns the achieved timeout for this hardware. For hardware independence this should be checked when scheduling updates. Other hardware dependent details may need to be considered such as a window time which sets a minimum update time, and this function should return a recommended delay for clearing.

For the STM32 nominal clock rate is 32 khz, but for the maximum clock rate of 60 khz and a prescaler of 4 yields a clock rate of 15 khz. The delay that is set in the watchdog assumes the nominal clock rate, but the delay for RTOS to use is 75% of the minimal delay.

Returns
Maximum recommended delay between updates based on PIOS_WATCHDOG_TIMEOUT constant

Definition at line 63 of file pios_wdg.c.

bool PIOS_WDG_RegisterFlag ( uint16_t  flag_requested)

Register a module against the watchdog.

There are two ways to use PIOS WDG: this is for when multiple modules must be monitored. In this case they must first register against the watchdog system and only when all of the modules have been updated with the watchdog be cleared. Each module must have its own bit in the 16 bit

Parameters
[in]flagthe bit this module wants to use
Returns
True if that bit is unregistered

Definition at line 86 of file pios_wdg.c.

bool PIOS_WDG_UpdateFlag ( uint16_t  flag)

Function called by modules to indicate they are still running.

This function will set this flag in the active flags register (which is a backup regsiter) and if all the registered flags are set will clear the watchdog and set only this flag in the backup register

Parameters
[in]flagthe flag to set
Returns
true if the watchdog cleared, false if flags are pending

Definition at line 102 of file pios_wdg.c.

Variable Documentation

uint32_t wdg_cleared_time

Definition at line 39 of file pios_wdg.c.

bool wdg_expired

Definition at line 42 of file pios_wdg.c.

uint32_t wdg_last_update_time

Definition at line 40 of file pios_wdg.c.

unsigned int wdg_registered_flags

Definition at line 37 of file pios_wdg.c.

unsigned int wdg_updated_flags

Definition at line 38 of file pios_wdg.c.