📄 usb_regs.c
字号:
* Input : bEpNum
* Output :
* Return :
*******************************************************************************/
u16 GetEPDblBuf0Count(u8 bEpNum)
{
return(_GetEPDblBuf0Count(bEpNum));
}
/*******************************************************************************
* Function Name : GetEPDblBuf1Count
* Description :
* Input : bEpNum
* Output :
* Return :
*******************************************************************************/
u16 GetEPDblBuf1Count(u8 bEpNum)
{
return(_GetEPDblBuf1Count(bEpNum));
}
#ifdef STR7xx /*STR7xx family */
/*******************************************************************************
* Function Name : GetEPDblBufDir
* Description : gets direction of the double buffered endpoint
* Input : bEpNum
* Output : EP_DBUF_OUT, EP_DBUF_IN,
EP_DBUF_ERR if the endpoint counter not yet programmed
* Return :
*******************************************************************************/
EP_DBUF_DIR GetEPDblBufDir(u8 bEpNum) {
if((u16)(*_pEPRxCount(bEpNum) & 0xFC00) != 0)
return(EP_DBUF_OUT);
else if(((u16)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0)
return(EP_DBUF_IN);
else
return(EP_DBUF_ERR);
}
#endif
/*******************************************************************************
* Function Name : FreeUserBuffer
* Description : free buffer used from the application realising it to the line
toggles bit SW_BUF in the double buffered endpoint register
* Input : bEpNum, bDir
* Output :
* Return :
*******************************************************************************/
void FreeUserBuffer(u8 bEpNum, u8 bDir)
{
if(bDir== EP_DBUF_OUT)
{ /* OUT double buffered endpoint */
_ToggleDTOG_TX(bEpNum);
}
else if(bDir == EP_DBUF_IN)
{ /* IN double buffered endpoint */
_ToggleDTOG_RX(bEpNum);
}
}
/*******************************************************************************
* Function Name : ToWord
* Description :
* Input : bh, bl
* Output :
* Return :
*******************************************************************************/
u16 ToWord(u8 bh, u8 bl)
{
u16 wRet;
wRet = (u16)bl | ((u16)bh << 8);
return(wRet);
}
/*******************************************************************************
* Function Name : ByteSwap
* Description :
* Input : wSwW
* Output :
* Return :
*******************************************************************************/
u16 ByteSwap(u16 wSwW)
{
u8 bTemp;
u16 wRet;
bTemp = (u8)(wSwW & 0xff);
wRet = (wSwW >> 8) | ((u16)bTemp << 8);
return(wRet);
}
/* DMA Functions only for STR91x */
#ifdef STR91x /*str91x family*/
/*******************************************************************************
* Function Name : SetDMAburstTxSize
* Description : Configure the Burst Size for a Tx Endpoint
* Input : DestBsize: Destination Burst Size
* Output : None
* Return : None
*******************************************************************************/
void SetDMABurstTxSize(u8 DestBsize)
{
*DMABSIZE &=~0xEF;
*DMABSIZE = (DestBsize<<4);
}
/*******************************************************************************
* Function Name : SetDMABurstRxSize
* Description : Configure the Burst Size for a Rx Endpoint
* Input : SrcBsize: Source Burst
* Output : None
* Return : None
*******************************************************************************/
void SetDMABurstRxSize(u8 SrcBsize)
{
*DMABSIZE &=~0x7;
*DMABSIZE = SrcBsize;
}
/*******************************************************************************
* Function Name : DMAUnlinkedModeTxConfig
* Description : Configure a Tx Endpoint to trigger TX Unlinked DMA request
* Note : Up to three endpoints could be configured to trigger DMA
request, an index[0:2] must be associated to an endpoint
* Input : -bEpNum: endpoint number[0:9]
* -index: 0,1 or 2
* Output : None
* Return : None
*******************************************************************************/
void DMAUnlinkedModeTxConfig(u8 bEpNum ,u8 index)
{
*DMACR2 &=~(0x0F<<(4*index));
*DMACR2 |=bEpNum<<(4*index);
}
/*******************************************************************************
* Function Name : DMAUnlinkedModeTxEnable
* Description : Enable a Tx endpoint to trigger Tx DMA request
* Input : -index :0,1 or 2 = index associated to endpoint in function
* "DMAUnlinkedModeTxConfig"
* Output : None
* Return : None
*******************************************************************************/
void DMAUnlinkedModeTxEnable(u8 index)
{
*DMACR3 &=~0x01; /*DMA Tx linked mode disabled*/
*DMACR2 &=~0x3000;
*DMACR2 |=(index+1)<<12;
}
/*******************************************************************************
* Function Name : DMAUnlinkedModeTxDisable
* Description : Enable a Tx endpoint to trigger Tx DMA request
* Input : index :0,1 or 2 = index associated to endpoint in function
* "DMAUnlinkedModeTxConfig"
* Output : None
* Return : None
*******************************************************************************/
void DMAUnlinkedModeTxDisable(u8 index)
{
*DMACR2 &=~0x3000;
}
/*******************************************************************************
* Function Name : DMAUnlinkedModeRxEnable
* Description : Enable a Rx Endpoint to trigger Rx DMA
* Input : bEpNum: endpoint number[0:9]
* Output : None
* Return : None
*******************************************************************************/
void DMAUnlinkedModeRxEnable(u8 bEpNum)
{
*DMACR3 &=~0x80; /*DMA Rx linked mode disabled*/
*DMACR1 |=(0x1<<bEpNum);
}
/*******************************************************************************
* Function Name : DMAUnlinkedModeRxDisable
* Description : Disable a Rx Endpoint to trigger Rx DMA
* Input : bEpNum: endpoint number[0:9]
* Output : None
* Return : None
*******************************************************************************/
void DMAUnlinkedModeRxDisable(u8 bEpNum)
{
*DMACR1 &=~(0x1<<bEpNum);
}
/*******************************************************************************
* Function Name : DMALinkedModeRxConfig
* Description : Configure a Rx endpoint to trigger DMA linked request
* Input : bEpNum: endpoint number[0:9]
* Output : None
* Return : None
*******************************************************************************/
void DMALinkedModeRxConfig(u8 bEpNum)
{
*DMACR3 &=~0x1E00;
*DMACR3 |=bEpNum<<9;
}
/*******************************************************************************
* Function Name : DMALinkedModeTxConfig
* Description : Configure a Tx endpoint to trigger DMA linked request
* Input : bEpNum: endpoint number[0:9]
* Output : None
* Return : None
*******************************************************************************/
void DMALinkedModeTxConfig(u8 bEpNum)
{
*DMACR3 &=~0x1E;
*DMACR3 |=bEpNum<<1;
}
/*******************************************************************************
* Function Name : DMALinkedModeRxEnable
* Description : Enable the DMA Linked Rx mode
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void DMALinkedModeRxEnable(void)
{
*DMACR3 |=0x100;
*DMACR3 |=0x2000;
}
/*******************************************************************************
* Function Name : DMALinkedModeTxEnable
* Description : Enable the DMA Linked Tx mode
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void DMALinkedModeTxEnable(void)
{
*DMACR3 |=0x1;
*DMACR3 |=0x20;
}
/*******************************************************************************
* Function Name : DMALinkedModeRxDisable
* Description : Disable the DMA Linked Rx mode
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void DMALinkedModeRxDisable(void)
{
*DMACR3 &=~0x100;
*DMACR3 &=~0x2000;
}
/*******************************************************************************
* Function Name : DMALinkedModeTxDisable
* Description : Disable the DMA Linked Tx mode
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void DMALinkedModeTxDisable(void)
{
*DMACR3 &=~0x1;
*DMACR3 &=~0x20;
}
/*******************************************************************************
* Function Name : USB_DMASynchEnable
* Description : Enable the Synchronization Logic
* Input : TRUE or FALSE
* Output : None
* Return : None
*******************************************************************************/
void DMASynchEnable(void)
{
*DMACR3 |=0x40;
}
/*******************************************************************************
* Function Name : USB_DMASynchDisable
* Description : Disable the Synchronization Logic
* Input : TRUE or FALSE
* Output : None
* Return : None
*******************************************************************************/
void DMASynchDisable(void)
{
*DMACR3 &=~0x40;
}
/*******************************************************************************
* Function Name : SetDMALLITxLength
* Description : Set the DMA LLI Tx length
* Input : length
* Output : None
* Return : None
*******************************************************************************/
void SetDMALLITxLength(u8 length)
{
*DMALLI &=~0xFF;
*DMALLI |= length;
}
/*******************************************************************************
* Function Name : SetDMALLIRxLength
* Description : Set the DMA LLI Rx length
* Input : length
* Output : None
* Return : None
*******************************************************************************/
void SetDMALLIRxLength(u8 length )
{
*DMALLI &=~0xFF00;
*DMALLI |= length<<8;
}
/*******************************************************************************
* Function Name : SetDMALLIRxPacketNum
* Description : Set the LLI_RX_NPACKETS field in register USB_DMABSIZE register
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SetDMALLIRxPacketNum(u8 PacketNum)
{
*DMABSIZE &=0xFF;
*DMABSIZE |=(PacketNum<<8);
}
/*******************************************************************************
* Function Name : GetDMALLIPacketNum
* Description : gets the LLI_RX_NPACKETS field value
* Input : None
* Output : None
* Return : LLI_RX_NPACKETS field value
*******************************************************************************/
u8 GetDMALLIRxPacketNum(void)
{
return((u8)(*DMABSIZE & 0xFF00)>>8);
}
#endif
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -