/* -----------------------------------------------------------------------------
  Filename:    ccl_par.c
  Description: Toolversion: 02.03.25.01.90.05.57.01.00.00
               
               Serial Number: CBD1900557
               Customer Info: Ningbo Joyson Preh Car Connect Co., Ltd.
                              Package: CBD_Vector_SLP2
                              Micro: MPC5745B
                              Compiler: Gnu 9.2.0
               
               
               Generator Fwk   : GENy 
               Generator Module: Ccl__core
               
               Configuration   : C:\Data\Users\huo_h1\Documents\NIO_FORCE_VBOX-SVN\30_DevelopLibrary\03_SW\90_Others\CANbedded\NIO_Geny_Force_BTA_CAN_Draft_0_1\NIO_Geny_For_CanMatrix\GENy.gny
               
               ECU: 
                       TargetSystem: Hw_Mpc5700Cpu
                       Compiler:     GNU
                       Derivates:    MPC5746C
               
               Channel "Channel0":
                       Databasefile: C:\Data\Users\huo_h1\Documents\NIO_FORCE_VBOX-SVN\30_DevelopLibrary\03_SW\90_Others\CANbedded\NIO_Geny_Force_BTA_CAN_Draft_0_1\NIO_Geny_For_CanMatrix\NIO_Force_BTA_CAN_draft_2020_9_22.dbc
                       Bussystem:    CAN
                       Manufacturer: Vector
                       Node:         SA

 ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
  C O P Y R I G H T
 -------------------------------------------------------------------------------
  Copyright (c) 2001-2015 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.
 -------------------------------------------------------------------------------
 ----------------------------------------------------------------------------- */

#define CCL_PAR_MODULE
#include "ccl_inc.h"
#include "ccl_par.h"

/******************************************************************************/
/* function external declaration                                              */
/******************************************************************************/



/******************************************************************************/
/* internal declarations (ROM const)                                          */
/******************************************************************************/
/******************************************************************************/
/* external declarations (ROM const)                                          */
/******************************************************************************/
V_MEMROM0 V_MEMROM1 vuint8 V_MEMROM2 cclNmWakeUpAble = 0x1;   /* The variable store the wake up able channels (one bit per channel). */
V_MEMROM0 V_MEMROM1 vuint16 V_MEMROM2 cclMissingAckTimeoutValue[1] = {
      15
 };
V_MEMROM0 V_MEMROM1 vuint16 V_MEMROM2 cclMissingAckPauseTimeoutValue[1] = {
      15
 };

V_MEMROM0 V_MEMROM1 vuint8 V_MEMROM2 cclNmType[1] = {
    kComponentNmAsrCan
 };
V_MEMROM0 V_MEMROM1 vuint8 V_MEMROM2 cclStartIndex[1] = {
    0
};

V_MEMROM0 V_MEMROM1 vuint8 V_MEMROM2 cclStopIndex[1] = {
    0
};
V_MEMROM0 V_MEMROM1 vuint8 V_MEMROM2 cclUserOffset[kCclNumberOfUser] = {
      0x0
};

V_MEMROM0 V_MEMROM1 vuint8 V_MEMROM2 cclUserMask[kCclNumberOfUser] = {
      0x1
};

V_MEMROM0 V_MEMROM1 vuint8 V_MEMROM2 cclUserChannel[kCclNumberOfUser] = {
    0x0
};
/******************************************************************************/
/* global data definitions                                                    */
/******************************************************************************/
V_MEMRAM0 static V_MEMRAM1 vuint8 V_MEMRAM2 cclCounterTask_10_0ms;        /* Counter for schedule task */
V_MEMRAM0 static V_MEMRAM1 vuint8 V_MEMRAM2 cclCounterTask_10_5ms;        /* Counter for schedule task */
/***************************************************************************** 
| NAME:             CclInitPowerOnFct                                          
| PROTOTYPE:        void CclInitPowerOnFct( void )                             
| CALLED BY:        CclInitPowerOn                                             
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS: void                                                       
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function is a generated init container function. It   
|                   contains different init routines depending on the          
|                   used modules.                                              
|*****************************************************************************/

void CclInitPowerOnFct(void)
{
  cclCounterTask_10_0ms = 0;    /* Counter for schedule task */
  cclCounterTask_10_5ms = 1;    /* Counter for schedule task */

  CanNm_InitMemory();
  #if defined(C_SINGLE_RECEIVE_CHANNEL) || defined(C_MULTIPLE_RECEIVE_CHANNEL)
    CanInitPowerOn();
  #else
    CanInitPowerOn(0);
  #endif
  IlInitPowerOn();
  Nm_Init(NULL_PTR);
  CanNm_Init(NULL_PTR);
  CbdWrpInit(0);
  TpInitPowerOn();
  DescInitPowerOn(kDescPowerOnInitParam);
}
/***************************************************************************** 
| NAME:             CclInitFct                                                 
| PROTOTYPE:        void CclInitFct( void )                                    
| CALLED BY:        CclInit                                                    
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS: void                                                       
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function is a generated init container function. It   
|                   contains different init routines depending on the          
|                   used modules.                                              
|*****************************************************************************/

void CclInitFct(void)
{
#if defined( C_MULTIPLE_RECEIVE_CHANNEL )
  CanInit(0, 0);
#else
  CanInit(0);
#endif
  IlInit();
  Nm_Init(NULL_PTR);
  CanNm_Init(NULL_PTR);
  CbdWrpInit(0);
  ApplCclInit();
}

/**************************************************************************************
| NAME:             CclSystemShutdownFct                                               
| PROTOTYPE:        void CclSystemShutdownFct( void )                                  
| CALLED BY:        CclSystemShutdown                                                  
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!                  
| INPUT PARAMETERS: void                                                               
| RETURN VALUE:     void                                                               
| DESCRIPTION:      This function is a generated system shutdown container             
|                   function. It could be used to stop services or deinitialize        
|                   variables after the system leaves the "normal" mode.             
|*************************************************************************************/

void CclSystemShutdownFct(void) 
{ 
}


/****************************************************************************************
| NAME:             CclScheduleTask                                                      
| PROTOTYPE:        void CclScheduleTask                                                 
| CALLED BY:        task handler                                                         
| PRECONDITIONS:    has to be called every 5ms                                           
| INPUT PARAMETERS: void                                                                 
| RETURN VALUE:     void                                                                 
| DESCRIPTION:      This function is a generated schedule task. This task call all other 
|                   task with in the right task cycle + offset.                          
|***************************************************************************************/
void CCL_API_CALL_TYPE CclScheduleTask(void)
{ 

  if( cclCounterTask_10_0ms == 0 )
  {
    IlTxTask();

    IlRxTask(); 

    ApplCclPreCCLTask();
    CclTask();
    ApplCclPostCCLTask();

    CanNm_MainFunction_0();

    CbdWrpTask(0);

    cclCounterTask_10_0ms = 2;
  }


  if( cclCounterTask_10_5ms == 0 )
  {
     TpRxTask();

    DescTask();

     TpTxTask();

    cclCounterTask_10_5ms = 2;
  }


  cclCounterTask_10_0ms--;
  cclCounterTask_10_5ms--;

}

/******************************************************************************
| NAME:             CclComStart                                                
| PROTOTYPE:        void CclComStart(void)                                  
| CALLED BY:        network management                                         
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS:                                                            
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function start the communication with interaction layer.
|*****************************************************************************/
void CclComStart(void)
{
  cclComSwState[0]=kCclComSwOn;
  ApplCclComStart();
  cclIlTxAction[0] = kCclIlTxWaitToStart;
  IlRxStart();
}
/******************************************************************************
| NAME:             CclComStop                                                 
| PROTOTYPE:        void CclComStop(void)                                      
| CALLED BY:        network management                                         
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS:                                                            
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function stop the communication with interaction layer.
|*****************************************************************************/
void CclComStop(void)
{
  if( cclIlTxAction[0] != kCclIlTxWaitToStart )
  {
    IlTxStop();
  }
  cclIlTxAction[0] = kCclIlTxNoAction; 
  IlRxStop();
  cclComSwState[0]=kCclComSwOff;
  ApplCclComStop();
}
/******************************************************************************
| NAME:             CclComWait                                                
| PROTOTYPE:        void CclComWait(void)                                  
| CALLED BY:        network management                                         
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS:                                                            
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function sets the interaction layer into the wait state.
|*****************************************************************************/
void CclComWait(void)
{
  cclComSwState[0]=kCclComSwOff;
  ApplCclComWait();
  if( cclIlTxAction[0] == kCclIlTxWaitToStart )
  {
    IlTxStart();
  }
  cclIlTxAction[0] = kCclIlTxNoAction; 
  IlTxWait();
  IlRxWait();
}
/******************************************************************************
| NAME:             CclComResume                                                 
| PROTOTYPE:        void CclComResume(void)                                      
| CALLED BY:        network management                                         
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS:                                                            
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function resumes the communication with interaction layer.
|*****************************************************************************/
void CclComResume(void)
{
  cclIlTxAction[0] = kCclIlTxWaitToResume;
  IlRxRelease();
  cclComSwState[0]=kCclComSwOn;
  ApplCclComResume();
}






/******************************************************************************
| NAME:             CclBusOffStart                                             
| PROTOTYPE:        void CclBusOffStart(void)                                  
| CALLED BY:        network management                                         
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS:                                          ,                 
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function stop the communication with interaction layer.
|*****************************************************************************/
void CclBusOffStart(void)
{
  #if defined( CCL_ENABLE_STOP_TIMEOUT)
    if( cclIlTxAction[0] == kCclIlTxWaitToStart )
    {
      IlTxStart();
    }
    cclIlTxAction[0] = kCclIlTxNoAction;
    IlTxWait();
    IlRxWait();
  #endif
  cclBusOffFlag[0] = kCclBusOffRecActive;
  ApplCclBusOffStart();
}
/******************************************************************************
| NAME:             CclBusOffEnd                                               
| PROTOTYPE:        void CclBusOffEnd(void)                                    
| CALLED BY:        network management                                         
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!          
| INPUT PARAMETERS:                                                            
| RETURN VALUE:     void                                                       
| DESCRIPTION:      This function start the communication with interaction layer.
|*****************************************************************************/
void CclBusOffEnd(void)
{
  #if defined(CCL_ENABLE_STOP_TIMEOUT)
    IlTxRelease();
    IlRxRelease();
  #endif
  cclBusOffFlag[0] = kCclBusOffRecNotActive;
  ApplCclBusOffEnd();
}

/**********************************************************************************
| NAME:             CclNmActiveReqFct                                              
| PROTOTYPE:        vuint8 CclNmActiveReqFct( vuint8 network )                     
| CALLED BY:        CclTask                                                        
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!              
| INPUT PARAMETERS: vuint8 network                                                 
| RETURN VALUE:     vuint8                                                         
| DESCRIPTION:      This function contains the algorithm to go in the active       
|                   mode. The algorithm depends on the used modules.               
|*********************************************************************************/

vuint8 CclNmActiveReqFct(vuint8 network)
{
#if defined V_ENABLE_USE_DUMMY_STATEMENT
  network = network;

#endif
  (void)Nm_NetworkRequest((NetworkHandleType)0);
  return NM_OK;
}
/***********************************************************************************
| NAME:             CclNmPrepareSleepReqFct                                          
| PROTOTYPE:        void CclNmPrepareSleepReqFct( void )                             
| CALLED BY:        CclTask                                                          
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!                
| INPUT PARAMETERS: void                                                             
| RETURN VALUE:     void                                                             
| DESCRIPTION:      This function contains the algorithm to set the system in        
|                   prepare sleep mode. The algorithm depends on the used            
|                   modules.                                                         
|***********************************************************************************/

void CclNmPrepareSleepReqFct(void)
{
  (void)Nm_PassiveStartUp((NetworkHandleType)0);
}
/***********************************************************************************
| NAME:             CclNmSleepReqFct                                                
| PROTOTYPE:        void CclNmSleepReqFct( vuint8 network )                         
| CALLED BY:        CclRelNetRequest                                                
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!               
| INPUT PARAMETERS: vuint8 network                                                  
| RETURN VALUE:     void                                                            
| DESCRIPTION:      This function contains the algorithm to go in the sleep         
|                   mode. The algorithm depends on the used modules.                
|**********************************************************************************/
void CclNmSleepReqFct(vuint8 network)
{
#if defined V_ENABLE_USE_DUMMY_STATEMENT
  network = network;

#endif
  (void)Nm_NetworkRelease((NetworkHandleType)0);
}
/********************************************************************************
| NAME:             CclExtEmcComReqFct                                              
| PROTOTYPE:        void CclExtEmcComReqFct(void)                                   
| CALLED BY:        ApplCanWakeUp,                                               
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!            
| INPUT PARAMETERS: void                                                         
| RETURN VALUE:     void                                                         
| DESCRIPTION:      This function sets a communication flag. This flag is        
|                   used to synchronize the state requests between CCL           
|                   and higher layer component.                                  
|*******************************************************************************/

void CclExtEmcComReqFct(void)
{
  CanWakupeMessageRxIndicaiton();
}
/********************************************************************************
| NAME:             CclExtCanComReqFct                                              
| PROTOTYPE:        void CclExtCanComReqFct(void)                                   
| CALLED BY:        ApplCanWakeUp,                                               
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!            
| INPUT PARAMETERS: void                                                         
| RETURN VALUE:     void                                                         
| DESCRIPTION:      This function sets a communication flag. This flag is        
|                   used to synchronize the state requests between CCL           
|                   and higher layer component.                                             
|*******************************************************************************/

void CclExtCanComReqFct(void)
{
  ApplWakeupByBusIndication();
}
/********************************************************************************
| NAME:             CclIntComReqFct                                              
| PROTOTYPE:        void CclIntComReqFct(void)                                   
| CALLED BY:        CclRequestNetwork                                            
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!            
| INPUT PARAMETERS: void                                                         
| RETURN VALUE:     void                                                         
| DESCRIPTION:      This function sets a communication flag. This flag is        
|                   used to synchronize the state requests between CCL           
|                   and higher layer component.                                             
|*******************************************************************************/

void CclIntComReqFct(void)
{
  ApplFirstCommReqIndication();
}
/********************************************************************************
| NAME:             CclComRelFct                                            
| PROTOTYPE:        void CclComRelFct(void)                                 
| CALLED BY:        ApplNmCanSleep                                               
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!            
| INPUT PARAMETERS: void                                                         
| RETURN VALUE:     void                                                         
| DESCRIPTION:      This function clears a communication flag. This flag are     
|                   used to synchronize the state requests between CCL           
|                   and higher layer component.                                             
|*******************************************************************************/

void CclComRelFct(void)
{
  ApplBusSleepIndication();
}

/********************************************************************************
| NAME:             CclInitTrcvFct                                              
| PROTOTYPE:        void CclInitTrcvFct( void )                                 
| CALLED BY:        CclInitPortsPowerOn                                          
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!            
| INPUT PARAMETERS: void                                                         
| RETURN VALUE:     void                                                         
| DESCRIPTION:      This function contains the transceiver init routine.         
|                   The routine depends on the used transceiver type.            
|*******************************************************************************/

void CclInitTrcvFct(void)
{
  ApplCclInitTrcv();
}
/************************************************************************************
| NAME:             CclWakeUpTrcvFct                                                
| PROTOTYPE:        void CclWakeUpTrcvFct( void )                                   
| CALLED BY:        ApplNmCanNormal                                                  
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!                
| INPUT PARAMETERS: void                                                             
| RETURN VALUE:     void                                                             
| DESCRIPTION:      This function contains the routine to wakeup the                 
|                   transceiver. The routine depends on the used transceiver         
|                   type.                                                            
|***********************************************************************************/

void CclWakeUpTrcvFct(void)
{ 
  ApplCclWakeUpTrcv();
}
/************************************************************************************
| NAME:             CclSleepTrcvFct                                                 
| PROTOTYPE:        void CclSleepTrcvFct( void )                                    
| CALLED BY:        ApplNmCanSleep                                                   
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!                
| INPUT PARAMETERS: void                                                             
| RETURN VALUE:     void                                                             
| DESCRIPTION:      This function contains the routine to switch the                 
|                   transceiver into sleep mode. The routine depends on              
|                   the used transceiver type.                                       
|***********************************************************************************/

void CclSleepTrcvFct(void)
{
  ApplCclStandbyTrcv();
  ApplCclSleepTrcv();
}





/*********************************************************************************
| NAME:             CclConfigTrcvIntFct                                           
| PROTOTYPE:        void CclConfigTrcvIntFct(void)                                
| CALLED BY:        CclInitPortsPowerOn                                           
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!             
| INPUT PARAMETERS: void                                                          
| RETURN VALUE:     void                                                          
| DESCRIPTION:      This function contains the routine to configure the           
|                   transceiver wakeup interrupt.                                 
|********************************************************************************/

void CclConfigTrcvIntFct(void)
{
  CAN_CONFIG_TRCV_INT;
}
/*********************************************************************************
| NAME:             CclClearTrcvIntFct                                            
| PROTOTYPE:        void CclClearTrcvIntFct(void)                                 
| CALLED BY:        CclInitPortsPowerOn,                                          
|                   ApplNmCanSleep                                                
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!             
| INPUT PARAMETERS: void                                                          
| RETURN VALUE:     void                                                          
| DESCRIPTION:      This function contains the routine to clear the               
|                   transceiver wakeup interrupt.                                 
|********************************************************************************/

void CclClearTrcvIntFct(void)
{
  CAN_CLEAR_TRCV_INT;
}


/*********************************************************************************
| NAME:             CclDisableTrcvIntFct                                          
| PROTOTYPE:        void CclDisableTrcvIntFct(void)                               
| CALLED BY:        CclInitPortsPowerOn,                                          
|                   CclCanWakeUpInt,                                              
|                   CclSetNetRequest                                              
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!             
| INPUT PARAMETERS: void                                                          
| RETURN VALUE:     void                                                          
| DESCRIPTION:      This function contains the routine to disable the             
|                   transceiver wakeup interrupt.                                 
|********************************************************************************/

void CclDisableTrcvIntFct(void)
{
  CAN_DISABLE_TRCV_INT;
}


/*********************************************************************************
| NAME:             CclEnableTrcvIntFct                                           
| PROTOTYPE:        void CclEnableTrcvIntFct(void)                                
| CALLED BY:        ApplNmCanSleep                                                
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!             
| INPUT PARAMETERS: void                                                          
| RETURN VALUE:     void                                                          
| DESCRIPTION:      This function contains the routine to enable the              
|                   transceiver wakeup interrupt.                                 
|********************************************************************************/

void CclEnableTrcvIntFct(void)
{
  CAN_ENABLE_TRCV_INT;
}
/**********************************************************************************
| NAME:             CclCheckTrcvIntFct                                             
| PROTOTYPE:        vuint8 CclCheckTrcvIntFct( void )                              
| CALLED BY:        CclCanStandby                                                  
| PRECONDITIONS:    Application is NOT ALLOWED to call this function!              
| INPUT PARAMETERS: void                                                           
| RETURN VALUE:     kCclTrcvWakeIntPending                                         
|                   kCclTrcvWakeIntNoPending                                       
| DESCRIPTION:      This function checks if an interrupt is pending at the wake up port.
|*********************************************************************************/

vuint8 CclCheckTrcvIntFct(void)
{
  return kCclTrcvWakeIntNoPending;
}







/* begin Fileversion check */
#ifndef SKIP_MAGIC_NUMBER
#ifdef MAGIC_NUMBER
  #if MAGIC_NUMBER != 362388152
      #error "The magic number of the generated file <C:\Data\Users\huo_h1\Documents\NIO_FORCE_VBOX-SVN\30_DevelopLibrary\03_SW\90_Others\CANbedded\NIO_Geny_Force_BTA_CAN_Draft_0_1\NIO_Geny_For_CanMatrix\Generate Files\ccl_par.c> is different. Please check time and date of generated files!"
  #endif
#else
  #error "The magic number is not defined in the generated file <C:\Data\Users\huo_h1\Documents\NIO_FORCE_VBOX-SVN\30_DevelopLibrary\03_SW\90_Others\CANbedded\NIO_Geny_Force_BTA_CAN_Draft_0_1\NIO_Geny_For_CanMatrix\Generate Files\ccl_par.c> "

#endif  /* MAGIC_NUMBER */
#endif  /* SKIP_MAGIC_NUMBER */

/* end Fileversion check */

