/* BEGIN_FILE_HDR ******************************************************************************** * NOTICE * This software is the property of HiRain Technologies. Any information * contained in this doc should not be reproduced, or used, or disclosed * without the written authorization from HiRain Technologies. ******************************************************************************** * File Name : Nm.c ******************************************************************************** * Project/Product : AUTOSAR R21-11 * Title : Nm.c * Author : Hirain ******************************************************************************** * Description : Implementation of Nm provided functionality * ******************************************************************************** * Limitations : None * ******************************************************************************** * ******************************************************************************** * Revision History: * * Version Date Initials CR# Descriptions * --------- ---------- ------------ ---------- --------------- * 04.00.00 01/09/2022 Feixiang.Dong N/A Original ******************************************************************************** * END_FILE_HDR*/ /******************************************************************************* * Includes *******************************************************************************/ #include "Nm.h" #include "Nm_Cbk.h" #include "Nm_Lcfg.h" #include "Nm_Callout.h" #include "SchM_Nm.h" /*SWS_Nm_00247*//*SWS_Nm_00124*/ #if(STD_ON == NM_BSWM_SUPPORT) #include "BswM_Nm.h" #endif #if(STD_ON == NM_COMM_SUPPORT) #include "ComM_Nm.h" #endif #if((STD_ON == NM_STATE_CHANGE_IND_ENABLED) && (STD_ON == NM_COM_SUPPORT)) #include "Com.h" #endif /*SWS_Nm_00243*/ #if(STD_ON == NM_DEV_ERROR_DETECT) #include "Det.h" #endif #if(NM_NUM_OF_CANNM_CHANNEL > 0) #include "CanNm.h" #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) #include "OsekNm.h" #endif #if(NM_NUM_OF_J1939NM_CHANNEL > 0) #include "J1939Nm.h" #endif #if(NM_NUM_OF_FR_CHANNEL > 0) #include "FrNm.h" #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) #include "UdpNm.h" #endif /******************************************************************************* * Version Check *******************************************************************************/ #if(STD_ON == NM_VERSION_CHECK) /* check Version with cfg file */ #if((NM_CONFIG_VARIANTS != STD_CONFIG_VARIANTS_PRECOMPILE) && \ (NM_CONFIG_VARIANTS != STD_CONFIG_VARIANTS_LINKTIME)) #error "The Nm module only supports Pre-Compile and Link-time Configuration." #endif #if((NM_AR_RELEASE_MAJOR_VERSION != NM_AR_RELEASE_MAJOR_VERSION_CFG) || \ (NM_AR_RELEASE_MINOR_VERSION != NM_AR_RELEASE_MINOR_VERSION_CFG)) #error "AutoSar Version Numbers of Nm and its cfg file are incompatible" #endif #if((NM_SW_MAJOR_VERSION != NM_SW_MAJOR_VERSION_CFG) || \ (NM_SW_MINOR_VERSION != NM_SW_MINOR_VERSION_CFG)) #error "SW Version Numbers of Nm and its cfg file are incompatible" #endif #endif/*#if(STD_ON == NM_VERSION_CHECK)*/ /******************************************************************************* * Macro *******************************************************************************/ #if(STD_ON == NM_DEV_ERROR_DETECT) #define NM_DET_REPORT_ERROR(ApiId, errcode) \ Det_ReportError(NM_MODULE_ID, NM_INSTANCE_ID, (ApiId), (errcode)) #else #define NM_DET_REPORT_ERROR(ApiId, errcode) #endif /*Initialization status*/ #define NM_IS_INITIALIZED() (STD_INITIALIZED == Nm_InitStatus) #define NM_SET_INITIALIZED() (Nm_InitStatus = STD_INITIALIZED) #define NM_SET_UNINITIALIZED() (Nm_InitStatus = STD_UNINITIALIZED) #if(STD_ON == NM_COORDINATOR_SUPPORT) #define NM_CLU_IS_MASTER(ClusterId) (Nm_ClusterContext[ClusterId].ClusterIsMaster) #define NM_CLU_PASSIVE_CHL(ClusterId) (Nm_ClusterContext[ClusterId].PassiveChannel) #if(NM_NUM_OF_FR_CHANNEL > 0) #define NM_CLU_SYNC_CHL(ClusterId) (Nm_ClusterContext[ClusterId].SynchronizingChannel) #endif #define NM_CLU_AWAKE_INFO(ClusterId) (Nm_ClusterContext[ClusterId].ClusterAwakeInfo) #define NM_CLU_STATE(ClusterId) (Nm_ClusterContext[ClusterId].ClusterState) #define NM_CLU_CON_CHL(ClusterId, Idx) (Nm_ClusterContext[ClusterId].ClusterConChannel[Idx]) #define NM_CHL_MODE(NetworkHandle) (Nm_ChannelMode[NetworkHandle]) #define NM_CHL_AWAKE_INFO(NetworkHandle) (Nm_ChannelAwakeInfo[NetworkHandle]) #define NM_CHL_DELAY_TIMER(NetworkHandle) (Nm_ShutdownDelayTimer[NetworkHandle]) #endif #if(STD_ON == NM_PN_SUPPORT_ENABLED) #define NM_PN_IRA_DATA(NetworkHandle, Idx) (Nm_PnIraData[NetworkHandle][Idx]) #define NM_PN_EIRA_DATA(Idx) (Nm_PnEiraData[Idx]) #define NM_PN_EIRA_NEW(Idx) (Nm_PnEiraNew[Idx]) #define NM_PN_EIRA_RESET_TIMER(Idx) (Nm_PnEiraResetTimer[Idx]) #if(STD_ON == NM_PNC_ERA_CALC_EN) #define NM_PN_ERA_DATA(NetworkHandle, Idx) (Nm_PnEraData[NetworkHandle][Idx]) #define NM_PN_ERA_NEW(NetworkHandle, Idx) (Nm_PnEraNew[NetworkHandle][Idx]) #define NM_PN_ERA_RESET_TIMER(NetworkHandle, Idx) (Nm_PnEraResetTimer[NetworkHandle][Idx]) #endif #endif /******************************************************************************* * Macros of configure parameter *******************************************************************************/ #if(NM_CONFIG_VARIANTS == STD_CONFIG_VARIANTS_LINKTIME) #define NM_CYCLETIME_MAINFUNCTION (Nm_LConfig.NmCycletimeMainFunction) #if(STD_ON == NM_PN_SUPPORT_ENABLED) #define NM_PNC_BIT_VECTOR_OFFSET (Nm_LConfig.NmPncBitVectorOffset) #define NM_PN_EIRA_CALC_ENABLED (Nm_LConfig.NmPnEiraCalcEnabled) #define NM_PN_RESET_TIME (Nm_LConfig.NmPnResetTime) #endif #define NM_CAR_WAKEUP_RX_ENABLED (Nm_LConfig.NmCarWakeUpRxEnabled) #define NM_CAR_WAKEUP_CALLOUT (Nm_LConfig.NmCarWakeUpCallout) #define NM_COORDINATOR_SYNC_SUPPORT (Nm_LConfig.NmCoordinatorSyncSupport) #endif/*#if(NM_CONFIG_VARIANTS == STD_CONFIG_VARIANTS_LINKTIME)*/ #if(STD_ON == NM_PN_SUPPORT_ENABLED) #define NM_GET_PN_RESET_CNT (NM_PN_RESET_TIME/NM_CYCLETIME_MAINFUNCTION) #endif #define NM_CFG_CHL_BUS_TYPE(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmStandardBusType) #define NM_CFG_CHL_COMM_REF(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmComMChannelRef) #define NM_CFG_CHL_BUSNM_REF(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmBusNmChannelRef) #define NM_CFG_CHL_COM_DATA_SUPPORT(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmComUserDataSupport) #define NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmPassiveModeEnabled) #if(STD_ON == NM_COORDINATOR_SUPPORT) #define NM_CFG_CHL_ACTIVE_COORD(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmActiveCoordinator) #define NM_CFG_CHL_SLEEP_MASTER(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmChannelSleepMaster) #define NM_CFG_CHL_SYNC_NETWORK(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmSynchronizingNetwork) #define NM_CFG_CHL_CLUSTER_INDEX(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmCoordClusterIndex) #define NM_CFG_CHL_SHUTDOWN_TIME(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmGenericBusNmShutdownTime) #endif #if(STD_ON == NM_STATE_CHANGE_IND_ENABLED) #define NM_CFG_CHL_STATE_REPORT(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmStateReportEnabled) #define NM_CFG_CHL_STATE_SIG_REF(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmStateReportSignalRef) #endif #if(STD_ON == NM_PN_SUPPORT_ENABLED) #define NM_CFG_CHL_PN_EN(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmPnEnabled) #define NM_CFG_CHL_PN_ERA_CALC_EN(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmPnEraCalcEnabled) #define NM_CFG_CHL_PNC_VECTOR_LEN(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmPncBitVectorLength) #define NM_CFG_CHL_PN_FILTER_MASK_PTR(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmPnFilterMaskValue) #define NM_CFG_CHL_PN_FILTER_MASK_VAL(NetworkHandle, Idx) (Nm_ChannelCfg[NetworkHandle].NmPnFilterMaskValue[Idx]) #if(STD_ON == NM_DYN_PNC_SUPPORT) #define NM_CFG_CHL_DYN_PNC_EN(NetworkHandle) (Nm_ChannelCfg[NetworkHandle].NmDynamicPncToChannelMappingEnabled) #endif #endif /******************************************************************************* * Local type definition *******************************************************************************/ #if(STD_ON == NM_COORDINATOR_SUPPORT) typedef enum { NM_CLUSTER_STATE_SHUTDOWN, NM_CLUSTER_STATE_NORMAL, NM_CLUSTER_STATE_WAIT_NET_SYNC, NM_CLUSTER_STATE_START_SHUTDOWN, NM_CLUSTER_STATE_PRE_SHUTDOWN } Nm_ClusterStateType; typedef uint8 Nm_AwakeInfoType; #define NM_AWAKE_NONE ((Nm_AwakeInfoType)0x00) /*Network has been request because of coordinate algorithm.*/ #define NM_AWAKE_COORD_REQUEST ((Nm_AwakeInfoType)0x01) /*Network has been request because of local request.*/ #define NM_AWAKE_LOCAL_REQUEST ((Nm_AwakeInfoType)0x02) /*Network should keep request because of receiving message on active channel.*/ #define NM_AWAKE_ACTIVE_RECEIVE ((Nm_AwakeInfoType)0x04) /*Network should keep request because of no receiving SleepReadyBit with 1 on passive channel.*/ #define NM_AWAKE_NO_SLEEPREADYBIT ((Nm_AwakeInfoType)0x08) /*Network should keep request because of Nm_SynchronizationPoint() has not been called by BusNm in Master coordinator.*/ #define NM_AWAKE_NO_SYNC_POINT ((Nm_AwakeInfoType)0x10) /*Network should keep request because of shutdown delay timer not timeout on active channel.*/ #define NM_AWAKE_SHUTDOWN_TIME_DELAY ((Nm_AwakeInfoType)0x20) typedef struct { /*SWS_Nm_00256 Support two or more NMCoordinators connected to the same NM Cluster.*/ boolean ClusterIsMaster; NetworkHandleType PassiveChannel; #if(NM_NUM_OF_FR_CHANNEL > 0) NetworkHandleType SynchronizingChannel; #endif Nm_AwakeInfoType ClusterAwakeInfo; Nm_ClusterStateType ClusterState; /*SWS_Nm_00001*//*Record all channels belong to the cluster.*/ NetworkHandleType ClusterConChannel[NM_MAX_CHL_PER_CLUSTER]; } Nm_ClusterContextType; #endif/*#if(STD_ON == NM_COORDINATOR_SUPPORT)*/ #if(STD_ON == NM_PN_SUPPORT_ENABLED) #define NM_BIT_LENGTH ((uint8)8) #endif /******************************************************************************* * Local Data Define *******************************************************************************/ #define NM_START_SEC_VAR_INIT_8 #include "Nm_MemMap.h" STATIC VAR(Std_InitStateType, NM_VAR) Nm_InitStatus = STD_UNINITIALIZED; #define NM_STOP_SEC_VAR_INIT_8 #include "Nm_MemMap.h" #if(STD_ON == NM_COORDINATOR_SUPPORT) #define NM_START_SEC_VAR_NOINIT_UNSPECIFIED #include "Nm_MemMap.h" /*SWS_Nm_00167 Multiple NM coordination clusters shall be coordinated independently*/ STATIC VAR(Nm_ClusterContextType, NM_VAR) Nm_ClusterContext[NM_NUM_OF_CLUSTERS]; STATIC VAR(Nm_ModeType, NM_VAR) Nm_ChannelMode[NM_NUM_OF_CHANNELS]; STATIC VAR(Nm_AwakeInfoType, NM_VAR) Nm_ChannelAwakeInfo[NM_NUM_OF_CHANNELS]; STATIC VAR(Nm_ShutdownTimeType, NM_VAR) Nm_ShutdownDelayTimer[NM_NUM_OF_CHANNELS]; #define NM_STOP_SEC_VAR_NOINIT_UNSPECIFIED #include "Nm_MemMap.h" #endif/*#if(STD_ON == NM_COORDINATOR_SUPPORT)*/ #if(STD_ON == NM_PN_SUPPORT_ENABLED) #define NM_START_SEC_VAR_NOINIT_8 #include "Nm_MemMap.h" /*SWS_Nm_00331*/ STATIC VAR(uint8, NM_VAR) Nm_PnIraData[NM_NUM_OF_CHANNELS][NM_PNC_BIT_VECTOR_MAX_LEN]; STATIC VAR(uint8, NM_VAR) Nm_PnEiraData[NM_PNC_BIT_VECTOR_MAX_LEN]; STATIC VAR(uint8, NM_VAR) Nm_PnEiraNew[NM_PNC_BIT_VECTOR_MAX_LEN]; #if(STD_ON == NM_PNC_ERA_CALC_EN) STATIC VAR(uint8, NM_VAR) Nm_PnEraData[NM_NUM_OF_CHANNELS][NM_PNC_BIT_VECTOR_MAX_LEN]; STATIC VAR(uint8, NM_VAR) Nm_PnEraNew[NM_NUM_OF_CHANNELS][NM_PNC_BIT_VECTOR_MAX_LEN]; #endif #define NM_STOP_SEC_VAR_NOINIT_8 #include "Nm_MemMap.h" #define NM_START_SEC_VAR_NOINIT_16 #include "Nm_MemMap.h" STATIC VAR(Nm_PnResetTimeType, NM_VAR) Nm_PnEiraResetTimer[(NM_PNC_BIT_VECTOR_MAX_LEN * NM_BIT_LENGTH)]; #if(STD_ON == NM_PNC_ERA_CALC_EN) STATIC VAR(Nm_PnResetTimeType, NM_VAR) Nm_PnEraResetTimer[NM_NUM_OF_CHANNELS][(NM_PNC_BIT_VECTOR_MAX_LEN * NM_BIT_LENGTH)]; #endif #define NM_STOP_SEC_VAR_NOINIT_16 #include "Nm_MemMap.h" #endif/*#if(STD_ON == NM_PN_SUPPORT_ENABLED)*/ #define NM_START_SEC_CODE #include "Nm_MemMap.h" /******************************************************************************* * Local Function declaration *******************************************************************************/ #if(STD_ON == NM_PN_SUPPORT_ENABLED) STATIC FUNC(void, NM_CODE) Nm_S_PnInit ( void ); STATIC FUNC(void, NM_CODE) Nm_S_PnEiraMainFunction ( void ); #if(STD_ON == NM_PNC_ERA_CALC_EN) STATIC FUNC(void, NM_CODE) Nm_S_PnEraMainFunction ( void ); #endif #endif STATIC FUNC(Std_ReturnType, NM_CODE) Nm_S_NetworkRequest ( NetworkHandleType NetworkHandle ); STATIC FUNC(Std_ReturnType, NM_CODE) Nm_S_NetworkRelease ( NetworkHandleType NetworkHandle ); /*SWS_Nm_00055*/ #if(STD_ON == NM_COORDINATOR_SUPPORT) STATIC FUNC(void, NM_CODE) Nm_S_CoodinatorInit ( void ); STATIC FUNC(void, NM_CODE) Nm_S_CoodinatorMainFunction ( void ); STATIC FUNC(void, NM_CODE) Nm_S_SetSleepReadyBit ( NetworkHandleType NetworkHandle, CONST(boolean, NM_CONST) nmSleepReadyBit ); STATIC FUNC(void, NM_CODE) Nm_S_RequestBusSynchronization ( NetworkHandleType NetworkHandle ); STATIC FUNC(boolean, NM_CODE) Nm_S_Shutdwon_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ); STATIC FUNC(boolean, NM_CODE) Nm_S_Normal_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ); STATIC FUNC(boolean, NM_CODE) Nm_S_WaitNetSync_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ); STATIC FUNC(boolean, NM_CODE) Nm_S_StartShutdwon_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ); STATIC FUNC(boolean, NM_CODE) Nm_S_PreShutdwon_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ); #endif/*#if(STD_ON == NM_COORDINATOR_SUPPORT)*/ /******************************************************************************* * Local Function definition *******************************************************************************/ #if(STD_ON == NM_PN_SUPPORT_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_PnInit * * Description: Called in Nm_Init to initialize the Pn parameters. * * Inputs: None * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ STATIC FUNC(void, NM_CODE) Nm_S_PnInit ( void ) { NetworkHandleType Channel; uint8 ByteIdx; uint8 BitIdx; uint16 offset; for(Channel = (NetworkHandleType)0; Channel < NM_NUM_OF_CHANNELS; Channel++) { if(TRUE == NM_CFG_CHL_PN_EN(Channel)) { if(((uint8)0 == NM_CFG_CHL_PNC_VECTOR_LEN(Channel)) || (NULL_PTR == NM_CFG_CHL_PN_FILTER_MASK_PTR(Channel))) { NM_DET_REPORT_ERROR(NM_INIT_APIID, NM_E_INIT_FAILED); } } #if(STD_ON == NM_PNC_ERA_CALC_EN) for(ByteIdx = (uint8)0; ByteIdx < NM_PNC_BIT_VECTOR_MAX_LEN; ByteIdx++) { /*SWS_Nm_00322*/ NM_PN_ERA_DATA(Channel, ByteIdx) = (uint8)0; NM_PN_ERA_NEW(Channel, ByteIdx) = (uint8)0; offset = (uint16)(ByteIdx * NM_BIT_LENGTH); for(BitIdx = (uint8)0; BitIdx < NM_BIT_LENGTH; BitIdx++) { /*SWS_Nm_00328*/ NM_PN_ERA_RESET_TIMER(Channel, (offset + (uint16)BitIdx)) = (Nm_PnResetTimeType)0; } } #endif } for(ByteIdx = (uint8)0; ByteIdx < NM_PNC_BIT_VECTOR_MAX_LEN; ByteIdx++) { /*SWS_Nm_00302*//*SWS_Nm_00330*/ NM_PN_EIRA_DATA(ByteIdx) = (uint8)0; NM_PN_EIRA_NEW(ByteIdx) = (uint8)0; offset = (uint16)(ByteIdx * NM_BIT_LENGTH); for(BitIdx = (uint8)0; BitIdx < NM_BIT_LENGTH; BitIdx++) { /*SWS_Nm_00328*/ NM_PN_EIRA_RESET_TIMER((offset + (uint16)BitIdx)) = (Nm_PnResetTimeType)0; } } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_PnEiraMainFunction * * Description: Called in Nm_MainFunction to manage the Pn internal and external request. * * Inputs: None * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ STATIC FUNC(void, NM_CODE) Nm_S_PnEiraMainFunction ( void ) { uint8 ByteIdx; uint8 BitIdx; uint16 offset; uint16 Idx; uint8 PnReq[NM_PNC_BIT_VECTOR_MAX_LEN] = {0}; boolean PnEiraChangedFlag = FALSE; SchM_Enter_Nm_NM_EXCLUSIVE_AREA_0(); Bsw_MemCpy(PnReq, &(NM_PN_EIRA_NEW(0)), NM_PNC_BIT_VECTOR_MAX_LEN); /*Clear the internal and external PN request data in temporary buffer.*/ for(ByteIdx = (uint8)0; ByteIdx < NM_PNC_BIT_VECTOR_MAX_LEN; ByteIdx++) { NM_PN_EIRA_NEW(ByteIdx) = (uint8)0; } SchM_Exit_Nm_NM_EXCLUSIVE_AREA_0(); for(ByteIdx = (uint8)0; ByteIdx < NM_PNC_BIT_VECTOR_MAX_LEN; ByteIdx++) { offset = (uint16)(ByteIdx * NM_BIT_LENGTH); /*SWS_Nm_00310*/ if((NM_PN_EIRA_DATA(ByteIdx) & PnReq[ByteIdx]) != PnReq[ByteIdx]) { /*SWS_Nm_00302*//*SWS_Nm_00313*//*SWS_Nm_00314*//*SWS_Nm_00330*/ NM_PN_EIRA_DATA(ByteIdx) |= PnReq[ByteIdx]; PnEiraChangedFlag = TRUE; } /*SWS_Nm_00329*/ for(BitIdx = (uint8)0; BitIdx < NM_BIT_LENGTH; BitIdx++) { Idx = (offset + (uint16)BitIdx); if(((PnReq[ByteIdx] >> BitIdx) & (uint8)0x01) != (uint8)0) { /*SWS_Nm_00319*/ NM_PN_EIRA_RESET_TIMER(Idx) = NM_GET_PN_RESET_CNT; } if(NM_PN_EIRA_RESET_TIMER(Idx) > (Nm_PnResetTimeType)0) { NM_PN_EIRA_RESET_TIMER(Idx)--; if(NM_PN_EIRA_RESET_TIMER(Idx) == (Nm_PnResetTimeType)0) { /*SWS_Nm_00320*/ NM_PN_EIRA_DATA(ByteIdx) &= (~((uint8)0x01 << BitIdx)); PnEiraChangedFlag = TRUE; } } } } if(PnEiraChangedFlag == TRUE) { /*SWS_Nm_00321*/ ComM_Nm_UpdateEIRA(&(NM_PN_EIRA_DATA(0))); } } #if(STD_ON == NM_PNC_ERA_CALC_EN) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_PnEraMainFunction * * Description: Called in Nm_MainFunction to manage the Pn external request. * * Inputs: None * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ STATIC FUNC(void, NM_CODE) Nm_S_PnEraMainFunction ( void ) { uint8 ByteIdx; uint8 BitIdx; uint16 offset; uint16 Idx; boolean PnEraChangedFlag; NetworkHandleType Channel; uint8 PnReq[NM_PNC_BIT_VECTOR_MAX_LEN] = {0}; for(Channel = (NetworkHandleType)0; Channel < NM_NUM_OF_CHANNELS; Channel++) { PnEraChangedFlag = FALSE; if(TRUE == NM_CFG_CHL_PN_ERA_CALC_EN(Channel)) { SchM_Enter_Nm_NM_EXCLUSIVE_AREA_0(); Bsw_MemCpy(PnReq, &(NM_PN_ERA_NEW(Channel, 0)), NM_CFG_CHL_PNC_VECTOR_LEN(Channel)); /*Clear the external PN request data in temporary buffer.*/ for(ByteIdx = (uint8)0; ByteIdx < NM_PNC_BIT_VECTOR_MAX_LEN; ByteIdx++) { NM_PN_ERA_NEW(Channel, ByteIdx) = (uint8)0; } SchM_Exit_Nm_NM_EXCLUSIVE_AREA_0(); SchM_Enter_Nm_NM_EXCLUSIVE_AREA_1(); for(ByteIdx = (uint8)0; ByteIdx < NM_CFG_CHL_PNC_VECTOR_LEN(Channel); ByteIdx++) { offset = (uint16)(ByteIdx * NM_BIT_LENGTH); if((NM_PN_ERA_DATA(Channel, ByteIdx) & PnReq[ByteIdx]) != PnReq[ByteIdx]) { /*SWS_Nm_00322*//*SWS_Nm_00323*/ NM_PN_ERA_DATA(Channel, ByteIdx) |= PnReq[ByteIdx]; PnEraChangedFlag = TRUE; } /*SWS_Nm_00329*/ for(BitIdx = (uint8)0; BitIdx < NM_BIT_LENGTH; BitIdx++) { Idx = (offset + (uint16)BitIdx); if(((PnReq[ByteIdx] >> BitIdx) & (uint8)0x01) != (uint8)0) { /*SWS_Nm_00325*/ NM_PN_ERA_RESET_TIMER(Channel, Idx) = NM_GET_PN_RESET_CNT; } if(NM_PN_ERA_RESET_TIMER(Channel, Idx) > (Nm_PnResetTimeType)0) { NM_PN_ERA_RESET_TIMER(Channel, Idx)--; if(NM_PN_ERA_RESET_TIMER(Channel, Idx) == (Nm_PnResetTimeType)0) { /*SWS_Nm_00326*/ NM_PN_ERA_DATA(Channel, ByteIdx) &= (~((uint8)0x01 << BitIdx)); PnEraChangedFlag = TRUE; } } } } SchM_Exit_Nm_NM_EXCLUSIVE_AREA_1(); } if(PnEraChangedFlag == TRUE) { /*SWS_Nm_00327*/ ComM_Nm_UpdateERA(NM_CFG_CHL_COMM_REF(Channel), &(NM_PN_ERA_DATA(Channel, 0))); } } } #endif #endif/*#if(STD_ON == NM_PN_SUPPORT_ENABLED)*/ /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_NetworkRequest * * Description: Calls the _NetworkRequest * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_S_NetworkRequest ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; /*SWS_Nm_00119*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_NetworkRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_NetworkRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_NetworkRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_NetworkRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_J1939NM_CHANNEL > 0) case NM_BUSNM_J1939NM: ret = J1939Nm_NetworkRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_LOCAL_CHANNEL > 0) case NM_BUSNM_LOCALNM: /*SWS_Nm_00483*//*SWS_Nm_00183*/ /*In case BusNmType is set to NM_BUSNM_LOCALNM Nm shall inform ComM about network startup by calling ComM_Nm_NetworkMode()*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_NetworkMode(NM_CFG_CHL_COMM_REF(NetworkHandle)); #endif ret = E_OK; break; #endif default: /*do nothing*/ break; } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_NetworkRelease * * Description: Calls the _NetworkRelease * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_S_NetworkRelease ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; /*SWS_Nm_00119*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_NetworkRelease(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_NetworkRelease(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_NetworkRelease(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_NetworkRelease(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_J1939NM_CHANNEL > 0) case NM_BUSNM_J1939NM: ret = J1939Nm_NetworkRelease(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_LOCAL_CHANNEL > 0) case NM_BUSNM_LOCALNM: /*This is not required by AUTOSAR Nm, but ComM has been told to enter NetworkMode in the PassiveStartup and NetworkRequest functions, so ComM needs to be told to enter BusSleepMode as well.*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_BusSleepMode(NM_CFG_CHL_COMM_REF(NetworkHandle)); #endif ret = E_OK; break; #endif default: /*do nothing*/ break; } return ret; } #if(STD_ON == NM_COORDINATOR_SUPPORT) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_CoodinatorInit * * Description: Called in Nm_Init to initialize the Cluster parameters and status. * * Inputs: None * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ STATIC FUNC(void, NM_CODE) Nm_S_CoodinatorInit ( void ) { Nm_ClusterIdType ClusterId; NetworkHandleType NetworkHandle; uint8 ArrayIdx; /*Cluster initialization*/ /*SWS_Nm_00167 Multiple NM coordination clusters shall be coordinated independently*/ for(ClusterId = (Nm_ClusterIdType)0; ClusterId < NM_NUM_OF_CLUSTERS; ClusterId++) { ArrayIdx = (uint8)0; /*Initialization sets the controller as the top-level coordinator of the Cluster*/ NM_CLU_IS_MASTER(ClusterId) = TRUE; NM_CLU_PASSIVE_CHL(ClusterId) = COMSTACK_INVALID_NETWORK_HANDLE; #if(NM_NUM_OF_FR_CHANNEL > 0) NM_CLU_SYNC_CHL(ClusterId) = COMSTACK_INVALID_NETWORK_HANDLE; #endif /*Set the initial state of the Cluster to sleep.*/ NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_SHUTDOWN; /*Clear the reasons for keeping the Cluster awake.*/ NM_CLU_AWAKE_INFO(ClusterId) = NM_AWAKE_NONE; /*Initializing the array with an invalid channel identifier.*/ for(NetworkHandle = (NetworkHandleType)0; NetworkHandle < NM_MAX_CHL_PER_CLUSTER; NetworkHandle++) { NM_CLU_CON_CHL(ClusterId, NetworkHandle) = COMSTACK_INVALID_NETWORK_HANDLE; } for(NetworkHandle = (NetworkHandleType)0; NetworkHandle < NM_NUM_OF_CHANNELS; NetworkHandle++) { /*SWS_Nm_00001 Several coordinated busses are connected to one NM Coordinator*/ /*SWS_Nm_00168 Each bus shall belong to zero or one NM coordination cluster.*/ if(NM_CFG_CHL_CLUSTER_INDEX(NetworkHandle) == ClusterId) { /*Record all channels belonging to the Cluster according to the configuration.*/ NM_CLU_CON_CHL(ClusterId, ArrayIdx) = NetworkHandle; /*Based on the configuration, determine whether the controller is the top-level coordinator for the Cluster.*/ if(NM_CFG_CHL_ACTIVE_COORD(NetworkHandle) == FALSE) { /*SWS_Nm_00256 Support two or more NMCoordinators connected to the same NM Cluster.*/ NM_CLU_IS_MASTER(ClusterId) = FALSE; NM_CLU_PASSIVE_CHL(ClusterId) = NetworkHandle; } /*SWS_Nm_00172*//*Based on the configuration, determine if there is a synchronizing channel in the Cluster.*/ #if(NM_NUM_OF_FR_CHANNEL > 0) if(NM_CFG_CHL_SYNC_NETWORK(NetworkHandle) == TRUE) { NM_CLU_SYNC_CHL(ClusterId) = NetworkHandle; } #endif ArrayIdx++; } } } /*Channel initialization*/ for(NetworkHandle = (NetworkHandleType)0; NetworkHandle < NM_NUM_OF_CHANNELS; NetworkHandle++) { /*Set the mode of channel with th default mode.*/ NM_CHL_MODE(NetworkHandle) = NM_MODE_BUS_SLEEP; /*Clear the reasons for keeping the channel awake.*/ NM_CHL_AWAKE_INFO(NetworkHandle) = NM_AWAKE_NONE; /*Reset the shutdown delay timer to 0.*/ NM_CHL_DELAY_TIMER(NetworkHandle) = NM_INVALID_TIMER_VALUE; } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_CoodinatorMainFunction * * Description: Called in Nm_MainFunction to manage the Cluster state. * * Inputs: None * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ STATIC FUNC(void, NM_CODE) Nm_S_CoodinatorMainFunction ( void ) { Nm_ClusterIdType ClusterId; uint8 ArrayIndex; NetworkHandleType NetworkHandle; boolean StateChanged = FALSE; /*SWS_Nm_00167 Multiple NM coordination clusters shall be coordinated independently*/ for(ClusterId = (Nm_ClusterIdType)0; ClusterId < NM_NUM_OF_CLUSTERS; ClusterId++) { NM_CLU_AWAKE_INFO(ClusterId) = NM_AWAKE_NONE; /*The reasons a Cluster keeps wakeup are equal to the collection of contained channels.*/ for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++) { /*SWS_Nm_00001 Several coordinated busses are connected to one NM Coordinator*/ NetworkHandle = NM_CLU_CON_CHL(ClusterId, ArrayIndex); if(NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) { NM_CLU_AWAKE_INFO(ClusterId) |= NM_CHL_AWAKE_INFO(NetworkHandle); } else { break; } } do { switch(NM_CLU_STATE(ClusterId)) { case NM_CLUSTER_STATE_SHUTDOWN: /*SWS_Nm_00181 The ComM request one of the networks with Nm_NetworkRequest() or Nm_PassiveStartUp().*/ StateChanged = Nm_S_Shutdwon_Process(ClusterId, NM_CLU_AWAKE_INFO(ClusterId)); break; case NM_CLUSTER_STATE_NORMAL: StateChanged = Nm_S_Normal_Process(ClusterId, NM_CLU_AWAKE_INFO(ClusterId)); break; case NM_CLUSTER_STATE_WAIT_NET_SYNC: StateChanged = Nm_S_WaitNetSync_Process(ClusterId, NM_CLU_AWAKE_INFO(ClusterId)); break; case NM_CLUSTER_STATE_START_SHUTDOWN: StateChanged = Nm_S_StartShutdwon_Process(ClusterId, NM_CLU_AWAKE_INFO(ClusterId)); break; case NM_CLUSTER_STATE_PRE_SHUTDOWN: StateChanged = Nm_S_PreShutdwon_Process(ClusterId, NM_CLU_AWAKE_INFO(ClusterId)); break; default: /*do nothing*/ break; } } while(StateChanged == TRUE); #if(NM_NUM_OF_FR_CHANNEL > 0) if(NM_CLU_STATE(ClusterId) <= NM_CLUSTER_STATE_WAIT_NET_SYNC) { NetworkHandle = NM_CLU_SYNC_CHL(ClusterId); if((NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) \ && ((NM_CHL_AWAKE_INFO(NetworkHandle) & NM_AWAKE_NO_SYNC_POINT) == (Nm_AwakeInfoType)0)) { /*SWS_Nm_00172*/ NM_CHL_AWAKE_INFO(NetworkHandle) |= NM_AWAKE_NO_SYNC_POINT; } } #endif }/*for(ClusterId = (Nm_ClusterIdType)0; ClusterId < NM_NUM_OF_CHANNELS; ClusterId++)*/ } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_SetSleepReadyBit * * Description: Calls the _SetSleepReadyBit * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_S_SetSleepReadyBit ( NetworkHandleType NetworkHandle, CONST(boolean, NM_CONST) nmSleepReadyBit ) { /*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: (void)CanNm_SetSleepReadyBit(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmSleepReadyBit); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: (void)FrNm_SetSleepReadyBit(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmSleepReadyBit); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: (void)UdpNm_SetSleepReadyBit(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmSleepReadyBit); break; #endif default: /*do nothing*/ break; } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_RequestBusSynchronization * * Description: Calls the _RequestBusSynchronizatio * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_S_RequestBusSynchronization ( NetworkHandleType NetworkHandle ) { /*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: (void)CanNm_RequestBusSynchronization(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: (void)FrNm_RequestBusSynchronization(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: (void)UdpNm_RequestBusSynchronization(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif default: /*do nothing*/ break; } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_Shutdwon_Process * * Description: This function implements the tasks that Nm needs to handle when * Cluster is in shutdown state. * * Inputs: ClusterId:Identification of the Nm coordinate cluster * CurAwakeInfo:Current awake information * * Outputs: None * * Limitations: Only used to process local/coordinate network request in * shutdown state of cluster. ******************************************************************************** END_FUNCTION_HDR*/ FUNC(boolean, NM_CODE) Nm_S_Shutdwon_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ) { uint8 ArrayIndex; NetworkHandleType NetworkHandle; Nm_AwakeInfoType FocusMask = (NM_AWAKE_LOCAL_REQUEST | NM_AWAKE_COORD_REQUEST); if((CurAwakeInfo & FocusMask) != (Nm_AwakeInfoType)0) { NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_NORMAL; } return FALSE; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_Normal_Process * * Description: This function implements the tasks that Nm needs to handle when * Cluster is in normal state. * * Inputs: ClusterId:Identification of the Nm coordinate cluster * CurAwakeInfo:Current awake information * * Outputs: None * * Limitations: Used to process network request because of local/RemoteSleepCancell * in normal state of cluster. ******************************************************************************** END_FUNCTION_HDR*/ FUNC(boolean, NM_CODE) Nm_S_Normal_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ) { uint8 ArrayIndex; NetworkHandleType NetworkHandle; Nm_AwakeInfoType FocusMask = (NM_AWAKE_LOCAL_REQUEST | NM_AWAKE_ACTIVE_RECEIVE); boolean StateChanged = FALSE; if((CurAwakeInfo & FocusMask) != (Nm_AwakeInfoType)0) { /*SWS_Nm_00002*//*SWS_Nm_00003*//*SWS_Nm_00177*/ /*As long as at least one node (including the node implementing the NM Coordinator) keeps any of the busses in the coordination cluster awake, the NM Coordinator shall keep all busses of that coordination cluster awake.*/ for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++) { NetworkHandle = NM_CLU_CON_CHL(ClusterId, ArrayIndex); if(NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) { if((NM_CHL_AWAKE_INFO(NetworkHandle) & NM_AWAKE_COORD_REQUEST) == (Nm_AwakeInfoType)0) { if(NM_CHL_MODE(NetworkHandle) == NM_MODE_BUS_SLEEP) { /*SWS_Nm_00182*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_RestartIndication(NetworkHandle); #endif } else { /*SWS_Nm_00183*/ /*SWS_Nm_00235 If _NetworkRequest returns E_NOT_OK, the channel does not enter or stay in NetworkMode and does not affect the sleep process, so the function return value is not judged here.*/ (void)Nm_S_NetworkRequest(NetworkHandle); NM_CHL_AWAKE_INFO(NetworkHandle) |= NM_AWAKE_COORD_REQUEST; } } } else { break; } }/*for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++)*/ } else { /*SWS_Nm_00171*//*All nodes ready to sleep.*/ if(NM_CLU_IS_MASTER(ClusterId) == FALSE) { /*Release network on passive channel.*/ NetworkHandle = NM_CLU_PASSIVE_CHL(ClusterId); /*SWS_Nm_00257*//*SWS_Nm_00236*/ (void)Nm_S_NetworkRelease(NetworkHandle); NM_CHL_AWAKE_INFO(NetworkHandle) &= (~NM_AWAKE_COORD_REQUEST); } NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_WAIT_NET_SYNC; StateChanged = TRUE; } return StateChanged; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_WaitNetSync_Process * * Description: This function implements the tasks that Nm needs to handle when * Cluster is in wait network synchronizing state. * * Inputs: ClusterId:Identification of the Nm coordinate cluster * CurAwakeInfo:Current awake information * * Outputs: None * * Limitations: Wait for the sync point of a synchronizing channel or SleepReadyBit * in nm message from passive channel, and process local/RemoteSleepCancell * request. ******************************************************************************** END_FUNCTION_HDR*/ FUNC(boolean, NM_CODE) Nm_S_WaitNetSync_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ) { uint8 ArrayIndex; NetworkHandleType NetworkHandle; Nm_ShutdownTimeType TempTime; Nm_AwakeInfoType FocusMask = (NM_AWAKE_LOCAL_REQUEST | NM_AWAKE_ACTIVE_RECEIVE); /*SWS_Nm_00173 Nm_SynchronizationPoint only works in wait network synchronizing state.*/ Nm_AwakeInfoType SetSleepReadyBitMask = (NM_AWAKE_NO_SLEEPREADYBIT | NM_AWAKE_NO_SYNC_POINT); boolean StateChanged = FALSE; /*SWS_Nm_00256 Support two or more NMCoordinators connected to the same NM Cluster.*/ if((CurAwakeInfo & FocusMask) == (Nm_AwakeInfoType)0) { /*SWS_Nm_00172*//*SWS_Nm_00173*//*SWS_Nm_00174*/ /*Master Coordinator: Nm_SynchronizationPoint() has been called.*/ /*Sub Coordinator: Receive SleepReadyBit 1 on passive channel or Passive channel mode changes to PrepareBusSleep mode.*/ if((CurAwakeInfo & SetSleepReadyBitMask) == (Nm_AwakeInfoType)0) { for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++) { NetworkHandle = NM_CLU_CON_CHL(ClusterId, ArrayIndex); /*SWS_Nm_00169 Shutdown shall only be coordinated on the presently awake networks of a coordination cluster.*/ if((NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) \ && ((NM_CHL_AWAKE_INFO(NetworkHandle) & NM_AWAKE_SHUTDOWN_TIME_DELAY) != (Nm_AwakeInfoType)0)) { if(NM_CHL_DELAY_TIMER(NetworkHandle) == NM_INVALID_TIMER_VALUE) { /*SWS_Nm_00175*//*SWS_Nm_00281*/ TempTime = (NM_GLOBAL_COORDINATOR_TIME - NM_CFG_CHL_SHUTDOWN_TIME(NetworkHandle)); NM_CHL_DELAY_TIMER(NetworkHandle) = (TempTime / NM_CYCLETIME_MAINFUNCTION); /*SWS_Nm_00259*//*SWS_Nm_00261*/ Nm_S_SetSleepReadyBit(NetworkHandle, TRUE); } } } /*SWS_Nm_00262*/ NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_START_SHUTDOWN; StateChanged = TRUE; } } else { /*SWS_Nm_00181*//*SWS_Nm_00185*//*SWS_Nm_00177*/ /*Local request on passive/active channel or receive message from active channels.*/ NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_NORMAL; } return StateChanged; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_StartShutdwon_Process * * Description: This function implements the tasks that Nm needs to handle when * Cluster is in start shutdown state. * * Inputs: ClusterId:Identification of the Nm coordinate cluster * CurAwakeInfo:Current awake information * * Outputs: None * * Limitations: Wait all active channel ShutdownDelayTimer timeout, and process * network request because of local/RemoteSleepCancell/SleepReadyBitCancell * in start shutdown state of cluster. ******************************************************************************** END_FUNCTION_HDR*/ FUNC(boolean, NM_CODE) Nm_S_StartShutdwon_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ) { uint8 ArrayIndex; NetworkHandleType NetworkHandle; Nm_ShutdownTimeType TempTime; Nm_AwakeInfoType FocusMask = (NM_AWAKE_LOCAL_REQUEST | NM_AWAKE_ACTIVE_RECEIVE | NM_AWAKE_NO_SLEEPREADYBIT); boolean StateChanged = FALSE; /*SWS_Nm_00256 Support two or more NMCoordinators connected to the same NM Cluster.*/ if((CurAwakeInfo & FocusMask) == (Nm_AwakeInfoType)0) { if((CurAwakeInfo & NM_AWAKE_SHUTDOWN_TIME_DELAY) != (Nm_AwakeInfoType)0) { for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++) { NetworkHandle = NM_CLU_CON_CHL(ClusterId, ArrayIndex); /*SWS_Nm_00169 Shutdown shall only be coordinated on the presently awake networks of a coordination cluster.*/ if((NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) \ && ((NM_CHL_AWAKE_INFO(NetworkHandle) & NM_AWAKE_SHUTDOWN_TIME_DELAY) != (Nm_AwakeInfoType)0)) { if(NM_CHL_DELAY_TIMER(NetworkHandle) > 0) { NM_CHL_DELAY_TIMER(NetworkHandle)--; } if(NM_CHL_DELAY_TIMER(NetworkHandle) == (Nm_ShutdownTimeType)0) { NM_CHL_AWAKE_INFO(NetworkHandle) &= (~NM_AWAKE_SHUTDOWN_TIME_DELAY); NM_CHL_AWAKE_INFO(NetworkHandle) &= (~NM_AWAKE_COORD_REQUEST); /*SWS_Nm_00176 Call the _RequestBusSynchronization followed by _NetworkRelease.*/ (void)Nm_S_RequestBusSynchronization(NetworkHandle); (void)Nm_S_NetworkRelease(NetworkHandle); } } } } else { NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_PRE_SHUTDOWN; StateChanged = TRUE; } } else { /*SWS_Nm_00181*/ /*Local request on passive/active channel or receive message from active channels or receive SleepReadyBit with 0 on passive channel.*/ /*Clear the SleepReadyBit.*/ for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++) { NetworkHandle = NM_CLU_CON_CHL(ClusterId, ArrayIndex); if(NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) { if(NM_CFG_CHL_ACTIVE_COORD(NetworkHandle) == TRUE) { /*SWS_Nm_00271*//*SWS_Nm_00267*/ Nm_S_SetSleepReadyBit(NetworkHandle, FALSE); NM_CHL_AWAKE_INFO(NetworkHandle) |= NM_AWAKE_SHUTDOWN_TIME_DELAY; NM_CHL_DELAY_TIMER(NetworkHandle) = NM_INVALID_TIMER_VALUE; } else { /*The else does: If the passive channel receives a 0 SleepReadyBit or switches from PrepareBusSleepMode to NetworkMode because of an nm message, the Cluster needs to request network on passive channel first.*/ /*The purpose of this judgment is to avoid repeating calls to BusNm_NetworkRequest on passive channel.*/ if((NM_CHL_AWAKE_INFO(NetworkHandle) & NM_AWAKE_COORD_REQUEST) == (Nm_AwakeInfoType)0) { Nm_S_NetworkRequest(NetworkHandle); NM_CHL_AWAKE_INFO(NetworkHandle) |= NM_AWAKE_COORD_REQUEST; } } } else { break; } } /*SWS_Nm_00185*//*SWS_Nm_00177*/ /*Cluster state changes to normal.*/ NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_NORMAL; } return StateChanged; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_S_PreShutdwon_Process * * Description: This function implements the tasks that Nm needs to handle when * Cluster is in prepare shutdown state. * * Inputs: ClusterId:Identification of the Nm coordinate cluster * CurAwakeInfo:Current awake information * * Outputs: None * * Limitations: Wait all channels go to BusSleepMode, and process * network request because of local/RemoteSleepCancell/SleepReadyBitCancell * in prepare shutdown state of cluster. ******************************************************************************** END_FUNCTION_HDR*/ FUNC(boolean, NM_CODE) Nm_S_PreShutdwon_Process ( CONST(Nm_ClusterIdType, NM_CONST) ClusterId, CONST(Nm_AwakeInfoType, NM_CONST) CurAwakeInfo ) { uint8 ArrayIndex; NetworkHandleType NetworkHandle; Nm_AwakeInfoType FocusMask = (NM_AWAKE_LOCAL_REQUEST | NM_AWAKE_ACTIVE_RECEIVE | NM_AWAKE_NO_SLEEPREADYBIT); boolean AllChannelSleep = TRUE; boolean StateChanged = FALSE; /*SWS_Nm_00256 Support two or more NMCoordinators connected to the same NM Cluster.*/ if((CurAwakeInfo & FocusMask) == (Nm_AwakeInfoType)0) { for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++) { NetworkHandle = NM_CLU_CON_CHL(ClusterId, ArrayIndex); if(NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) { if(NM_CHL_MODE(NetworkHandle) != NM_MODE_BUS_SLEEP) { AllChannelSleep = FALSE; break; } } else { break; } } if(AllChannelSleep == TRUE) { NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_SHUTDOWN; StateChanged = TRUE; } } else { /*SWS_Nm_00181*/ /*Local request on passive/active channel or receive message from active channels or receive SleepReadyBit with 0 on passive channel.*/ /*Clear the SleepReadyBit.*/ for(ArrayIndex = (uint8)0; ArrayIndex < NM_MAX_CHL_PER_CLUSTER; ArrayIndex++) { NetworkHandle = NM_CLU_CON_CHL(ClusterId, ArrayIndex); if(NetworkHandle != COMSTACK_INVALID_NETWORK_HANDLE) { if(NM_CFG_CHL_ACTIVE_COORD(NetworkHandle) == TRUE) { /*SWS_Nm_00271*//*SWS_Nm_00267*/ Nm_S_SetSleepReadyBit(NetworkHandle, FALSE); NM_CHL_AWAKE_INFO(NetworkHandle) |= NM_AWAKE_SHUTDOWN_TIME_DELAY; NM_CHL_DELAY_TIMER(NetworkHandle) = NM_INVALID_TIMER_VALUE; } else { /*The else does: If the passive channel receives a 0 SleepReadyBit or switches from PrepareBusSleepMode to NetworkMode because of an nm message, the Cluster needs to request network on passive channel first.*/ /*The purpose of this judgment is to avoid repeating calls to BusNm_NetworkRequest on passive channel.*/ if((NM_CHL_AWAKE_INFO(NetworkHandle) & NM_AWAKE_COORD_REQUEST) == (Nm_AwakeInfoType)0) { Nm_S_NetworkRequest(NetworkHandle); NM_CHL_AWAKE_INFO(NetworkHandle) |= NM_AWAKE_COORD_REQUEST; } } } else { break; } } /*SWS_Nm_00185*//*SWS_Nm_00177*/ /*Cluster state changes to normal.*/ NM_CLU_STATE(ClusterId) = NM_CLUSTER_STATE_NORMAL; } return StateChanged; } #endif/*#if(STD_ON == NM_COORDINATOR_SUPPORT)*/ /******************************************************************************* * Global Function definition *******************************************************************************/ /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_Init SWS_Nm_00030 * * Description: Initializes the NM Interface * * * Inputs: ConfigPtr:Pointer to the selected configuration set. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_Init ( P2CONST(Nm_ConfigType, AUTOMATIC, NM_CONST) ConfigPtr ) { /*SWS_Nm_00283*/ (void)ConfigPtr; #if(STD_ON == NM_COORDINATOR_SUPPORT) Nm_S_CoodinatorInit(); #endif #if(STD_ON == NM_PN_SUPPORT_ENABLED) Nm_S_PnInit(); #endif NM_SET_INITIALIZED(); } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_PassiveStartUp SWS_Nm_00031 * * Description: This function calls the _PassiveStartUp function * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_PassiveStartUp ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_PASSIVESTARTUP_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00488*/ NM_DET_REPORT_ERROR(NM_PASSIVESTARTUP_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_COORDINATOR_SUPPORT) if((NM_CFG_CHL_CLUSTER_INDEX(NetworkHandle) < NM_NUM_OF_CLUSTERS) && (NM_CHL_MODE(NetworkHandle) != NM_MODE_NETWORK)) { /*SWS_Nm_00245*/ ret = Nm_S_NetworkRequest(NetworkHandle); if(E_OK == ret) { Nm_S_SetSleepReadyBit(NetworkHandle, FALSE); NM_CHL_AWAKE_INFO(NetworkHandle) |= NM_AWAKE_COORD_REQUEST; } } else #endif { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00119*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_PassiveStartUp(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_PassiveStartUp(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_PassiveStartUp(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_PassiveStartUp(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_J1939NM_CHANNEL > 0) case NM_BUSNM_J1939NM: ret = J1939Nm_PassiveStartUp(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_LOCAL_CHANNEL > 0) case NM_BUSNM_LOCALNM: /*SWS_Nm_00483*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_NetworkMode(NM_CFG_CHL_COMM_REF(NetworkHandle)); #endif ret = E_OK; break; #endif default: /*do nothing*/ break; } } } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_NetworkRequest SWS_Nm_00032 * * Description: This function calls the _NetworkRequest * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_NetworkRequest ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_NETWORKREQUEST_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00489*/ NM_DET_REPORT_ERROR(NM_NETWORKREQUEST_APIID, NM_E_INVALID_CHANNEL); } else if(NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) == TRUE) { /*SWS_Nm_00130*/ NM_DET_REPORT_ERROR(NM_NETWORKREQUEST_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*/ ret = Nm_S_NetworkRequest(NetworkHandle); #if(STD_ON == NM_COORDINATOR_SUPPORT) if((E_OK == ret) && (NM_CFG_CHL_CLUSTER_INDEX(NetworkHandle) < NM_NUM_OF_CLUSTERS)) { Nm_S_SetSleepReadyBit(NetworkHandle, FALSE); NM_CHL_AWAKE_INFO(NetworkHandle) |= (NM_AWAKE_COORD_REQUEST | NM_AWAKE_LOCAL_REQUEST); } #endif } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_NetworkRelease SWS_Nm_00046 * * Description: This function calls the _NetworkRelease bus specific function * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_NetworkRelease ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_NETWORKRELEASE_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00490*/ NM_DET_REPORT_ERROR(NM_NETWORKRELEASE_APIID, NM_E_INVALID_CHANNEL); } else if(NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) == TRUE) { /*SWS_Nm_00132*/ NM_DET_REPORT_ERROR(NM_NETWORKRELEASE_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_COORDINATOR_SUPPORT) if(NM_CFG_CHL_CLUSTER_INDEX(NetworkHandle) < NM_NUM_OF_CLUSTERS) { NM_CHL_AWAKE_INFO(NetworkHandle) &= (~NM_AWAKE_LOCAL_REQUEST); ret = E_OK; } else #endif { /*SWS_Nm_00006*//*SWS_Nm_00091*/ ret = Nm_S_NetworkRelease(NetworkHandle); } } return ret; } /*SWS_Nm_00134*//*SWS_Nm_00136*/ #if(STD_ON == NM_COM_CONTROL_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_DisableCommunication SWS_Nm_00033 * * Description: Disables the NM PDU transmission ability * * Inputs: NetworkHandle Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_DisableCommunication ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_DISABLECOMMUNICATION_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00491*/ NM_DET_REPORT_ERROR(NM_DISABLECOMMUNICATION_APIID, NM_E_INVALID_CHANNEL); } else if(NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) == TRUE) { /*SWS_Nm_00286*/ NM_DET_REPORT_ERROR(NM_DISABLECOMMUNICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_DisableCommunication(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_Silent(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_DisableCommunication(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_DisableCommunication(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif default: /*do nothing*/ break; } } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_EnableCommunication SWS_Nm_00034 * * Description: Enables the NM PDU transmission ability * * Inputs: NetworkHandle Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_EnableCommunication ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_ENABLECOMMUNICATION_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00492*/ NM_DET_REPORT_ERROR(NM_ENABLECOMMUNICATION_APIID, NM_E_INVALID_CHANNEL); } else if(NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) == TRUE) { /*SWS_Nm_00287*/ NM_DET_REPORT_ERROR(NM_ENABLECOMMUNICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_EnableCommunication(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_Talk(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_EnableCommunication(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_EnableCommunication(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif default: /*do nothing*/ break; } } return ret; } #endif/*#if(STD_ON == NM_COM_CONTROL_ENABLED)*/ #if(STD_ON == NM_PN_SUPPORT_ENABLED) #if(STD_ON == NM_SYNC_PNC_SHUTDOWN_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_RequestSynchronizedPncShutdown SWS_Nm_91005 * * Description: This function forward the request for a synchronized PNC shutdown * of a particular PNC given by PncId to the affected Nm by * calling Nm_RequestSynchronizedPncShutdown * * Inputs: NetworkHandle:Identification of the NM-channel. * PncId:Identification of the Pnc which is requested for a synchronized * shutdown across the PNC network topology * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_RequestSynchronizedPncShutdown ( NetworkHandleType NetworkHandle, PNCHandleType PncId ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_REQSYNCPNCSHUTDOWN_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00508*/ NM_DET_REPORT_ERROR(NM_REQSYNCPNCSHUTDOWN_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00506*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_RequestSynchronizedPncShutdown(NM_CFG_CHL_BUSNM_REF(NetworkHandle), PncId); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_RequestSynchronizedPncShutdown(NM_CFG_CHL_BUSNM_REF(NetworkHandle), PncId); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_RequestSynchronizedPncShutdown(NM_CFG_CHL_BUSNM_REF(NetworkHandle), PncId); break; #endif default: /*do nothing*/ break; } } return ret; } #endif/*#if(STD_ON == NM_SYNC_PNC_SHUTDOWN_ENABLED)*/ /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_UpdateIRA SWS_Nm_91007 * * Description: Indication by ComM of internal PNC requests. This is used to * aggregate the internal PNC requests. * * Inputs: NetworkHandle:Identification of the NM-channel. * PncBitVectorPtr:Pointer to the bit vector with all PNC bits set * to "1" of internal requested PNCs (IRA). * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_UpdateIRA ( NetworkHandleType NetworkHandle, P2CONST(uint8, AUTOMATIC, NM_CONST) PncBitVectorPtr ) { uint8 i; Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_UPDATEIRA_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_UPDATEIRA_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == PncBitVectorPtr) { NM_DET_REPORT_ERROR(NM_UPDATEIRA_APIID, NM_E_PARAM_POINTER); } else { if(TRUE == NM_CFG_CHL_PN_EN(NetworkHandle)) { /*SWS_Nm_00317*/ for(i = (uint8)0; i < NM_CFG_CHL_PNC_VECTOR_LEN(NetworkHandle); i++) { NM_PN_IRA_DATA(NetworkHandle, i) = PncBitVectorPtr[i]; } } } } #endif /*SWS_Nm_00138*//*SWS_Nm_00140*/ #if(STD_ON == NM_USER_DATA_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_SetUserData SWS_Nm_00035 * * Description: Set user data for NM messages transmitted next on the bus. * * Inputs: NetworkHandle:Identification of the NM-channel. * nmUserDataPtr:User data for the next transmitted NM message * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_SetUserData ( NetworkHandleType NetworkHandle, P2CONST(uint8, AUTOMATIC, NM_CONST) nmUserDataPtr ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_SETUSERDATA_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00493*/ NM_DET_REPORT_ERROR(NM_SETUSERDATA_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == nmUserDataPtr) { NM_DET_REPORT_ERROR(NM_SETUSERDATA_APIID, NM_E_PARAM_POINTER); } else if(NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) == TRUE) { /*SWS_Nm_00288*/ NM_DET_REPORT_ERROR(NM_SETUSERDATA_APIID, NM_E_INVALID_CHANNEL); } else if(NM_CFG_CHL_COM_DATA_SUPPORT(NetworkHandle) == TRUE) { /*SWS_Nm_00241*/ } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_SetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_SetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_SetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_SetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif default: /*do nothing*/ break; } } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_GetUserData SWS_Nm_00036 * * Description: Get user data out of the last successfully received NM message * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: nmUserDataPtr:Pointer where user data out of the last successfully * received NM message shall be copied to * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_GetUserData ( NetworkHandleType NetworkHandle, P2VAR(uint8, AUTOMATIC, NM_APPL_DATA) nmUserDataPtr ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_GETUSERDATA_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00494*/ NM_DET_REPORT_ERROR(NM_GETUSERDATA_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == nmUserDataPtr) { NM_DET_REPORT_ERROR(NM_GETUSERDATA_APIID, NM_E_PARAM_POINTER); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_GetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_GetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_GetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_GetUserData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmUserDataPtr); break; #endif default: /*do nothing*/ break; } } return ret; } #endif/*#if(STD_ON == NM_USER_DATA_ENABLED)*/ /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_GetPduData SWS_Nm_00037 * * Description: Get the whole PDU data out of the most recently received NM message * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: nmPduData:Pointer where NM PDU shall be copied to. * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_GetPduData ( NetworkHandleType NetworkHandle, P2VAR(uint8, AUTOMATIC, NM_APPL_DATA) nmPduData ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_GETPDUDATA_APIID, NM_E_UNINIT); } else if (NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00495*/ NM_DET_REPORT_ERROR(NM_GETPDUDATA_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == nmPduData) { NM_DET_REPORT_ERROR(NM_GETPDUDATA_APIID, NM_E_PARAM_POINTER); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_GetPduData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmPduData); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_GetPduData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmPduData); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_GetPduData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmPduData); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_GetPduData(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmPduData); break; #endif default: /*do nothing*/ break; } } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_RepeatMessageRequest SWS_Nm_00038 * * Description: Set Repeat Message Request Bit for NM messages transmitted next * on the bus. This will force all nodes on the bus to transmit NM * messages so that they can be identified. * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: None * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_RepeatMessageRequest ( NetworkHandleType NetworkHandle ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_REPEATEMESSAGEREQUEST_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00496*/ NM_DET_REPORT_ERROR(NM_REPEATEMESSAGEREQUEST_APIID, NM_E_INVALID_CHANNEL); } else if(NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) == TRUE) { /*SWS_Nm_00289*/ NM_DET_REPORT_ERROR(NM_REPEATEMESSAGEREQUEST_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_RepeatMessageRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = E_OK; break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_RepeatMessageRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_RepeatMessageRequest(NM_CFG_CHL_BUSNM_REF(NetworkHandle)); break; #endif default: /*do nothing*/ break; } } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_GetNodeIdentifier SWS_Nm_00039 * * Description: Get node identifier out of the last successfully received NM-message * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: nmNodeIdPtr:Pointer where node identifier out of the last successfully * received NM-message shall be copied to * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_GetNodeIdentifier ( NetworkHandleType NetworkHandle, P2VAR(uint8, AUTOMATIC, NM_APPL_DATA) nmNodeIdPtr ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_GETNODEIDENTIFIER_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00497*/ NM_DET_REPORT_ERROR(NM_GETNODEIDENTIFIER_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == nmNodeIdPtr) { NM_DET_REPORT_ERROR(NM_GETNODEIDENTIFIER_APIID, NM_E_PARAM_POINTER); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_GetNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_GetNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_GetNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_GetNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif default: /*do nothing*/ break; } } return ret; } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_GetLocalNodeIdentifier SWS_Nm_00040 * * Description: Get node identifier configured for the local node. * * Inputs: NetworkHandle Identification of the NM-channel. * * Outputs: nmNodeIdPtr Pointer where node identifier of the local node shall be * copied to * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_GetLocalNodeIdentifier ( NetworkHandleType NetworkHandle, P2VAR(uint8, AUTOMATIC, NM_APPL_DATA) nmNodeIdPtr ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_GETLOCALNODEIDENTIFIER_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00498*/ NM_DET_REPORT_ERROR(NM_GETLOCALNODEIDENTIFIER_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == nmNodeIdPtr) { NM_DET_REPORT_ERROR(NM_GETLOCALNODEIDENTIFIER_APIID, NM_E_PARAM_POINTER); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_GetLocalNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_GetLocalNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_GetLocalNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_GetLocalNodeIdentifier(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmNodeIdPtr); break; #endif default: /*do nothing*/ break; } } return ret; } /*SWS_Nm_00150*/ #if(STD_ON == NM_REMOTE_SLEEP_IND_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_CheckRemoteSleepIndication SWS_Nm_00042 * * Description: Check if remote sleep indication takes place or not * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: nmRemoteSleepIndPtr:Pointer where check result of remote sleep indication * shall be copied to * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_CheckRemoteSleepIndication ( NetworkHandleType NetworkHandle, P2VAR(boolean, AUTOMATIC, NM_APPL_DATA) nmRemoteSleepIndPtr ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_CHECKREMOTESLEEPINDICATION_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00499*/ NM_DET_REPORT_ERROR(NM_CHECKREMOTESLEEPINDICATION_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == nmRemoteSleepIndPtr) { NM_DET_REPORT_ERROR(NM_CHECKREMOTESLEEPINDICATION_APIID, NM_E_PARAM_POINTER); } else if(NM_CFG_CHL_PASSIVE_MODE_EN(NetworkHandle) == TRUE) { /*SWS_Nm_00290*/ NM_DET_REPORT_ERROR(NM_CHECKREMOTESLEEPINDICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00166*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_CheckRemoteSleepIndication(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmRemoteSleepIndPtr); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = E_OK; break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_CheckRemoteSleepIndication(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmRemoteSleepIndPtr); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_CheckRemoteSleepIndication(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmRemoteSleepIndPtr); break; #endif default: /*do nothing*/ break; } } return ret; } #endif /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_GetState SWS_Nm_00043 * * Description: Returns the state of the network management * * Inputs: NetworkHandle:Identification of the NM-channel. * * Outputs: nmStatePtr:Pointer where state of the network management shall be * copied to * nmModePtr:Pointer to the location where the mode of the network * management shall be copied to * * Limitations: None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_GetState ( NetworkHandleType NetworkHandle, P2VAR(Nm_StateType, AUTOMATIC, NM_APPL_DATA) nmStatePtr, P2VAR(Nm_ModeType, AUTOMATIC, NM_APPL_DATA) nmModePtr ) { Std_ReturnType ret = E_NOT_OK; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_GETSTATE_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*SWS_Nm_00500*/ NM_DET_REPORT_ERROR(NM_GETSTATE_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == nmStatePtr) { NM_DET_REPORT_ERROR(NM_GETSTATE_APIID, NM_E_PARAM_POINTER); } else if(NULL_PTR == nmModePtr) { NM_DET_REPORT_ERROR(NM_GETSTATE_APIID, NM_E_PARAM_POINTER); } else { /*SWS_Nm_00006*//*SWS_Nm_00091*//*SWS_Nm_00119*/ switch(NM_CFG_CHL_BUS_TYPE(NetworkHandle)) { #if(NM_NUM_OF_CANNM_CHANNEL > 0) case NM_BUSNM_CANNM: ret = CanNm_GetState(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmStatePtr, nmModePtr); break; #endif #if(NM_NUM_OF_OSEKNM_CHANNEL > 0) case NM_BUSNM_OSEKNM: ret = OsekNm_GetState(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmStatePtr, nmModePtr); break; #endif #if(NM_NUM_OF_FR_CHANNEL > 0) case NM_BUSNM_FRNM: ret = FrNm_GetState(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmStatePtr, nmModePtr); break; #endif #if(NM_NUM_OF_UDP_CHANNEL > 0) case NM_BUSNM_UDPNM: ret = UdpNm_GetState(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmStatePtr, nmModePtr); break; #endif #if(NM_NUM_OF_J1939NM_CHANNEL > 0) case NM_BUSNM_J1939NM: ret = J1939Nm_GetState(NM_CFG_CHL_BUSNM_REF(NetworkHandle), nmStatePtr, nmModePtr); break; #endif default: /*do nothing*/ break; } } return ret; } #if(NM_VERSION_INFO_API == STD_ON) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_GetVersionInfo SWS_Nm_00044 * * Description : This function returns the version information of this module. * * Inputs : nmVerInfoPtr:Pointer to where to store the version information * of this module. * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_GetVersionInfo ( P2VAR(Std_VersionInfoType, AUTOMATIC, NM_APPL_DATA) nmVerInfoPtr ) { if(NULL_PTR == nmVerInfoPtr) { NM_DET_REPORT_ERROR(NM_GETVERSIONINFO_APIID, NM_E_PARAM_POINTER); } else { nmVerInfoPtr->vendorID = NM_VENDOR_ID; nmVerInfoPtr->moduleID = NM_MODULE_ID; nmVerInfoPtr->sw_major_version = (uint8)NM_SW_MAJOR_VERSION; nmVerInfoPtr->sw_minor_version = (uint8)NM_SW_MINOR_VERSION; nmVerInfoPtr->sw_patch_version = (uint8)NM_SW_PATCH_VERSION; } } #endif /*SWS_Nm_00502*/ #if(NM_DYN_PNC_SUPPORT == STD_ON) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_PnLearningRequest SWS_Nm_91003 * * Description : Set Repeat Message Request Bit and Partial Network Learning Bit * for NM messages transmitted next on the bus. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(Std_ReturnType, NM_CODE) Nm_PnLearningRequest ( NetworkHandleType NetworkHandle ) { /*The related requirements of this function in the specification are still in draft state and will not be implemented.*/ (void)NetworkHandle; } #endif /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_NetworkStartIndication SWS_Nm_00154 * * Description : Notification that a NM-message has been received in the Bus-Sleep * Mode, what indicates that some nodes in the network have already * entered the Network Mode * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_NetworkStartIndication ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_NETWORKSTARTINDICATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_NETWORKSTARTINDICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00155*//*SWS_Nm_00012*//*SWS_Nm_00091*//*SWS_Nm_00119*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_NetworkStartIndication(NM_CFG_CHL_COMM_REF(nmNetworkHandle)); #endif } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_NetworkMode SWS_Nm_00156 * * Description : Notification that the network management has entered Network Mode * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_NetworkMode ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_NETWORKMODE_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_NETWORKMODE_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_COORDINATOR_SUPPORT) if(NM_CFG_CHL_CLUSTER_INDEX(nmNetworkHandle) < NM_NUM_OF_CLUSTERS) { if(NM_CFG_CHL_ACTIVE_COORD(nmNetworkHandle) == TRUE) { /*SWS_Nm_00228*/ if(NM_CFG_CHL_SLEEP_MASTER(nmNetworkHandle) == FALSE) { NM_CHL_AWAKE_INFO(nmNetworkHandle) |= NM_AWAKE_ACTIVE_RECEIVE; } NM_CHL_AWAKE_INFO(nmNetworkHandle) |= NM_AWAKE_SHUTDOWN_TIME_DELAY; } else { /*SWS_Nm_00280*/ if(NM_COORDINATOR_SYNC_SUPPORT == TRUE) { NM_CHL_AWAKE_INFO(nmNetworkHandle) |= NM_AWAKE_NO_SLEEPREADYBIT; } } #if(NM_NUM_OF_FR_CHANNEL > 0) if(NM_CFG_CHL_SYNC_NETWORK(nmNetworkHandle) == TRUE) { NM_CHL_AWAKE_INFO(nmNetworkHandle) |= NM_AWAKE_NO_SYNC_POINT; } #endif } /*Record the channel mode*/ NM_CHL_MODE(nmNetworkHandle) = NM_MODE_NETWORK; #endif /*SWS_Nm_00158*//*SWS_Nm_00012*//*SWS_Nm_00091*//*SWS_Nm_00119*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_NetworkMode(NM_CFG_CHL_COMM_REF(nmNetworkHandle)); #endif } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_BusSleepMode SWS_Nm_00162 * * Description : Notification that the network management has entered Bus-Sleep Mode. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_BusSleepMode ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_BUSSLEEPMODE_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_BUSSLEEPMODE_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_COORDINATOR_SUPPORT) /*Record the channel mode*/ NM_CHL_MODE(nmNetworkHandle) = NM_MODE_BUS_SLEEP; #endif /*SWS_Nm_00163*//*SWS_Nm_00012*//*SWS_Nm_00091*//*SWS_Nm_00119*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_BusSleepMode(NM_CFG_CHL_COMM_REF(nmNetworkHandle)); #endif } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_PrepareBusSleepMode SWS_Nm_00159 * * Description : Notification that the network management has entered Prepare Bus-Sleep Mode. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_PrepareBusSleepMode ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_PREPAREBUSSLEEPMODE_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_PREPAREBUSSLEEPMODE_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_COORDINATOR_SUPPORT) /*This operation prevents communication loss of passive channel from affecting the sleep of subsequent networks.*/ /*SWS_Nm_00280*/ if(NM_CFG_CHL_CLUSTER_INDEX(nmNetworkHandle) < NM_NUM_OF_CLUSTERS) { if((NM_COORDINATOR_SYNC_SUPPORT == TRUE) && (NM_CFG_CHL_ACTIVE_COORD(nmNetworkHandle) == FALSE)) { NM_CHL_AWAKE_INFO(nmNetworkHandle) &= (~NM_AWAKE_NO_SLEEPREADYBIT); } } /*Record the channel mode*/ NM_CHL_MODE(nmNetworkHandle) = NM_MODE_PREPARE_BUS_SLEEP; #endif /*SWS_Nm_00161*//*SWS_Nm_00012*//*SWS_Nm_00091*//*SWS_Nm_00119*/ #if(STD_ON == NM_COMM_SUPPORT) ComM_Nm_PrepareBusSleepMode(NM_CFG_CHL_COMM_REF(nmNetworkHandle)); #endif } } #if(NM_NUM_OF_FR_CHANNEL > 0) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_SynchronizeMode SWS_Nm_91002 * * Description : Notification that the network management has entered Synchronize Mode. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_SynchronizeMode ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_SYNCHRONIZEMODE_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_SYNCHRONIZEMODE_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_COORDINATOR_SUPPORT) /*Record the channel mode*/ if(NM_CFG_CHL_BUS_TYPE(nmNetworkHandle) == NM_BUSNM_FRNM) { NM_CHL_MODE(nmNetworkHandle) = NM_MODE_SYNCHRONIZE; } #endif } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_SynchronizationPoint SWS_Nm_00194 * * Description : Notification to the NM Coordinator functionality that this is a * suitable point in time to initiate the coordination algorithm on * * Inputs : nmNetworkHandle Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_SynchronizationPoint ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_SYNCHRONIZATIONPOINT_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_SYNCHRONIZATIONPOINT_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_COORDINATOR_SUPPORT) /*The notification that this is a suitable point in time to initiate the coordination algorithm on is only needed for internal purposes of the NM Coordinator.*/ if((NM_CFG_CHL_CLUSTER_INDEX(nmNetworkHandle) < NM_NUM_OF_CLUSTERS) \ && (NM_CFG_CHL_SYNC_NETWORK(nmNetworkHandle) == TRUE)) { NM_CHL_AWAKE_INFO(nmNetworkHandle) &= (~NM_AWAKE_NO_SYNC_POINT); } #endif } } #endif/*#if(NM_NUM_OF_FR_CHANNEL > 0)*/ /*SWS_Nm_00277*//*SWS_Nm_00278*/ #if(STD_ON == NM_REMOTE_SLEEP_IND_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_RemoteSleepIndication SWS_Nm_00192 * * Description : Notification that the network management has detected that all * other nodes on the network are ready to enter Bus-Sleep Mode. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_RemoteSleepIndication ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_REMOTESLEEPINDICATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_REMOTESLEEPINDICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*The notification that all other nodes on the network are ready to enter Bus-Sleep Mode is only needed for internal purposes of the NM Coordinator.*/ /*Record the remote sleep infomation*/ #if(STD_ON == NM_COORDINATOR_SUPPORT) if((NM_CFG_CHL_CLUSTER_INDEX(nmNetworkHandle) < NM_NUM_OF_CLUSTERS) \ && (NM_CFG_CHL_ACTIVE_COORD(nmNetworkHandle) == TRUE)) { NM_CHL_AWAKE_INFO(nmNetworkHandle) &= (~NM_AWAKE_ACTIVE_RECEIVE); } #endif } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_RemoteSleepCancellation SWS_Nm_00193 * * Description : Notification that the network management has detected that not * all other nodes on the network are longer ready to enter Bus-Sleep Mode. * * Inputs : nmNetworkHandle Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_RemoteSleepCancellation ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_REMOTESLEEPCANCELLATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_REMOTESLEEPCANCELLATION_APIID, NM_E_INVALID_CHANNEL); } else { /*The notification that not all other nodes on the network are longer ready to enter BusSleep Mode is only needed for internal purposes of the NM Coordinator.*/ /*Clear the remote sleep infomation*/ #if(STD_ON == NM_COORDINATOR_SUPPORT) if((NM_CFG_CHL_CLUSTER_INDEX(nmNetworkHandle) < NM_NUM_OF_CLUSTERS) \ && (NM_CFG_CHL_ACTIVE_COORD(nmNetworkHandle) == TRUE)) { /*SWS_Nm_00228*/ if(NM_CFG_CHL_SLEEP_MASTER(nmNetworkHandle) == FALSE) { NM_CHL_AWAKE_INFO(nmNetworkHandle) |= NM_AWAKE_ACTIVE_RECEIVE; } } #endif } } #endif/*#if(STD_ON == NM_REMOTE_SLEEP_IND_ENABLED)*/ #if(STD_ON == NM_COORDINATOR_SUPPORT) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_CoordReadyToSleepIndication SWS_Nm_00254 * * Description : Sets an indication, when the NM Coordinator Sleep Ready bit in * the Control Bit Vector is set * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_CoordReadyToSleepIndication ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_COORDREADYTOSLEEPINDICATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_COORDREADYTOSLEEPINDICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00255*//*SWS_Nm_00280*/ if(NM_COORDINATOR_SYNC_SUPPORT == TRUE) { if((NM_CFG_CHL_CLUSTER_INDEX(nmNetworkHandle) < NM_NUM_OF_CLUSTERS) \ && (NM_CFG_CHL_ACTIVE_COORD(nmNetworkHandle) == FALSE)) { /*SWS_Nm_00261*/ NM_CHL_AWAKE_INFO(nmNetworkHandle) &= (~NM_AWAKE_NO_SLEEPREADYBIT); } } } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_CoordReadyToSleepCancellation SWS_Nm_00272 * * Description : Cancels an indication, when the NM Coordinator Sleep Ready bit * in the Control Bit Vector is set back to 0. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_CoordReadyToSleepCancellation ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_COORDREADYTOSLEEPCANCELLATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_COORDREADYTOSLEEPCANCELLATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00273*//*SWS_Nm_00280*/ if(NM_COORDINATOR_SYNC_SUPPORT == TRUE) { if((NM_CFG_CHL_CLUSTER_INDEX(nmNetworkHandle) < NM_NUM_OF_CLUSTERS) \ && (NM_CFG_CHL_ACTIVE_COORD(nmNetworkHandle) == FALSE)) { /*SWS_Nm_00271*/ NM_CHL_AWAKE_INFO(nmNetworkHandle) |= NM_AWAKE_NO_SLEEPREADYBIT; } } } } #endif/*#if(STD_ON == NM_COORDINATOR_SUPPORT)*/ #if(STD_ON == NM_PN_SUPPORT_ENABLED) #if(STD_ON == NM_SYNC_PNC_SHUTDOWN_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_ForwardSynchronizedPncShutdown SWS_Nm_91009 * * Description : Notification that the network management has received a PN shutdown * message on a particular NM-channel. This is used to grant a nearly * synchronized PNC shutdown across the entire PN topology. * * Inputs : NetworkHandle:Identification of the NM-channel * PncBitVectorPtr:Pointer to the bit vector with all PNC bits set * to "1" which are indicated for a synchronized PNC shutdown * * Outputs : None * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_ForwardSynchronizedPncShutdown ( NetworkHandleType NetworkHandle, P2CONST(uint8, AUTOMATIC, NM_CONST) PncBitVectorPtr ) { uint8 i; uint8 RelevantPnc; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_FORWARDSYNCPNCSHUTDOWN_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_FORWARDSYNCPNCSHUTDOWN_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == PncBitVectorPtr) { NM_DET_REPORT_ERROR(NM_FORWARDSYNCPNCSHUTDOWN_APIID, NM_E_PARAM_POINTER); } else { if(TRUE == NM_CFG_CHL_PN_EN(NetworkHandle)) { SchM_Enter_Nm_NM_EXCLUSIVE_AREA_1(); for(i = (uint8)0; i < NM_CFG_CHL_PNC_VECTOR_LEN(NetworkHandle); i++) { RelevantPnc = (NM_CFG_CHL_PN_FILTER_MASK_VAL(NetworkHandle, i) & PncBitVectorPtr[i]); if((uint8)0 != RelevantPnc) { #if(STD_ON == NM_PNC_ERA_CALC_EN) NM_PN_ERA_DATA(NetworkHandle, i) &= (~RelevantPnc); #endif } } SchM_Exit_Nm_NM_EXCLUSIVE_AREA_1(); /*SWS_Nm_00305*/ ComM_Nm_ForwardSynchronizedPncShutdown(NM_CFG_CHL_COMM_REF(NetworkHandle), PncBitVectorPtr); } } } #endif/*#if(STD_ON == NM_SYNC_PNC_SHUTDOWN_ENABLED)*/ /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_PncBitVectorRxIndication SWS_Nm_91006 * * Description : Indication that a bus specific network management has received * a NM message on a particular NM-channel that contain a PNC bit * vector. This is used to aggregate the external PNC requests. * * Inputs : NetworkHandle:Identification of the NM-channel * PncBitVectorPtr:Pointer to the bit vector with all PNC bits set * to "1" of external requested PNCs * * Outputs : RelevantPncRequestDetectedPtr:Pointer to a boolean variable which * indicates, if a relevant PNC request is available in the * given PncBitVector * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_PncBitVectorRxIndication ( NetworkHandleType NetworkHandle, P2CONST(uint8, AUTOMATIC, NM_CONST) PncBitVectorPtr, P2VAR(boolean, AUTOMATIC, NM_APPL_DATA) RelevantPncRequestDetectedPtr ) { uint8 i; uint8 RelevantPnc; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_PNCBITVECTORRXINDICATION_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_PNCBITVECTORRXINDICATION_APIID, NM_E_INVALID_CHANNEL); } else if((NULL_PTR == PncBitVectorPtr) || (NULL_PTR == RelevantPncRequestDetectedPtr)) { NM_DET_REPORT_ERROR(NM_PNCBITVECTORRXINDICATION_APIID, NM_E_PARAM_POINTER); } else { if(TRUE == NM_CFG_CHL_PN_EN(NetworkHandle)) { SchM_Enter_Nm_NM_EXCLUSIVE_AREA_0(); *RelevantPncRequestDetectedPtr = FALSE; /*SWS_Nm_00308*/ for(i = (uint8)0; i < NM_CFG_CHL_PNC_VECTOR_LEN(NetworkHandle); i++) { /*SWS_Nm_00311*/ RelevantPnc = (NM_CFG_CHL_PN_FILTER_MASK_VAL(NetworkHandle, i) & PncBitVectorPtr[i]); if((uint8)0 != RelevantPnc) { /*SWS_Nm_00312*/ *RelevantPncRequestDetectedPtr = TRUE; /*SWS_Nm_00302*//*SWS_Nm_00313*//*SWS_Nm_00330*/ NM_PN_EIRA_NEW(i) |= RelevantPnc; #if(STD_ON == NM_PNC_ERA_CALC_EN) /*SWS_Nm_00322*//*SWS_Nm_00323*/ NM_PN_ERA_NEW(NetworkHandle, i) |= RelevantPnc; #endif } } SchM_Exit_Nm_NM_EXCLUSIVE_AREA_0(); } } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_PncBitVectorTxIndication SWS_Nm_91008 * * Description : Function called by Nms to request the aggregated internal * PNC requests for transmission within the Nm message. * * Inputs : NetworkHandle:Identification of the NM-channel * * Outputs : PncBitVectorPtr:Pointer to the bit vector with all PNC bits set * to "1" of internal requested PNCs * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_PncBitVectorTxIndication ( NetworkHandleType NetworkHandle, P2VAR(uint8, AUTOMATIC, NM_APPL_DATA) PncBitVectorPtr ) { uint8 i; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_PNCBITVECTORTXINDICATION_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_PNCBITVECTORTXINDICATION_APIID, NM_E_INVALID_CHANNEL); } else if(NULL_PTR == PncBitVectorPtr) { NM_DET_REPORT_ERROR(NM_PNCBITVECTORTXINDICATION_APIID, NM_E_PARAM_POINTER); } else { if(TRUE == NM_CFG_CHL_PN_EN(NetworkHandle)) { SchM_Enter_Nm_NM_EXCLUSIVE_AREA_0(); /*SWS_Nm_00332*/ for(i = (uint8)0; i < NM_CFG_CHL_PNC_VECTOR_LEN(NetworkHandle); i++) { PncBitVectorPtr[i] = NM_PN_IRA_DATA(NetworkHandle, i); /*SWS_Nm_00302*//*SWS_Nm_00314*//*SWS_Nm_00330*/ NM_PN_EIRA_NEW(i) |= NM_PN_IRA_DATA(NetworkHandle, i); } SchM_Exit_Nm_NM_EXCLUSIVE_AREA_0(); } } } #if(STD_ON == NM_WAKEUP_CHECK_VALID_WITH_PN) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_CheckIfContainsValidPN * * Description : The function is called by the underlying if module to check whether * the received data contains a valid PN. * * Inputs : NetworkHandle:Identification of the NM-channel * PduInfoPtr: received data * * Outputs : TRUE:Indicate that the received data contains a valid PN. * FALSE:not contain valid PN. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(boolean, NM_CODE) Nm_CheckIfContainsValidPN ( NetworkHandleType NetworkHandle, P2CONST(PduInfoType, AUTOMATIC, NM_APPL_DATA) PduInfoPtr ) { boolean ret = FALSE; uint8 i; uint8 RelevantPnc; uint8* PncBitVectorPtr; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_CANIFCHECKPNVALID_APIID, NM_E_UNINIT); } else if(NetworkHandle >= NM_NUM_OF_CHANNELS) { /*do nothing*/ } else if((NULL_PTR == PduInfoPtr) || (NULL_PTR == (PduInfoPtr->SduDataPtr))) { NM_DET_REPORT_ERROR(NM_CANIFCHECKPNVALID_APIID, NM_E_PARAM_POINTER); } else if((NM_CFG_CHL_PNC_VECTOR_LEN(NetworkHandle) + NM_PNC_BIT_VECTOR_OFFSET) > (PduInfoPtr->SduLength)) { /*do nothing*/ } else { if(TRUE == NM_CFG_CHL_PN_EN(NetworkHandle)) { PncBitVectorPtr = &(PduInfoPtr->SduDataPtr[NM_PNC_BIT_VECTOR_OFFSET]); for(i = (uint8)0; i < NM_CFG_CHL_PNC_VECTOR_LEN(NetworkHandle); i++) { RelevantPnc = (NM_CFG_CHL_PN_FILTER_MASK_VAL(NetworkHandle, i) & PncBitVectorPtr[i]); if((uint8)0 != RelevantPnc) { ret = TRUE; break; } } } } return ret; } #endif #endif/*#if(STD_ON == NM_PN_SUPPORT_ENABLED)*/ /*SWS_Nm_00164*/ #if(STD_ON == NM_PDU_RXINDICATION_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_PduRxIndication SWS_Nm_00112 * * Description : Notification that a NM message has been received. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_PduRxIndication ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_PDURXINDICATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_PDURXINDICATION_APIID, NM_E_INVALID_CHANNEL); } else { Nm_PduRxIndication_Callout(nmNetworkHandle); } } #endif /*SWS_Nm_00165*/ #if(STD_ON == NM_STATE_CHANGE_IND_ENABLED) /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_StateChangeNotification SWS_Nm_00114 * * Description : Notification that the state of the lower layer has changed. * * Inputs : nmNetworkHandle:Identification of the NM-channel * nmPreviousState, nmCurrentState * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_StateChangeNotification ( NetworkHandleType nmNetworkHandle, Nm_StateType nmPreviousState, Nm_StateType nmCurrentState ) { Nm_StateType NmState = nmCurrentState; if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_STATECHANGENOTIFICATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_STATECHANGENOTIFICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00249*/ #if(STD_ON == NM_COM_SUPPORT) if(NM_CFG_CHL_STATE_REPORT(nmNetworkHandle) == TRUE) { (void)Com_SendSignal(NM_CFG_CHL_STATE_SIG_REF(nmNetworkHandle), &NmState); } #endif /*SWS_Nm_00487*/ #if(STD_ON == NM_BSWM_SUPPORT) BswM_Nm_StateChangeNotification(nmNetworkHandle, nmCurrentState); #endif /*Here the Callout function is not an AUTOSAR Nm requirement, but a custom requirement, in order to inform the application of the Nm states.*/ Nm_StateChangeNotification_Callout(nmNetworkHandle, nmPreviousState, nmCurrentState); } } #endif /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_RepeatMessageIndication SWS_Nm_00230 * * Description : Service to indicate that an NM message with set Repeat Message * Request Bit has been received. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_RepeatMessageIndication ( NetworkHandleType nmNetworkHandle, boolean pnLearningBitSet ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_STATECHANGENOTIFICATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_STATECHANGENOTIFICATION_APIID, NM_E_INVALID_CHANNEL); } else { #if(STD_ON == NM_DYN_PNC_SUPPORT) /*SWS_Nm_00504*/ if(TRUE == NM_CFG_CHL_DYN_PNC_EN(nmNetworkHandle)) { ComM_Nm_PncLearningBitIndication(NM_CFG_CHL_COMM_REF(nmNetworkHandle)); } #endif Nm_RepeatMessageIndication_Callout(nmNetworkHandle, pnLearningBitSet); } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_TxTimeoutException SWS_Nm_00234 * * Description : Service to indicate that an attempt to send an NM message failed. * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_TxTimeoutException ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_TXTIMEOUTEXCEPTION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_TXTIMEOUTEXCEPTION_APIID, NM_E_INVALID_CHANNEL); } else { Nm_TxTimeoutException_Callout(nmNetworkHandle); } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_CarWakeUpIndication SWS_Nm_00250 * * Description : This function is called by a Nm to indicate reception of a CWU request * * Inputs : nmNetworkHandle:Identification of the NM-channel * * Outputs : None. * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_CarWakeUpIndication ( NetworkHandleType nmNetworkHandle ) { if(!NM_IS_INITIALIZED()) { NM_DET_REPORT_ERROR(NM_CARWAKEUPINDICATION_APIID, NM_E_UNINIT); } else if(nmNetworkHandle >= NM_NUM_OF_CHANNELS) { NM_DET_REPORT_ERROR(NM_CARWAKEUPINDICATION_APIID, NM_E_INVALID_CHANNEL); } else { /*SWS_Nm_00251*/ if(NM_CAR_WAKEUP_RX_ENABLED == TRUE) { /*ECUC_Nm_00234*/ if(NM_CAR_WAKEUP_CALLOUT != NULL_PTR) { /*SWS_Nm_00252*//*SWS_Nm_00291*/ NM_CAR_WAKEUP_CALLOUT(nmNetworkHandle); } #if(STD_ON == NM_BSWM_SUPPORT) else { /*SWS_Nm_00285*/ BswM_Nm_CarWakeUpIndication(nmNetworkHandle); } #endif } } } /* BEGIN_FUNCTION_HDR ******************************************************************************** * Function Name: Nm_MainFunction SWS_Nm_00118 * * Description : This function implements the processes of the NM Interface, which * need a fix cyclic scheduling. * * Inputs : None * * Outputs : None * * Limitations : None ******************************************************************************** END_FUNCTION_HDR*/ FUNC(void, NM_CODE) Nm_MainFunction ( void ) { if(NM_IS_INITIALIZED()) { /*SWS_Nm_00279*/ #if(STD_ON == NM_COORDINATOR_SUPPORT) Nm_S_CoodinatorMainFunction(); #endif #if(STD_ON == NM_PN_SUPPORT_ENABLED) /*SWS_Nm_00318*/ Nm_S_PnEiraMainFunction(); #if(STD_ON == NM_PNC_ERA_CALC_EN) /*SWS_Nm_00324*/ Nm_S_PnEraMainFunction(); #endif #endif } } #define NM_STOP_SEC_CODE #include "Nm_MemMap.h"