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
16 /** @addtogroup Lin LIN Driver
\r
20 * API and type definitions for LIN Driver.
\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
34 #include "Std_Types.h"
\r
35 #include "Lin_Cfg.h"
\r
36 #include "ComStack_Types.h"
\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
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
50 /** Represents all valid protected Identifier used by Lin_SendHeader(). */
\r
51 typedef uint8 Lin_FramePidType;
\r
53 /** This type is used to specify the Checksum model to be used for the LIN Frame. */
\r
57 } Lin_FrameCsModelType;
\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
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
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
71 } Lin_FrameResponseType;
\r
73 /** This type is used to specify the number of SDU data bytes to copy. */
\r
74 typedef uint8 Lin_FrameDIType;
\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
79 Lin_FrameCsModelType Cs;
\r
80 Lin_FramePidType Pid;
\r
83 Lin_FrameResponseType Drc;
\r
89 }Lin_DriverStatusType;
\r
92 /** LIN frame operation return value.
\r
93 * Development or production error occurred */
\r
96 /** LIN frame operation return value.
\r
97 * Successful transmission. */
\r
100 /** LIN frame operation return value.
\r
101 * Ongoing transmission (Header or Response). */
\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
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
117 /** LIN frame operation return value.
\r
118 * Reception of correct response. */
\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
126 /** LIN frame operation return value.
\r
127 * Erroneous response reception such as:
\r
130 * - Checksum error or
\r
131 * - Short response */
\r
135 /** LIN frame operation return value.
\r
136 * No response byte has been received so far. */
\r
137 LIN_RX_NO_RESPONSE,
\r
139 /** LIN channel state return value.
\r
140 * LIN channel not initialized. */
\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
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
156 /** @name Service id's */
\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
171 /** @name Error Codes */
\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
180 void Lin_Init( const Lin_ConfigType* Config );
\r
184 void Lin_WakeupValidation( void );
\r
186 void Lin_InitChannel( uint8 Channel, const Lin_ChannelConfigType* Config );
\r
188 void Lin_DeInitChannel( uint8 Channel );
\r
190 Std_ReturnType Lin_SendHeader( uint8 Channel, Lin_PduType* PduInfoPtr );
\r
192 Std_ReturnType Lin_SendResponse( uint8 Channel, Lin_PduType* PduInfoPtr );
\r
194 Std_ReturnType Lin_GoToSleep( uint8 Channel );
\r
196 Std_ReturnType Lin_GoToSleepInternal( uint8 Channel );
\r
198 Std_ReturnType Lin_WakeUp( uint8 Channel );
\r
200 Lin_StatusType Lin_GetStatus( uint8 Channel, uint8** Lin_SduPtr );
\r