]> rtime.felk.cvut.cz Git - arc.git/blob - include/CanSM.h
EcuM: Added more on the statemachine
[arc.git] / include / CanSM.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 /** @req CANSM008 */\r
17 \r
18 #ifndef CANSM_H_\r
19 #define CANSM_H_\r
20 \r
21 #include "ComStack_Types.h"       /**< @req CANSM238 */\r
22 #include "ComM.h"\r
23 #include "CanSM_ConfigTypes.h"\r
24 #include "Modules.h"\r
25 \r
26 #define CANSM_VENDOR_ID                 1\r
27 #define CANSM_MODULE_ID                 MODULE_ID_CANSM\r
28 \r
29 #define CANSM_AR_MAJOR_VERSION  1\r
30 #define CANSM_AR_MINOR_VERSION  0\r
31 #define CANSM_AR_PATCH_VERSION  1\r
32 \r
33 #define CANSM_SW_MAJOR_VERSION  1\r
34 #define CANSM_SW_MINOR_VERSION  0\r
35 #define CANSM_SW_PATCH_VERSION  0\r
36 \r
37 #include "CanSM_Cfg.h"             /**< @req CANSM239  @req CANSM025.configuration */\r
38 \r
39 \r
40 #define CANSM_E_UNINIT                                  0x01    /**< API service used without module initialization */\r
41 #define CANSM_E_PARAM_POINTER                   0x02    /**< API service called with wrong pointer */\r
42 #define CANSM_E_INVALID_NETWORK_HANDLE  0x03    /**< API service called with wrong parameter */\r
43 #define CANSM_E_INVALID_NETWORK_MODE    0x04    /**< API service called with wrong parameter */\r
44 \r
45 \r
46 #define CANSM_SERVICEID_INIT                                    0x00\r
47 #define CANSM_SERVICEID_GETVERSIONINFO                  0x01\r
48 #define CANSM_SERVICEID_REQUESTCOMMODE                  0x02\r
49 #define CANSM_SERVICEID_GETCURRENTCOMMODE               0x03\r
50 #define CANSM_SERVICEID_CONTROLLERBUSOFF                0x04\r
51 #define CANSM_SERVICEID_MAINFUNCTION                    0x05\r
52 \r
53 \r
54 /** This type shall define the states of the network mode state machine. */\r
55 typedef enum {\r
56         CANSM_UNINITED,\r
57         CANSM_NO_COMMUNICATION,\r
58         CANSM_SILENT_COMMUNICATION,\r
59         CANSM_FULL_COMMUNICATION\r
60 } CanSM_NetworkModeStateType;\r
61 \r
62 /** This type shall define the states of the bus-off recovery state machine. */\r
63 typedef enum {\r
64         CANSM_BOR_IDLE, /**< Idle state */\r
65         CANSM_BOR_CHECK, /**<  Initial bus-off check at beginning of full-communication */\r
66         CANSM_BOR_NO_BUS_OFF, /**<  Regular state during full-communication without detected bus-off events */\r
67         CANSM_BOR_TXOFF_L1, /**<  Bus-off recovery level 1 state, TX disabled */\r
68         CANSM_BOR_CHECK_L1, /**<  Bus-off recovery level 1 state, TX enabled again */\r
69         CANSM_BOR_TXOFF_L2, /**<  Bus-off recovery level 2 state, TX disabled */\r
70         CANSM_BOR_CHECK_L2 /**<  Bus-off recovery level 2 state, TX enabled again */\r
71 } CanSM_BusOffRecoveryStateType; /** @req CANSM169 */\r
72 \r
73 /** @req CANSM037 */\r
74 \r
75 \r
76 /** This service puts out the version information of this module */\r
77 /** @req CANSM024  @req CANSM180 */\r
78 #if (CANSM_VERSION_INFO_API == STD_ON)\r
79 #define CanSM_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,CANSM)\r
80 #endif\r
81 \r
82 /** This service shall change the communication mode of a CAN network to the requested one. */\r
83 /** @req CANSM062 */\r
84 Std_ReturnType CanSM_RequestComMode( NetworkHandleType NetworkHandle, ComM_ModeType ComM_Mode );\r
85 \r
86 /** This service shall put out the current communication mode of a CAN network. */\r
87 /** @req CANSM063 */\r
88 Std_ReturnType CanSM_GetCurrentComMode( NetworkHandleType NetworkHandle, ComM_ModeType* ComM_ModePtr );\r
89 \r
90 /** Init function for CanSM */\r
91 /** @req CANSM023 */\r
92 void CanSM_Init( const CanSM_ConfigType* ConfigPtr );\r
93 \r
94 /** Scheduled function of the CanSM */\r
95 /** @req CANSM065 */\r
96 void CanSM_MainFunction(void);\r
97 \r
98 \r
99 \r
100 \r
101 \r
102 #endif /* CANSM_H_ */\r