⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_regs.c

📁 STR912的usb例程
💻 C
📖 第 1 页 / 共 3 页
字号:

/*******************************************************************************
* Function Name  : GetRxStallStatus
* Description    : checks if endpoint Rx status ==STALL
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : TRUE or FALSE
*******************************************************************************/
BOOL GetRxStallStatus(BYTE bEpNum)
{
  return(_GetRxStallStatus(bEpNum));
}

/*******************************************************************************
* Function Name  : ClearEP_CTR_RX
* Description    : Clears the CTR_RX flag in endpoint
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : None
*******************************************************************************/
void ClearEP_CTR_RX(BYTE bEpNum)
{
  _ClearEP_CTR_RX(bEpNum);
}

/*******************************************************************************
* Function Name  : ClearEP_CTR_Tx
* Description    : Clears the CTR_Tx flag
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : None
*******************************************************************************/
void ClearEP_CTR_TX(BYTE bEpNum)
{
  _ClearEP_CTR_TX(bEpNum);
}

/*******************************************************************************
* Function Name  : ToggleDTOG_RX
* Description    : Toggles the DTOG_RX bit
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : None
*******************************************************************************/
void ToggleDTOG_RX(BYTE bEpNum)
{
  _ToggleDTOG_RX(bEpNum);
}

/*******************************************************************************
* Function Name  : ToggleDTOG_TX
* Description    : Toggles the DTOG_Tx bit
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : None
*******************************************************************************/
void ToggleDTOG_TX(BYTE bEpNum)
{
  _ToggleDTOG_TX(bEpNum);
}

/*******************************************************************************
* Function Name  : ClearDTOG_RX
* Description    : Clears the DTOG_RX bit
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : None
*******************************************************************************/
void ClearDTOG_RX(BYTE bEpNum)
{
  _ClearDTOG_RX(bEpNum);
}

/*******************************************************************************
* Function Name  : ClearDTOG_TX
* Description    : Clears the DTOG_TX bit
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : None
*******************************************************************************/
void ClearDTOG_TX(BYTE bEpNum)
{
  _ClearDTOG_TX(bEpNum);
}

/*******************************************************************************
* Function Name  : SetEPAddress
* Description    : Sets the Endpoint Address
* Input          : -bEpNum: endpoint number[0:9]
*                  -bAddr : Address value
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPAddress(BYTE bEpNum,BYTE bAddr)
{
  _SetEPAddress(bEpNum,bAddr);
}

/*******************************************************************************
* Function Name  : GetEPAddress
* Description    : Gets the Endpoint Address
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : Endpoint address value
*******************************************************************************/
BYTE GetEPAddress(BYTE bEpNum)
{
  return(_GetEPAddress(bEpNum));
}

/*******************************************************************************
* Function Name  : SetEPTxAddr
* Description    : Sets the Endpoint Tx buffer Addr offset in the PMA
* Input          : - bEpNum: endpoint number[0:9]
*                  - wAddr : Tx buffer address offset value in the PMA
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPTxAddr(BYTE bEpNum, WORD wAddr)
{
	_SetEPTxAddr(bEpNum,wAddr);
}

/*******************************************************************************
* Function Name  : SetEPRxAddr
* Description    : Sets the Endpoint Rx buffer Addr in the Packet Memory Area PMA
* Input          : - bEpNum: endpoint number[0:9]
*                  - wAddr : Rx buffer address offset value in the PMA
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPRxAddr(BYTE bEpNum, WORD wAddr)
{
   _SetEPRxAddr(bEpNum,wAddr);
}

/*******************************************************************************
* Function Name  : GetEPTxAddr
* Description    : Gets the Endpoint Tx buffer address offset in PMA
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : Endpoint Tx buffer Address offset in PMA
*******************************************************************************/
WORD GetEPTxAddr(BYTE bEpNum)
{
  return (_GetEPTxAddr(bEpNum));
}

/*******************************************************************************
* Function Name  : GetEPRxAddr
* Description    : Gets the Endpoint Rx buffer address offset in the PMA
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : Endpoint Rx buffer Address offset in PMA
*******************************************************************************/
WORD GetEPRxAddr(BYTE bEpNum)
{
 return(_GetEPRxAddr(bEpNum));
}

/*******************************************************************************
* Function Name  : SetEPTxCount
* Description    : Sets the Endpoint Tx buffer size
* Input          : - bEpNum: endpoint number[0:9]
*                  - wCount: size (in bytes) of the Tx buffer in the PMA
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPTxCount(BYTE bEpNum, WORD wCount)
{
  _SetEPTxCount(bEpNum,wCount);
}

/*******************************************************************************
* Function Name  : SetEPRxCount
* Description    : Sets the Endpoint Rx buffer size
* Input          : - bEpNum: endpoint number[0:9]
*                  - wCount : size (in bytes) of the Rx buffer in the PMA
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPRxCount(BYTE bEpNum, WORD wCount)
{
   _SetEPRxCount(bEpNum,wCount);
}
/*******************************************************************************
* Function Name  : GetEPTxCount
* Description    : Gets the Endpoint count value
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : Endpoint TxCount value
*******************************************************************************/

WORD GetEPTxCount(BYTE bEpNum)
{
	  return(_GetEPTxCount(bEpNum));
}

/*******************************************************************************
* Function Name  : GetEPRxCount
* Description    : Gets the Endpoint Count register value
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : Endpoint Rx Count value
*******************************************************************************/
WORD GetEPRxCount(BYTE bEpNum)
{
   return(_GetEPRxCount(bEpNum));
}

/*******************************************************************************
* Function Name  : SetEPDblBuffAddr
* Description    : Set double buffer buffer0, buffer1 addresses in the PMA
* Input          : - bEpNum: endpoint number[0:9]
*                  - wBuf0Addr : buffer0 Address offset in PMA
*                  - wBuf1Addr : buffer1 Address offset in PMA
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPDblBuffAddr(BYTE bEpNum, WORD wBuf0Addr, WORD wBuf1Addr)
{
  _SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr);
}

/*******************************************************************************
* Function Name  : SetEPDBlBuf0Addr
* Description    : Set buffer0 address in PMA
* Input          : -bEpNum: endpoint number[0:9]
*                  -wBuf0Addr: buffer0 Address offset in PMA
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPDblBuf0Addr(BYTE bEpNum,WORD wBuf0Addr)
{
  _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);
}
/*******************************************************************************
* Function Name  : SetEPDBlBuf1Addr
* Description    : Set buffer1 address in PMA
* Input          : -bEpNum: endpoint number[0:9]
*                  -wBuf1Addr: buffer1 Address offset in PMA
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPDblBuf1Addr(BYTE bEpNum,WORD wBuf1Addr)
{
  _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);
}

/*******************************************************************************
* Function Name  : GetEPDblBuf0Addr
* Description    : Gets buffer0 address
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : Buffer 0 Address offset in PMA
*******************************************************************************/
WORD GetEPDblBuf0Addr(BYTE bEpNum)
{
  return(_GetEPDblBuf0Addr(bEpNum));
}

/*******************************************************************************
* Function Name  : GetEPDblbuf1Addr
* Description    : Gets buffer1 address
* Input          : bEpNum: endpoint number[0:9]
* Output         : None
* Return         : Buffer 1 Address offset in PMA
*******************************************************************************/
WORD GetEPDblBuf1Addr(BYTE bEpNum)
{
  return(_GetEPDblBuf1Addr(bEpNum));
}
/*******************************************************************************
* Function Name  : SetEPDblBuf1Count
* Description    : Set buffer1 size
* Input          : - bEpNum: endpoint number[0:9]
*                  - bDir: buffer direction :  EP_DBUF_OUT or EP_DBUF_IN
*                  - wCount: bytes count value
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPDblBuf1Count(BYTE bEpNum, BYTE bDir,WORD wCount)
{
 if(bDir == EP_DBUF_IN)					
 /* IN double buffered endpoint */						
 {
   *_pEPBufCount(bEpNum)&= 0x000FFFF;
   *_pEPBufCount(bEpNum)|=(wCount<<16);
 }
 else if(bDir == EP_DBUF_OUT)				
 /* OUT double buffered endpoint */						
  _SetEPRxCount(bEpNum, wCount);
}


/*******************************************************************************
* Function Name  : SetEPDblBuf0Count
* Description    : Set buffer0 size
* Input          : - bEpNum: endpoint number[0:9]
*                  - bDir: buffer direction :  EP_DBUF_OUT or EP_DBUF_IN
*                  - wCount: bytes count value
* Output         : None
* Return         : None
*******************************************************************************/
void SetEPDblBuf0Count(BYTE bEpNum, BYTE bDir,WORD wCount)
{
DWORD BLsize=0;
DWORD Blocks;
if(bDir == EP_DBUF_IN)   					
/* IN double bufferd endpoint */						
SetEPTxCount(bEpNum,wCount);
else if(bDir == EP_DBUF_OUT) {				
/* OUT double bufferd endpoint */			

   if (wCount < 64) Blocks = wCount>>1;
   else
   {
   BLsize = 0x8000;
   Blocks = wCount>>6;
   }
	 *_pEPBufCount(bEpNum) &=~0x8000;
	 *_pEPBufCount(bEpNum) |=BLsize;
	 *_pEPBufCount(bEpNum)  &=~0x7C00;
	 *_pEPBufCount(bEpNum) |=Blocks<<10;
	 *_pEPBufCount(bEpNum) &=0xFFFFFC00;
 }
}

/*******************************************************************************
* Function Name  : SetEPDblBuffCount
* Description    : Set buffer0 or 1 size
* Input          : - bEpNum: endpoint number[0:9]
                   - bDir: buffer direction :  EP_DBUF_OUT, EP_DBUF_IN
                   - wCount: bytes count value

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -