]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/rpp/include/sys/ti_drv_lin.h
8baa64e9e54ef08d1170d62616fca3791870acc6
[pes-rpp/rpp-test-sw.git] / rpp / lib / rpp / include / sys / ti_drv_lin.h
1 /** @file lin.h
2 *   @brief LIN Driver Definition File
3 *   @date 15.Mar.2012
4 *   @version 03.01.00
5 *
6 */
7
8 /* (c) Texas Instruments 2009-2012, All rights reserved. */
9
10
11 #ifndef __LIN_H__
12 #define __LIN_H__
13
14 #include "base.h"
15 #include "sys/ti_drv_gio.h"
16
17
18 /** @def LIN_BREAK_INT
19 *   @brief Alias for break detect interrupt flag
20 *
21 *   Used with linEnableNotification, linDisableNotification.
22 */
23 #define LIN_BREAK_INT 0x00000001U
24
25
26 /** @def LIN_WAKEUP_INT
27 *   @brief Alias for wakeup interrupt flag
28 *
29 *   Used with linEnableNotification, linDisableNotification.
30 */
31 #define LIN_WAKEUP_INT 0x00000002U
32
33
34 /** @def LIN_TO_INT
35 *   @brief Alias for time out interrupt flag
36 *
37 *   Used with linEnableNotification, linDisableNotification.
38 */
39 #define LIN_TO_INT 0x00000010U
40
41
42 /** @def LIN_TOAWUS_INT
43 *   @brief Alias for time out after wakeup signal interrupt flag
44 *
45 *   Used with linEnableNotification, linDisableNotification.
46 */
47 #define LIN_TOAWUS_INT 0x00000040U
48
49
50 /** @def LIN_TOA3WUS_INT
51 *   @brief Alias for time out after 3 wakeup signals interrupt flag
52 *
53 *   Used with linEnableNotification, linDisableNotification.
54 */
55 #define LIN_TOA3WUS_INT 0x00000080U
56
57
58 /** @def LIN_TX_READY
59 *   @brief Alias for transmit buffer ready flag
60 *
61 *   Used with linIsTxReady.
62 */
63 #define LIN_TX_READY 0x00000100U
64
65
66 /** @def LIN_RX_INT
67 *   @brief Alias for receive buffer ready interrupt flag
68 *
69 *   Used with linEnableNotification, linDisableNotification.
70 */
71 #define LIN_RX_INT 0x00000200U
72
73
74 /** @def LIN_ID_INT
75 *   @brief Alias for received matching identifier interrupt flag
76 *
77 *   Used with linEnableNotification, linDisableNotification.
78 */
79 #define LIN_ID_INT 0x00002000U
80
81
82 /** @def LIN_PE_INT
83 *   @brief Alias for parity error interrupt flag
84 *
85 *   Used with linEnableNotification, linDisableNotification.
86 */
87 #define LIN_PE_INT 0x01000000U
88
89
90 /** @def LIN_OE_INT
91 *   @brief Alias for overrun error interrupt flag
92 *
93 *   Used with linEnableNotification, linDisableNotification.
94 */
95 #define LIN_OE_INT 0x02000000U
96
97
98 /** @def LIN_FE_INT
99 *   @brief Alias for framming error interrupt flag
100 *
101 *   Used with linEnableNotification, linDisableNotification.
102 */
103 #define LIN_FE_INT 0x04000000U
104
105
106 /** @def LIN_NRE_INT
107 *   @brief Alias for no response error interrupt flag
108 *
109 *   Used with linEnableNotification, linDisableNotification.
110 */
111 #define LIN_NRE_INT 0x08000000U
112
113
114 /** @def LIN_ISFE_INT
115 *   @brief Alias for inconsistent sync field error interrupt flag
116 *
117 *   Used with linEnableNotification, linDisableNotification.
118 */
119 #define LIN_ISFE_INT 0x10000000U
120
121
122 /** @def LIN_CE_INT
123 *   @brief Alias for checksum error interrupt flag
124 *
125 *   Used with linEnableNotification, linDisableNotification.
126 */
127 #define LIN_CE_INT 0x20000000U
128
129
130 /** @def LIN_PBE_INT
131 *   @brief Alias for physical bus error interrupt flag
132 *
133 *   Used with linEnableNotification, linDisableNotification.
134 */
135 #define LIN_PBE_INT 0x40000000U
136
137
138 /** @def LIN_BE_INT
139 *   @brief Alias for bit error interrupt flag
140 *
141 *   Used with linEnableNotification, linDisableNotification.
142 */
143 #define LIN_BE_INT 0x80000000U
144
145
146 /** @struct linBase
147 *   @brief LIN Register Definition
148 *
149 *   This structure is used to access the LIN module egisters.
150 */
151 /** @typedef linBASE_t
152 *   @brief LIN Register Frame Type Definition
153 *
154 *   This type is used to access the LIN Registers.
155 */
156
157 enum linPinSelect
158 {
159     PIN_LIN_TX   = 0,
160     PIN_LIN_RX = 1
161 };
162
163 /** @struct linBase
164 *   @brief LIN Base Register Definition
165 *
166 *   This structure is used to access the LIN module egisters.
167 */
168 /** @typedef linBASE_t
169 *   @brief LIN  Register Frame Type Definition
170 *
171 *   This type is used to access the LIN Registers.
172 */
173
174 typedef volatile struct linBase
175 {
176     uint32_t      GCR0;         /**< 0x0000: Global control register 0              */
177     uint32_t      GCR1;         /**< 0x0004: Global control register 1              */
178     uint32_t      GCR2;         /**< 0x0008: Global control register 2              */
179     uint32_t      SETINT;       /**< 0x000C: Set interrupt enable register          */
180     uint32_t      CLRINT;       /**< 0x0010: Clear interrupt enable register        */
181     uint32_t      SETINTLVL;    /**< 0x0014: Set interrupt level register           */
182     uint32_t      CLRINTLVL;    /**< 0x0018: Set interrupt level register           */
183     uint32_t      FLR;          /**< 0x001C: interrupt flag register                */
184     uint32_t      INTVECT0;     /**< 0x0020: interrupt vector Offset 0              */
185     uint32_t      INTVECT1;     /**< 0x0024: interrupt vector Offset 1              */
186 #if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))
187     uint32_t      CHAR   :  3U; /**< 0x0028: Character length control register      */
188     uint32_t             : 13U; /**< 0x0028: Reserved                               */
189     uint32_t      LENGTH :  3U; /**< 0x0028: Length control register                */
190     uint32_t             : 13U; /**< 0x0028: Reserved                               */
191 #else
192     uint32_t             : 13U; /**< 0x0028: Reserved                               */
193     uint32_t      LENGTH :  3U; /**< 0x0028: Length control register                */
194     uint32_t             : 13U; /**< 0x0028: Reserved                               */
195     uint32_t      CHAR   :  3U; /**< 0x0028: Character length control register      */
196 #endif
197     uint32_t      BRSR;         /**< 0x002C: Baud rate selection register           */
198     uint32_t      ED;           /**< 0x0030: Emulation register                     */
199     uint32_t      RD;           /**< 0x0034: Receive data register                  */
200     uint32_t      TD;           /**< 0x0038: Transmit data register                 */
201     uint32_t      FUN;          /**< 0x003C: Pin function register                  */
202     uint32_t      DIR;          /**< 0x0040: Pin direction register                 */
203     uint32_t      DIN;          /**< 0x0044: Pin data in register                   */
204     uint32_t      DOUT;         /**< 0x0048: Pin data out register                  */
205     uint32_t      SET;          /**< 0x004C: Pin data set register                  */
206     uint32_t      CLR;          /**< 0x0050: Pin data clr register                  */
207     uint32_t      ODR;          /**< 0x0054: Pin open drain output enable register  */
208     uint32_t      PD;           /**< 0x0058: Pin pullup/pulldown disable register   */
209     uint32_t      PSL;          /**< 0x005C: Pin pullup/pulldown selection register */
210     uint32_t      COMP;         /**< 0x0060: Compare register                       */
211     uint8_t       RDx[8U];      /**< 0x0064-0x0068: RX buffer register              */
212     uint32_t      MASK;         /**< 0x006C: Mask register                          */
213 #if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))
214     uint8_t       IDBYTE;       /**< 0x0070: Identifier byte register               */
215     uint8_t       IDSTB;        /**< 0x0070: Identifier slave task byte register    */
216     uint8_t       RXID;         /**< 0x0070: Received identifier register           */
217     uint32_t      : 8U;         /**< 0x0070: Reserved                               */
218 #else
219     uint32_t      : 8U;         /**< 0x0070: Reserved                               */
220     uint8_t       RXID;         /**< 0x0070: Received identifier register           */
221     uint8_t       IDSTB;        /**< 0x0070: Identifier Slave task byte register    */
222     uint8_t       IDBYTE;       /**< 0x0070: Identifier byte register               */
223 #endif
224     uint8_t       TDx[8U];      /**< 0x0074-0x0078: TX buffer register              */
225     uint32_t      MBRSR;        /**< 0x007C: Maximum baud rate selection register   */
226     uint32_t      SL;           /**< 0x0080: Pin slew rate register                 */
227     uint32_t      : 32U;        /**< 0x0084: Reserved                               */
228     uint32_t      : 32U;        /**< 0x0088: Reserved                               */
229     uint32_t      : 32U;        /**< 0x008C: Reserved                               */
230     uint32_t      IODFTCTRL;    /**< 0x0090: IODFT loopback register                */
231 } linBASE_t;
232
233
234 /** @def linREG
235 *   @brief LIN Register Frame Pointer
236 *
237 *   This pointer is used by the LIN driver to access the lin module registers.
238 */
239 #define linREG ((linBASE_t *)0xFFF7E400U)
240
241
242 /** @def linPORT
243 *   @brief LIN GIO Port Register Pointer
244 *
245 *   Pointer used by the GIO driver to access I/O PORT of LIN
246 *   (use the GIO drivers to access the port pins).
247 */
248 #define linPORT ((gioPORT_t *)0xFFF7E440U)
249
250 /* LIN Interface Functions */
251 void     linInit(void);
252 void     linSetFunctional(linBASE_t *lin, uint32_t port);
253 void     linSendHeader(linBASE_t *lin, uint8_t identifier);
254 void     linSendWakupSignal(linBASE_t *lin);
255 void     linEnterSleep(linBASE_t *lin);
256 void     linSoftwareReset(linBASE_t *lin);
257 uint32_t linIsTxReady(linBASE_t *lin);
258 void     linSetLength(linBASE_t *lin, uint32_t length);
259 void     linSend(linBASE_t *lin, const uint8_t *data);
260 uint32_t linIsRxReady(linBASE_t *lin);
261 uint32_t linTxRxError(linBASE_t *lin);
262 uint32_t linGetIdentifier(linBASE_t *lin);
263 void     linGetData(linBASE_t *lin, uint8_t * const data);
264 void     linEnableNotification(linBASE_t *lin, uint32_t flags);
265 void     linDisableNotification(linBASE_t *lin, uint32_t flags);
266 void     linEnableLoopback(linBASE_t *lin, Loopbacktype_t Loopbacktype);
267 void     linDisableLoopback(linBASE_t *lin);
268
269 /** @fn void linNotification(linBASE_t *lin, uint32_t flags)
270 *   @brief Interrupt callback
271 *   @param[in] lin   - lin module base address
272 *   @param[in] flags - copy of error interrupt flags
273 *
274 * This is a callback that is provided by the application and is called apon
275 * an interrupt.  The parameter passed to the callback is a copy of the
276 * interrupt flag register.
277 */
278 void linNotification(linBASE_t *lin, uint32_t flags);
279 #endif