26
|
1 |
/* can.h
|
|
2 |
* Header file for the Linux CAN-bus driver.
|
|
3 |
* Written by Arnaud Westenberg email:arnaud@wanadoo.nl
|
|
4 |
* Rewritten for new CAN queues by Pavel Pisa - OCERA team member
|
|
5 |
* email:pisa@cmp.felk.cvut.cz
|
|
6 |
* This software is released under the GPL-License.
|
|
7 |
* Version lincan-0.3 17 Jun 2004
|
|
8 |
*/
|
|
9 |
|
|
10 |
#ifndef _CAN_DRVAPI_T_H
|
|
11 |
#define _CAN_DRVAPI_T_H
|
|
12 |
|
|
13 |
#ifdef __KERNEL__
|
|
14 |
|
|
15 |
#include <linux/time.h>
|
|
16 |
#include <linux/types.h>
|
|
17 |
#include <linux/ioctl.h>
|
|
18 |
|
|
19 |
#else /* __KERNEL__ */
|
|
20 |
|
|
21 |
#include <sys/time.h>
|
|
22 |
#include <sys/types.h>
|
|
23 |
#include <sys/ioctl.h>
|
|
24 |
|
|
25 |
#endif /* __KERNEL__ */
|
|
26 |
|
|
27 |
#include "./canmsg.h"
|
|
28 |
|
|
29 |
#ifdef __cplusplus
|
|
30 |
extern "C" {
|
|
31 |
#endif
|
|
32 |
|
|
33 |
/* CAN ioctl magic number */
|
|
34 |
#define CAN_IOC_MAGIC 'd'
|
|
35 |
|
|
36 |
typedef unsigned long bittiming_t;
|
|
37 |
typedef unsigned short channel_t;
|
|
38 |
|
|
39 |
/**
|
|
40 |
* struct can_baudparams_t - datatype for calling CONF_BAUDPARAMS IOCTL
|
|
41 |
* @flags: reserved for additional flags for chip configuration, should be written -1 or 0
|
|
42 |
* @baudrate: baud rate in Hz
|
|
43 |
* @sjw: synchronization jump width (0-3) prescaled clock cycles
|
|
44 |
* @sampl_pt: sample point in % (0-100) sets (TSEG1+1)/(TSEG1+TSEG2+2) ratio
|
|
45 |
*
|
|
46 |
* The structure is used to configure new set of parameters into CAN controller chip.
|
|
47 |
* If default value of some field should be preserved, fill field by value -1.
|
|
48 |
*/
|
|
49 |
struct can_baudparams_t {
|
|
50 |
long flags;
|
|
51 |
long baudrate;
|
|
52 |
long sjw;
|
|
53 |
long sample_pt;
|
|
54 |
};
|
|
55 |
|
|
56 |
/* CAN ioctl functions */
|
|
57 |
#define CAN_DRV_QUERY _IO(CAN_IOC_MAGIC, 0)
|
|
58 |
#define CAN_DRV_QRY_BRANCH 0 /* returns driver branch value - "LINC" for LinCAN driver */
|
|
59 |
#define CAN_DRV_QRY_VERSION 1 /* returns driver version as (major<<16) | (minor<<8) | patch */
|
|
60 |
#define CAN_DRV_QRY_MSGFORMAT 2 /* format of canmsg_t structure */
|
|
61 |
|
|
62 |
#define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel_t)
|
|
63 |
#define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel_t)
|
|
64 |
//#define CMD_RESET 3
|
|
65 |
|
|
66 |
#define CONF_BAUD _IOW(CAN_IOC_MAGIC, 4, bittiming_t)
|
|
67 |
//#define CONF_ACCM
|
|
68 |
//#define CONF_XTDACCM
|
|
69 |
//#define CONF_TIMING
|
|
70 |
//#define CONF_OMODE
|
|
71 |
#define CONF_FILTER _IOW(CAN_IOC_MAGIC, 8, unsigned char)
|
|
72 |
|
|
73 |
//#define CONF_FENABLE
|
|
74 |
//#define CONF_FDISABLE
|
|
75 |
|
|
76 |
#define STAT _IO(CAN_IOC_MAGIC, 9)
|
|
77 |
#define CANQUE_FILTER _IOW(CAN_IOC_MAGIC, 10, struct canfilt_t)
|
|
78 |
#define CANQUE_FLUSH _IO(CAN_IOC_MAGIC, 11)
|
|
79 |
#define CONF_BAUDPARAMS _IOW(CAN_IOC_MAGIC, 11, struct can_baudparams_t)
|
|
80 |
#define CANRTR_READ _IOWR(CAN_IOC_MAGIC, 12, struct canmsg_t)
|
|
81 |
|
|
82 |
#ifdef __cplusplus
|
|
83 |
} /* extern "C"*/
|
|
84 |
#endif
|
|
85 |
|
|
86 |
#endif /*_CAN_DRVAPI_T_H*/
|