/*
* codrv_error.h
*
* Copyright (c) 2012-2023 emotas embedded communication GmbH
*-------------------------------------------------------------------
* SVN  $Id: codrv_error.h 51612 2023-12-19 17:23:36Z ro $
*
*
*-------------------------------------------------------------------
*
*
*/

/********************************************************************/
/**
* \file
* \brief can error handling
*
*/

#ifndef CODRV_ERROR_H
#define CODRV_ERROR_H 1

/** CAN controller state */
typedef enum {
	Error_Offline,		/**< disabled */
	Error_Active,		/**< Error Active */
	Error_Passive,		/**< Error Passive */
	Error_Busoff		/**< Error bus off */
} CAN_ERROR_STATES_T;

/** CAN state event collection structure */
typedef struct {
	BOOL_T canErrorRxOverrun; 			/**< CAN controller overrun */

	BOOL_T canErrorPassive;				/**< CAN Passive event occured */
	BOOL_T canErrorActive;				/**< CAN active event occured */
	BOOL_T canErrorBusoff;				/**< CAN busoff event occured */

	BOOL_T drvErrorGeneric;				/**< CAN for generic errors */

	CAN_ERROR_STATES_T canOldState; 	/**< last signaled state */
	CAN_ERROR_STATES_T canNewState; 	/**< current state */

} CAN_ERROR_FLAGS_T;

/* externals
*--------------------------------------------------------------------------*/

/* function prototypes
*--------------------------------------------------------------------------*/
CAN_ERROR_FLAGS_T * codrvCanErrorGetFlags(CO_LINE_DECL);
void codrvCanErrorInit(CO_LINE_DECL);
RET_T codrvCanErrorInformStack(CO_LINE_DECL);

#endif /* CODRV_ERROR_H */

