
/**********************************************************************************************************************
 *  COPYRIGHT
 *  -------------------------------------------------------------------------------------------------------------------
 *  \verbatim
 *  Copyright (c) 2007-2014 by Vector Informatik GmbH.                                             All rights reserved.
 *
 *                This software is copyright protected and proprietary to Vector Informatik GmbH.
 *                Vector Informatik GmbH grants to you only those rights as set out in the license conditions.
 *                All other rights remain with Vector Informatik GmbH.
 *  \endverbatim
 *  -------------------------------------------------------------------------------------------------------------------
 *  FILE DESCRIPTION
 *  -------------------------------------------------------------------------------------------------------------------
 *         File:  CanNm.h
 *    Component:  AUTOSAR CAN Network Management
 *       Module:  AUTOSAR Network Management
 *    Generator:  -
 *
 *  Description:  Header of AUTOSAR CAN Network Management
 *                AUTOSAR Release 3.0
 *  
 *********************************************************************************************************************/
#ifndef CAN_BUS_OFF_CFG_H
#define CAN_BUS_OFF_CFG_H

#include "ComStack_Types.h"
#include "Can_Cfg.h"


#define CAN_BUSOFF_CONFIG_CONST

typedef uint16 nmTimerCntType;

#define NM_MAINFUNCTION_PERIOD              (5)

#define BusOffCanInterruptRestore()              \
    Can_EnableGlobalInterrupts()
#define BusOffCanInterruptDisable()              \
    Can_DisableGlobalInterrupts()

#define NM_BUSOFF_FAST_RECOVERY_ENABLE (STD_ON)

#define NmCanTxOffline(NmChanneld)         \
    CanIf_SetPduMode(NmChanneld, CANIF_SET_TX_OFFLINE)

#define NmCanTxOnline(NmChanneld)            \
    CanIf_SetPduMode(NmChanneld, CANIF_SET_TX_ONLINE)


#define NmCanClearBuffer(NmChanneld)        \
    CanIf_ClearTransmitBuffer(NmChanneld)


#define NMBusErrorCanInit(NmChanneld)   \
    Can_InitController(((NmChanneld)),\
    (P2VAR(Can_ControllerBaudrateConfigType, AUTOMATIC, CAN_CONFIG_CONST))(0))

#define NMBusErrorCanStart(NmChanneld)   \
    (void)CanIf_SetControllerMode(NmChanneld,CANIF_CS_STARTED)



extern CONST(uint16,CAN_BUSOFF_CONFIG_CONST) 
    nmBusOffFastRecoveryAry[CAN_USED_CONTROLLER_NUM]; 
extern CONST(nmTimerCntType,CAN_BUSOFF_CONFIG_CONST) 
    nmCountBusoffFastTimerAry[CAN_USED_CONTROLLER_NUM];
extern CONST(uint16,CAN_BUSOFF_CONFIG_CONST) 
    nmBusOffSlowRecoveryAry[CAN_USED_CONTROLLER_NUM];
extern CONST(nmTimerCntType,CAN_BUSOFF_CONFIG_CONST) 
    nmCountBusoffSlowTimerAry[CAN_USED_CONTROLLER_NUM];
#endif