]> rtime.felk.cvut.cz Git - arc.git/blob - include/CanNm_Internal.h
Merge branch 'mikulka' of git@rtime.felk.cvut.cz:arc into mikulka
[arc.git] / include / CanNm_Internal.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_INTERNAL_H_\r
18 #define CANNM_INTERNAL_H_\r
19 \r
20 /** @req CANNM188  @req CANNM196  @req CANNM199    */\r
21 #if (CANNM_DEV_ERROR_DETECT == STD_ON)\r
22 #define CANNM_DET_REPORTERROR(serviceId, errorId, instanceId)                   \\r
23         Det_ReportError(MODULE_ID_CANNM, (uint8)instanceId, serviceId, errorId)\r
24 \r
25 #define CANNM_VALIDATE(expression, serviceId, errorId, instanceId, ...) \\r
26         if (!(expression)) {                                                                    \\r
27                 CANNM_DET_REPORTERROR(serviceId, errorId, instanceId);                  \\r
28                 return __VA_ARGS__;                                                                     \\r
29         }\r
30 \r
31 #else\r
32 #define CANNM_DET_REPORTERROR(...)\r
33 #define CANNM_VALIDATE(...)\r
34 #endif\r
35 \r
36 #define CANNM_VALIDATE_INIT(serviceID, ...)                                     \\r
37                 CANNM_VALIDATE((CanNm_Internal.InitStatus == CANNM_INIT), serviceID, CANNM_E_NO_INIT, 0, __VA_ARGS__)\r
38 \r
39 /** @req CANNM192 */\r
40 #define CANNM_VALIDATE_CHANNEL(channel, serviceID, ...)                                 \\r
41                 CANNM_VALIDATE( (channel < CANNM_CHANNEL_COUNT), serviceID, CANNM_E_INVALID_CHANNEL, channel, __VA_ARGS__)\r
42 \r
43 #define CANNM_VALIDATE_NOTNULL(ptr, serviceID, ...)     \\r
44                 CANNM_VALIDATE( (ptr != NULL), serviceID, NM_E_NULL_POINTER, 0, __VA_ARGS__)\r
45 \r
46 typedef enum {\r
47         CANNM_INIT,\r
48         CANNM_UNINIT\r
49 } CanNm_InitStatusType;\r
50 \r
51 typedef struct {\r
52         Nm_ModeType                                     Mode;                           /**< @req CANNM092 */\r
53         Nm_StateType                            State;                          /**< @req CANNM094 */\r
54         boolean                                         Requested;\r
55         uint32                                          TimeoutTimeLeft;\r
56         uint32                                          RepeatMessageTimeLeft;\r
57         uint32                                          WaitBusSleepTimeLeft;\r
58         uint32                                          MessageCycleTimeLeft;\r
59         uint32                                          MessageCycleOffsetTimeLeft;\r
60         uint8                                           TxMessageSdu[8];\r
61         uint8                                           RxMessageSdu[8];\r
62 } CanNm_Internal_ChannelType;\r
63 \r
64 typedef struct {\r
65         CanNm_InitStatusType            InitStatus;\r
66         CanNm_Internal_ChannelType      Channels[CANNM_CHANNEL_COUNT];\r
67 } CanNm_InternalType;\r
68 \r
69 /* Timer helpers */\r
70 static inline void CanNm_Internal_TickTimeoutTime( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
71 static inline void CanNm_Internal_TickRepeatMessageTime( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
72 static inline void CanNm_Internal_TickWaitBusSleepTime( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
73 static inline void CanNm_Internal_TickMessageCycleTime( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
74 static inline void CanNm_Internal_ClearCbv( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
75 \r
76 /* Message helpers */\r
77 static inline void CanNm_Internal_TransmitMessage( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
78 static inline uint8 CanNm_Internal_GetUserDataOffset( const CanNm_ChannelType* ChannelConf );\r
79 static inline uint8* CanNm_Internal_GetUserDataPtr( const CanNm_ChannelType* ChannelConf, uint8* MessageSduPtr );\r
80 static inline uint8 CanNm_Internal_GetUserDataLength( const CanNm_ChannelType* ChannelConf );\r
81 \r
82 /* Transition helpers */\r
83 static inline void CanNm_Internal_PrepareBusSleep_to_RepeatMessage( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
84 static inline void CanNm_Internal_PrepareBusSleep_to_BusSleep( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
85 \r
86 static inline void CanNm_Internal_BusSleep_to_RepeatMessage( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
87 static inline void CanNm_Internal_BusSleep_to_BusSleep( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
88 \r
89 static inline void CanNm_Internal_RepeatMessage_to_RepeatMessage( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
90 static inline void CanNm_Internal_RepeatMessage_to_ReadySleep( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
91 static inline void CanNm_Internal_RepeatMessage_to_NormalOperation( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
92 \r
93 static inline void CanNm_Internal_NormalOperation_to_RepeatMessage( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
94 static inline void CanNm_Internal_NormalOperation_to_ReadySleep( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
95 static inline void CanNm_Internal_NormalOperation_to_NormalOperation( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
96 \r
97 static inline void CanNm_Internal_ReadySleep_to_NormalOperation( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
98 static inline void CanNm_Internal_ReadySleep_to_PrepareBusSleep( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
99 static inline void CanNm_Internal_ReadySleep_to_RepeatMessage( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
100 \r
101 static inline void CanNm_Internal_NetworkMode_to_NetworkMode( const CanNm_ChannelType* ChannelConf, CanNm_Internal_ChannelType* ChannelInternal );\r
102 \r
103 \r
104 #endif /* CANNM_INTERNAL_H_ */\r