]> rtime.felk.cvut.cz Git - arc.git/blob - include/Lin.h
realized I removed some stuff unnecessarely during mpc5606b port
[arc.git] / include / Lin.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 /** @addtogroup Lin LIN Driver\r
17  *  @{ */\r
18 \r
19 /** @file Lin.h\r
20  * API and type definitions for LIN Driver.\r
21  */\r
22 \r
23 #ifndef LIN_H_\r
24 #define LIN_H_\r
25 \r
26 \r
27 #define LIN_SW_MAJOR_VERSION    1\r
28 #define LIN_SW_MINOR_VERSION    0\r
29 #define LIN_SW_PATCH_VERSION    0\r
30 #define LIN_AR_MAJOR_VERSION    1\r
31 #define LIN_AR_MINOR_VERSION    2\r
32 #define LIN_AR_PATCH_VERSION    1\r
33 \r
34 #include "Std_Types.h"\r
35 #include "Lin_Cfg.h"\r
36 #include "ComStack_Types.h"\r
37 \r
38 #if (LIN_VERSION_INFO_API == STD_ON)\r
39 void Lin_GetVersionInfo( Std_VersionInfoType *versionInfo );\r
40 #define Lin_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,LIN)\r
41 #endif\r
42 \r
43 /* This is the type of the external data structure containing the overall\r
44  * initialization data for the LIN driver and SFR settings affecting all\r
45  * LIN channels. A pointer to such a structure is provided to the LIN driver\r
46  * initialization routine for configuration of the driver and LIN hardware unit. */\r
47 typedef struct {\r
48 } Lin_ConfigType;\r
49 \r
50 /** Represents all valid protected Identifier used by Lin_SendHeader(). */\r
51 typedef uint8 Lin_FramePidType;\r
52 \r
53 /** This type is used to specify the Checksum model to be used for the LIN Frame. */\r
54 typedef enum {\r
55         LIN_ENHANCED_CS,\r
56         LIN_CLASSIC_CS,\r
57 } Lin_FrameCsModelType;\r
58 \r
59 /** This type is used to specify whether the frame processor is required to transmit the\r
60  *  response part of the LIN frame. */\r
61 typedef enum {\r
62         /** Response is generated from this (master) node */\r
63         LIN_MASTER_RESPONSE=0,\r
64         /** Response is generated from a remote slave node */\r
65         LIN_SLAVE_RESPONSE,\r
66         /** Response is generated from one slave to another slave,\r
67          *  for the master the response will be anonymous, it does not\r
68          *  have to receive the response. */\r
69         IN_SLAVE_TO_SLAVE,\r
70 \r
71 } Lin_FrameResponseType;\r
72 \r
73 /** This type is used to specify the number of SDU data bytes to copy. */\r
74 typedef uint8 Lin_FrameDIType;\r
75 \r
76 /** This Type is used to provide PID, checksum model, data length and SDU pointer\r
77  *  from the LIN Interface to the LIN driver. */\r
78 typedef struct {\r
79         Lin_FrameCsModelType Cs;\r
80         Lin_FramePidType  Pid;\r
81         uint8* SduPtr;\r
82         Lin_FrameDIType DI;\r
83         Lin_FrameResponseType Drc;\r
84 } Lin_PduType;\r
85 \r
86 typedef enum {\r
87         LIN_UNINIT,\r
88         LIN_INIT,\r
89 }Lin_DriverStatusType;\r
90 \r
91 typedef enum {\r
92         /** LIN frame operation return value.\r
93          *  Development or production error occurred */\r
94         LIN_NOT_OK,\r
95 \r
96         /** LIN frame operation return value.\r
97          *  Successful transmission. */\r
98         LIN_TX_OK,\r
99 \r
100         /** LIN frame operation return value.\r
101          *  Ongoing transmission (Header or Response). */\r
102         LIN_TX_BUSY,\r
103 \r
104         /** LIN frame operation return value.\r
105          *  Erroneous header transmission such as:\r
106          *  - Mismatch between sent and read back data\r
107          *  - Identifier parity error or\r
108          *  - Physical bus error */\r
109         LIN_TX_HEADER_ERRORLIN,\r
110 \r
111         /** LIN frame operation return value.\r
112          *  Erroneous response transmission such as:\r
113          *  - Mismatch between sent and read back data\r
114          *  - Physical bus error */\r
115         LIN_TX_ERROR,\r
116 \r
117         /** LIN frame operation return value.\r
118          *  Reception of correct response. */\r
119         LIN_RX_OK,\r
120 \r
121         /** LIN frame operation return value. Ongoing reception: at\r
122          *  least one response byte has been received, but the\r
123          *  checksum byte has not been received. */\r
124         LIN_RX_BUSY,\r
125 \r
126         /** LIN frame operation return value.\r
127          *  Erroneous response reception such as:\r
128          *  - Framing error\r
129          *  - Overrun error\r
130          *  - Checksum error or\r
131          *  - Short response */\r
132         LIN_RX_ERROR,\r
133 \r
134 \r
135         /** LIN frame operation return value.\r
136          *  No response byte has been received so far. */\r
137         LIN_RX_NO_RESPONSE,\r
138 \r
139         /** LIN channel state return value.\r
140          *  LIN channel not initialized. */\r
141         LIN_CH_UNINIT,\r
142 \r
143         /** LIN channel state return value.\r
144          *  Normal operation; the related LIN channel is ready to\r
145          *  transmit next header. No data from previous frame\r
146          *  available (e.g. after initialization) */\r
147         LIN_CH_OPERATIONAL,\r
148 \r
149         /** LIN channel state return value.\r
150          *  Sleep mode operation; in this mode wake-up detection\r
151          *  from slave nodes is enabled. */\r
152         LIN_CH_SLEEP\r
153 \r
154 } Lin_StatusType;\r
155 \r
156 /** @name Service id's */\r
157 //@{\r
158 #define LIN_INIT_SERVICE_ID               0x00\r
159 #define LIN_GETVERSIONINFO_SERVICE_ID     0x01\r
160 #define LIN_WAKEUPVALIDATION_SERVICE_ID   0x0A\r
161 #define LIN_INIT_CHANNEL_SERVICE_ID       0x02\r
162 #define LIN_DEINIT_CHANNEL_SERVICE_ID     0x03\r
163 #define LIN_SEND_HEADER_SERVICE_ID        0x04\r
164 #define LIN_SEND_RESPONSE_SERVICE_ID      0x05\r
165 #define LIN_GO_TO_SLEEP_SERVICE_ID        0x06\r
166 #define LIN_WAKE_UP_SERVICE_ID            0x07\r
167 #define LIN_GETSTATUS_SERVICE_ID          0x08\r
168 #define LIN_GO_TO_SLEEP_INTERNAL_SERVICE_ID 0x09\r
169 //@}\r
170 \r
171 /** @name Error Codes */\r
172 //@{\r
173 #define LIN_E_UNINIT                    0x00\r
174 #define LIN_E_CHANNEL_UNINIT                    0x01\r
175 #define LIN_E_INVALID_CHANNEL                   0x02\r
176 #define LIN_E_INVALID_POINTER                   0x03\r
177 #define LIN_E_STATE_TRANSITION                  0x04\r
178 //@}\r
179 \r
180 void Lin_Init( const Lin_ConfigType* Config );\r
181 \r
182 void Lin_DeInit();\r
183 \r
184 void Lin_WakeupValidation( void );\r
185 \r
186 void Lin_InitChannel(  uint8 Channel,   const Lin_ChannelConfigType* Config );\r
187 \r
188 void Lin_DeInitChannel( uint8 Channel );\r
189 \r
190 Std_ReturnType Lin_SendHeader(  uint8 Channel,  Lin_PduType* PduInfoPtr );\r
191 \r
192 Std_ReturnType Lin_SendResponse(  uint8 Channel,   Lin_PduType* PduInfoPtr );\r
193 \r
194 Std_ReturnType Lin_GoToSleep(  uint8 Channel );\r
195 \r
196 Std_ReturnType Lin_GoToSleepInternal(  uint8 Channel );\r
197 \r
198 Std_ReturnType Lin_WakeUp( uint8 Channel );\r
199 \r
200 Lin_StatusType Lin_GetStatus( uint8 Channel, uint8** Lin_SduPtr );\r
201 \r
202 #endif\r
203 /** @} */\r
204 \r
205 \r
206 \r
207 \r