1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
17 #if defined(USE_CANNM)
\r
21 #include "Nm_Internal.h"
\r
23 /* Globally fulfilled requirements */
\r
27 const Nm_ConfigType* Nm_ConfigPtr;
\r
29 /** Initializes the NM Interface. */
\r
30 void Nm_Init( const Nm_ConfigType * const nmConfigPtr ){
\r
31 Nm_ConfigPtr = nmConfigPtr;
\r
34 /** This service returns the version information of this module */
\r
35 void Nm_GetVersionInfo( Std_VersionInfoType* nmVerInfoPtr ){}
\r
37 /** This function calls the <BusNm>_PassiveStartUp function
\r
38 * (e.g. CanNm_PassiveStartUp function is called if channel is configured as CAN). */
\r
39 Nm_ReturnType Nm_PassiveStartUp( const NetworkHandleType NetworkHandle ){
\r
40 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
41 NM_CALL_BUSNM(PassiveStartUp, ChannelConf);
\r
44 /** This function calls the <BusNm>_NetworkRequest
\r
45 * (e.g. CanNm_NetworkRequest function is called if channel is configured as CAN). */
\r
46 Nm_ReturnType Nm_NetworkRequest( const NetworkHandleType NetworkHandle ){
\r
47 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
48 NM_CALL_BUSNM(NetworkRequest, ChannelConf)
\r
51 /** This function calls the <BusNm>_NetworkRelease bus specific function
\r
52 * (e.g. CanNm_NetworkRelease function is called if channel is configured as CAN). */
\r
53 Nm_ReturnType Nm_NetworkRelease( const NetworkHandleType NetworkHandle ){
\r
54 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
55 NM_CALL_BUSNM(NetworkRelease, ChannelConf)
\r
58 /** This function calls the CanNm_NetworkRelease bus specific function, to disable
\r
59 * the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service */
\r
60 Nm_ReturnType Nm_DisableCommunication( const NetworkHandleType NetworkHandle ){
\r
61 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
62 NM_CALL_BUSNM(DisableCommunication, ChannelConf)
\r
65 /** This function calls the CanNm_NetworkRequest bus specific function, to enable
\r
66 * the NM PDU transmission ability due to a ISO14229 Communication Control (28hex) service */
\r
67 Nm_ReturnType Nm_EnableCommunication( const NetworkHandleType NetworkHandle ){
\r
68 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
69 NM_CALL_BUSNM(EnableCommunication, ChannelConf)
\r
72 /** Set user data for NM messages transmitted next on the bus.
\r
73 * For that purpose <BusNm>_SetUserData shall be called
\r
74 * (e.g. CanNm_SetUserData function is called if channel is configured as CAN). */
\r
75 #if (NM_USER_DATA_ENABLED == STD_ON)
\r
76 Nm_ReturnType Nm_SetUserData( const NetworkHandleType NetworkHandle, const uint8 * const nmUserDataPtr ){
\r
77 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
78 NM_CALL_BUSNM(SetUserData, ChannelConf, nmUserDataPtr)
\r
82 /** Get user data out of the last successfully received NM message.
\r
83 * For that purpose <BusNm>_GetUserData shall be called
\r
84 * (e.g. CanNm_GetUserData function is called if channel is configured as CAN). */
\r
85 #if (NM_USER_DATA_ENABLED == STD_ON)
\r
86 Nm_ReturnType Nm_GetUserData( const NetworkHandleType NetworkHandle, uint8 * const nmUserDataPtr, uint8 * const nmNodeIdPtr ){
\r
87 /* For some reason the signature of this service differs from its busNm equivalents... */
\r
88 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
89 switch(ChannelConf->BusType) {
\r
90 #if defined(USE_CANNM)
\r
91 case NM_BUSNM_CANNM:
\r
92 NM_BUSNM_GET_USERDATA_AND_NODEID( CanNm, ChannelConf, nmUserDataPtr, nmNodeIdPtr )
\r
94 #if defined(USE_FRNM)
\r
96 NM_BUSNM_GET_USERDATA_AND_NODEID( FrNm, ChannelConf, nmUserDataPtr, nmNodeIdPtr )
\r
98 #if defined(USE_LINNM)
\r
99 case NM_BUSNM_LINNM:
\r
100 NM_BUSNM_GET_USERDATA_AND_NODEID( LinNm, ChannelConf, nmUserDataPtr, nmNodeIdPtr )
\r
102 default: return NM_E_NOT_OK;
\r
107 /** Get the whole PDU data out of the most recently received NM message.
\r
108 * For that purpose CanNm_GetPduData shall be called. */
\r
109 #if ((NM_NODE_ID_ENABLED == STD_ON) || (NM_NODE_DETECTION_ENABLED == STD_ON) || (NM_USER_DATA_ENABLED == STD_ON))
\r
110 Nm_ReturnType Nm_GetPduData( const NetworkHandleType NetworkHandle, uint8 * const nmPduData ){
\r
111 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
112 NM_CALL_BUSNM(GetPduData, ChannelConf, nmPduData)
\r
116 /** Set Repeat Message Request Bit for NM messages transmitted next on the bus.
\r
117 * For that purpose <BusNm>_RepeatMessageRequest shall be called
\r
118 * (e.g. CanNm_RepeatMessageRequest function is called if channel is configured as CAN) */
\r
119 #if (NM_NODE_DETECTION_ENABLED == STD_ON)
\r
120 Nm_ReturnType Nm_RepeatMessageRequest( const NetworkHandleType NetworkHandle ){
\r
121 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
122 NM_CALL_BUSNM(RepeatMessageRequest, ChannelConf)
\r
126 /** Get node identifier out of the last successfully received NM-message.
\r
127 * The function <BusNm>_GetNodeIdentifier shall be called. */
\r
128 #if (NM_NODE_ID_ENABLED == STD_ON)
\r
129 Nm_ReturnType Nm_GetNodeIdentifier( const NetworkHandleType NetworkHandle, uint8 * const nmNodeIdPtr ){
\r
130 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
131 NM_CALL_BUSNM(GetNodeIdentifier, ChannelConf, nmNodeIdPtr)
\r
134 /** Get node identifier configured for the local node.
\r
135 * For that purpose <BusNm>_GetLocalNodeIdentifier shall be called
\r
136 * (e.g. CanNm_GetLocalNodeIdentifier function is called if channel is configured as CAN). */
\r
137 Nm_ReturnType Nm_GetLocalNodeIdentifier( const NetworkHandleType NetworkHandle, uint8 * const nmNodeIdPtr ){
\r
138 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
139 NM_CALL_BUSNM(GetLocalNodeIdentifier, ChannelConf, nmNodeIdPtr)
\r
143 /** Check if remote sleep indication takes place or not. This in turn calls the
\r
144 * <BusNm>_CheckRemoteSleepIndication for the bus specific NM layer
\r
145 * (e.g. CanNm_CheckRemoteSleepIndication function is called if channel is configured as CAN). */
\r
146 Nm_ReturnType Nm_CheckRemoteSleepIndication( const NetworkHandleType NetworkHandle, boolean * const nmRemoteSleepIndPtr ){
\r
150 /** Returns the state of the network management. This function in turn calls the
\r
151 * <BusNm>_GetState function (e.g. CanNm_GetState function is called if channel is configured as CAN). */
\r
152 Nm_ReturnType Nm_GetState( const NetworkHandleType NetworkHandle, Nm_StateType* const nmStatePtr, Nm_ModeType* const nmModePtr ){
\r
153 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
154 NM_CALL_BUSNM(GetState, ChannelConf, nmStatePtr, nmModePtr)
\r
157 /** Notification that a NM-message has been received in the Bus-Sleep Mode, what
\r
158 * indicates that some nodes in the network have already entered the Network Mode.
\r
159 * The callback function shall start the network management state machine. */
\r
160 /** @req NM012.partially.1 */
\r
161 void Nm_NetworkStartIndication( const NetworkHandleType NetworkHandle ){
\r
162 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
163 ComM_Nm_NetworkStartIndication(ChannelConf->ComMNetworkHandle);
\r
166 /** Notification that the network management has entered Network Mode. The
\r
167 * callback function shall enable transmission of application messages. */
\r
168 /** @req NM012.partially.2 */
\r
169 void Nm_NetworkMode( const NetworkHandleType NetworkHandle ){
\r
170 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
171 ComM_Nm_NetworkMode(ChannelConf->ComMNetworkHandle);
\r
174 /** Notification that the network management has entered Prepare Bus-Sleep Mode.
\r
175 * The callback function shall disable transmission of application messages. */
\r
176 /** @req NM012.partially.3 */
\r
177 void Nm_PrepareBusSleepMode( const NetworkHandleType NetworkHandle ){
\r
178 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
179 ComM_Nm_PrepareBusSleepMode(ChannelConf->ComMNetworkHandle);
\r
182 /** Notification that the network management has entered Bus-Sleep Mode. */
\r
183 /** @req NM012.partially.4 */
\r
184 void Nm_BusSleepMode( const NetworkHandleType NetworkHandle ){
\r
185 const Nm_ChannelType* ChannelConf = &Nm_ConfigPtr->Channels[NetworkHandle];
\r
186 ComM_Nm_BusSleepMode(ChannelConf->ComMNetworkHandle);
\r
189 /** Notification that a NM message has been received. */
\r
190 void Nm_PduRxIndication( const NetworkHandleType NetworkHandle ){}
\r
192 /** Notification that the CAN Generic NM state has changed. */
\r
193 void Nm_StateChangeNotification(
\r
194 const NetworkHandleType nmNetworkHandle,
\r
195 const Nm_StateType nmPreviousState,
\r
196 const Nm_StateType nmCurrentState ){}
\r
198 /** This function implements the processes of the NM Interface, which need a fix
\r
199 * cyclic scheduling. This function is supplied for the NM coordinator functionality
\r
200 * (Nm020). However, specific implementation may not need it (Nm093) */
\r
202 void Nm_MainFunction(){}
\r