/*  keapiWatchdog.c - KEAPI BSP support for sensors at Kontron nanoETXsp module
  *
  *  KEAPI v1.2.0.3 implementation.
  *  
  *  Initialization.
  */

/*
 * Copyright 2011 Kontron KGSC.
 */

/*
 modification history
 --------------------
  01b,11may11,ivo update for nanoETXsp
  01a,12apr11,ivo initial version
 */

/*
DESCRIPTION:
    KEAPI BSP support for sensors at Kontron  nanoETXsp module.
    KEAPI v1.2.0.3 implementation. Initialization.
*/

#include <vxWorks.h>
#include <config.h>

#include <../3rdparty/kontron/h/keapiVxW.h>

#include "keapi/keapiBSPCommon.h"

#define KEAPI_BSP_WATCHDOG
#include "keapi/keapiBSP.h"
#undef  KEAPI_BSP_WATCHDOG   

/* KEAPI staff */

KEAPI_RETVAL keapiWatchdogEnable
    (
    KEAPI_INT32 timeout
    )
    {
	if(!WATCHDOG_RESG_INITED)
		{
		return KEAPI_RET_ERROR;
		}
	
	if (timeout <= 0 || timeout > KEAPI_MAXIMUM_WATCHDOG)
		{
		return KEAPI_RET_PARAM_ERROR;
		}
	
	/* We have a chance to do it */
	WATCHDOG_ENABLE(timeout);
	
	return KEAPI_RET_SUCCESS;
    }

KEAPI_RETVAL keapiWatchdogTrigger(void)
    {
	if(!WATCHDOG_RESG_INITED)
		{
		return KEAPI_RET_ERROR;
		}
	
	WATCHDOG_TRIGGER();
	
	return KEAPI_RET_SUCCESS;
    }

KEAPI_RETVAL keapiWatchdogDisable(void)
    {
	if(!WATCHDOG_RESG_INITED)
		{
		return KEAPI_RET_ERROR;
		}
		
	WATCHDOG_DISABLE();
		
	return KEAPI_RET_SUCCESS;
    }

