]> rtime.felk.cvut.cz Git - arc.git/blob - include/CanNm.h
Dcm, Dynamic DIDs should be excluded in lookupDid.
[arc.git] / include / CanNm.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\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
9  *\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
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 #ifndef CANNM_H\r
18 #define CANNM_H\r
19 \r
20 #include "ComStack_Types.h"\r
21 #include "NmStack_Types.h"\r
22 #include "CanNm_ConfigTypes.h"\r
23 #include "Modules.h"\r
24 #include "CanNm_Cbk.h"\r
25 \r
26 /** @req CANNM021 */\r
27 #define CANNM_VENDOR_ID  1\r
28 #define CANNM_MODULE_ID  MODULE_ID_CANNM\r
29 \r
30 #define CANNM_AR_MAJOR_VERSION  3\r
31 #define CANNM_AR_MINOR_VERSION  0\r
32 #define CANNM_AR_PATCH_VERSION  1\r
33 \r
34 #define CANNM_SW_MAJOR_VERSION  1\r
35 #define CANNM_SW_MINOR_VERSION  0\r
36 #define CANNM_SW_PATCH_VERSION  0\r
37 \r
38 /** @req CANNM200.configFiles */\r
39 #include "CanNm_Cfg.h"\r
40 \r
41 /** @req CANNM018 */\r
42 #define CANNM_E_NO_INIT                                         0x01u /**< API service used */\r
43 #define CANNM_E_INVALID_CHANNEL                         0x02u /**< API service called with wrong channel handle */\r
44 /** NM-Timeout Timer has abnormally expired outside of the Ready Sleep State;\r
45 it may happen: (1) because of Bus-Off state, (2) if some ECU requests bus communication or node detection shortly\r
46 before the NMTimeout Timer expires so that a NM message can not be transmitted in time;\r
47 this race condition applies to event-triggered systems */\r
48 #define CANNM_E_DEV_NETWORK_TIMEOUT                     0x11u\r
49 #define NM_E_NULL_POINTER                                       0x12u /**< Null pointer has been passed as an argument (Does not apply to function CanNm_Init) */\r
50 \r
51 \r
52 #define CANNM_SERVICEID_INIT                                                            0x00u\r
53 #define CANNM_SERVICEID_PASSIVESTARTUP                                          0x01u\r
54 #define CANNM_SERVICEID_NETWORKREQUEST                                          0x02u\r
55 #define CANNM_SERVICEID_NETWORKRELEASE                                          0x03u\r
56 #define CANNM_SERVICEID_DISABLECOMMUNICATION                            0x0Cu\r
57 #define CANNM_SERVICEID_ENABLECOMMUNICATION                                     0x0Du\r
58 #define CANNM_SERVICEID_SETUSERDATA                                                     0x04u\r
59 #define CANNM_SERVICEID_GETUSERDATA                                                     0x05u\r
60 #define CANNM_SERVICEID_GETNODEIDENTIFIER                                       0x06u\r
61 #define CANNM_SERVICEID_GETLOCALNODEIDENTIFIER                          0x07u\r
62 #define CANNM_SERVICEID_REPEATMESSAGEREQUEST                            0x08u\r
63 #define CANNM_SERVICEID_GETPDUDATA                                                      0x0Au\r
64 #define CANNM_SERVICEID_GETSTATE                                                        0x0Bu\r
65 #define CANNM_SERVICEID_GETVERSIONINFO                                          0xF1u\r
66 #define CANNM_SERVICEID_REQUESTBUSSYNCHRONIZATION                       0xC0u\r
67 #define CANNM_SERVICEID_CHECKREMOTESLEEPINDICATION                      0xD0u\r
68 #define CANNM_SERVICEID_TXCONFIRMATION                                          0x0Fu\r
69 #define CANNM_SERVICEID_RXINDICATION                                            0x10u\r
70 #define CANNM_SERVICEID_ARC_MAINFUNCTION                                        0x13u\r
71 \r
72 #define CANNM_CBV_REPEAT_MESSAGE_REQUEST                                        0x01u  /**< @req CANNM045 */\r
73 \r
74 // Functions called by NM Interface\r
75 // --------------------------------\r
76 \r
77 /** Initialize the complete CanNm module, i.e. all channels which are activated */\r
78 void CanNm_Init( const CanNm_ConfigType * const cannmConfigPtr );\r
79 \r
80 /** Passive startup of the AUTOSAR CAN NM. It triggers the transition from Bus-\r
81   * Sleep Mode to the Network Mode in Repeat Message State.\r
82   * This service has no effect if the current state is not equal to Bus-Sleep Mode. In\r
83   * that case NM_E_NOT_EXECUTED is returned. */\r
84 Nm_ReturnType CanNm_PassiveStartUp( const NetworkHandleType nmChannelHandle );\r
85 \r
86 /** Request the network, since ECU needs to communicate on the bus. Network\r
87   * state shall be changed to \91requested\92 */\r
88 Nm_ReturnType CanNm_NetworkRequest( const NetworkHandleType nmChannelHandle );\r
89 \r
90 /** Release the network, since ECU doesn\92t have to communicate on the bus. Network\r
91   * state shall be changed to \91released\92. */\r
92 Nm_ReturnType CanNm_NetworkRelease( const NetworkHandleType nmChannelHandle );\r
93 \r
94 /** Disable the NM PDU transmission ability due to a ISO14229 Communication\r
95   * Control (28hex) service */\r
96 Nm_ReturnType CanNm_DisableCommunication( const NetworkHandleType nmChannelHandle );\r
97 \r
98 /** Enable the NM PDU transmission ability due to a ISO14229 Communication\r
99   * Control (28hex) service */\r
100 Nm_ReturnType CanNm_EnableCommunication( const NetworkHandleType nmChannelHandle );\r
101 \r
102 /** Set user data for NM messages transmitted next on the bus. */\r
103 Nm_ReturnType CanNm_SetUserData( const NetworkHandleType nmChannelHandle, const uint8* const nmUserDataPtr );\r
104 \r
105 /** Get user data out of the most recently received NM message. */\r
106 Nm_ReturnType CanNm_GetUserData( const NetworkHandleType nmChannelHandle, uint8* const nmUserDataPtr );\r
107 \r
108 /** Get node identifier out of the most recently received NM PDU. */\r
109 Nm_ReturnType CanNm_GetNodeIdentifier( const NetworkHandleType nmChannelHandle, uint8 * const nmNodeIdPtr );\r
110 \r
111 /** Get node identifier configured for the local node. */\r
112 Nm_ReturnType CanNm_GetLocalNodeIdentifier( const NetworkHandleType nmChannelHandle, uint8 * const nmNodeIdPtr );\r
113 \r
114 /** Set Repeat Message Request Bit for NM messages transmitted next on the bus. */\r
115 Nm_ReturnType CanNm_RepeatMessageRequest( const NetworkHandleType nmChannelHandle );\r
116 \r
117 /** Get the whole PDU data out of the most recently received NM message. */\r
118 Nm_ReturnType CanNm_GetPduData( const NetworkHandleType nmChannelHandle, uint8 * const nmPduDataPtr );\r
119 \r
120 /** Returns the state and the mode of the network management. */\r
121 Nm_ReturnType CanNm_GetState( const NetworkHandleType nmChannelHandle, Nm_StateType * const nmStatePtr, Nm_ModeType * const nmModePtr );\r
122 \r
123 /** This service returns the version information of this module. */\r
124 #if ( CANNM_VERSION_INFO_API == STD_ON )\r
125 #define CanNm_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,CANNM)\r
126 #endif /* CANNM_VERSION_INFO_API */\r
127 \r
128 /** Request bus synchronization. */\r
129 Nm_ReturnType CanNm_RequestBusSynchronization( const NetworkHandleType nmChannelHandle );\r
130 \r
131 /** Check if remote sleep indication takes place or not. */\r
132 Nm_ReturnType CanNm_CheckRemoteSleepIndication( const NetworkHandleType nmChannelHandle, boolean * const nmRemoteSleepIndPtr );\r
133 \r
134 \r
135 // Functions called by CAN Interface\r
136 // ---------------------------------\r
137 \r
138 /** This service confirms a previous successfully processed CAN transmit request.\r
139   * This callback service is called by the CanIf and implemented by the CanNm. */\r
140 void CanNm_TxConfirmation( PduIdType canNmTxPduId );\r
141 \r
142 /** This service indicates a successful reception of a received NM message to the\r
143   * CanNm after passing all filters and validation checks.\r
144   * This callback service is called by the CAN Interface and implemented by the CanNm. */\r
145 void CanNm_RxIndication( PduIdType canNmRxPduId, const uint8 *canSduPtr );\r
146 \r
147 \r
148 #endif /* CANNM_H */\r