]> rtime.felk.cvut.cz Git - linux-lin.git/blob - misc/tty_lin_master/lin_common.h
Userspace LIN master: Provide state encapsulation to test kernel code.
[linux-lin.git] / misc / tty_lin_master / lin_common.h
1 #ifndef _LIN_COMMON_H
2 #define _LIN_COMMON_H
3
4 #include <stdint.h>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10
11 /* maximum buffer len to store whole LIN message*/
12 #define SLLIN_DATA_MAX   8
13 #define SLLIN_BUFF_LEN  (1 /*break*/ + 1 /*sync*/ + 1 /*ID*/ + \
14                          SLLIN_DATA_MAX + 1 /*checksum*/)
15 #define SLLIN_BUFF_BREAK 0
16 #define SLLIN_BUFF_SYNC  1
17 #define SLLIN_BUFF_ID    2
18 #define SLLIN_BUFF_DATA  3
19
20 extern const unsigned char sllin_id_parity_table[64];
21
22 struct sllin_tty;
23
24 struct sllin {
25         /* Various fields. */
26         struct sllin_tty        *tty;           /* ptr to TTY structure      */
27
28         /* LIN message buffer and actual processed data counts */
29         unsigned char           rx_buff[SLLIN_BUFF_LEN]; /* LIN Rx buffer */
30         unsigned char           tx_buff[SLLIN_BUFF_LEN]; /* LIN Tx buffer */
31         int                     rx_expect;      /* expected number of Rx chars */
32         int                     rx_lim;         /* maximum Rx chars for ID  */
33         int                     rx_cnt;         /* message buffer Rx fill level  */
34         int                     tx_lim;         /* actual limit of bytes to Tx */
35         int                     tx_cnt;         /* number of already Tx bytes */
36         char                    lin_master;     /* node is a master node */
37         int                     lin_baud;       /* LIN baudrate */
38         int                     lin_break_baud; /* Baudrate used for break send */
39         int                     lin_state;      /* state */
40         int                     id_to_send;     /* there is ID to be sent */
41
42         unsigned long           flags;          /* Flag values/ mode etc     */
43 #define SLF_INUSE               0               /* Channel in use            */
44 #define SLF_ERROR               1               /* Parity, etc. error        */
45 #define SLF_RXEVENT             2               /* Rx wake event             */
46 #define SLF_TXEVENT             3               /* Tx wake event             */
47 #define SLF_MSGEVENT            4               /* CAN message to sent       */
48 };
49
50 int sllin_setup_msg(struct sllin *sl, int mode, int id,
51                 unsigned char *data, int len);
52
53
54 #ifdef __cplusplus
55 } /* extern "C"*/
56 #endif
57
58
59 #endif /*_LIN_COMMON_H*/