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

Subversion Repositories opb_usblite

[/] [opb_usblite/] [trunk/] [drivers/] [opb_usblite_v1_00_a/] [src/] [usblite_l.h] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 rehnmaak
/*
2
--
3
--    opb_usblite - opb_uartlite replacement
4
--
5
--    opb_usblite is using components from Rudolf Usselmann see
6
--    http://www.opencores.org/cores/usb_phy/
7
--    and Joris van Rantwijk see http://www.xs4all.nl/~rjoris/fpga/usb.html
8
--
9
--    Copyright (C) 2010 Ake Rehnman
10
--
11
--    This program is free software: you can redistribute it and/or modify
12
--    it under the terms of the GNU General Public License as published by
13
--    the Free Software Foundation, either version 3 of the License, or
14
--    (at your option) any later version.
15
--
16
--    This program is distributed in the hope that it will be useful,
17
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
18
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
--    GNU General Public License for more details.
20
--
21
--    You should have received a copy of the GNU General Public License
22
--    along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
--
24
*/
25
 
26
#ifndef USBLITE_L_H /* prevent circular inclusions */
27
#define USBLITE_L_H /* by using protection macros */
28
 
29
#ifdef __cplusplus
30
extern "C" {
31
#endif
32
 
33
/* register offsets */
34
 
35
#define XUL_RX_FIFO_OFFSET              0   /* receive FIFO, read only */
36
#define XUL_TX_FIFO_OFFSET              4   /* transmit FIFO, write only */
37
#define XUL_STATUS_REG_OFFSET           8   /* status register, read only */
38
#define XUL_CONTROL_REG_OFFSET          12  /* control register, write only */
39
 
40
/* control register bit positions */
41
 
42
#define XUL_CR_ENABLE_INTR              0x10    /* enable interrupt */
43
#define XUL_CR_FIFO_RX_RESET            0x02    /* reset receive FIFO */
44
#define XUL_CR_FIFO_TX_RESET            0x01    /* reset transmit FIFO */
45
 
46
/* status register bit positions */
47
 
48
#define XUL_SR_INTR_ENABLED             0x10    /* interrupt enabled */
49
#define XUL_SR_TX_FIFO_FULL             0x08    /* transmit FIFO full */
50
#define XUL_SR_TX_FIFO_EMPTY            0x04    /* transmit FIFO empty */
51
#define XUL_SR_RX_FIFO_FULL             0x02    /* receive FIFO full */
52
#define XUL_SR_RX_FIFO_VALID_DATA       0x01    /* data in receive FIFO */
53
 
54
/*****************************************************************************/
55
#define usblite_out32(addr, data) *(unsigned int*)(addr)=(unsigned int)(data)
56
 
57
#define usblite_in32(addr) *(unsigned int*)(addr)
58
 
59
#define usblite_mSetControlReg(BaseAddress, Mask) \
60
                    usblite_out32((BaseAddress) + XUL_CONTROL_REG_OFFSET, (Mask))
61
 
62
#define usblite_mGetStatusReg(BaseAddress) \
63
                    usblite_in32((BaseAddress) + XUL_STATUS_REG_OFFSET)
64
 
65
#define usblite_mIsReceiveEmpty(BaseAddress) \
66
  ((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_RX_FIFO_VALID_DATA) != \
67
    XUL_SR_RX_FIFO_VALID_DATA)
68
 
69
#define usblite_mIsTransmitFull(BaseAddress) \
70
    ((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_FULL) == \
71
      XUL_SR_TX_FIFO_FULL)
72
 
73
#define usblite_mIsIntrEnabled(BaseAddress) \
74
    ((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_INTR_ENABLED) == \
75
      XUL_SR_INTR_ENABLED)
76
 
77
#define usblite_mEnableIntr(BaseAddress) \
78
               usblite_mSetControlReg((BaseAddress), XUL_CR_ENABLE_INTR)
79
 
80
#define usblite_mDisableIntr(BaseAddress) \
81
              usblite_mSetControlReg((BaseAddress), 0)
82
 
83
 
84
/************************** Function Prototypes *****************************/
85
 
86
void usblite_SendByte(unsigned int base, unsigned char Data);
87
 
88
unsigned char usblite_RecvByte(unsigned int base);
89
 
90
#ifdef __cplusplus
91
}
92
#endif
93
 
94
#endif            /* end of protection macro */
95
 

powered by: WebSVN 2.1.0

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