]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/include/usbcan.h
Embedded code and LinCAN driver now working
[lincan.git] / lincan / include / usbcan.h
index 3e79bf06ed1d2fde26d41136ee8e52341e88bf85..b01a6275d0d6a953a9b3f7049462f55efa4d135b 100644 (file)
@@ -66,7 +66,7 @@ int usbcan_irq_handler(int irq, struct canchip_t *chip);
 int usbcan_init(void);
 void usbcan_exit(void);
 
-void usbcan_read_kthread(kthread_t *kthread);
+int usbcan_read_kthread(void *data);
 int usbcan_chip_queue_status(struct canchip_t *chip);
 
 #ifdef CONFIG_OC_LINCAN_DETAILED_ERRORS
@@ -115,15 +115,23 @@ int usbcan_chip_queue_status(struct canchip_t *chip);
 
 #endif /*CONFIG_OC_LINCAN_DETAILED_ERRORS*/
 
-/* CAN message over usb */
-struct usbcan_canmsg_t{
-       __u8 chip_id;
-       __u16 flags;
-       __u8 id[4];
-       __u8 length;
-       __u8 data[8];
+struct usbcan_message {
+       struct urb      *u;
+       u8      msg[16];
+       spinlock_t              acc;            /* access lock */
+       long    flags;
 };
 
+#define USBCAN_MESSAGE_FREE (1)
+#define USBCAN_MESSAGE_READY_TO_SEND (2)
+#define USBCAN_MESSAGE_SENDING                 (3)
+#define USBCAN_MESSAGE_TERMINATE               (4)
+#define USBCAN_MESSAGE_ERROR                           (5)
+#define USBCAN_MESSAGE_DATA_READ               (6)
+
+#define USBCAN_TOT_RX_URBS 8
+#define USBCAN_TOT_TX_URBS 8
+
 /* Structure to hold all of our device specific stuff */
 struct usbcan_usb {
        struct usb_device       *udev;                  /* the usb device for this device */
@@ -134,20 +142,21 @@ struct usbcan_usb {
        unsigned char           *ctl_in_buffer; /* the buffer to receive data */
        size_t                  bulk_in_size;           /* the size of the receive buffer */
        size_t                  ctl_in_size;            /* the size of the receive buffer */
-       __u8                    ctl_in_endpointAddr;    /* the address of the bulk in endpoint */
-       __u8                    ctl_out_endpointAddr;   /* the address of the bulk in endpoint */
-       __u8                    bulk_in_endpointAddr;   /* the address of the bulk in endpoint */
-       __u8                    bulk_out_endpointAddr;  /* the address of the bulk out endpoint */
+       u8                      ctl_in_endpointAddr;    /* the address of the bulk in endpoint */
+       u8                      ctl_out_endpointAddr;   /* the address of the bulk in endpoint */
+       u8                      bulk_in_endpointAddr;   /* the address of the bulk in endpoint */
+       u8                      bulk_out_endpointAddr;  /* the address of the bulk out endpoint */
        int                     errors;                 /* the last request tanked */
        int                     open_count;             /* count the number of openers */
        spinlock_t              err_lock;               /* lock for errors */
        struct mutex            io_mutex;               /* synchronize I/O with disconnect */
-       struct urb              *rcv;
-/*     uchar8_t        rcv_msg[16];
-       uchar8_t        tx_msg[16];*/
-       __u8    rcv_msg[16];
-       __u8    tx_msg[16];
-       kthread_t  rcvthread;                      /* usb receive kernel thread  */
+       struct urb              *rx;
+       struct urb              *tx;
+       u8      rx_msg[16];
+       u8      tx_msg[16];
+
+       struct task_struct *comthread;                      /* usb communication kernel thread  */
+
 
        struct candevice_t *candev;
        long flags;