/*
|
/*
|
--
|
--
|
-- opb_usblite - opb_uartlite replacement
|
-- opb_usblite - opb_uartlite replacement
|
--
|
--
|
-- opb_usblite is using components from Rudolf Usselmann see
|
-- opb_usblite is using components from Rudolf Usselmann see
|
-- http://www.opencores.org/cores/usb_phy/
|
-- http://www.opencores.org/cores/usb_phy/
|
-- and Joris van Rantwijk see http://www.xs4all.nl/~rjoris/fpga/usb.html
|
-- and Joris van Rantwijk see http://www.xs4all.nl/~rjoris/fpga/usb.html
|
--
|
--
|
-- Copyright (C) 2010 Ake Rehnman
|
-- Copyright (C) 2010 Ake Rehnman
|
--
|
--
|
-- This program is free software: you can redistribute it and/or modify
|
-- This program is free software: you can redistribute it and/or modify
|
-- it under the terms of the GNU General Public License as published by
|
-- it under the terms of the GNU Lesser General Public License as published by
|
-- the Free Software Foundation, either version 3 of the License, or
|
-- the Free Software Foundation, either version 3 of the License, or
|
-- (at your option) any later version.
|
-- (at your option) any later version.
|
--
|
--
|
-- This program is distributed in the hope that it will be useful,
|
-- This program is distributed in the hope that it will be useful,
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- GNU General Public License for more details.
|
-- GNU Lesser General Public License for more details.
|
--
|
--
|
-- You should have received a copy of the GNU General Public License
|
-- You should have received a copy of the GNU Lesser General Public License
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
--
|
--
|
*/
|
*/
|
|
|
#ifndef USBLITE_L_H /* prevent circular inclusions */
|
#ifndef USBLITE_L_H /* prevent circular inclusions */
|
#define USBLITE_L_H /* by using protection macros */
|
#define USBLITE_L_H /* by using protection macros */
|
|
|
#ifdef __cplusplus
|
#ifdef __cplusplus
|
extern "C" {
|
extern "C" {
|
#endif
|
#endif
|
|
|
/* register offsets */
|
/* register offsets */
|
|
|
#define XUL_RX_FIFO_OFFSET 0 /* receive FIFO, read only */
|
#define XUL_RX_FIFO_OFFSET 0 /* receive FIFO, read only */
|
#define XUL_TX_FIFO_OFFSET 4 /* transmit FIFO, write only */
|
#define XUL_TX_FIFO_OFFSET 4 /* transmit FIFO, write only */
|
#define XUL_STATUS_REG_OFFSET 8 /* status register, read only */
|
#define XUL_STATUS_REG_OFFSET 8 /* status register, read only */
|
#define XUL_CONTROL_REG_OFFSET 12 /* control register, write only */
|
#define XUL_CONTROL_REG_OFFSET 12 /* control register, write only */
|
|
|
/* control register bit positions */
|
/* control register bit positions */
|
|
|
#define XUL_CR_ENABLE_INTR 0x10 /* enable interrupt */
|
#define XUL_CR_ENABLE_INTR 0x10 /* enable interrupt */
|
#define XUL_CR_FIFO_RX_RESET 0x02 /* reset receive FIFO */
|
#define XUL_CR_FIFO_RX_RESET 0x02 /* reset receive FIFO */
|
#define XUL_CR_FIFO_TX_RESET 0x01 /* reset transmit FIFO */
|
#define XUL_CR_FIFO_TX_RESET 0x01 /* reset transmit FIFO */
|
|
|
/* status register bit positions */
|
/* status register bit positions */
|
|
|
#define XUL_SR_INTR_ENABLED 0x10 /* interrupt enabled */
|
#define XUL_SR_INTR_ENABLED 0x10 /* interrupt enabled */
|
#define XUL_SR_TX_FIFO_FULL 0x08 /* transmit FIFO full */
|
#define XUL_SR_TX_FIFO_FULL 0x08 /* transmit FIFO full */
|
#define XUL_SR_TX_FIFO_EMPTY 0x04 /* transmit FIFO empty */
|
#define XUL_SR_TX_FIFO_EMPTY 0x04 /* transmit FIFO empty */
|
#define XUL_SR_RX_FIFO_FULL 0x02 /* receive FIFO full */
|
#define XUL_SR_RX_FIFO_FULL 0x02 /* receive FIFO full */
|
#define XUL_SR_RX_FIFO_VALID_DATA 0x01 /* data in receive FIFO */
|
#define XUL_SR_RX_FIFO_VALID_DATA 0x01 /* data in receive FIFO */
|
|
|
/*****************************************************************************/
|
/*****************************************************************************/
|
#define usblite_out32(addr, data) *(unsigned int*)(addr)=(unsigned int)(data)
|
#define usblite_out32(addr, data) *(unsigned int*)(addr)=(unsigned int)(data)
|
|
|
#define usblite_in32(addr) *(unsigned int*)(addr)
|
#define usblite_in32(addr) *(unsigned int*)(addr)
|
|
|
#define usblite_mSetControlReg(BaseAddress, Mask) \
|
#define usblite_mSetControlReg(BaseAddress, Mask) \
|
usblite_out32((BaseAddress) + XUL_CONTROL_REG_OFFSET, (Mask))
|
usblite_out32((BaseAddress) + XUL_CONTROL_REG_OFFSET, (Mask))
|
|
|
#define usblite_mGetStatusReg(BaseAddress) \
|
#define usblite_mGetStatusReg(BaseAddress) \
|
usblite_in32((BaseAddress) + XUL_STATUS_REG_OFFSET)
|
usblite_in32((BaseAddress) + XUL_STATUS_REG_OFFSET)
|
|
|
#define usblite_mIsReceiveEmpty(BaseAddress) \
|
#define usblite_mIsReceiveEmpty(BaseAddress) \
|
((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_RX_FIFO_VALID_DATA) != \
|
((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_RX_FIFO_VALID_DATA) != \
|
XUL_SR_RX_FIFO_VALID_DATA)
|
XUL_SR_RX_FIFO_VALID_DATA)
|
|
|
#define usblite_mIsTransmitFull(BaseAddress) \
|
#define usblite_mIsTransmitFull(BaseAddress) \
|
((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_FULL) == \
|
((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_FULL) == \
|
XUL_SR_TX_FIFO_FULL)
|
XUL_SR_TX_FIFO_FULL)
|
|
|
#define usblite_mIsIntrEnabled(BaseAddress) \
|
#define usblite_mIsIntrEnabled(BaseAddress) \
|
((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_INTR_ENABLED) == \
|
((usblite_mGetStatusReg((BaseAddress)) & XUL_SR_INTR_ENABLED) == \
|
XUL_SR_INTR_ENABLED)
|
XUL_SR_INTR_ENABLED)
|
|
|
#define usblite_mEnableIntr(BaseAddress) \
|
#define usblite_mEnableIntr(BaseAddress) \
|
usblite_mSetControlReg((BaseAddress), XUL_CR_ENABLE_INTR)
|
usblite_mSetControlReg((BaseAddress), XUL_CR_ENABLE_INTR)
|
|
|
#define usblite_mDisableIntr(BaseAddress) \
|
#define usblite_mDisableIntr(BaseAddress) \
|
usblite_mSetControlReg((BaseAddress), 0)
|
usblite_mSetControlReg((BaseAddress), 0)
|
|
|
|
|
/************************** Function Prototypes *****************************/
|
/************************** Function Prototypes *****************************/
|
|
|
void usblite_SendByte(unsigned int base, unsigned char Data);
|
void usblite_SendByte(unsigned int base, unsigned char Data);
|
|
|
unsigned char usblite_RecvByte(unsigned int base);
|
unsigned char usblite_RecvByte(unsigned int base);
|
|
|
#ifdef __cplusplus
|
#ifdef __cplusplus
|
}
|
}
|
#endif
|
#endif
|
|
|
#endif /* end of protection macro */
|
#endif /* end of protection macro */
|
|
|
|
|