csl_usbfaux.h
来自「dsp在音频处理中的运用」· C头文件 代码 · 共 405 行
H
405 行
/**==========================================================================
* @file csl_usbfAux.h
*
* @path $(CSLPATH)\arm\usbf\src
*
* @desc API Auxilary header file for USBF CSL.
*
*/
/*===========================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
*===========================================================================
*/
/* @(#) PSP/CSL 3.00.01.00[5912] (2004-06-22) */
#ifndef _CSL_USBFAUX_H
#define _CSL_USBFAUX_H
#include <cslr_usbf.h>
#include <csl_usbf.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline
void
CSL_usbfStartDmaTransfer (
CSL_UsbfHandle hUsbf,
CSL_UsbfDmaNum dmaNum
)
{
switch (dmaNum)
{
case 0:
CSL_FINS(hUsbf->regs->TXDMA0, USBF_TXDMA0_TX0_START, 1 );
break;
case 1:
CSL_FINS(hUsbf->regs->TXDMA1, USBF_TXDMA1_TX1_START, 1 );
break;
case 2:
CSL_FINS(hUsbf->regs->TXDMA2, USBF_TXDMA2_TX2_START, 1 );
break;
}
}
static inline
void
CSL_usbfInitRemoteWakeup(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->SYSCON2, USBF_SYSCON2_RMT_WKP, 1 );
}
static inline
void
CSL_usbfStallUsbCmd(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->SYSCON2, USBF_SYSCON2_STALL_CMD, 1 );
}
static inline
void
CSL_usbfInformDeviceCfgDone(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->SYSCON2, USBF_SYSCON2_DEV_CFG, 1 );
}
static inline
void
CSL_usbfInformDeviceCfgCleared(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->SYSCON2, USBF_SYSCON2_CLR_CFG, 1 );
}
static inline
void
CSL_usbfClearHalt(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->CTRL, USBF_CTRL_CLR_HALT, 1 );
}
static inline
void
CSL_usbfHaltEp(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->CTRL, USBF_CTRL_SET_HALT, 1 );
}
static inline
void
CSL_usbfResetEp(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->CTRL, USBF_CTRL_RESET_EP, 1 );
}
static inline
void
CSL_usbfEnableFifo(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->CTRL, USBF_CTRL_SET_FIFO_EN, 1 );
}
static inline
void
CSL_usbfConnectDevice(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->SYSCON1, USBF_SYSCON1_PULLUP_EN, 1 );
}
static inline
void
CSL_usbfDisconnectDevice(
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->SYSCON1, USBF_SYSCON1_PULLUP_EN, 0 );
}
static inline
void
CSL_usbfClearInterrupt(
CSL_UsbfHandle hUsbf,
CSL_BitMask16 intMask
)
{
hUsbf->regs->IRQ_SRC |= intMask ;
}
static inline
void
CSL_usbfEnableInterrupt(
CSL_UsbfHandle hUsbf,
CSL_BitMask16 intMask
)
{
hUsbf->regs->IRQ_EN |= intMask ;
}
static inline
void
CSL_usbfDisableInterrupt(
CSL_UsbfHandle hUsbf,
CSL_BitMask16 intMask
)
{
hUsbf->regs->IRQ_EN &= ~intMask ;
}
static inline
void
CSL_usbfEnableDmaInterrupt(
CSL_UsbfHandle hUsbf,
CSL_BitMask16 intMask
)
{
hUsbf->regs->DMA_IRQ_EN |= intMask ;
}
static inline
void
CSL_usbfDisableDmaInterrupt(
CSL_UsbfHandle hUsbf,
CSL_BitMask16 intMask
)
{
hUsbf->regs->DMA_IRQ_EN &= ~intMask ;
}
static inline
void
CSL_usbfWriteFifo(
CSL_UsbfHandle hUsbf,
CSL_UsbfRxTxFifo *pTxfifo
)
{
CSL_UsbfEpNum epNum;
Uint16 i ;
epNum = (CSL_UsbfEpNum) CSL_FEXT(hUsbf->regs->EPNUM, USBF_EPNUM_EP_NUM);
/* Enable access to endpoint FIFO */
CSL_FINS(hUsbf->regs->EPNUM, USBF_EPNUM_EP_SEL, 1);
if (pTxfifo->length > 64)
pTxfifo->length = 64;
for ( i = 0 ; i < pTxfifo->length ; i++ )
*(volatile Uint8 *)&hUsbf->regs->DATA = *(pTxfifo->data)++;
hUsbf->regs->EPNUM = 0x10 | epNum;
hUsbf->regs->CTRL = 0x0004;
}
static inline
void
CSL_usbfReadFifo(
CSL_UsbfHandle hUsbf,
CSL_UsbfRxTxFifo *pRxfifo
)
{
CSL_UsbfEpNum epNum;
Uint16 i ;
Uint32 length = 0;
length = hUsbf->regs->RXFSTAT;
epNum = (CSL_UsbfEpNum) CSL_FEXT(hUsbf->regs->EPNUM, USBF_EPNUM_EP_NUM);
/* Enable access to endpoint FIFO */
CSL_FINS(hUsbf->regs->EPNUM, USBF_EPNUM_EP_SEL, 1);
if (length > pRxfifo->length)
length = pRxfifo->length;
for ( i = 0 ; i < length ; i++ )
*(pRxfifo->data)++ = *(volatile Uint8 *)&hUsbf->regs->DATA;
/* Setup Endpoint to retreive the next incoming packet. */
hUsbf->regs->EPNUM = 0x00 | epNum;
/* Setup USB to receive data on Endpoint [endpt_num] */
hUsbf->regs->CTRL = 0x0004;
pRxfifo->length = length;
}
static inline
void
CSL_usbfSelectEp (
CSL_UsbfHandle hUsbf,
Uint8 epNum
)
{
register Uint16 _epnum ;
Uint8 epDir;
_epnum = hUsbf->regs->EPNUM;
epDir = (epNum & 0x10) >> 4 ;
epNum = epNum & 0xf ;
CSL_FINS(_epnum, USBF_EPNUM_EP_NUM, epNum );
CSL_FINS(_epnum, USBF_EPNUM_EP_DIR, epDir );
CSL_FINS(_epnum, USBF_EPNUM_EP_SEL, 1);
hUsbf->regs->EPNUM = _epnum;
}
static inline
void
CSL_usbfDeselectEp (
CSL_UsbfHandle hUsbf
)
{
CSL_FINS(hUsbf->regs->EPNUM, USBF_EPNUM_EP_SEL, 0);
}
static inline
void
CSL_usbfReadSetup (
CSL_UsbfHandle hUsbf,
CSL_UsbfSetupPacket * pSetupPacket
)
{
register Uint16 _epnum ;
Uint16 data;
/* Select endpoint 0 for setup FIFO reading */
_epnum = hUsbf->regs->EPNUM ;
CSL_FINS(_epnum, USBF_EPNUM_EP_NUM, 0 );
CSL_FINS(_epnum, USBF_EPNUM_EP_DIR, 0 );
CSL_FINS(_epnum, USBF_EPNUM_SETUP_SEL, 1);
CSL_FINS(_epnum, USBF_EPNUM_EP_SEL, 0);
hUsbf->regs->EPNUM = _epnum;
data = hUsbf->regs->DATA ;
pSetupPacket->new_packet = TRUE;
pSetupPacket->bmRequestType = data & 0xff;
pSetupPacket->bRequest = ( data >> 8 ) & 0xff;
pSetupPacket->wValue = hUsbf->regs->DATA;
pSetupPacket->wIndex = hUsbf->regs->DATA;
pSetupPacket->wLength = hUsbf->regs->DATA;
/* Deselect endpoint 0 for setup FIFO reading */
CSL_FINS(hUsbf->regs->EPNUM, USBF_EPNUM_SETUP_SEL, 0);
}
static inline
Uint16
CSL_usbfGetRxFifoCount (
CSL_UsbfHandle hUsbf
)
{
return (CSL_FEXT(hUsbf->regs->RXFSTAT, USBF_RXFSTAT_RXF_COUNT));
}
static inline
Uint16
CSL_usbfGetIsoEpStatus (
CSL_UsbfHandle hUsbf
)
{
return (hUsbf->regs->STAT_FLG);
}
static inline
Uint16
CSL_usbfGetNonIsoEpStatus (
CSL_UsbfHandle hUsbf
)
{
return (hUsbf->regs->STAT_FLG);
}
static inline
Uint16
CSL_usbfGetDeviceStatus (
CSL_UsbfHandle hUsbf
)
{
return (hUsbf->regs->DEVSTAT);
}
static inline
Uint16
CSL_usbfGetFrameTimerStatus (
CSL_UsbfHandle hUsbf
)
{
return (hUsbf->regs->SOF);
}
static inline
void
CSL_usbfGetFrameNonisoEpIntStatus(
CSL_UsbfHandle hUsbf,
CSL_UsbfNonIsoEpIntStatus * intStatus
)
{
intStatus->rxEpIntSource = (CSL_UsbfEpNum) CSL_FEXT(hUsbf->regs->EPN_STAT, USBF_EPN_STAT_RX_IT_SRC);
intStatus->txEpIntSource = (CSL_UsbfEpNum) CSL_FEXT(hUsbf->regs->EPN_STAT, USBF_EPN_STAT_TX_IT_SRC);
}
static inline
void
CSL_usbfGetFrameNonisoEpDmaIntStatus(
CSL_UsbfHandle hUsbf,
CSL_UsbfNonIsoDmaIntStatus * intStatus
)
{
register Uint16 _reg ;
_reg = hUsbf->regs->DMAN_STAT ;
intStatus->eotDmaIntPending = CSL_FEXT(_reg, USBF_DMAN_STAT_RX_SB);
intStatus->rxdmaIntSource = (CSL_UsbfEpNum) CSL_FEXT(_reg, USBF_DMAN_STAT_RX_IT_SRC);
intStatus->txdmaIntSource = (CSL_UsbfEpNum) CSL_FEXT(_reg, USBF_DMAN_STAT_TX_IT_SRC);
}
static inline
CSL_BitMask16
CSL_usbfGetIntSrc(
CSL_UsbfHandle hUsbf
)
{
return (hUsbf->regs->IRQ_SRC);
}
static inline
CSL_UsbfRev
CSL_usbfGetDeviceRevision(
CSL_UsbfHandle hUsbf
)
{
return ((CSL_UsbfRev)CSL_FEXT(hUsbf->regs->REV, USBF_REV_REV_NB));
}
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?