/**********************************************************************************************************************
 *  COPYRIGHT
 *  -------------------------------------------------------------------------------------------------------------------
 *  \verbatim
 *
 *                 TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
 *
 *                 Property of Texas Instruments, Unauthorized reproduction and/or distribution
 *                 is strictly prohibited.  This product  is  protected  under  copyright  law
 *                 and  trade  secret law as an  unpublished work.
 *                 (C) Copyright Texas Instruments - 2014.  All rights reserved.
 *
 *  \endverbatim
 *  -------------------------------------------------------------------------------------------------------------------
 *  FILE DESCRIPTION
 *  -------------------------------------------------------------------------------------------------------------------
 *  File:       Wdg.c
 *  Project:    Tms570_AutosarWdgDriver
 *  Module:     Wdg
 *  Generator:  None
 *
 *  Description:  The Wdg Driver provides services for initialization, changing the operation mode and setting the
 *                trigger condition (timeout).
 *
 *---------------------------------------------------------------------------------------------------------------------
 * Author:  Enrique Lizarraga
 *---------------------------------------------------------------------------------------------------------------------
 * Revision History
 *---------------------------------------------------------------------------------------------------------------------
 * Version        Date         Author                 Change ID       Description
 *---------------------------------------------------------------------------------------------------------------------
 * 02.21.00       30Sep2014    Enrique Lizarraga      SDOCM00112272   -Initial Release
 * 02.21.01       29Feb2016    Enrique Lizarraga      SDOCM00121247   -Update version info
 * 02.30.00       01Dec2016    Sudhakar Singh         None            -Update version info 
 * 05.30.00       15Mar2017    Sudhakar Singh         SDOCM00122834    Version supports TMS570LSxx Family of Devices.
 *********************************************************************************************************************/
#define WDG_SOURCE

/**********************************************************************************************************************
 * Standard Header Files
 *********************************************************************************************************************/

/*********************************************************************************************************************
 * Other Header Files
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_017 */
/* DesignId : WDG_DesignId_002 */
/* Requirements : AR_WDG_SR2, AR_WDG_SR4 */
#include "Wdg.h"
#include "SchM_Wdg.h"
#include "Wdg_Cbk.h"
#if (STD_ON == WDG_DEV_ERROR_DETECT)
#include "Det.h"
#endif
/* SourceId : WDG_SourceId_001 */
/* DesignId : WDG_DesignId_003 */
/* Requirements : AR_WDG_SR6, AR_WDG_SR13, AR_WDG_SR43 */
#include "Dem.h"

/*********************************************************************************************************************
 * Version Check
 *********************************************************************************************************************/
#define WDG_SW_C_MAJOR_VERSION               (5U)
#define WDG_SW_C_MINOR_VERSION               (30U)
#define WDG_SW_C_PATCH_VERSION               (0U)
 
 /* SourceId : WDG_SourceId_002 */
/* DesignId : WDG_DesignId_014 */
/* Requirements : AR_WDG_SR7 */
/* AUTOSAR version information check has to match definition in header file */
#if (  (WDG_AR_RELEASE_MAJOR_VERSION    != (0x04U)) \
    || (WDG_AR_RELEASE_MINOR_VERSION    != (0x00U)) \
    || (WDG_AR_RELEASE_REVISION_VERSION != (0x03U)) )
  #error "WDG: AUTOSAR Version Numbers of WDG are different"
#endif

/* vendor specific version information is BCD coded */
#if ((WDG_SW_MAJOR_VERSION != WDG_SW_C_MAJOR_VERSION) || \
     (WDG_SW_MINOR_VERSION != WDG_SW_C_MINOR_VERSION))
  #error "Version numbers of Wdg.c and Wdg.h are inconsistent!"
#endif

#if ((WDG_CFG_MAJOR_VERSION != WDG_SW_C_MAJOR_VERSION) || \
     (WDG_CFG_MINOR_VERSION != WDG_SW_C_MINOR_VERSION))
   #error "Version numbers of Wdg.c and Wdg_Cfg.h are inconsistent!"
#endif

/*********************************************************************************************************************
 * Local Preprocessor #define Constants
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_003 */
/* DesignId : WDG_DesignId_011 */
/* Requirements : AR_WDG_SR25 */
/* Digital Watchdog Registers Base Address */
#define WDG_DWD_REG_BASE        ((P2VAR(Wdg_DwdRegisterType, WDG_CONST, REGSPACE))0xFFFFFC90U)

/* Digital Watchdog Control */
#define WDG_CTL_ENABLED         ((uint32)0xA98559DAU)
#define WDG_CTL_DISABLED        ((uint32)0x5312ACEDU)

/* Watchdog Triggers */
#define WDG_TRIGGER_FIRST_KEY   ((uint32)0xE51AU)
#define WDG_TRIGGER_SECOND_KEY  ((uint32)0xA35CU)
#define WDG_TRIGGER_RESET_KEY   ((uint32)0x2345U)

#define WDG_MHZ_TO_KHZ          ((uint32)1000)

/*********************************************************************************************************************
 * Local Preprocessor #define Macros
 *********************************************************************************************************************/

/*********************************************************************************************************************
 * Local Type Declarations
 *********************************************************************************************************************/
/* Digital Watchdog Control Registers (DWD) */
typedef volatile struct Wdg_DwdRegisterTag
{
   uint32 rtidwdctrl;                  /* 0x0000 */
   uint32 rtidwdprld;                  /* 0x0004 */
   uint32 rtiwdstatus;                 /* 0x0008 */
   uint32 rtiwdkey;                    /* 0x000C */
   uint32 rtidwdcntr;                  /* 0x0010 */
   uint32 rtiwwdrxnctrl;               /* 0x0014 */
   uint32 rtiwwdsizectrl;              /* 0x0018 */
}Wdg_DwdRegisterType;

/*********************************************************************************************************************
 * Exported Object Definitions
 *********************************************************************************************************************/

/*********************************************************************************************************************
 * Local Object Definitions
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_018 */
/* DesignId : WDG_DesignId_005 */
/* Requirements : AR_WDG_SR35, AR_WDG_SR37, AR_WDG_SR40 */
#define WDG_START_SEC_VAR_INIT_32
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"
static uint32 Wdg_Timeout_Counter = 0U;
static uint32 Wdg_Counter_Reference = 0U;
#define WDG_STOP_SEC_VAR_INIT_32
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

#if (STD_ON == WDG_DEV_ERROR_DETECT)
#define WDG_START_SEC_VAR_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"
/* SourceId : WDG_SourceId_019 */
/* DesignId : WDG_DesignId_005 */
/* Requirements : AR_WDG_SR35, AR_WDG_SR37, AR_WDG_SR39 */
volatile Wdg_StatusType Wdg_Status = WDG_UNINIT;
#define WDG_STOP_SEC_VAR_INIT_UNSPECIFIED
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */

/*********************************************************************************************************************
 *  Local Function Prototypes
 *********************************************************************************************************************/

/*********************************************************************************************************************
 *  Local Inline Function Definitions and Function-Like Macros
 *********************************************************************************************************************/

/*********************************************************************************************************************
 *  External Functions Definition
 *********************************************************************************************************************/
#define WDG_START_SEC_CODE
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"

#if (STD_ON == WDG_GET_VERSION_INFO_API)
/*********************************************************************************************************************
 * Function name:  Wdg_GetVersionInfo(Std_VersionInfoType* versioninfo)
 *********************************************************************************************************************/
/** \brief This service returns the version information of this module.
 *
 * This service returns the version information of this module.
 *
 * \param[in] None
 * \param[out] versioninfo - Pointer to where to store the version information of this module.
 * \pre None
 * \post None
 * \return None
 * \retval None
 *
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_004 */
/* DesignId : WDG_DesignId_009 */
/* Requirements : AR_WDG_SR15, AR_WDG_SR17, AR_WDG_SR19, AR_WDG_SR71, AR_WDG_SR72, AR_WDG_SR73, AR_WDG_SR75 */
FUNC(void, WDG_CODE) Wdg_GetVersionInfo(Std_VersionInfoType* versioninfo)
{
#if (STD_ON == WDG_DEV_ERROR_DETECT)
   /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Null pointer definition" */
   if(NULL_PTR == versioninfo)
   {
      (void)Det_ReportError(WDG_MODULE_ID, WDG_INSTANCE_ID,  WDG_API_GET_VERSION_INFO, WDG_E_PARAM_POINTER);
   }
   else
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */
   {
      versioninfo->vendorID         = (WDG_VENDOR_ID);
      versioninfo->moduleID         = (WDG_MODULE_ID);
      versioninfo->sw_major_version = (uint8)(WDG_SW_MAJOR_VERSION);
      versioninfo->sw_minor_version = (uint8)(WDG_SW_MINOR_VERSION);
      versioninfo->sw_patch_version = (uint8)(WDG_SW_PATCH_VERSION);
   }
}   /* Wdg_GetVersionInfo()*/
#endif  /* STD_ON == WDG_GET_VERSION_INFO_API */

/*********************************************************************************************************************
 * Function name:  Wdg_Init(const Wdg_ConfigType* ConfigPtr)
 *********************************************************************************************************************/
/** \brief This service initializes the WDG driver.
 *
 * Performs DWD general initialization.
 *
 * \param[in] ConfigPtr - Pointer to WDG driver configuration set.
 * \param[out] None
 * \pre None
 * \post None
 * \return None
 * \retval None
 *
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_005 */
/* DesignId : WDG_DesignId_006 */
/* Requirements : AR_WDG_SR15, AR_WDG_SR17, AR_WDG_SR19, AR_WDG_SR25, AR_WDG_SR45, AR_WDG_SR46,
 * AR_WDG_SR47, AR_WDG_SR48, AR_WDG_SR49, AR_WDG_SR50, AR_WDG_SR51, AR_WDG_SR53, AR_WDG_SR79 */
FUNC(void, WDG_CODE) Wdg_Init(P2CONST(Wdg_ConfigType, AUTOMATIC, WDG_APPL_CONST)ConfigPtr)
{
#if (STD_ON == WDG_DEV_ERROR_DETECT)
   if(NULL_PTR == ConfigPtr)
   {
      (void)Det_ReportError(WDG_MODULE_ID, WDG_INSTANCE_ID, WDG_API_INIT, WDG_E_PARAM_POINTER);
   }
   else
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */
   {
      /* Clear any previous violations */
      WDG_DWD_REG_BASE->rtiwdstatus = 0xFFU;

      /* Check if enabled by default */
      if(WDGIF_FAST_MODE == ConfigPtr->Wdg_Default_Mode)
      {
         /* Set Initial Trigger Timeout */
         Wdg_Timeout_Counter = WDG_INITIAL_TIMEOUT;
         /* Set DWD preload value */
         WDG_DWD_REG_BASE->rtidwdprld = WDG_PRELOAD_VALUE;
         /* Set Window Size */
         WDG_DWD_REG_BASE->rtiwwdsizectrl = WDG_WINDOW_SIZE;
         /* Set Watchdog Reaction */
         WDG_DWD_REG_BASE->rtiwwdrxnctrl = WDG_REACTION;
         /* Save initial watchdog counter value */
         Wdg_Counter_Reference =  WDG_DWD_REG_BASE->rtidwdcntr;
         /* Enable DWD */
         WDG_DWD_REG_BASE->rtidwdctrl = WDG_CTL_ENABLED;
#if (STD_ON == WDG_DEV_ERROR_DETECT)
         Wdg_Status = WDG_IDLE;
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */
      }
      else
      {
#if(WDG_E_MODE_FAILED != WDG_DEM_NO_EVENT)
         /* Mode not supported */
         Dem_ReportErrorStatus(WDG_E_MODE_FAILED, DEM_EVENT_STATUS_FAILED);
#else
         /* Mode Failed error not assigned to any DEM event */
#endif
#if(WDG_E_DISABLE_REJECTED != WDG_DEM_NO_EVENT)
         if(WDGIF_OFF_MODE == ConfigPtr->Wdg_Default_Mode)
         {
            Dem_ReportErrorStatus(WDG_E_DISABLE_REJECTED, DEM_EVENT_STATUS_FAILED);
         }
#else
         /* Disable Rejected error not assigned to any DEM event */
#endif
      }
   }
} /*end of Wdg_Init()*/


/*********************************************************************************************************************
 * Function name:  Wdg_SetMode(WdgIf_ModeType Mode)
 *********************************************************************************************************************/
/** \brief Switches the watchdog into the mode Mode.
 *
 * Only Fast mode supported.
 *
 * \param[in] Mode
 * \param[out] None
 * \pre This function shall be called after the call of Wdg_Init()
 * \post None
 * \return None
 * \retval None
 *
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_006 */
/* DesignId : WDG_DesignId_007 */
/* Requirements : AR_WDG_SR9, AR_WDG_SR15, AR_WDG_SR17, AR_WDG_SR19, AR_WDG_SR54, AR_WDG_SR55,
 * AR_WDG_SR58, AR_WDG_SR59, AR_WDG_SR60, AR_WDG_SR61, AR_WDG_SR62, AR_WDG_SR63, AR_WDG_SR64, AR_WDG_SR79 */
FUNC(Std_ReturnType, WDG_CODE) Wdg_SetMode(WdgIf_ModeType Mode)
{
   Std_ReturnType wdg_set_mode_return = E_NOT_OK;

#if (STD_ON == WDG_DEV_ERROR_DETECT)
   if(WDG_IDLE != Wdg_Status)
   {
      (void)Det_ReportError(WDG_MODULE_ID, WDG_INSTANCE_ID, WDG_API_SET_MODE, WDG_E_DRIVER_STATE);
   }
   else
   {
      /* Set driver status as busy */
      Wdg_Status = WDG_BUSY;
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */
      if(WDGIF_FAST_MODE != Mode)
      {
#if (STD_ON == WDG_DEV_ERROR_DETECT)
         /* API is being called with an invalid mode */
         (void)Det_ReportError(WDG_MODULE_ID, WDG_INSTANCE_ID, WDG_API_SET_MODE, WDG_E_PARAM_MODE);
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */
         if(WDGIF_OFF_MODE == Mode)
         {
#if(WDG_E_DISABLE_REJECTED != WDG_DEM_NO_EVENT)
            /* WDG can't be disabled */
            Dem_ReportErrorStatus(WDG_E_DISABLE_REJECTED, DEM_EVENT_STATUS_FAILED);
#else
            /* Disable Rejected error not assigned to any DEM event */
#endif
         }
         else
         {
#if(WDG_E_MODE_FAILED != WDG_DEM_NO_EVENT)
            /* WDG mode not supported */
            Dem_ReportErrorStatus(WDG_E_MODE_FAILED, DEM_EVENT_STATUS_FAILED);
#else
            /* Mode Failed error not assigned to any DEM event */
#endif
         }
      }
      else
      {
         /* Set return value */
         wdg_set_mode_return = E_OK;
      }
#if (STD_ON == WDG_DEV_ERROR_DETECT)
      /* Set driver status as idle */
      Wdg_Status = WDG_IDLE;
   }
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */
   return(wdg_set_mode_return);
} /*end of the Wdg_SetMode()*/

/*********************************************************************************************************************
 * Function name:  Wdg_SetTriggerCondition(uint16 timeout)
 *********************************************************************************************************************/
/** \brief This service sets the timeout value for the trigger counter.
 *
 * Sets the timeout value for the trigger counter.
 *
 * \param[in] timeout - Timeout value (milliseconds) for setting the trigger counter.
 * \param[out] None
 * \pre None
 * \post None
 * \return None
 * \retval None
 *
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_007 */
/* DesignId : WDG_DesignId_008 */
/* Requirements : AR_WDG_SR15, AR_WDG_SR17, AR_WDG_SR19, AR_WDG_SR25, AR_WDG_SR27, AR_WDG_SR65, AR_WDG_SR66,
 * AR_WDG_SR67, AR_WDG_SR69, AR_WDG_SR70 */
FUNC(void, WDG_CODE) Wdg_SetTriggerCondition(uint16 timeout)
{
#if (STD_ON == WDG_DEV_ERROR_DETECT)
   if(WDG_MAX_TIMEOUT < timeout)
   {
      /* API is being called with an invalid timeout value */
      (void)Det_ReportError(WDG_MODULE_ID, WDG_INSTANCE_ID, WDG_SET_TRIGGER_CONDITION, WDG_E_PARAM_TIMEOUT);
   }
   else
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */
   {
      if(0U == timeout)
      {
         /* Cause a WD reset if timeout is set as 0 */
         WDG_DWD_REG_BASE->rtiwdkey = WDG_TRIGGER_RESET_KEY;
      }
      else
      {
         /* Save current watchdog counter value */
         Wdg_Counter_Reference =  WDG_DWD_REG_BASE->rtidwdcntr;
         /* Update trigger condition */
         Wdg_Timeout_Counter = timeout;
      }
   }

} /*end of Wdg_SetTriggerCondition()*/

#if (STD_ON == WDG_REGISTER_READBACK_API)
/*******************************************************************************************************************
 *  Wdg_RegisterReadback
 *******************************************************************************************************************/
/*! \brief      This method is Wdg_RegisterReadback Api.
 *  \param[in]  Wdg_RegisterReadbackType       RegisterReadbackPtr
 *  \param[out] none
 *  \return     E_OK, E_NOT_OK
 *  \context    Function could be called from from task level
 *******************************************************************************************************************/
/* SourceId : WDG_SourceId_015 */
/* DesignId : WDG_DesignId_010 */
/* Requirements : AR_WDG_SR84 */
FUNC(Std_ReturnType, WDG_CODE) Wdg_RegisterReadback
(
    P2VAR(Wdg_RegisterReadbackType, AUTOMATIC, WDG_APPL_DATA) RegisterReadbackPtr
)
{
   Std_ReturnType register_readback_return = E_NOT_OK;

   /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Null pointer definition" */
   if(NULL_PTR == RegisterReadbackPtr)
   {
      /* Do nothing. Incorrect pointer. */
   }
   else
   {
      /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Pointer to register definition" */
      RegisterReadbackPtr->Wdg_RtiDwdCtrl     = WDG_DWD_REG_BASE->rtidwdctrl;
      /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Pointer to register definition" */
      RegisterReadbackPtr->Wdg_RtiDwdprld     = WDG_DWD_REG_BASE->rtidwdprld;
      /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Pointer to register definition" */
      RegisterReadbackPtr->Wdg_RtiWdStatus    = WDG_DWD_REG_BASE->rtiwdstatus;
      /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Pointer to register definition" */
      RegisterReadbackPtr->Wdg_RtiWdKey       = WDG_DWD_REG_BASE->rtiwdkey;
      /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Pointer to register definition" */
      RegisterReadbackPtr->Wdg_RtiDwdCntr     = WDG_DWD_REG_BASE->rtidwdcntr;
      /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Pointer to register definition" */
      RegisterReadbackPtr->Wdg_RtiWwdRxnCtrl  = WDG_DWD_REG_BASE->rtiwwdrxnctrl;
      /*SAFETYMCUSW 440 S MR:11.3 <APPROVED> "Pointer to register definition" */
      RegisterReadbackPtr->Wdg_RtiWwdSizeCtrl = WDG_DWD_REG_BASE->rtiwwdsizectrl;

      register_readback_return = E_OK;
   }

   return(register_readback_return);
}
#endif /*STD_ON == WDG_REGISTER_READBACK_API*/

/*********************************************************************************************************************
 *  Internal Functions Definition
 *********************************************************************************************************************/

/*********************************************************************************************************************
 * Function name:  Wdg_Trigger(void)
 *********************************************************************************************************************/
/** \brief This service sets the timeout value for the trigger counter.
 *
 * Sets the timeout value for the trigger counter.
 *
 * \param[in] None
 * \param[out] None
 * \pre None
 * \post None
 * \return None
 * \retval None
 *
 *********************************************************************************************************************/
/* SourceId : WDG_SourceId_008 */
/* DesignId : WDG_DesignId_011 */
/* Requirements : AR_WDG_SR15, AR_WDG_SR19, AR_WDG_SR25, AR_WDG_SR28, AR_WDG_SR29, AR_WDG_SR33, AR_WDG_SR34,
 * AR_WDG_SR67 */
FUNC(void, WDG_CODE) Wdg_Trigger(void)
{
   uint32 wdg_elapsed_time;

#if (STD_ON == WDG_DEV_ERROR_DETECT)
   /* Check if driver already initialized */
   if(WDG_IDLE != Wdg_Status)
   {
      (void)Det_ReportError(WDG_MODULE_ID, WDG_INSTANCE_ID, WDG_API_TRIGGER, WDG_E_DRIVER_STATE);
   }
   else
   {
      /* Set driver status as busy */
      Wdg_Status = WDG_BUSY;
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */

      /* If Timeout counter hasn't expired, continue trigger routine */
      if(0U < Wdg_Timeout_Counter)
      {
         /* Counter reference shall not be smaller than current WDW counter */
         wdg_elapsed_time = WDG_DWD_REG_BASE->rtidwdcntr;
         if(Wdg_Counter_Reference > wdg_elapsed_time)
         {
            /* Calculate elapsed time since last trigger invocation */
            wdg_elapsed_time = Wdg_Counter_Reference - wdg_elapsed_time;
            /* Convert elapsed time to milliseconds */
            wdg_elapsed_time = (wdg_elapsed_time / (WDG_RTI_FREQUENCY * WDG_MHZ_TO_KHZ));
            /* Elapsed time is smaller than the last received trigger condition */
            if(Wdg_Timeout_Counter > wdg_elapsed_time)
            {
               /* Write key sequence to reload the DWD */
               WDG_DWD_REG_BASE->rtiwdkey = WDG_TRIGGER_FIRST_KEY;
               WDG_DWD_REG_BASE->rtiwdkey = WDG_TRIGGER_SECOND_KEY;
               /* Decrement Counter */
               Wdg_Timeout_Counter = Wdg_Timeout_Counter - wdg_elapsed_time;
            }
            else
            {
               /* Elapsed time is larger than last received trigger condition, stop servicing watchdog*/
               Wdg_Timeout_Counter = 0U;
            }
         }
      }
#if (STD_ON == WDG_DEV_ERROR_DETECT)
      /* Set driver status as idle */
      Wdg_Status = WDG_IDLE;
   }
#endif /* STD_ON == WDG_DEV_ERROR_DETECT */

} /* Wdg_Trigger() */

#define WDG_STOP_SEC_CODE
/*SAFETYMCUSW 338 S MR:19.1 <APPROVED> "Based on Autosar Memory Map strategy" */
#include "MemMap.h"
/*********************************************************************************************************************
 *  End of File: Wdg.c
 *********************************************************************************************************************/
