2 * @brief LIN Driver Definition File
8 /* (c) Texas Instruments 2009-2012, All rights reserved. */
15 #include "sys/ti_drv_gio.h"
18 /** @def LIN_BREAK_INT
19 * @brief Alias for break detect interrupt flag
21 * Used with linEnableNotification, linDisableNotification.
23 #define LIN_BREAK_INT 0x00000001U
26 /** @def LIN_WAKEUP_INT
27 * @brief Alias for wakeup interrupt flag
29 * Used with linEnableNotification, linDisableNotification.
31 #define LIN_WAKEUP_INT 0x00000002U
35 * @brief Alias for time out interrupt flag
37 * Used with linEnableNotification, linDisableNotification.
39 #define LIN_TO_INT 0x00000010U
42 /** @def LIN_TOAWUS_INT
43 * @brief Alias for time out after wakeup signal interrupt flag
45 * Used with linEnableNotification, linDisableNotification.
47 #define LIN_TOAWUS_INT 0x00000040U
50 /** @def LIN_TOA3WUS_INT
51 * @brief Alias for time out after 3 wakeup signals interrupt flag
53 * Used with linEnableNotification, linDisableNotification.
55 #define LIN_TOA3WUS_INT 0x00000080U
59 * @brief Alias for transmit buffer ready flag
61 * Used with linIsTxReady.
63 #define LIN_TX_READY 0x00000100U
67 * @brief Alias for receive buffer ready interrupt flag
69 * Used with linEnableNotification, linDisableNotification.
71 #define LIN_RX_INT 0x00000200U
75 * @brief Alias for received matching identifier interrupt flag
77 * Used with linEnableNotification, linDisableNotification.
79 #define LIN_ID_INT 0x00002000U
83 * @brief Alias for parity error interrupt flag
85 * Used with linEnableNotification, linDisableNotification.
87 #define LIN_PE_INT 0x01000000U
91 * @brief Alias for overrun error interrupt flag
93 * Used with linEnableNotification, linDisableNotification.
95 #define LIN_OE_INT 0x02000000U
99 * @brief Alias for framming error interrupt flag
101 * Used with linEnableNotification, linDisableNotification.
103 #define LIN_FE_INT 0x04000000U
107 * @brief Alias for no response error interrupt flag
109 * Used with linEnableNotification, linDisableNotification.
111 #define LIN_NRE_INT 0x08000000U
114 /** @def LIN_ISFE_INT
115 * @brief Alias for inconsistent sync field error interrupt flag
117 * Used with linEnableNotification, linDisableNotification.
119 #define LIN_ISFE_INT 0x10000000U
123 * @brief Alias for checksum error interrupt flag
125 * Used with linEnableNotification, linDisableNotification.
127 #define LIN_CE_INT 0x20000000U
131 * @brief Alias for physical bus error interrupt flag
133 * Used with linEnableNotification, linDisableNotification.
135 #define LIN_PBE_INT 0x40000000U
139 * @brief Alias for bit error interrupt flag
141 * Used with linEnableNotification, linDisableNotification.
143 #define LIN_BE_INT 0x80000000U
147 * @brief LIN Register Definition
149 * This structure is used to access the LIN module egisters.
151 /** @typedef linBASE_t
152 * @brief LIN Register Frame Type Definition
154 * This type is used to access the LIN Registers.
164 * @brief LIN Base Register Definition
166 * This structure is used to access the LIN module egisters.
168 /** @typedef linBASE_t
169 * @brief LIN Register Frame Type Definition
171 * This type is used to access the LIN Registers.
174 typedef volatile struct linBase
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 */
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 */
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 */
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 */
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 */
235 * @brief LIN Register Frame Pointer
237 * This pointer is used by the LIN driver to access the lin module registers.
239 #define linREG ((linBASE_t *)0xFFF7E400U)
243 * @brief LIN GIO Port Register Pointer
245 * Pointer used by the GIO driver to access I/O PORT of LIN
246 * (use the GIO drivers to access the port pins).
248 #define linPORT ((gioPORT_t *)0xFFF7E440U)
250 /* LIN Interface Functions */
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);
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
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.
278 void linNotification(linBASE_t *lin, uint32_t flags);