| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Defines | Typedefs | Enumerations | Functions | Variables
Software Watchdog (SWWDG)

## Data Structures
struct | stc_swwdg_config
| Software and Hardware Watchdog configuration. More...
## Defines
#define | SWWDG_DEFAULT_VAL (0xFFFFFFFFu)
#define | SWWDG_CTL_INTEN (0x01u)
#define | SWWDG_CTL_RESEN (0x02u)
#define | SWWDG_CTL_TWD100 (0x00u)
#define | SWWDG_CTL_TWD75 (0x04u)
#define | SWWDG_CTL_TWD50 (0x08u)
#define | SWWDG_CTL_TWD25 (0x0Cu)
#define | SWWDG_CTL_SPM (0x10u)
#define | SWWDG_SPMC_TGR (0x01u)
#define | SWWDG_REG_UNLOCK (0x1ACCE551u)
## Typedefs
typedef enum en_swwdg_timing_window | en_swwdg_timing_window_t
| Software watchdog timing window settings.
typedef struct stc_swwdg_config | stc_swwdg_config_t
| Software and Hardware Watchdog configuration.
## Enumerations
enum | en_swwdg_timing_window { en_swwdg_timing_window_100 = 0x00, en_swwdg_timing_window_75 = 0x01, en_swwdg_timing_window_50 = 0x02, en_swwdg_timing_window_25 = 0x03 }
| Software watchdog timing window settings. More...
## Functions
void | SwwdgIrqHandler (void)
| Software Watchdog Interrupt Handler.
en_result_t | Swwdg_Init (stc_swwdg_config_t *pstcConfig)
| Initialize Software Watchdog.
void | Swwdg_DeInit (void)
| Un-Initialize Software Watchdog.
en_result_t | Swwdg_Start (func_ptr_t pfnSwwdgCb)
| Start the Software Watchdog.
void | Swwdg_Stop (void)
| Stop the Software Watchdog.
void | Swwdg_WriteWdgLoad (uint32_t u32LoadValue)
| Write the load value for Software Watchdog.
uint32_t | Swwdg_ReadWdgValue (void)
| Read the count value for Software Watchdog.
void | Swwdg_Feed (void)
| Feed Software Watchdog (Call function)
void | Swwdg_EnableDbgBrkWdgCtl (void)
| Enable Debug Break Watchdog Timer Control.
void | Swwdg_DisableDbgBrkWdgCtl (void)
| Disable Debug Break Watchdog Timer Control.
static void | Swwdg_QuickFeed (void)
| Quickly feed Software Watchdog (inline function)
## Variables
static func_ptr_t | pfnSwwdgCallback
| callback function pointer for SW-Wdg Irq

## Detailed Description

Provided functions of SWWDG module:

- Swwdg_Init()
- Swwdg_DeInit()
- Swwdg_Start()
- Swwdg_Stop()
- Swwdg_WriteWdgLoad()
- Swwdg_ReadWdgValue()
- Swwdg_Feed()
- Swwdg_QuickFeed()
- Swwdg_EnableDbgBrkWdgCtl()
- Swwdg_DisableDbgBrkWdgCtl()

This module has dedicated interrupt callback functions, in which the user has to feed the Software Watchdog.

For the Software Watchdog Swwdg_Init() is used for setting the interval time. Swwdg_Feed() resets the Watchdog timer by a function call. Swwdg_QuickFeed() does the same, but the code is inline expanded for e.g. time-critical polling loops.

Additionaly Software Watchdog has the window watchdog mode. The Window Watchdog Mode detects whether counter reload by software is implemented at the right timing. This mode can be set on Swwdg_Init() by setting the parameter of stc_swwdg_config_t::bWinWdgEnable in stc_swwdg_config_t to TRUE. The timing is set by parameter of stc_swwdg_config_t::u8TimingWindow. If the parameter of stc_swwdg_config_t::bWinWdgResetEnable is set to TRUE, when the counter is reloaded at timing outside the timing window set previously, or when the counter is underflow, the Software Watchdog timer issues an reset.

Swwdg_Init() sets the Software Watchdog interval and mode. Mode is set by configuration bWinWdgEnable::stc_swwdg_config_t. This function has to call before using Software Watchdog. Swwdg_DeInit() disables the Watchdog. Swwdg_Start() starts interruption and count of the Software Watchdog. Swwdg_Stop() stops interruption and count of the Software Watchdog. Swwdg_WriteWdgLoad() writes load value for the Software Watchdog. Swwdg_ReadWdgValue() reads counter value of the Software Watchdog. Swwdg_Feed() resets the Watchdog timer by a function call. Swwdg_QuickFeed() does the same, but the code is inline expanded for e.g. time-critical polling loops. Swwdg_EnableDbgBrkWdgCtl() continues couting at the tool break. Swwdg_DisableDbgBrkWdgCtl() stops counting at the tool break.

## Define Documentation

#define SWWDG_CTL_INTEN (0x01u)

Definition at line 73 of file swwdg.c.

#define SWWDG_CTL_RESEN (0x02u)

Definition at line 74 of file swwdg.c.

Referenced by Swwdg_Init().

#define SWWDG_CTL_SPM (0x10u)

Definition at line 79 of file swwdg.c.

Referenced by Swwdg_Init().

#define SWWDG_CTL_TWD100 (0x00u)

Definition at line 75 of file swwdg.c.

Referenced by Swwdg_Init().

#define SWWDG_CTL_TWD25 (0x0Cu)

Definition at line 78 of file swwdg.c.

Referenced by Swwdg_Init().

#define SWWDG_CTL_TWD50 (0x08u)

Definition at line 77 of file swwdg.c.

Referenced by Swwdg_Init().

#define SWWDG_CTL_TWD75 (0x04u)

Definition at line 76 of file swwdg.c.

Referenced by Swwdg_Init().

#define SWWDG_DEFAULT_VAL (0xFFFFFFFFu)

Definition at line 70 of file swwdg.c.

Referenced by Swwdg_DeInit().

#define SWWDG_REG_UNLOCK (0x1ACCE551u)

Definition at line 124 of file swwdg.h.

Referenced by Swwdg_DeInit(), Swwdg_Feed(), Swwdg_Init(), Swwdg_QuickFeed(), Swwdg_Start(), Swwdg_Stop(), and Swwdg_WriteWdgLoad().

#define SWWDG_SPMC_TGR (0x01u)

Definition at line 82 of file swwdg.c.

Referenced by Swwdg_Init().

## Typedef Documentation

typedef enum en_swwdg_timing_window en_swwdg_timing_window_t

Software watchdog timing window settings.

typedef struct stc_swwdg_config stc_swwdg_config_t

Software and Hardware Watchdog configuration.

## Enumeration Type Documentation

enum en_swwdg_timing_window

Software watchdog timing window settings.

Enumerator:

  en_swwdg_timing_window_100 | Reload can be executed at less than or equal to WDOGLOAD.
  en_swwdg_timing_window_75 | Reload can be executed at less than or equal to 75% of WDOGLOAD.
  en_swwdg_timing_window_50 | Reload can be executed at less than or equal to 50% of WDOGLOAD.
  en_swwdg_timing_window_25 | Reload can be executed at less than or equal to 25% of WDOGLOAD.

Definition at line 134 of file swwdg.h.

## Function Documentation

void Swwdg_DeInit | ( | void |  | ) |

Un-Initialize Software Watchdog.

Definition at line 214 of file swwdg.c.

References PDL_DEFAULT_INTERRUPT_LEVEL, pfnSwwdgCallback, SWWDG_DEFAULT_VAL, and SWWDG_REG_UNLOCK.

void Swwdg_DisableDbgBrkWdgCtl | ( | void |  | ) |

Disable Debug Break Watchdog Timer Control.

Definition at line 340 of file swwdg.c.

References FALSE.

void Swwdg_EnableDbgBrkWdgCtl | ( | void |  | ) |

Enable Debug Break Watchdog Timer Control.

Definition at line 326 of file swwdg.c.

References TRUE.

void Swwdg_Feed | ( | void |  | ) |

Feed Software Watchdog (Call function)

This function feeds the Software Watchdog with the unlock, feed, and lock sequence.

Definition at line 314 of file swwdg.c.

References SWWDG_REG_UNLOCK.

en_result_t Swwdg_Init | ( | stc_swwdg_config_t * | pstcConfig | ) |

Initialize Software Watchdog.

Parameters:

  [in] | pstcConfig | Pointer to Software Watchdog configuration

Return values:

  Ok | Setup successful
  ErrorInvalidParameter | pstcConfig == NULL

Note:
  This function only initializes the Software Watchdog configuration. If Swwdg_Start() is called, MCU start the Software Watchdog.

Definition at line 134 of file swwdg.c.

References stc_swwdg_config::bResetEnable, stc_swwdg_config::bWinWdgEnable, stc_swwdg_config::bWinWdgResetEnable, en_swwdg_timing_window_100, en_swwdg_timing_window_25, en_swwdg_timing_window_50, en_swwdg_timing_window_75, ErrorInvalidParameter, Ok, PDL_IRQ_LEVEL_SWWDG, pfnSwwdgCallback, SWWDG_CTL_RESEN, SWWDG_CTL_SPM, SWWDG_CTL_TWD100, SWWDG_CTL_TWD25, SWWDG_CTL_TWD50, SWWDG_CTL_TWD75, SWWDG_REG_UNLOCK, SWWDG_SPMC_TGR, TRUE, stc_swwdg_config::u32LoadValue, and stc_swwdg_config::u8TimingWindow.

static __INLINE void Swwdg_QuickFeed | ( | void |  | ) | `[static]`

Quickly feed Software Watchdog (inline function)

This function feeds the Software Watchdog with the unlock, feed, and lock sequence as an inline function for quick execution in polling loops.

Definition at line 201 of file swwdg.h.

References SWWDG_REG_UNLOCK.

uint32_t Swwdg_ReadWdgValue | ( | void |  | ) |

Read the count value for Software Watchdog.

Return values:

  uint32_t:Value | of value register

Definition at line 301 of file swwdg.c.

en_result_t Swwdg_Start | ( | func_ptr_t | pfnSwwdgCb | ) |

Start the Software Watchdog.

Parameters:

  [in] | pfnSwwdgCb | Pointer to callback function

Return values:

  Ok | Setup successful
  ErrorOperationInProgress | Software Watchdog is active now

Note:
  Please initialize by calling Swwdt_Init() before executing this function.

Definition at line 241 of file swwdg.c.

References ErrorOperationInProgress, Ok, pfnSwwdgCallback, SWWDG_REG_UNLOCK, and TRUE.

void Swwdg_Stop | ( | void |  | ) |

Stop the Software Watchdog.

Definition at line 270 of file swwdg.c.

References FALSE, SWWDG_REG_UNLOCK, and TRUE.

void Swwdg_WriteWdgLoad | ( | uint32_t | u32LoadValue | ) |

Write the load value for Software Watchdog.

Parameters:

  [in] | u32LoadValue | Load value

Definition at line 287 of file swwdg.c.

References SWWDG_REG_UNLOCK.

void SwwdgIrqHandler | ( | void |  | ) |

Software Watchdog Interrupt Handler.

Definition at line 109 of file swwdg.c.

References pfnSwwdgCallback, and TRUE.

Referenced by SWDT_IRQHandler().

Here is the caller graph for this function:

## Variable Documentation

func_ptr_t pfnSwwdgCallback`[static]`

callback function pointer for SW-Wdg Irq

Definition at line 87 of file swwdg.c.

Referenced by Swwdg_DeInit(), Swwdg_Init(), Swwdg_Start(), and SwwdgIrqHandler().