/**************************************************************************************************
 * Copyright (c) 2017 Epsilon Kran GmbH
 * Christophorusstraße 30, 5061 Elsbethen-Glasenbach, Austria. epsilon@palfinger.com
 *************************************************************************************************/
/**********************************************************************************************//**
 * \file EPS_Error.h
 *
 * \latexonly \hypertarget{EPS Error}{} \endlatexonly
 *
 * \brief EPS Error Type description
 *
 *   Contains the definition and documentation of all possible error types.\n
 *
 * \note
 *   This is a Note.\n
 *
 *
 * Each object is allowed to return an error code.
 *
 *
 *************************************************************************************************/

#ifndef INC_CLASS_EPS_ERROR_H_
#define INC_CLASS_EPS_ERROR_H_


/**************************************************************************************************
 *
 * I N C L U D E S
 *
 *************************************************************************************************/

#include "ptypes_tms570.h"

/**************************************************************************************************
 *
 * D A T A   S T R U C T U R E S
 *
 *************************************************************************************************/

/** \brief EPS error type
 *
 * Type definition for all the IO Driver errors and Epsilon errors.
 */
typedef ubyte2 EPS_ErrorType;



/**************************************************************************************************
 *
 * D E F I N I T I O N S
 *
 *************************************************************************************************/

/*
 * E R R O R   V A L U E S
 */

/* general codes */

/** Epsilon Error Code Offset
 * All generated errors have this offset from zero
 */
#define EPS_E_OFSET                     1000U

/** everything is fine, no error has occurred. */
#define EPS_E_OK                        (0U)

/** Module or function is busy.\n
 *  This error is reported if a function or module has not yet finished its task. For example the
 *  init function will return this error code if a previous init command has not been
 *  finished yet.
 */
#define EPS_E_BUSY                      (1U)

/** General error. No further information can be provided. */
#define EPS_E_UNKNOWN                   (2U)

/** A NULL pointer has been passed to the function.\n
 *  This error is reported if a non-optional pointer parameter of the function has been set to
 *  \c #NULL.
 */
#define EPS_E_NULLPTR                   (4U)

/** If a task method of an object is called even if the init process was not successful then
 *  this error code is called. For example, the CAN bus init was not sucessfull and an
 *  sync message in the pre method should be sent.
 *
 *  Or a method of the class is called, which needs a init run before calling.
 */
#define EPS_E_INIT_ERROR                (EPS_E_OFSET + 1U)

/** There is not more space left to add an element to a buffer.
 *  E.g. The message is given by the class todo if an message has to be sent.
 */
#define EPS_E_WRITE_BUFFER_FULL         (EPS_E_OFSET + 2U)

/** Before every division an check for zero is done.
 * If the divisor is zero, this error accours.
 */
#define EPS_E_DIVBYZERO                 (EPS_E_OFSET + 3U)

/* can bus codes */

/** Not every can bus message could be send in very operation state of
 * the device. If the device is not in the right mode to perform the wanted
 * operation, this error is passed.
 */
#define EPS_E_CANOPENDEVICE_WRONG_MODE  (EPS_E_OFSET + 4U)

/** Non optional can bus device is not connected to the bus
 *
 */
#define EPS_E_CANOPEN_DEV_NOT_CONNECTED     (EPS_E_OFSET + 5U)

/** If the object, added to the can hardware class has the same
 * is a anouther already connected object, this error is returned
 */
#define EPS_E_CANOPEN_NODEID                (EPS_E_OFSET + 6U)

/**
 * No more objects could be connected to the can hardware class
 * the internal buffer is full
 */
#define EPS_E_CANOPEN_OBJECT_FULL           (EPS_E_OFSET + 7U)

/**
 * The given handle of the object is not known by the hardware class
 */
#define EPS_E_CANOPEN_MSG_HANDLE_UNKNOWN    (EPS_E_OFSET + 8U)

/**
 * The called function is not allowed to do anything
 * because it is disabled. The enable() function has to be called
 * before.
 */
#define EPS_E_DISABLED						(EPS_E_OFSET + 9U)

#endif
