OpenCores
URL https://opencores.org/ocsvn/xulalx25soc/xulalx25soc/trunk

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [usbi.h] - Blame information for rev 55

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    usbi.h
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     This package attempts to convet a JTAG over USB based
8
//              communication system into something similar to a serial port
9
//      based communication system.  Some differences include the fact that,
10
//      if the USB port isn't polled, nothing comes out of the port.  Hence,
11
//      on connecting (or polling for the first time) ... there might be a 
12
//      bunch of stuff to (initially) ignore.
13
//
14
//
15
// Creator:     Dan Gisselquist, Ph.D.
16
//              Gisselquist Technology, LLC
17
//
18
////////////////////////////////////////////////////////////////////////////////
19
//
20
// Copyright (C) 2015, Gisselquist Technology, LLC
21
//
22
// This program is free software (firmware): you can redistribute it and/or
23
// modify it under the terms of  the GNU General Public License as published
24
// by the Free Software Foundation, either version 3 of the License, or (at
25
// your option) any later version.
26
//
27
// This program is distributed in the hope that it will be useful, but WITHOUT
28
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
29
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
30
// for more details.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
//
38
//
39 5 dgisselq
#ifndef USBI_H
40
#define USBI_H
41
 
42
#include <libusb.h>
43
 
44
#define VENDOR_ID               0x04d8
45
#define PRODUCT_ID              0x0ff8c
46
#define XESS_INTERFACE          0
47
#define XESS_ENDPOINT_OUT       0x01
48
#define XESS_ENDPOINT_IN        0x81
49
#define XESS_ENDPOINT_IN        0x81
50
//
51
#define JTAG_CMD        0x4f
52
#define GET_TDO_MASK    0x01
53
#define PUT_TMS_MASK    0x02
54
#define TMS_VAL_MASK    0x04
55
#define PUT_TDI_MASK    0x08
56
#define TDI_VAL_MASK    0x10
57
//
58
// #define      USER1_INSTR     0x02    // a SIX bit two
59
#define USB_PKTLEN      32
60
#define RCV_BUFLEN      512
61
#define RCV_BUFMASK     (RCV_BUFLEN-1)
62
 
63
#include "llcomms.h"
64
 
65
class   USBI : public LLCOMMSI { // USB Interface
66
private:
67
        char    m_rbuf[RCV_BUFLEN];
68
        char    m_txbuf[2*USB_PKTLEN], m_rxbuf[2*USB_PKTLEN];
69
        int     m_rbeg, m_rend;
70
 
71
        libusb_context          *m_usb_context;
72
        libusb_device           **m_usb_dev_list;
73
        libusb_device_handle    *m_xula_usb_device;
74
 
75
        virtual int     pop_fifo(char *buf, int len);
76
        virtual void    push_fifo(char *buf, int len);
77
        virtual void    raw_read(int len, int timeout_ms);
78
        virtual void    flush_read(void);
79
 
80
public:
81
        USBI(void);
82
 
83
        virtual void    close(void);
84
        virtual int     read(char *buf, int len);
85
        virtual int     read(char *buf, int len, int timeout_ms);
86
        virtual void    write(char *buf, int len);
87
        virtual bool    poll(unsigned ms);
88
};
89
 
90
#endif // USBI_H
91
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.