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